View Source Actors.Actor.StateManager.Behaviour behaviour (spawn v2.0.0-RC2)

StateManager.Behaviour Defines behavior that allows an Actor's state to be saved to persistent storage using database drivers.

Summary

Types

data()

@type data() :: struct()

opts()

@type opts() :: Keyword.t()

params()

@type params() :: struct()

projection_type()

@type projection_type() :: module()

query()

@type query() :: String.t()

table_name()

@type table_name() :: String.t()

Callbacks

is_new?(t, any)

@callback is_new?(String.t(), any()) :: {:error, term()} | boolean()

load(t)

@callback load(String.t()) :: {:ok, term()} | {:not_found, %{}} | {:error, term()}

load(t, number)

@callback load(String.t(), number()) ::
  {:ok, term()} | {:not_found, %{}} | {:error, term()}

projection_create_or_update_table(projection_type, table_name)

@callback projection_create_or_update_table(projection_type(), table_name()) :: :ok

projection_query(projection_type, query, params, opts)

@callback projection_query(projection_type(), query(), params(), opts()) ::
  {:error, term()} | {:ok, data()}

projection_upsert(projection_type, table_name, data)

@callback projection_upsert(projection_type(), table_name(), data()) :: :ok

save(t, term, t)

@callback save(String.t(), term(), Keyword.t()) ::
  {:ok, term(), String.t()}
  | {:error, term(), term(), term()}
  | {:error, term(), term()}

save_async(t, term, t)

@callback save_async(String.t(), term(), Keyword.t()) ::
  {:ok, term(), String.t()}
  | {:error, term(), term(), term()}
  | {:error, term(), term()}