Skip to content

Commit

Permalink
Update client wrappers with new async APIs (#1327)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylanisikdemir committed Apr 2, 2024
1 parent 68afcb9 commit 08b284a
Show file tree
Hide file tree
Showing 8 changed files with 839 additions and 213 deletions.
18 changes: 18 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ type (
// - InternalServiceError
StartWorkflow(ctx context.Context, options StartWorkflowOptions, workflowFunc interface{}, args ...interface{}) (*workflow.Execution, error)

// StartWorkflowAsync behaves like StartWorkflow except that the request is first queued and then processed asynchronously.
// See StartWorkflow for parameter details.
// The returned AsyncWorkflowExecution doesn't contain run ID, because the workflow hasn't started yet.
// The errors it can return:
// - EntityNotExistsError, if domain does not exists
// - BadRequestError
// - InternalServiceError
StartWorkflowAsync(ctx context.Context, options StartWorkflowOptions, workflow interface{}, args ...interface{}) (*workflow.ExecutionAsync, error)

// ExecuteWorkflow starts a workflow execution and return a WorkflowRun instance and error
// The user can use this to start using a function or workflow type name.
// Either by
Expand Down Expand Up @@ -169,6 +178,15 @@ type (
SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{},
options StartWorkflowOptions, workflowFunc interface{}, workflowArgs ...interface{}) (*workflow.Execution, error)

// SignalWithStartWorkflowAsync behaves like SignalWithStartWorkflow except that the request is first queued and then processed asynchronously.
// See SignalWithStartWorkflow for parameter details.
// The errors it can return:
// - EntityNotExistsError, if domain does not exist
// - BadRequestError
// - InternalServiceError
SignalWithStartWorkflowAsync(ctx context.Context, workflowID string, signalName string, signalArg interface{},
options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (*workflow.ExecutionAsync, error)

// CancelWorkflow cancels a workflow in execution
// - workflow ID of the workflow.
// - runID can be default(empty string). if empty string then it will pick the running execution of that workflow ID.
Expand Down
18 changes: 18 additions & 0 deletions internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ type (
// subjected to change in the future.
StartWorkflow(ctx context.Context, options StartWorkflowOptions, workflow interface{}, args ...interface{}) (*WorkflowExecution, error)

// StartWorkflowAsync behaves like StartWorkflow except that the request is first queued and then processed asynchronously.
// See StartWorkflow for parameter details.
// The returned AsyncWorkflowExecution doesn't contain run ID, because the workflow hasn't started yet.
// The errors it can return:
// - EntityNotExistsError, if domain does not exists
// - BadRequestError
// - InternalServiceError
StartWorkflowAsync(ctx context.Context, options StartWorkflowOptions, workflow interface{}, args ...interface{}) (*WorkflowExecutionAsync, error)

// ExecuteWorkflow starts a workflow execution and return a WorkflowRun instance and error
// The user can use this to start using a function or workflow type name.
// Either by
Expand Down Expand Up @@ -160,6 +169,15 @@ type (
SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{},
options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (*WorkflowExecution, error)

// SignalWithStartWorkflowAsync behaves like SignalWithStartWorkflow except that the request is first queued and then processed asynchronously.
// See SignalWithStartWorkflow for parameter details.
// The errors it can return:
// - EntityNotExistsError, if domain does not exist
// - BadRequestError
// - InternalServiceError
SignalWithStartWorkflowAsync(ctx context.Context, workflowID string, signalName string, signalArg interface{},
options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (*WorkflowExecutionAsync, error)

// CancelWorkflow cancels a workflow in execution
// - workflow ID of the workflow.
// - runID can be default(empty string). if empty string then it will pick the running execution of that workflow ID.
Expand Down
28 changes: 15 additions & 13 deletions internal/common/metrics/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ package metrics

// Workflow Creation metrics
const (
CadenceMetricsPrefix = "cadence-"
WorkflowStartCounter = CadenceMetricsPrefix + "workflow-start"
WorkflowCompletedCounter = CadenceMetricsPrefix + "workflow-completed"
WorkflowCanceledCounter = CadenceMetricsPrefix + "workflow-canceled"
WorkflowFailedCounter = CadenceMetricsPrefix + "workflow-failed"
WorkflowContinueAsNewCounter = CadenceMetricsPrefix + "workflow-continue-as-new"
WorkflowEndToEndLatency = CadenceMetricsPrefix + "workflow-endtoend-latency" // measure workflow execution from start to close
WorkflowGetHistoryCounter = CadenceMetricsPrefix + "workflow-get-history-total"
WorkflowGetHistoryFailedCounter = CadenceMetricsPrefix + "workflow-get-history-failed"
WorkflowGetHistorySucceedCounter = CadenceMetricsPrefix + "workflow-get-history-succeed"
WorkflowGetHistoryLatency = CadenceMetricsPrefix + "workflow-get-history-latency"
WorkflowSignalWithStartCounter = CadenceMetricsPrefix + "workflow-signal-with-start"
DecisionTimeoutCounter = CadenceMetricsPrefix + "decision-timeout"
CadenceMetricsPrefix = "cadence-"
WorkflowStartCounter = CadenceMetricsPrefix + "workflow-start"
WorkflowStartAsyncCounter = CadenceMetricsPrefix + "workflow-start-async"
WorkflowCompletedCounter = CadenceMetricsPrefix + "workflow-completed"
WorkflowCanceledCounter = CadenceMetricsPrefix + "workflow-canceled"
WorkflowFailedCounter = CadenceMetricsPrefix + "workflow-failed"
WorkflowContinueAsNewCounter = CadenceMetricsPrefix + "workflow-continue-as-new"
WorkflowEndToEndLatency = CadenceMetricsPrefix + "workflow-endtoend-latency" // measure workflow execution from start to close
WorkflowGetHistoryCounter = CadenceMetricsPrefix + "workflow-get-history-total"
WorkflowGetHistoryFailedCounter = CadenceMetricsPrefix + "workflow-get-history-failed"
WorkflowGetHistorySucceedCounter = CadenceMetricsPrefix + "workflow-get-history-succeed"
WorkflowGetHistoryLatency = CadenceMetricsPrefix + "workflow-get-history-latency"
WorkflowSignalWithStartCounter = CadenceMetricsPrefix + "workflow-signal-with-start"
WorkflowSignalWithStartAsyncCounter = CadenceMetricsPrefix + "workflow-signal-with-start-async"
DecisionTimeoutCounter = CadenceMetricsPrefix + "decision-timeout"

DecisionPollCounter = CadenceMetricsPrefix + "decision-poll-total"
DecisionPollFailedCounter = CadenceMetricsPrefix + "decision-poll-failed"
Expand Down

0 comments on commit 08b284a

Please sign in to comment.