Dynamically compiles a module containing the startup information for each worker pool.
Cofiguration example:
[{cluster_a, [{servers, [{" server1", 11211}, {"server2", 11211}]}, {sharding_algorithm, {mero, shard_phash2}}, {workers_per_shard, 3}, {pool_worker_module, mero_wrk_tcp_txt}] }, {cluster_b, [{servers, [{"server3", 11211}]}, {sharding_algorithm, {mero, shard_crc32}}, {workers_per_shard, 1}, {pool_worker_module, mero_wrk_tcp_binary}] } ]
Module generated:
-module(mero_cluster_util). -export([child_definitions/1, sup_by_cluster_name/1, worker_by_index/3, cluster_shards/1, workers_per_shard/1, clusters/0, sharding_algorithm/1]).
child_definitions(cluster_a) -> [{"server1",11211,mero_cluster_a_server1_0_0, mero_wrk_tcp_txt}, {"server1",11211,mero_cluster_a_server1_0_1, mero_wrk_tcp_txt}, {"server1",11211,mero_cluster_a_server1_0_2, mero_wrk_tcp_txt},
{"server2",11211,mero_cluster_a_server2_1_0, mero_wrk_tcp_txt}, {"server2",11211,mero_cluster_a_server2_1_1, mero_wrk_tcp_txt}, {"server2",11211,mero_cluster_a_server2_1_2, mero_wrk_tcp_txt}]; child_definitions(cluster_b) -> [{"server3",11211,mero_cluster_b_server3_0_0, mero_wrk_tcp_binary}].
sup_by_cluster_name(cluster_a) -> mero_cluster_a_sup; sup_by_cluster_name(cluster_b) -> mero_cluster_b_sup.
worker_by_index(cluster_a, 0, 0) -> mero_cluster_a_server1_0_0; worker_by_index(cluster_a, 0, 1) -> mero_cluster_a_server1_0_1; worker_by_index(cluster_a, 0, 2) -> mero_cluster_a_server1_0_2; worker_by_index(cluster_a, 1, 0) -> mero_cluster_a_server2_1_0; worker_by_index(cluster_a, 1, 1) -> mero_cluster_a_server2_1_1; worker_by_index(cluster_a, 1, 2) -> mero_cluster_a_server2_1_2; worker_by_index(cluster_b, 0, 0) -> mero_cluster_b_server3_0_0.
cluster_shards(cluster_a) -> 2; cluster_shards(cluster_b) -> 1.
workers_per_shard(cluster_a) -> 3; workers_per_shard(cluster_b) -> 1.
pool_worker_module(cluster_a) -> mero_wrk_tcp_txt; pool_worker_module(cluster_b) -> mero_wrk_tcp_binary.
sharding_algorithm(cluster_a) -> {mero, shard_phash2}; sharding_algorithm(cluster_b) -> {mero, shard_crc32}.
clusters() -> [cluster_a, cluster_b]child_definitions() = [{Host::string(), Port::pos_integer(), WorkerName::atom(), WorkerModule::module()}]
child_definitions/1 | |
cluster_shards/1 | |
clusters/0 | |
group_by_shards/2 | |
group_by_shards/3 | |
load_clusters/1 | Loads a file with the pool configuration. |
one_pool_of_each_shard_of_cluster/1 | |
pool_worker_module/1 | |
purge/0 | Purges old mero_cluster_util code from the system. |
random_pool_of_shard/2 | |
server/2 | |
sharding_algorithm/1 | |
sup_by_cluster_name/1 | |
total_workers/1 | |
version/0 | Returns the current version of mero_cluster_util. |
workers_per_shard/1 |
child_definitions(ClusterName::atom()) -> child_definitions()
cluster_shards(Name) -> any()
clusters() -> any()
group_by_shards(ClusterName::atom(), Keys::[mero:mero_key()]) -> [{PoolName::atom(), Keys::[binary()]}]
group_by_shards(ClusterName::atom(), Items::[tuple()], KeyPos::pos_integer()) -> [{PoolName::atom(), Items::[tuple()]}]
load_clusters(ClusterConfig::mero:cluster_config()) -> ok
Loads a file with the pool configuration
one_pool_of_each_shard_of_cluster(ClusterName) -> any()
pool_worker_module(Name) -> any()
purge() -> ok
Purges old mero_cluster_util code from the system
random_pool_of_shard(Name, ShardIdentifier) -> any()
server(Name::atom(), Key::mero:mero_key()) -> Server::atom()
sharding_algorithm(Name) -> any()
sup_by_cluster_name(ClusterName::atom()) -> atom()
total_workers(Name) -> any()
version() -> pos_integer()
Returns the current version of mero_cluster_util
workers_per_shard(Name) -> any()
Generated by EDoc