-module(aion@workflow@continuation). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/aion/workflow/continuation.gleam"). -export([continue_as_new/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(" continue_as_new workflow primitive.\n"). -file("src/aion/workflow/continuation.gleam", 14). ?DOC( " Continue the current workflow as a new run with fresh history.\n" "\n" " The input is serialized through the workflow's input codec — the same\n" " codec the entry wrapper decodes with — so the replacement run receives\n" " exactly the payload shape it expects. On success the engine records\n" " `WorkflowContinuedAsNew` and terminates the current run, so an `Ok` value\n" " is intentionally uninhabited.\n" ). -spec continue_as_new(EXS, aion@codec:codec(EXS)) -> {ok, nil} | {error, aion@error:workflow_error()}. continue_as_new(Input, Input_codec) -> case aion_flow_ffi:continue_as_new((erlang:element(2, Input_codec))(Input)) of {ok, Value} -> {ok, Value}; {error, Raw_error} -> {error, {workflow_engine_failure, Raw_error}} end.