/
sqs.go
46 lines (41 loc) · 1.5 KB
/
sqs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package step
import (
"math/rand"
)
// SQSTaskParameters represents params for the SQS notification
// Ref: https://docs.aws.amazon.com/sns/latest/api/API_Publish.html#API_Publish_RequestParameters
type SQSTaskParameters struct {
MessageBody string `json:",omitempty"`
QueueURL string `json:",omitempty"`
DelaySeconds int `json:",omitempty"`
MessageAttributes map[string]interface{} `json:",omitempty"`
MessageDeduplicationID string `json:"MessageDeduplicationId,omitempty"`
MessageGroupID string `json:"MessageGroupId,omitempty"`
}
// SQSTaskState represents bindings for
// https://docs.aws.amazon.com/step-functions/latest/dg/connectors-sqs.html
type SQSTaskState struct {
BaseTask
parameters SQSTaskParameters
}
// MarshalJSON for custom marshalling, since this will be stringified and we need it
// to turn into a stringified
// Ref: https://docs.aws.amazon.com/step-functions/latest/dg/connectors-sqs.html
func (sqs *SQSTaskState) MarshalJSON() ([]byte, error) {
return sqs.BaseTask.marshalMergedParams("arn:aws:states:::sqs:sendMessage",
&sqs.parameters)
}
// NewSQSTaskState returns an initialized SQSTaskState
func NewSQSTaskState(stateName string,
parameters SQSTaskParameters) *SQSTaskState {
sns := &SQSTaskState{
BaseTask: BaseTask{
baseInnerState: baseInnerState{
name: stateName,
id: rand.Int63(),
},
},
parameters: parameters,
}
return sns
}