Packages
launchdarkly_server_sdk
2.1.2
3.11.0
3.10.1
3.9.0
3.8.1
3.8.0
3.7.2
3.7.1
3.7.0
3.6.0
3.5.0
3.4.0
3.3.1
3.3.0
3.2.0
3.1.0
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
2.1.2
2.1.1
2.1.0
2.0.5
2.0.4
2.0.3
2.0.2
2.0.1
2.0.0
1.6.0
1.5.0
1.4.0
1.3.2
1.3.1
1.3.0
1.2.0
1.1.3
1.1.2
1.1.1
retired
1.1.0
retired
1.0.1
retired
1.0.0
retired
1.0.0-beta4
retired
1.0.0-beta3
retired
1.0.0-beta2
retired
LaunchDarkly SDK for Erlang
Current section
Files
Jump to
Current section
Files
src/ldclient_storage_engine.erl
%%-------------------------------------------------------------------
%% @doc `ldclient_storage_engine' module
%% @private
%% This is a behavior that all storage engines must implement. It works with
%% the concept of buckets and keys.
%% @end
%%-------------------------------------------------------------------
-module(ldclient_storage_engine).
%% Types
-type event_operation() :: put | patch | delete.
%% Operation for processing events.
-export_type([event_operation/0]).
%% `init' gets called during startup. Typically storage engine would initialize
%% here. E.g. start application, supervisor, workers, establish connections, or
%% any other initialization resources as needed.
%% It is expected that `features' and `segments' buckets will be reachable after
%% initialization, which should also be accounted for here.
-callback init(SupRef :: atom(), Tag :: atom(), Options :: list()) ->
ok.
%% `create' must create a named bucket with a given atom. It must return
%% `already_exists' error if the bucket by that name was previously created.
-callback create(Tag :: atom(), Bucket :: atom()) ->
ok
| {error, already_exists, string()}.
%% `empty' must delete all records from the specified bucket.
%% If the bucket doesn't exist, it must return `bucket_not_found' error.
-callback empty(Tag :: atom(), Bucket :: atom()) ->
ok
| {error, bucket_not_found, string()}.
%% `get' must look up the given key in the bucket and return the result as a
%% list of matching key-value pairs as tuples. If the bucket doesn't exist it
%% must return `bucket_not_found' error.
-callback get(Tag :: atom(), Bucket :: atom(), Key :: binary()) ->
[{Key :: binary(), Value :: any()}]
| {error, bucket_not_found, string()}.
%% `all' must return all key-value pairs for the specified bucket as tuples.
%% If the bucket doesn't exist, it must return `bucket_not_found' error.
-callback all(Tag :: atom(), Bucket :: atom()) ->
[{Key :: binary(), Value :: any()}]
| {error, bucket_not_found, string()}.
%% `upsert' must create or update key-value pair records in the given bucket.
%% If the bucket doesn't exist, it must return `bucket_not_found' error.
-callback upsert(Tag :: atom(), Bucket :: atom(), Item :: #{Key :: binary() => Value :: any()}) ->
ok
| {error, bucket_not_found, string()}.
%% `upsert_clean' must perform `empty' and `upsert' atomically on a given bucket.
-callback upsert_clean(Tag :: atom(), Bucket :: atom(), Item :: #{Key :: binary() => Value :: any()}) ->
ok
| {error, bucket_not_found, string()}.
%% `delete` must delete a record from the specified bucket.
-callback delete(Tag:: atom(), Bucket :: atom(), Key :: binary()) ->
ok
| {error, bucket_not_found, string()}.
%% `terminate' is the opposite of `init'. It is expected to clean up any
%% resources and fully shut down the storage backend.
-callback terminate(Tag :: atom()) -> ok.