Help us shape the future of Go! Take the 2026 Go Developer Survey

taskpoller

package
v1.32.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DrainWorkflowTask returns an empty RespondWorkflowTaskCompletedRequest
	DrainWorkflowTask = func(task *workflowservice.PollWorkflowTaskQueueResponse) (*workflowservice.RespondWorkflowTaskCompletedRequest, error) {
		return &workflowservice.RespondWorkflowTaskCompletedRequest{}, nil
	}
	// CompleteWorkflowHandler is a workflow task handler that always completes the workflow.
	CompleteWorkflowHandler = func(task *workflowservice.PollWorkflowTaskQueueResponse) (*workflowservice.RespondWorkflowTaskCompletedRequest, error) {
		return &workflowservice.RespondWorkflowTaskCompletedRequest{
			Commands: []*commandpb.Command{{
				CommandType: enumspb.COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION,
				Attributes: &commandpb.Command_CompleteWorkflowExecutionCommandAttributes{
					CompleteWorkflowExecutionCommandAttributes: &commandpb.CompleteWorkflowExecutionCommandAttributes{},
				},
			}},
		}, nil
	}
	// CompleteActivityTask returns a RespondActivityTaskCompletedRequest with an auto-generated `Result` from `tv.Any().Payloads()`.
	CompleteActivityTask = func(tv *testvars.TestVars) func(task *workflowservice.PollActivityTaskQueueResponse) (*workflowservice.RespondActivityTaskCompletedRequest, error) {
		return func(task *workflowservice.PollActivityTaskQueueResponse) (*workflowservice.RespondActivityTaskCompletedRequest, error) {
			return &workflowservice.RespondActivityTaskCompletedRequest{
				Result: tv.Any().Payloads(),
			}, nil
		}
	}
	// WithTimeout defines a timeout for a task poller method (includes *all* RPC calls it has to make)
	WithTimeout = func(timeout time.Duration) optionFunc {
		return func(o *options) {
			o.timeout = timeout
		}
	}
	// WithTimeout sets a context for a task poller method (includes *all* RPC calls it has to make)
	WithContext = func(ctx context.Context) optionFunc {
		return func(o *options) {
			o.ctx = ctx
		}
	}
	NoWorkflowTaskAvailable = errors.New("taskpoller test helper timed out while waiting for the PollWorkflowTaskQueue API response, meaning no workflow task was ever created")
	NoActivityTaskAvailable = errors.New("taskpoller test helper timed out while waiting for the PollActivityTaskQueue API response, meaning no activity task was ever created")
)

Functions

This section is empty.

Types

type Helper added in v1.27.0

type Helper interface {
	Helper()
}

type TaskPoller

type TaskPoller struct {
	// contains filtered or unexported fields
}

func New

func New(
	t Helper,
	client workflowservice.WorkflowServiceClient,
	namespace string,
) *TaskPoller

func (*TaskPoller) HandleActivityTask

HandleActivityTask invokes the provided handler with the provided task, and completes/fails the task accordingly. Is it a blocking call. Any unspecified but required request and response fields are automatically generated using `tv`. Returning an error from `handler` fails the task.

func (*TaskPoller) HandleWorkflowTask

HandleWorkflowTask invokes the provided handler with the provided task, and completes/fails the task accordingly. Is it a blocking call. Any unspecified but required request and response fields are automatically generated using `tv`. Returning an error from `handler` fails the task.

func (*TaskPoller) PollActivityTask

func (p *TaskPoller) PollActivityTask(
	req *workflowservice.PollActivityTaskQueueRequest,
) *activityTaskPoller

PollActivityTask creates an activity task poller that uses the given PollActivityTaskQueueRequest.

func (*TaskPoller) PollAndHandleActivityTask

PollAndHandleActivityTask issues a PollActivityTaskQueueRequest to obtain a new activity task, invokes the handler with the task, and completes/fails the task accordingly. Is it a blocking call. Any unspecified but required request and response fields are automatically generated using `tv`. Returning an error from `handler` fails the task. If no task is available, it returns `NoActivityTaskAvailable`.

func (*TaskPoller) PollAndHandleWorkflowTask

PollAndHandleWorkflowTask issues a PollWorkflowTaskQueueRequest to obtain a new workflow task, invokes the handler with the task, and completes/fails the task accordingly. Is it a blocking call. Any unspecified but required request and response fields are automatically generated using `tv`. Returning an error from `handler` fails the task. If no task is available, it returns `NoWorkflowTaskAvailable`.

func (*TaskPoller) PollNexusTask added in v1.27.0

func (p *TaskPoller) PollNexusTask(
	req *workflowservice.PollNexusTaskQueueRequest,
) *nexusTaskPoller

func (*TaskPoller) PollWorkflowTask

func (p *TaskPoller) PollWorkflowTask(
	req *workflowservice.PollWorkflowTaskQueueRequest,
) *workflowTaskPoller

PollWorkflowTask creates a workflow task poller that uses the given PollWorkflowTaskQueueRequest.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL