1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package swf 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/swf/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Used by workers to get an ActivityTask from the specified activity taskList. 15// This initiates a long poll, where the service holds the HTTP connection open and 16// responds as soon as a task becomes available. The maximum time the service holds 17// on to the request before responding is 60 seconds. If no task is available 18// within 60 seconds, the poll returns an empty result. An empty result, in this 19// context, means that an ActivityTask is returned, but that the value of taskToken 20// is an empty string. If a task is returned, the worker should use its type to 21// identify and process it correctly. Workers should set their client side socket 22// timeout to at least 70 seconds (10 seconds higher than the maximum time service 23// may hold the poll request). Access Control You can use IAM policies to control 24// this action's access to Amazon SWF resources as follows: 25// 26// * Use a Resource 27// element with the domain name to limit the action to only specified domains. 28// 29// * 30// Use an Action element to allow or deny permission to call this action. 31// 32// * 33// Constrain the taskList.name parameter by using a Condition element with the 34// swf:taskList.name key to allow the action to access only certain task lists. 35// 36// If 37// the caller doesn't have sufficient permissions to invoke the action, or the 38// parameter values fall outside the specified constraints, the action fails. The 39// associated event attribute's cause parameter is set to OPERATION_NOT_PERMITTED. 40// For details and example IAM policies, see Using IAM to Manage Access to Amazon 41// SWF Workflows 42// (https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html) 43// in the Amazon SWF Developer Guide. 44func (c *Client) PollForActivityTask(ctx context.Context, params *PollForActivityTaskInput, optFns ...func(*Options)) (*PollForActivityTaskOutput, error) { 45 if params == nil { 46 params = &PollForActivityTaskInput{} 47 } 48 49 result, metadata, err := c.invokeOperation(ctx, "PollForActivityTask", params, optFns, addOperationPollForActivityTaskMiddlewares) 50 if err != nil { 51 return nil, err 52 } 53 54 out := result.(*PollForActivityTaskOutput) 55 out.ResultMetadata = metadata 56 return out, nil 57} 58 59type PollForActivityTaskInput struct { 60 61 // The name of the domain that contains the task lists being polled. 62 // 63 // This member is required. 64 Domain *string 65 66 // Specifies the task list to poll for activity tasks. The specified string must 67 // not start or end with whitespace. It must not contain a : (colon), / (slash), | 68 // (vertical bar), or any control characters (\u0000-\u001f | \u007f-\u009f). Also, 69 // it must not be the literal string arn. 70 // 71 // This member is required. 72 TaskList *types.TaskList 73 74 // Identity of the worker making the request, recorded in the ActivityTaskStarted 75 // event in the workflow history. This enables diagnostic tracing when problems 76 // arise. The form of this identity is user defined. 77 Identity *string 78} 79 80// Unit of work sent to an activity worker. 81type PollForActivityTaskOutput struct { 82 83 // The unique ID of the task. 84 // 85 // This member is required. 86 ActivityId *string 87 88 // The type of this activity task. 89 // 90 // This member is required. 91 ActivityType *types.ActivityType 92 93 // The ID of the ActivityTaskStarted event recorded in the history. 94 // 95 // This member is required. 96 StartedEventId int64 97 98 // The opaque string used as a handle on the task. This token is used by workers to 99 // communicate progress and response information back to the system about the task. 100 // 101 // This member is required. 102 TaskToken *string 103 104 // The workflow execution that started this activity task. 105 // 106 // This member is required. 107 WorkflowExecution *types.WorkflowExecution 108 109 // The inputs provided when the activity task was scheduled. The form of the input 110 // is user defined and should be meaningful to the activity implementation. 111 Input *string 112 113 // Metadata pertaining to the operation's result. 114 ResultMetadata middleware.Metadata 115} 116 117func addOperationPollForActivityTaskMiddlewares(stack *middleware.Stack, options Options) (err error) { 118 err = stack.Serialize.Add(&awsAwsjson10_serializeOpPollForActivityTask{}, middleware.After) 119 if err != nil { 120 return err 121 } 122 err = stack.Deserialize.Add(&awsAwsjson10_deserializeOpPollForActivityTask{}, middleware.After) 123 if err != nil { 124 return err 125 } 126 if err = addSetLoggerMiddleware(stack, options); err != nil { 127 return err 128 } 129 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 130 return err 131 } 132 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 133 return err 134 } 135 if err = addResolveEndpointMiddleware(stack, options); err != nil { 136 return err 137 } 138 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 139 return err 140 } 141 if err = addRetryMiddlewares(stack, options); err != nil { 142 return err 143 } 144 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 145 return err 146 } 147 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 148 return err 149 } 150 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 151 return err 152 } 153 if err = addClientUserAgent(stack); err != nil { 154 return err 155 } 156 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 157 return err 158 } 159 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 160 return err 161 } 162 if err = addOpPollForActivityTaskValidationMiddleware(stack); err != nil { 163 return err 164 } 165 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPollForActivityTask(options.Region), middleware.Before); err != nil { 166 return err 167 } 168 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 169 return err 170 } 171 if err = addResponseErrorMiddleware(stack); err != nil { 172 return err 173 } 174 if err = addRequestResponseLogging(stack, options); err != nil { 175 return err 176 } 177 return nil 178} 179 180func newServiceMetadataMiddleware_opPollForActivityTask(region string) *awsmiddleware.RegisterServiceMetadata { 181 return &awsmiddleware.RegisterServiceMetadata{ 182 Region: region, 183 ServiceID: ServiceID, 184 SigningName: "swf", 185 OperationName: "PollForActivityTask", 186 } 187} 188