Current section

Files

Jump to
aion_flow src aion@workflow.erl
Raw

src/aion@workflow.erl

-module(aion@workflow).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/aion/workflow.gleam").
-export([run/1, run_with_default/2, all/1, all_with_default/2, race/1, race_with_default/2, map/2, map_with_default/3, id/0, now/0, random/0, random_int/2, sleep/1, start_timer/2, cancel_timer/1, with_timeout/2, continue_as_new/2, 'receive'/1, timer_id/1, spawn/6, spawn_and_wait/6, timestamp_to_milliseconds/1, define/5, name/1, input_codec/1, output_codec/1, error_codec/1, entry_fn/1, entrypoint/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Workflow authoring surface.\n"
"\n"
" This module is an aggregator only: it forwards declarations from the\n"
" workflow submodules and contains no workflow business logic. `run` is the\n"
" only recorded activity dispatch surface in this brief; deterministic time\n"
" and random values come from AD through `aion/internal/ffi`.\n"
).
-file("src/aion/workflow.gleam", 38).
-spec run(aion@activity:activity(any(), GCE)) -> {ok, GCE} |
{error, aion@error:activity_error()}.
run(Activity) ->
aion@workflow@run:run(Activity).
-file("src/aion/workflow.gleam", 47).
?DOC(
" `run`, supplying the workflow-level default task queue applied when the\n"
" activity selects none. Precedence (activity override > workflow default >\n"
" the named `\"default\"` queue) is resolved once at the engine schedule seam.\n"
).
-spec run_with_default(
aion@activity:activity(any(), GCK),
gleam@option:option(binary())
) -> {ok, GCK} | {error, aion@error:activity_error()}.
run_with_default(Activity, Workflow_default_task_queue) ->
aion@workflow@run:run_with_default(Activity, Workflow_default_task_queue).
-file("src/aion/workflow.gleam", 54).
-spec all(list(aion@activity:activity(any(), GCR))) -> {ok, list(GCR)} |
{error, aion@error:activity_error()}.
all(Activities) ->
aion@workflow@concurrency:all(Activities).
-file("src/aion/workflow.gleam", 62).
?DOC(
" `all`, supplying the workflow-level default task queue for any member that\n"
" selects none. See [`run_with_default`] for the resolution precedence.\n"
).
-spec all_with_default(
list(aion@activity:activity(any(), GCZ)),
gleam@option:option(binary())
) -> {ok, list(GCZ)} | {error, aion@error:activity_error()}.
all_with_default(Activities, Workflow_default_task_queue) ->
aion@workflow@concurrency:all_with_default(
Activities,
Workflow_default_task_queue
).
-file("src/aion/workflow.gleam", 69).
-spec race(list(aion@activity:activity(any(), GDI))) -> {ok, GDI} |
{error, aion@error:activity_error()}.
race(Activities) ->
aion@workflow@concurrency:race(Activities).
-file("src/aion/workflow.gleam", 77).
?DOC(
" `race`, supplying the workflow-level default task queue for any member that\n"
" selects none. See [`run_with_default`] for the resolution precedence.\n"
).
-spec race_with_default(
list(aion@activity:activity(any(), GDP)),
gleam@option:option(binary())
) -> {ok, GDP} | {error, aion@error:activity_error()}.
race_with_default(Activities, Workflow_default_task_queue) ->
aion@workflow@concurrency:race_with_default(
Activities,
Workflow_default_task_queue
).
-file("src/aion/workflow.gleam", 84).
-spec map(list(GDW), fun((GDW) -> aion@activity:activity(any(), GDZ))) -> {ok,
list(GDZ)} |
{error, aion@error:activity_error()}.
map(Items, To_activity) ->
aion@workflow@concurrency:map(Items, To_activity).
-file("src/aion/workflow.gleam", 93).
?DOC(
" `map`, supplying the workflow-level default task queue for any produced\n"
" activity that selects none. See [`run_with_default`] for the precedence.\n"
).
-spec map_with_default(
list(GEF),
fun((GEF) -> aion@activity:activity(any(), GEI)),
gleam@option:option(binary())
) -> {ok, list(GEI)} | {error, aion@error:activity_error()}.
map_with_default(Items, To_activity, Workflow_default_task_queue) ->
aion@workflow@concurrency:map_with_default(
Items,
To_activity,
Workflow_default_task_queue
).
-file("src/aion/workflow.gleam", 101).
-spec id() -> {ok, binary()} | {error, aion@error:engine_error()}.
id() ->
aion@workflow@run:id().
-file("src/aion/workflow.gleam", 105).
-spec now() -> {ok, aion@workflow@run:timestamp()} |
{error, aion@error:engine_error()}.
now() ->
aion@workflow@run:now().
-file("src/aion/workflow.gleam", 109).
-spec random() -> {ok, float()} | {error, aion@error:engine_error()}.
random() ->
aion@workflow@run:random().
-file("src/aion/workflow.gleam", 113).
-spec random_int(integer(), integer()) -> {ok, integer()} |
{error, aion@error:engine_error()}.
random_int(Min, Max) ->
aion@workflow@run:random_int(Min, Max).
-file("src/aion/workflow.gleam", 117).
-spec sleep(aion@duration:duration()) -> {ok, nil} |
{error, aion@error:engine_error()}.
sleep(Duration) ->
aion@workflow@timer:sleep(Duration).
-file("src/aion/workflow.gleam", 121).
-spec start_timer(binary(), aion@duration:duration()) -> {ok,
aion@workflow@timer:timer_ref()} |
{error, aion@error:engine_error()}.
start_timer(Name, Duration) ->
aion@workflow@timer:start_timer(Name, Duration).
-file("src/aion/workflow.gleam", 128).
-spec cancel_timer(aion@workflow@timer:timer_ref()) -> {ok, nil} |
{error, aion@error:engine_error()}.
cancel_timer(Reference) ->
aion@workflow@timer:cancel_timer(Reference).
-file("src/aion/workflow.gleam", 132).
-spec with_timeout(
fun(() -> {ok, GFD} | {error, GFE}),
aion@duration:duration()
) -> {ok, GFD} | {error, aion@error:timeout_result_error(GFE)}.
with_timeout(Operation, Deadline) ->
aion@workflow@timer:with_timeout(Operation, Deadline).
-file("src/aion/workflow.gleam", 139).
-spec continue_as_new(GFK, aion@codec:codec(GFK)) -> {ok, nil} |
{error, aion@error:workflow_error()}.
continue_as_new(Input, Input_codec) ->
aion@workflow@continuation:continue_as_new(Input, Input_codec).
-file("src/aion/workflow.gleam", 146).
-spec 'receive'(aion@signal:signal_ref(GFO)) -> {ok, GFO} |
{error, aion@error:receive_error()}.
'receive'(Reference) ->
aion@signal:'receive'(Reference).
-file("src/aion/workflow.gleam", 152).
-spec timer_id(aion@workflow@timer:timer_ref()) -> binary().
timer_id(Reference) ->
aion@workflow@timer:timer_id(Reference).
-file("src/aion/workflow.gleam", 156).
-spec spawn(
binary(),
fun((GFS) -> {ok, GFT} | {error, GFU}),
GFS,
aion@codec:codec(GFS),
aion@codec:codec(GFT),
aion@codec:codec(GFU)
) -> {ok, aion@child:child_handle(GFT, GFU)} |
{error, aion@error:engine_error()}.
spawn(Name, Workflow_fn, Input, Input_codec, Output_codec, Error_codec) ->
aion@child:spawn(
Name,
Workflow_fn,
Input,
Input_codec,
Output_codec,
Error_codec
).
-file("src/aion/workflow.gleam", 167).
-spec spawn_and_wait(
binary(),
fun((GGE) -> {ok, GGF} | {error, GGG}),
GGE,
aion@codec:codec(GGE),
aion@codec:codec(GGF),
aion@codec:codec(GGG)
) -> {ok, GGF} | {error, aion@error:child_error(GGG)}.
spawn_and_wait(Name, Workflow_fn, Input, Input_codec, Output_codec, Error_codec) ->
aion@child:spawn_and_wait(
Name,
Workflow_fn,
Input,
Input_codec,
Output_codec,
Error_codec
).
-file("src/aion/workflow.gleam", 185).
-spec timestamp_to_milliseconds(aion@workflow@run:timestamp()) -> integer().
timestamp_to_milliseconds(Timestamp) ->
aion@workflow@run:timestamp_to_milliseconds(Timestamp).
-file("src/aion/workflow.gleam", 189).
-spec define(
binary(),
aion@codec:codec(GGP),
aion@codec:codec(GGR),
aion@codec:codec(GGT),
fun((GGP) -> {ok, GGR} | {error, GGT})
) -> aion@workflow@define:workflow_definition(GGP, GGR, GGT).
define(Name, Input_codec, Output_codec, Error_codec, Entry_fn) ->
aion@workflow@define:define(
Name,
Input_codec,
Output_codec,
Error_codec,
Entry_fn
).
-file("src/aion/workflow.gleam", 199).
-spec name(aion@workflow@define:workflow_definition(any(), any(), any())) -> binary().
name(Definition) ->
aion@workflow@define:name(Definition).
-file("src/aion/workflow.gleam", 205).
-spec input_codec(aion@workflow@define:workflow_definition(GHG, any(), any())) -> aion@codec:codec(GHG).
input_codec(Definition) ->
aion@workflow@define:input_codec(Definition).
-file("src/aion/workflow.gleam", 211).
-spec output_codec(aion@workflow@define:workflow_definition(any(), GHO, any())) -> aion@codec:codec(GHO).
output_codec(Definition) ->
aion@workflow@define:output_codec(Definition).
-file("src/aion/workflow.gleam", 217).
-spec error_codec(aion@workflow@define:workflow_definition(any(), any(), GHW)) -> aion@codec:codec(GHW).
error_codec(Definition) ->
aion@workflow@define:error_codec(Definition).
-file("src/aion/workflow.gleam", 223).
-spec entry_fn(aion@workflow@define:workflow_definition(GIB, GIC, GID)) -> fun((GIB) -> {ok,
GIC} |
{error, GID}).
entry_fn(Definition) ->
aion@workflow@define:entry_fn(Definition).
-file("src/aion/workflow.gleam", 241).
?DOC(
" Drive a workflow's typed entry from the engine's raw spawn argument,\n"
" making the hand-written `run` adapter a one-line shim:\n"
"\n"
" ```gleam\n"
" pub fn run(raw_input: Dynamic) -> Result(String, String) {\n"
" workflow.entrypoint(definition(), raw_input)\n"
" }\n"
" ```\n"
"\n"
" Success encodes with the definition's output codec, typed failure with its\n"
" error codec (byte-identical to the hand-written adapter); an undecodable\n"
" input yields the documented `{\"aion_error\":\"input_decode\",...}` envelope.\n"
).
-spec entrypoint(
aion@workflow@define:workflow_definition(any(), any(), any()),
gleam@dynamic:dynamic_()
) -> {ok, binary()} | {error, binary()}.
entrypoint(Definition, Raw_input) ->
aion@workflow@entrypoint:entrypoint(Definition, Raw_input).