View Source ProcessHub.Service.Storage (ProcessHub v0.6.0)
Local storage service. Provides API functions for managing local storage used by ProcessHub for three concerns:
- Misc storage — strategy configs, runtime state. Always ETS.
- Hook storage — registered hook handlers. Always ETS.
- Process registry — child registrations. Routed through the
configured
ProcessHub.Service.Storage.Behaviourbackend (defaultProcessHub.Service.Storage.Ets).
When a registry backend is opened it registers itself with this
module via register_backend/3. From then on, calls to the public
API that target a registry table (the hub_id atom) are dispatched
through the configured backend module. Misc and hook storage
(passed by tid) bypass the dispatcher and use ETS directly.
The public function signatures and return values are unchanged from prior releases.
Summary
Functions
Deletes all objects from the storage table.
Returns a boolean indicating whether the key exists in local storage.
Exports all objects from the storage table.
Folds over all objects in the storage table with a function.
Returns the value for the key in local storage.
Inserts the key and value into local storage.
Matches the given expression against the storage table.
Registers {module, ref} as the registry backend for hub_id.
Returns {module, ref} for the registered registry backend, or
nil if hub_id has no registered backend.
Removes an entry from the storage.
Removes the registered backend for hub_id. Called by the
coordinator at shutdown.
Updates the value for the key in local storage.
Types
Functions
Deletes all objects from the storage table.
Never use in custom code. Should only be used for testing purposes.
Returns a boolean indicating whether the key exists in local storage.
@spec export_all(table_id()) :: [{atom() | binary(), term(), pos_integer() | nil}]
Exports all objects from the storage table.
Folds over all objects in the storage table with a function.
More memory efficient than export_all + filter for large tables as it doesn't create an intermediate copy of the entire table.
Returns the value for the key in local storage.
If the key does not exist, nil is returned; otherwise, the value is returned in
the format of a tuple: {key, value, ttl}.
Inserts the key and value into local storage.
Available options:
ttl: The time to live for the key in milliseconds.
Matches the given expression against the storage table.
The match_expr is a tuple that specifies the pattern.
Registers {module, ref} as the registry backend for hub_id.
After registration, public API calls passing hub_id (an atom) are
dispatched through module. Called by the coordinator at startup.
Returns {module, ref} for the registered registry backend, or
nil if hub_id has no registered backend.
Removes an entry from the storage.
@spec unregister_backend(atom()) :: :ok
Removes the registered backend for hub_id. Called by the
coordinator at shutdown.
Updates the value for the key in local storage.
The func function is expected to take the current value as an argument and
return the new value.
If the key does not exist, the current value is nil.