temporal_sdk (temporal_sdk v0.1.14)

View Source

Common workflow services module.

Summary

Types

application_failure()

-type application_failure() ::
          #{source => temporal_sdk:serializable(),
            message => temporal_sdk:serializable(),
            stack_trace => temporal_sdk:serializable(),
            encoded_attributes => temporal_sdk:term_to_payload(),
            type => unicode:chardata(),
            non_retryable => boolean(),
            details => temporal_sdk:term_to_payloads(),
            next_retry_delay => temporal_sdk:time()}.

convertable()

-type convertable() :: dynamic().

deconverted()

-type deconverted() :: dynamic().

failure_from_temporal()

-type failure_from_temporal() ::
          #{source => unicode:chardata(),
            message => unicode:chardata(),
            stack_trace => unicode:chardata(),
            encoded_attributes => temporal_sdk:term_from_payload(),
            failure_info =>
                {atom(), map()} |
                {application_failure_info,
                 #{type => unicode:chardata(),
                   non_retryable => boolean(),
                   details => temporal_sdk:term_from_payloads(),
                   next_retry_delay => pos_integer()}}}.

retry_policy()

-type retry_policy() ::
          #{initial_interval => pos_integer(),
            backoff_coefficient => number(),
            maximum_interval => pos_integer(),
            maximum_attempts => pos_integer(),
            non_retryable_error_types => [unicode:chardata()]}.

serializable()

-type serializable() :: dynamic().

temporal_mapstring_payload()

-type temporal_mapstring_payload() :: #{unicode:chardata() => temporal_payload()}.

temporal_mapstring_payloads()

-type temporal_mapstring_payloads() :: #{unicode:chardata() => temporal_payloads()}.

temporal_payload()

temporal_payloads()

term_from_mapstring_payload()

-type term_from_mapstring_payload() :: #{unicode:chardata() => term_from_payload()}.

term_from_mapstring_payloads()

-type term_from_mapstring_payloads() :: #{unicode:chardata() => term_from_payloads()}.

term_from_payload()

-type term_from_payload() :: deconverted().

term_from_payloads()

-type term_from_payloads() :: [deconverted()].

term_to_mapstring_payload()

-type term_to_mapstring_payload() :: #{unicode:chardata() | atom() => term_to_payload()}.

term_to_mapstring_payloads()

-type term_to_mapstring_payloads() :: #{unicode:chardata() | atom() => term_to_payloads()}.

term_to_payload()

-type term_to_payload() :: convertable().

term_to_payloads()

-type term_to_payloads() :: [convertable()].

time()

-type time() ::
          {TimeLength :: number(), TimeUnit :: time_unit()} | (TimeMilliseconds :: non_neg_integer()).

time_unit()

-type time_unit() :: millisecond | second | minute | hour | day.

user_application_failure()

-type user_application_failure() ::
          [{source, temporal_sdk:serializable()} |
           {message, temporal_sdk:serializable()} |
           {stack_trace, temporal_sdk:serializable()} |
           {encoded_attributes, temporal_sdk:term_to_payload()} |
           {type, unicode:chardata()} |
           {non_retryable, boolean()} |
           non_retryable |
           {details, temporal_sdk:term_to_payloads()} |
           {next_retry_delay, temporal_sdk:time()}].

user_metadata()

-type user_metadata() :: #{summary => term_to_payload(), details => term_to_payload()}.

workflow_execution()

Functions

await_workflow(Cluster, WorkflowExecution)

-spec await_workflow(Cluster :: temporal_sdk_cluster:cluster_name(),
                     WorkflowExecution :: workflow_execution()) ->
                        {ok, workflow_result()} |
                        {error, Reason :: map() | invalid_cluster} |
                        call_response_error().

await_workflow(Cluster, WorkflowExecution, Opts)

-spec await_workflow(Cluster :: temporal_sdk_cluster:cluster_name(),
                     WorkflowExecution :: workflow_execution(),
                     Opts :: await_workflow_opts()) ->
                        {ok, workflow_result()} |
                        {error, Reason :: map() | invalid_cluster} |
                        call_response_error().

format_response(Cluster, MessageName, Response)

get_workflow_history(Cluster, WorkflowExecution)

-spec get_workflow_history(Cluster :: temporal_sdk_cluster:cluster_name(),
                           WorkflowExecution :: workflow_execution()) ->
                              {ok,
                               [temporal_sdk_proto_service_workflow_binaries:'temporal.api.history.v1.HistoryEvent'(),
                                ...]} |
                              call_response_error() |
                              {error, Reason :: term()}.

get_workflow_history(Cluster, WorkflowExecution, Opts)

get_workflow_state(Cluster, WorkflowExecution)

