Module cartridge.roles | Tarantool
Tarantool Cartridge Table of contents Module cartridge.roles

Module cartridge.roles

Role management (internal module).

The module consolidates all the role management functions: cfg , some getters, validate_config and apply_config .

The module is almost stateless, it’s only state is a collection of registered roles.

(Added in v1.2.0-20)

Perform hot-reload of cartridge roles code.

This is an experimental feature, it’s only allowed if the application enables it explicitly: cartridge.cfg({roles_reload_allowed = true}) .

Reloading starts by stopping all roles and restoring the initial state. It’s supposed that a role cleans up the global state when stopped, but even if it doesn’t, cartridge kills all fibers and removes global variables and HTTP routes.

All Lua modules that were loaded during cartridge.cfg are unloaded, including supplementary modules required by a role. Modules, loaded before cartridge.cfg aren’t affected.

Instance performs roles reload in a dedicated state ReloadingRoles . If reload fails, the instance enters the ReloadError state, which can later be retried. Otherwise, if reload succeeds, instance proceeds to the ConfiguringRoles state and initializes them as usual with validate_config() , init() , and apply_config() callbacks.

Hot-reload could be forbidden in runtime with forbid_reload function.

Returns:

(boolean) true

Or

(nil)

(table) Error description

Forbid hot-reload of cartridge roles code.

Returns:

(boolean) true

Or

(nil)

(table) Error description

Allow hot-reload of cartridge roles code.

Returns:

(boolean) true

Or

(nil)

(table) Error description

Returns true if hot-reload of cartridge roles code is forbidden.

Returns:

(boolean) true

Or

(nil)

(table) Error description

Do additional job after the roles configuration applying.

Parameters:

  • table: conf
  • string: state

Returns:

(boolean) true

Or

(nil)

(table) Error description

Load modules and register them as Cartridge Roles.

This function is internal, it’s called as a part of cartridge.cfg.

Parameters:

Returns:

(boolean) true

Or

(nil)

(table) Error description

List all registered roles.

Hidden and permanent roles are listed too.

Returns:

({string,..})

List registered roles names.

Hidden roles are not listed as well as permanent ones.

Returns:

({string,..})

List top-level roles names.

Dependencies of top-level roles of the replicaset, hidden roles are not listed as well as permanent ones.

Returns:

({string,..})

Roles to be enabled on the server. This function returns all roles that will be enabled including their dependencies (both hidden and not) and permanent roles. By default, only permanent roles are returned. When you pass table with the roles names as an argument, This function also checks their dependencies and returns them as well.

Parameters:

Returns:

({[string]=boolean,…})

List role dependencies. Including sub-dependencies.

Parameters:

Returns:

({string,..})

Validate configuration by all roles.

Parameters:

Returns:

(boolean) true

Or

(nil)

(table) Error description

Apply the role configuration.

Parameters:

  • conf: (table)
  • opts: (table)
  • is_master: (boolean)

Returns:

(boolean) true

Or

(nil)

(table) Error description

Stop all roles.

Found what you were looking for?
Feedback