Current section
Files
Jump to
Current section
Files
src/aion@workflow@define.erl
-module(aion@workflow@define).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/aion/workflow/define.gleam").
-export([define/5, name/1, input_codec/1, output_codec/1, error_codec/1, entry_fn/1]).
-export_type([workflow_definition/3]).
-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.define: typed entry contract (entry fn + input/output/error codecs)\n").
-opaque workflow_definition(FLJ, FLK, FLL) :: {workflow_definition,
binary(),
aion@codec:codec(FLJ),
aion@codec:codec(FLK),
aion@codec:codec(FLL),
fun((FLJ) -> {ok, FLK} | {error, FLL})}.
-file("src/aion/workflow/define.gleam", 29).
?DOC(" Define a typed workflow entry contract consumed by AE at spawn.\n").
-spec define(
binary(),
aion@codec:codec(FLM),
aion@codec:codec(FLO),
aion@codec:codec(FLQ),
fun((FLM) -> {ok, FLO} | {error, FLQ})
) -> workflow_definition(FLM, FLO, FLQ).
define(Name, Input_codec, Output_codec, Error_codec, Entry_fn) ->
{workflow_definition,
Name,
Input_codec,
Output_codec,
Error_codec,
Entry_fn}.
-file("src/aion/workflow/define.gleam", 46).
?DOC(" Return the workflow name carried by the definition.\n").
-spec name(workflow_definition(any(), any(), any())) -> binary().
name(Definition) ->
erlang:element(2, Definition).
-file("src/aion/workflow/define.gleam", 51).
?DOC(" Return the input codec used by AE to decode the spawn Payload.\n").
-spec input_codec(workflow_definition(FMD, any(), any())) -> aion@codec:codec(FMD).
input_codec(Definition) ->
erlang:element(3, Definition).
-file("src/aion/workflow/define.gleam", 58).
?DOC(" Return the output codec used by AE to encode successful completion Payloads.\n").
-spec output_codec(workflow_definition(any(), FML, any())) -> aion@codec:codec(FML).
output_codec(Definition) ->
erlang:element(4, Definition).
-file("src/aion/workflow/define.gleam", 65).
?DOC(" Return the error codec used by AE to encode failed completion Payloads.\n").
-spec error_codec(workflow_definition(any(), any(), FMT)) -> aion@codec:codec(FMT).
error_codec(Definition) ->
erlang:element(5, Definition).
-file("src/aion/workflow/define.gleam", 72).
?DOC(" Return the typed entry function carried for AE to invoke/drive.\n").
-spec entry_fn(workflow_definition(FMY, FMZ, FNA)) -> fun((FMY) -> {ok, FMZ} |
{error, FNA}).
entry_fn(Definition) ->
erlang:element(6, Definition).