-spec get_workflow_state(Cluster :: temporal_sdk_cluster:cluster_name(),
                         WorkflowExecution :: workflow_execution()) ->
                            get_workflow_state_ret().

get_workflow_state(Cluster, WorkflowExecution, Opts)

-spec get_workflow_state(Cluster :: temporal_sdk_cluster:cluster_name(),
                         WorkflowExecution :: workflow_execution(),
                         Opts :: get_workflow_state_opts()) ->
                            get_workflow_state_ret().

replay_file(Cluster, WorkflowMod, Filename)

-spec replay_file(Cluster :: temporal_sdk_cluster:cluster_name(),
                  WorkflowMod :: module(),
                  Filename :: file:name_all()) ->
                     replay_json_ret() |
                     {error, Reason :: file:posix() | badarg | terminated | system_limit}.

replay_file(Cluster, WorkflowMod, Filename, Opts)

-spec replay_file(Cluster :: temporal_sdk_cluster:cluster_name(),
                  WorkflowMod :: module(),
                  Filename :: file:name_all(),
                  Opts :: replay_workflow_opts()) ->
                     replay_json_ret() |
                     {error, Reason :: file:posix() | badarg | terminated | system_limit}.

replay_json(Cluster, WorkflowMod, Json)

-spec replay_json(Cluster :: temporal_sdk_cluster:cluster_name(),
                  WorkflowMod :: module(),
                  Json :: unicode:chardata()) ->
                     replay_json_ret().

replay_json(Cluster, WorkflowMod, Json, Opts)

-spec replay_json(Cluster :: temporal_sdk_cluster:cluster_name(),
                  WorkflowMod :: module(),
                  Json :: unicode:chardata(),
                  Opts :: replay_workflow_opts()) ->
                     replay_json_ret().

replay_task(Cluster, TaskQueue, WorkflowType, WorkflowMod)

-spec replay_task(Cluster :: temporal_sdk_cluster:cluster_name(),
                  TaskQueue :: unicode:chardata(),
                  WorkflowType :: atom() | unicode:chardata(),
                  WorkflowMod :: module()) ->
                     replay_json_ret() | call_response_error().

replay_task(Cluster, TaskQueue, WorkflowType, WorkflowMod, Opts)

-spec replay_task(Cluster :: temporal_sdk_cluster:cluster_name(),
                  TaskQueue :: unicode:chardata(),
                  WorkflowType :: atom() | unicode:chardata(),
                  WorkflowMod :: module(),
                  Opts :: replay_task_opts()) ->
                     replay_json_ret() |
                     {ok, replay_workflow_ret(), file:name_all()} |
                     call_response_error().

start_workflow(Cluster, TaskQueue, WorkflowType)

-spec start_workflow(Cluster :: temporal_sdk_cluster:cluster_name(),
                     TaskQueue :: unicode:chardata(),
                     WorkflowType :: atom() | unicode:chardata()) ->
                        {ok, start_workflow_ret()} |
                        {error, Reason :: map() | invalid_cluster} |
                        call_response_error().

start_workflow(Cluster, TaskQueue, WorkflowType, Opts)

-spec start_workflow(Cluster :: temporal_sdk_cluster:cluster_name(),
                     TaskQueue :: unicode:chardata(),
                     WorkflowType :: atom() | unicode:chardata(),
                     Opts :: start_workflow_opts()) ->
                        {ok, start_workflow_ret(), workflow_result()} |
                        {start_workflow_ret(), workflow_result()} |
                        no_return() |
                        {ok, start_workflow_ret()} |
                        {error, Reason :: map() | invalid_cluster} |
                        call_response_error().

wait_workflow(Cluster, WorkflowExecution)

-spec wait_workflow(Cluster :: temporal_sdk_cluster:cluster_name(),
                    WorkflowExecution :: workflow_execution()) ->
                       workflow_result() | no_return().

wait_workflow(Cluster, WorkflowExecution, Opts)

-spec wait_workflow(Cluster :: temporal_sdk_cluster:cluster_name(),
                    WorkflowExecution :: workflow_execution(),
                    Opts :: await_workflow_opts()) ->
                       workflow_result() | no_return().

Functions types

await_workflow_opts()

-type await_workflow_opts() :: [{namespace, unicode:chardata()} | {timeout, time() | infinity}].

call_response_error()

-type call_response_error() :: temporal_sdk_client:call_result_error().

get_workflow_history_opts()

