Pike.Store behaviour (pike v0.2.0)

View Source

Behaviour module defining the interface for Pike API key stores.

Any module used as a store in Pike must implement these functions.

Summary

Callbacks

Checks if the given key struct permits the specified action on a resource.

Optional: Deletes a key from the store.

Inserts a key into the store. Used primarily for in-memory stores like ETS.

Optional: Updates a key in the store.

Callbacks

action?(map, resource, action)

@callback action?(map(), resource :: String.t(), action :: atom()) :: boolean()

Checks if the given key struct permits the specified action on a resource.

delete_key(t)

(optional)
@callback delete_key(String.t()) :: :ok | {:error, term()}

Optional: Deletes a key from the store.

get_key(t)

@callback get_key(String.t()) :: {:ok, map()} | :error

insert(map)

@callback insert(map()) :: :ok | {:error, term()}

Inserts a key into the store. Used primarily for in-memory stores like ETS.

update_key(t, map)

(optional)
@callback update_key(String.t(), map()) :: :ok | {:error, term()}

Optional: Updates a key in the store.