Submodule cluster.lua is a part of GraphQL API module provided functions specific to cluster application architecture. This particular implementation was made for Tarantool Cartridge Application (requires: Cartridge, VShard and DDL modules), for any custom application architecture, for example for so called pure-Tarantool applications most functions of this module may need to be overridden to comply it.
cluster.get_servers() - method to get connections to all cluster instances,
returns:
[1](table) - array of maps with the following structure:alias(string) - alias of instanceconn(table) - conn object. For more details see: net_box module
[2](table) - array of errors if any of need instances is not available.
cluster.get_masters() - method to get connections to active master instances of all cluster replicasets,
returns:
[1](table) - array of maps with the following structure:alias(string) - alias of instanceconn(table) - conn object. For more details see: net_box module
[2](table) - array of errors if any of need instances is not available.
cluster.get_storages_instances(mode, prefer_replica, balance) - method to get connections to get one instance from of all storage replicasets according to desired policy,
where:
mode(string) - optional, have to be 'write' for replicaset masters (default) or 'read' for replicas if available;prefer_replica(boolean) - optional, if true then the preferred target is one of the replicas, false by default;balance(boolean) - use replica according to vshard load balancing policy;
returns:
[1](table) - array of maps with the following structure:alias(string) - alias of instanceconn(table) - conn object. For more details see: net_box module
[2](table) - array of errors if any of need instances is not available.
cluster.get_self_alias() - method to get instance alias this function called on,
returns:
[1](string) - name of instance.
cluster.get_self_uri() - method to get instance URI this function called on,
returns:
[1](string) - URI (IP:port or FQDN:port) of instance.
cluster.get_replicasets() - method to get all cluster replicasets alias names,
returns:
[1](table) - array of strings - cluster replicasets alias names.
cluster.get_replicaset_instances(replicaset) - method to get all replicaset instances alias names,
where:
replicaset(table) - alias name of replicaset;
returns:
[1](table) - map with cluster replicaset instances, has the following format:alias(string) - instance alias name;uri(string) - instance connection string;status(string) - server status.
cluster.get_instances() - method to get all cluster replicasets alias names,
returns:
[1](table) - map with cluster replicaset instances, has the following format:alias(string) - instance alias name;uri(string) - instance connection string;status(string) - server status.
cluster.get_candidates(role) - method to get all cluster instances with the provided role,
where:
role(string) - mandatory, role name,
returns:
[1](table) - map with cluster replicaset instances, has the following format:alias(string) - instance alias name;uri(string) - instance connection string;status(string) - server status.
cluster.get_servers_by_list() - method to get servers objects by provided list of instances alias names,
returns:
-
[1](table) - array of conn objects to all servers. For more details see: net_box module -
[2](table) - array of errors if some instances is not available.
cluster.get_existing_spaces() - method to get list of existing spaces,
returns:
[1](table) - array ofstringsof existing non-system spaces on instance this function called on.
cluster.is_space_exists(space) - method to check if the desired space is exists,
where:
space(string) - name of space to be checked;
returns:
[1](boolean) - true if space exists, false - if not.
cluster.get_schema() - method to get database schema (ddl.get_schema() wrapper),
returns:
[1](table) - database schema, for additional info see ddl.get_schema().
cluster.check_schema() - method to get database schema (ddl.check_schema() wrapper),
returns:
[1](boolean) -trueif no error, otherwise returnnil;[2](error) - error object.
For additional info see ddl.check_schema().
cluster.set_schema() - method to get database schema (ddl.set_schema() wrapper),
returns:
[1](boolean) -trueif no error, otherwise returnnil;[2](error) - error object.
For additional info see ddl.set_schema().