Instance manager that shards instances across multiple Spex.InstanceManager.Server processes.
This manager hashes each instance identifier and routes operations to one of several server shards. It is useful when you want to reduce contention versus a single-manager setup while preserving the same high-level API.
See Spex for info on using this instance manager.
Configuration
This manager accepts one distribution-specific option (:distribution_factor) plus server options
forwarded to each shard (Spex.InstanceManager.Server.server_opt()).
:distribution_factor(pos_integer()) Number of server shards. Default:4. Must be a positive integer; otherwisestart_link/1raisesArgumentError.:dets_tableis set per shard by this module (Spex.InstanceManager.DistributedInstanceManager.Server_<n>), so callers should not provide it.For the other opts, see
Spex.InstanceManager.SimpleInstanceManager
Routing semantics
Instance routing is deterministic:
- hash =
:erlang.phash2(instance_identifier) - shard index =
rem(hash, distribution_factor) + 1
All operations for a given instance identifier are routed to the same shard.
Methods that aggregate globally (all_instances/0, all_instances/1, delete_instances/1,
all_impl_models/0) query all shards and combine the results.
Summary
Functions
Callback implementation for Spex.InstanceManager.all_impl_models/0.
Callback implementation for Spex.InstanceManager.all_instances/0.
Callback implementation for Spex.InstanceManager.all_instances/1.
Callback implementation for Spex.InstanceManager.child_spec/1.
Callback implementation for Spex.InstanceManager.delete_instance/1.
Callback implementation for Spex.InstanceManager.delete_instances/1.
Callback implementation for Spex.InstanceManager.export_impl_models/0.
Callback implementation for Spex.InstanceManager.get_instance/1.
Callback implementation for Spex.InstanceManager.init_instance/4.
Callback implementation for Spex.InstanceManager.init_instance!/4.
Callback implementation for Spex.InstanceManager.init_instance_async/4.
Callback implementation for Spex.InstanceManager.mock_instance!/4.
Callback implementation for Spex.InstanceManager.start_link/1.
Callback implementation for Spex.InstanceManager.transition/3.
Callback implementation for Spex.InstanceManager.transition!/3.
Callback implementation for Spex.InstanceManager.transition_async/3.
Functions
Callback implementation for Spex.InstanceManager.all_impl_models/0.
Callback implementation for Spex.InstanceManager.all_instances/0.
Callback implementation for Spex.InstanceManager.all_instances/1.
Callback implementation for Spex.InstanceManager.child_spec/1.
Callback implementation for Spex.InstanceManager.delete_instance/1.
Callback implementation for Spex.InstanceManager.delete_instances/1.
Callback implementation for Spex.InstanceManager.export_impl_models/0.
Callback implementation for Spex.InstanceManager.get_instance/1.
Callback implementation for Spex.InstanceManager.init_instance/4.
Callback implementation for Spex.InstanceManager.init_instance!/4.
Callback implementation for Spex.InstanceManager.init_instance_async/4.
Callback implementation for Spex.InstanceManager.mock_instance!/4.
Callback implementation for Spex.InstanceManager.start_link/1.
Callback implementation for Spex.InstanceManager.transition/3.
Callback implementation for Spex.InstanceManager.transition!/3.
Callback implementation for Spex.InstanceManager.transition_async/3.