temporal_sdk_nexus behaviour (temporal_sdk v0.1.14)
View SourceTemporal nexus task module.
WIP. Module will provide Temporal Nexus services.
Summary
Types
-type cancel_action() :: {cancel, CanceledDetails :: temporal_sdk:term_to_payloads()}.
-type complete_action() :: {complete, Result :: temporal_sdk:term_to_payloads()}.
-type context() :: #{cluster := temporal_sdk_cluster:cluster_name(), executor_pid := pid(), otel_ctx := otel_ctx:t(), task := task(), worker_opts := temporal_sdk_worker:opts(), operation := unicode:chardata(), started_at := SystemTime :: integer(), task_timeout := erlang:timeout()}.
-type data() :: term().
-type data_action() :: {data, NewData :: data()}.
-type fail_action() :: {fail, {Source :: temporal_sdk:serializable(), Message :: temporal_sdk:serializable(), Stacktrace :: temporal_sdk:serializable()}}.
-type handler_context() :: #{data := data(), cancel_requested := boolean(), elapsed_time := non_neg_integer(), remaining_time := erlang:timeout()}.
-type terminate_action() :: cancel_action() | complete_action() | fail_action().
Callbacks
-callback execute(Context :: context(), RequestPayload :: temporal_sdk:term_from_payload()) -> ResponsePayload :: temporal_sdk:term_to_payload().
-callback handle_cancel(HandlerContext :: handler_context()) -> terminate_action() | ignore.
-callback handle_message(HandlerContext :: handler_context(), Message :: term()) -> terminate_action() | data_action() | ignore.
-callback handle_terminate(HandlerContext :: handler_context()) -> any().
Functions
-spec await_data(EtsPattern :: term(), Timeout :: erlang:timeout()) -> {ok, data()} | timeout | invalid_pattern | no_return().
-spec cancel(CanceledDetails :: temporal_sdk:term_to_payloads()) -> no_return().
-spec complete(Result :: temporal_sdk:term_to_payloads()) -> no_return().
-spec elapsed_time() -> NativeTime :: non_neg_integer() | no_return().
-spec elapsed_time(Unit :: erlang:time_unit()) -> non_neg_integer() | no_return().
-spec fail(ApplicationFailure :: temporal_sdk:application_failure() | temporal_sdk:user_application_failure()) -> no_return().
-spec remaining_time() -> NativeTime :: non_neg_integer() | infinity | no_return().
-spec remaining_time(Unit :: erlang:time_unit()) -> non_neg_integer() | infinity | no_return().
-spec set_data(TaskData :: term()) -> ok.