-type get_workflow_history_opts() ::
          [{namespace, unicode:chardata()} |
           {maximum_page_size, pos_integer()} |
           {next_page_token, binary()} |
           {wait_new_event, boolean()} |
           {history_event_filter_type,
            temporal_sdk_proto_service_workflow_binaries:'temporal.api.enums.v1.HistoryEventFilterType'()} |
           {raw_request,
            temporal_sdk_proto_service_workflow_binaries:'temporal.api.workflowservice.v1.GetWorkflowExecutionHistoryRequest'()} |
           {timeout, time() | infinity} |
           {grpc_opts, temporal_sdk_client:grpc_opts()} |
           {await_all, boolean()} |
           await_all |
           {await_all_close, boolean()} |
           await_all_close |
           {await_close, boolean()} |
           await_close |
           {history_file, boolean() | file:name_all()} |
           history_file |
           {history_file_write_modes, [file:mode()]} |
           {json, boolean()} |
           json].

get_workflow_state_opts()

-type get_workflow_state_opts() :: [{namespace, unicode:chardata()}].

get_workflow_state_ret()

-type get_workflow_state_ret() ::
          {ok,
           completed | failed | timed_out | terminated | canceled | continued_as_new | unspecified |
           running} |
          call_response_error().

replay_json_ret()

-type replay_json_ret() ::
          {ok, replay_workflow_ret()} |
          {error,
           Reason ::
               timeout | unclosed_history | malformed_history | invalid_cluster |
               {invalid_opts, map()} |
               term()}.

replay_task_opts()

-type replay_task_opts() ::
          [{start_workflow_opts, start_workflow_opts()} |
           {replay_workflow_opts, replay_workflow_opts()} |
           {history_file, boolean() | file:name_all()} |
           history_file |
           {history_file_write_modes, [file:mode()]}].

replay_workflow_opts()

-type replay_workflow_opts() ::
          [{timeout, erlang:timeout()} |
           {grpc_opts, temporal_sdk_client:grpc_opts()} |
           {worker_id, term()} |
           {worker_opts, term()}].

replay_workflow_ret()

-type replay_workflow_ret() ::
          {completed, Result :: temporal_sdk:term_to_payloads()} |
          {canceled, Details :: temporal_sdk:term_to_payloads()} |
          {failed,
           Failure :: temporal_sdk:application_failure() | temporal_sdk:user_application_failure()} |
          {error, Error :: temporal_sdk_telemetry:exception()}.

response()

-type response() ::
          {ok, FormattedResponse :: map()} |
          {error, FormattedGrpcResponseErrorMessage :: unicode:chardata()} |
          temporal_sdk_client:result().

response_type()

-type response_type() :: call_formatted | call | cast | msg.

start_workflow_opts()

-type start_workflow_opts() ::
          [{namespace, unicode:chardata()} |
           {workflow_id, unicode:chardata()} |
           {input, term_to_payloads()} |
           {workflow_execution_timeout, time()} |
           {workflow_run_timeout, time()} |
           {workflow_task_timeout, time()} |
           {identity, unicode:chardata()} |
           {request_id, unicode:chardata()} |
           {workflow_id_reuse_policy,
            temporal_sdk_proto_service_workflow_binaries:'temporal.api.enums.v1.WorkflowIdReusePolicy'()} |
           {workflow_id_conflict_policy,
            temporal_sdk_proto_service_workflow_binaries:'temporal.api.enums.v1.WorkflowIdConflictPolicy'()} |
           {signal_name, unicode:chardata()} |
           {signal_input, term_to_payloads()} |
           {retry_policy, retry_policy()} |
           {cron_schedule, unicode:chardata()} |
           {memo, term_to_mapstring_payload()} |
           {search_attributes, term_to_mapstring_payload()} |
           {header, term_to_mapstring_payload()} |
           {request_eager_execution, boolean() | atom()} |
           request_eager_execution |
           {workflow_start_delay, time()} |
           {user_metadata, user_metadata()} |
           {versioning_override,
            temporal_sdk_proto_service_workflow_binaries:'temporal.api.workflow.v1.VersioningOverride'()} |
           {on_conflict_options,
            temporal_sdk_proto_service_workflow_binaries:'temporal.api.workflow.v1.OnConflictOptions'()} |
           {priority, temporal_sdk_proto_service_workflow_binaries:'temporal.api.common.v1.Priority'()} |
           {eager_worker_deployment_options,
            temporal_sdk_proto_service_workflow_binaries:'temporal.api.deployment.v1.WorkerDeploymentOptions'()} |
           {eager_worker_id, temporal_sdk_worker:id()} |
           {raw_request,
            temporal_sdk_proto_service_workflow_binaries:'temporal.api.workflowservice.v1.StartWorkflowExecutionRequest'()} |
           {await, true | time() | infinity} |
           await |
           {wait, true | time() | infinity} |
           wait].

start_workflow_ret()

-type start_workflow_ret() ::
          #{request_id := unicode:chardata(),
            started := boolean(),
            workflow_execution := workflow_execution()}.

workflow_result()