adk_ambient (erlang_adk v0.7.0)

View Source

Bounded OTP-native runtime for ambient/background invocations.

Triggers are registered with an immutable Runner and an explicit session policy. submit/2 performs synchronous admission into a bounded queue, then returns a stable event reference while a lightweight supervised job owns the invocation, retry policy, deadline, and cleanup. Repeated idempotency keys return the original reference for as long as its result is retained.

Summary

Types

event_ref/0

-type event_ref() :: binary().

outcome/0

-type outcome() ::
          {completed, map()} |
          {paused, map()} |
          {failed, term()} |
          {timed_out, deadline_exceeded} |
          {cancelled, term()}.

Functions

await(EventRef)

-spec await(event_ref()) -> outcome() | {error, term()}.

await(EventRef, Timeout)

-spec await(event_ref(), timeout()) -> outcome() | {error, term()}.

cancel(EventRef)

-spec cancel(event_ref()) -> ok | {error, term()}.

cancel(EventRef, Reason)

-spec cancel(event_ref(), term()) -> ok | {error, term()}.

child_spec(Options)

-spec child_spec(map()) -> supervisor:child_spec().

code_change(OldVersion, State, Extra)

handle_call(Request, From, State0)

handle_cast(Message, State)

handle_info(Info, State0)

init(Options)

register_trigger(Name, Runner, Options)

-spec register_trigger(binary(), adk_runner:runner(), map()) -> ok | {error, term()}.

run(Name, Event)

-spec run(binary(), map()) -> outcome() | {error, term()}.

run(Name, Event, Timeout)

-spec run(binary(), map(), timeout()) -> outcome() | {error, term()}.

start_link()

-spec start_link() -> gen_server:start_ret().

start_link(Options)

-spec start_link(map()) -> gen_server:start_ret().

status(EventRef)

-spec status(event_ref()) -> {ok, map()} | {error, term()}.

submit(Name, Event)

-spec submit(binary(), map()) -> {ok, event_ref()} | {ok, event_ref(), duplicate} | {error, term()}.

terminate(Reason, State)

trigger_status(Name)

-spec trigger_status(binary()) -> {ok, map()} | {error, term()}.

unregister_trigger(Name)

-spec unregister_trigger(binary()) -> ok | {error, term()}.