The base plugin that all services include by default.
This module provides a set of essential callbacks that form the foundation of a Malla service's behavior. All services include this plugin in their dependency list, even if not explicitly declared.
Summary
Callbacks
Called when Malla.authorize/3 is called.
Called from Malla.remote/4 and functions in Malla.Node when a remote callback is received.
By default it will simply call apply(service_module, fun, args) but you
can override it in your plugins to add tracing, etc.
Called when Malla.Service.drain/1 is called.
Called when Malla.Service.is_ready?/1 is called.
Called when the service status changes.
Types
@type class() :: Malla.class()
@type config() :: map()
@type cont() :: Malla.cont()
@type id() :: Malla.id()
@type user_state() :: map()
Callbacks
@callback malla_authorize(term(), term(), Malla.authorize_opt()) :: boolean() | {boolean(), term()} | {:error, term()}
Called when Malla.authorize/3 is called.
By default it returns {:error, :auth_not_implemented}
Called from Malla.remote/4 and functions in Malla.Node when a remote callback is received.
By default it will simply call apply(service_module, fun, args) but you
can override it in your plugins to add tracing, etc.
Called when Malla.Service.drain/1 is called.
Each plugin must prepare for stop, cleaning its state.
If it could clean everything ok, it should return :cont to jump to next.
If it could not, it should return false, meaning the drain could not complete,
and it will be retried later.
Called when Malla.Service.is_ready?/1 is called.
Each plugin must return either 'false' (when it is not ready) or 'cont' to go to next (when it is ready).
@callback service_status_changed(Malla.Service.running_status()) :: :ok
Called when the service status changes.
This callback is called when the running_status of the service
changes. You should always return :cont so next plugin can receive the change too.
The service information can be obtained using Malla.get_service_id!/0 or by calling
service_module.service() to get the full service struct.