Behaviour contract plus shared helpers for Spex instance managers.
Summary
Callbacks
Returns all currently known implementation models.
Returns all instances managed by this instance manager.
Returns all instances for a given specification module.
Returns a child spec for supervising the instance manager.
Deletes one instance by identifier.
Deletes all instances matching the provided filter function.
Serialises and exports implementation models as {filename, content} tuples.
Fetches one instance by identifier.
Initializes a new instance and records initialisation as the first transition.
Same as init_instance/4, but raises on errors.
Asynchronously initializes a new instance.
Inserts or updates a mock instance at a given state for testing purposes.
Starts the instance manager process tree.
Records an observed transition for an existing instance.
Same as transition/3, but raises on errors.
Asynchronously records a transition for an existing instance.
Functions
Injects the Spex.InstanceManager behaviour and shared convenience functions.
Returns the compile-time configured default instance manager module.
Returns compile-time options for the default instance manager.
Types
@type instance_manager_opt() :: Spex.InstanceManager.Server.server_opt() | (other_opt :: {atom(), term()})
Callbacks
@callback all_impl_models() :: {:ok, [Spex.ImplModel.t()]}
Returns all currently known implementation models.
@callback all_instances() :: {:ok, [Spex.InstanceManager.Instance.t()]} | {:error, Spex.Errors.DetsError.t()}
Returns all instances managed by this instance manager.
@callback all_instances(Spex.Specification.t()) :: {:ok, [Spex.InstanceManager.Instance.t()]} | {:error, Spex.Errors.DetsError.t()}
Returns all instances for a given specification module.
@callback child_spec(term()) :: Supervisor.child_spec()
Returns a child spec for supervising the instance manager.
@callback delete_instance(Spex.InstanceManager.Instance.instance_identifier()) :: :ok | {:error, Spex.Errors.DetsError.t()}
Deletes one instance by identifier.
@callback delete_instances((Spex.InstanceManager.Instance.t() -> as_boolean(term()))) :: :ok | {:error, Spex.Errors.DetsError.t()}
Deletes all instances matching the provided filter function.
@callback export_impl_models() :: {:ok, [{filename :: String.t(), Spex.ImplModel.serialisation()}]}
Serialises and exports implementation models as {filename, content} tuples.
@callback get_instance(Spex.InstanceManager.Instance.instance_identifier()) :: {:ok, Spex.InstanceManager.Instance.t()} | {:error, Spex.Errors.InstanceError.t()} | {:error, Spex.Errors.DetsError.t()}
Fetches one instance by identifier.
@callback init_instance( Spex.Specification.t(), Spex.InstanceManager.Instance.instance_identifier(), Spex.InstanceManager.Instance.meta() | nil, Spex.state() | nil ) :: :ok | Spex.Specification.error_handler_return()
Initializes a new instance and records initialisation as the first transition.
Returns :ok on success or an error-handler return when initialization fails.
@callback init_instance!( Spex.Specification.t(), Spex.InstanceManager.Instance.instance_identifier(), Spex.InstanceManager.Instance.meta() | nil, Spex.state() | nil ) :: :ok
Same as init_instance/4, but raises on errors.
@callback init_instance_async( Spex.Specification.t(), Spex.InstanceManager.Instance.instance_identifier(), Spex.InstanceManager.Instance.meta() | nil, Spex.state() | nil ) :: :ok
Asynchronously initializes a new instance.
Errors are reported via specification error handling instead of direct return.
@callback mock_instance!( Spex.Specification.t(), Spex.InstanceManager.Instance.instance_identifier(), Spex.state(), Spex.InstanceManager.Instance.meta() | nil ) :: :ok
Inserts or updates a mock instance at a given state for testing purposes.
@callback start_link([instance_manager_opt()]) :: Supervisor.on_start()
Starts the instance manager process tree.
@callback transition( Spex.InstanceManager.Instance.instance_identifier(), Spex.action(), Spex.state() ) :: :ok | Spex.Specification.error_handler_return()
Records an observed transition for an existing instance.
Returns :ok on success or an error-handler return when validation/storage fails.
@callback transition!( Spex.InstanceManager.Instance.instance_identifier(), Spex.action(), Spex.state() ) :: :ok
Same as transition/3, but raises on errors.
@callback transition_async( Spex.InstanceManager.Instance.instance_identifier(), Spex.action(), Spex.state() ) :: :ok
Asynchronously records a transition for an existing instance.
Functions
Injects the Spex.InstanceManager behaviour and shared convenience functions.
Generated convenience functions:
child_spec/1init_instance!/4transition!/3
@spec default_instance_manager() :: module()
Returns the compile-time configured default instance manager module.
@spec default_instance_manager_opts() :: keyword()
Returns compile-time options for the default instance manager.