adk_artifact_service behaviour (erlang_adk v0.7.0)

View Source

Behaviour for immutable, versioned binary artifacts.

Artifact names are logical names within an explicit application, user, or session scope. Implementations must create a new positive version on every successful put; an existing version is never overwritten.

Summary

Types

artifact/0

-type artifact() ::
          #{scope := scope(),
            name := binary(),
            version := pos_integer(),
            mime_type := binary(),
            digest := binary(),
            size := non_neg_integer(),
            created_at := integer(),
            metadata := map(),
            data := binary()}.

artifact_meta/0

-type artifact_meta() ::
          #{scope := scope(),
            name := binary(),
            version := pos_integer(),
            mime_type := binary(),
            digest := binary(),
            size := non_neg_integer(),
            created_at := integer(),
            metadata := map()}.

call_options/0

-type call_options() :: #{timeout_ms => pos_integer()}.

delete_selector/0

-type delete_selector() :: selector() | all.

handle/0

-type handle() :: term().

name_page/0

-type name_page() :: #{scope := scope(), items := [binary()], next_cursor := binary() | undefined}.

name_page_options/0

-type name_page_options() :: #{limit => pos_integer(), cursor => binary()}.

scope/0

-type scope() :: {app, binary()} | {user, binary(), binary()} | {session, binary(), binary(), binary()}.

selector/0

-type selector() :: pos_integer() | latest.

version_page/0

-type version_page() :: #{items := [artifact_meta()], next_cursor := pos_integer() | undefined}.

version_page_options/0

-type version_page_options() :: #{limit => pos_integer(), cursor => pos_integer()}.

Callbacks

capabilities/1

-callback capabilities(Handle :: handle()) -> {ok, map()} | {error, term()}.

delete/4

-callback delete(Handle :: handle(), Scope :: scope(), Name :: binary(), Selector :: delete_selector()) ->
                    ok | {error, not_found | term()}.

delete/5

-callback delete(Handle :: handle(),
                 Scope :: scope(),
                 Name :: binary(),
                 Selector :: delete_selector(),
                 CallOptions :: call_options()) ->
                    ok | {error, not_found | term()}.

get/4

-callback get(Handle :: handle(), Scope :: scope(), Name :: binary(), Selector :: selector()) ->
                 {ok, artifact()} | {error, not_found | term()}.

get/5

-callback get(Handle :: handle(),
              Scope :: scope(),
              Name :: binary(),
              Selector :: selector(),
              CallOptions :: call_options()) ->
                 {ok, artifact()} | {error, not_found | term()}.

list/2

-callback list(Handle :: handle(), Scope :: scope()) -> {ok, [artifact_meta()]} | {error, term()}.

list_names/3

-callback list_names(Handle :: handle(), Scope :: scope(), Options :: name_page_options()) ->
                        {ok, name_page()} | {error, term()}.

list_versions/4

-callback list_versions(Handle :: handle(),
                        Scope :: scope(),
                        Name :: binary(),
                        Options :: version_page_options()) ->
                           {ok, version_page()} | {error, term()}.

put/5

-callback put(Handle :: handle(), Scope :: scope(), Name :: binary(), Data :: binary(), Options :: map()) ->
                 {ok, artifact_meta()} | {error, term()}.

put/6

-callback put(Handle :: handle(),
              Scope :: scope(),
              Name :: binary(),
              Data :: binary(),
              Options :: map(),
              CallOptions :: call_options()) ->
                 {ok, artifact_meta()} | {error, term()}.

start_link/1

-callback start_link(Config :: map()) -> {ok, handle()} | {error, term()}.