taskpoller

package
v1.26.2-rc.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 13 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
	}
	// 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
		}
	}
	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 TaskPoller

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

func New

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

func (*TaskPoller) HandleActivityTask

func (p *TaskPoller) HandleActivityTask(
	tv *testvars.TestVars,
	task *workflowservice.PollActivityTaskQueueResponse,
	handler func(task *workflowservice.PollActivityTaskQueueResponse) (*workflowservice.RespondActivityTaskCompletedRequest, error),
	opts ...optionFunc,
) (*workflowservice.RespondActivityTaskCompletedResponse, error)

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

func (*TaskPoller) HandleWorkflowTask

func (p *TaskPoller) HandleWorkflowTask(
	tv *testvars.TestVars,
	task *workflowservice.PollWorkflowTaskQueueResponse,
	handler func(task *workflowservice.PollWorkflowTaskQueueResponse) (*workflowservice.RespondWorkflowTaskCompletedRequest, error),
	opts ...optionFunc,
) (*workflowservice.RespondWorkflowTaskCompletedResponse, error)

HandleWorkflowTask invokes the provided handler with the provided task, and completes/fails the task accordingly. 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

func (p *TaskPoller) PollAndHandleActivityTask(
	tv *testvars.TestVars,
	handler func(task *workflowservice.PollActivityTaskQueueResponse) (*workflowservice.RespondActivityTaskCompletedRequest, error),
	opts ...optionFunc,
) (*workflowservice.RespondActivityTaskCompletedResponse, error)

PollAndHandleActivityTask issues a PollActivityTaskQueueRequest to obtain a new activity task, invokes the handler with the task, and completes/fails the task accordingly. 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 NoTaskAvailable.

func (*TaskPoller) PollAndHandleWorkflowTask

func (p *TaskPoller) PollAndHandleWorkflowTask(
	tv *testvars.TestVars,
	handler func(task *workflowservice.PollWorkflowTaskQueueResponse) (*workflowservice.RespondWorkflowTaskCompletedRequest, error),
	opts ...optionFunc,
) (*workflowservice.RespondWorkflowTaskCompletedResponse, error)

PollAndHandleWorkflowTask issues a PollWorkflowTaskQueueRequest to obtain a new workflow task, invokes the handler with the task, and completes/fails the task accordingly. 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 NoTaskAvailable.

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