Documentation ¶
Index ¶
- func CreateClientAndValidateQueue(region, queueName string) (*sqs.SQS, string, error)
- type Chooser
- type Dump
- type FallthroughPipeline
- type FilterChooser
- type Handler
- type MessageOutput
- type NoOpSink
- type PassthroughChooser
- type Pipeline
- type Poller
- type Redrive
- type RightPassthroughChooser
- type SQSSink
- type Sinker
- type WriterSink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Chooser ¶
Chooser is an interface that given an array of SQS messages will choose if the SQS messages go to the left sink, the right sink, or both. It is assumed all messages that are passed in are passed back out.
By convention the right sink is always the fallthrough sink. Pass any message that don't meet your criteria to the
type Dump ¶
Dump persists all messages in a queue to disk and then makes sure all of the messages end up back in the source queue.
type FallthroughPipeline ¶
type FallthroughPipeline struct { Chooser Chooser LeftSink Sinker RightSinkFunc func(queueURL string, client sqsiface.SQSAPI) Sinker SourceClient sqsiface.SQSAPI SourceQueueURL string }
FallthroughPipeline is a higher level pipeline that manages creating fallthrough queues, running the forward pipeline, redriving the messages in the fallthrough queues back into the source queues, and removing the fallthrough queue.
It's written to be as general as possible so you may want to check out filtered redrive or Dump for examples on how it's used
func (*FallthroughPipeline) Run ¶
func (f *FallthroughPipeline) Run() error
Run is the entrypoint for running the FilterRunner
type FilterChooser ¶
FilterChooser passes the body of a SQS message through a JMESPath, if it is present, and through a Regular Expression. Messages that satisfy the regular expression go to the left sink and all other go to the right sink.
func NewFilterChooser ¶
func NewFilterChooser(jmespath string, regex string) (*FilterChooser, error)
NewFilterChooser returns an initialized FilterChooser if the passed in regular expression can be compiled. It returns an error otherwise.
func (*FilterChooser) Choose ¶
Choose will pass the body of the SQS Messages through the JMESPath, if it is present, and then through the regular expression. If a message body fails anywhere in the path an error message is logged and the SQS message is put in the right sink.
If a JMESPath is present and is successfully run against the SQS Message body the JMESPath output replaces the SQS message body in the filter. This allows you to run a JMESPath against a large object to filter it down and then run a regular expression against the output to choose between the left sink or the right sink.
NOTE: the JMESPath expression must return a valid JSON object. If the output is not valid the SQS message will be put in the right sink.
type Handler ¶
Handler represents any type that can process SQS messages. Messages returned by the handler will be removed from the source queue if there is one. In other words the handler need not worry about the lifecyle of the SQS messages.
type MessageOutput ¶
type MessageOutput struct { Body *string `json:",omitempty"` MessageAttributes map[string]*sqs.MessageAttributeValue `json:",omitempty"` MessageId *string ReceiptHandle *string }
MessageOutput is a simplified version of the SQS Message that's appropriate to write to disk or STDOUT.
TODO: will have to handle the case when putting messages from STDIN to queue
where the message body is JSON.
type NoOpSink ¶
type NoOpSink struct{}
NoOpSink drops the messages on the floor. Use it only as a signal to other developers that your other sink is doing all of the work.
type PassthroughChooser ¶
type PassthroughChooser struct{}
PassthroughChooser always passes messages to the left
type Pipeline ¶
Pipeline is a simple struct to manage the interaction between a source, a chooser, and sinks. Pipeline satisfies the Handler interface and can be passed to a Poller.
type Poller ¶
type Poller struct { QueueURL string Handler Handler Client sqsClient MaxEmptyReceives int // SQS ReceiveMessage API pass through WaitTimeSeconds int64 MaxNumberOfMessages int64 }
Poller manages the business logic of polling a queue for messages, handing them off to a Handler, and deleting the succesfully processed messages from the queue.
func NewPoller ¶
NewPoller returns a Poller that defaults to long polling and receiving at most 10 messages at a time
type Redrive ¶
type Redrive struct { SourceClient *sqs.SQS SourceQueueURL string DestClient *sqs.SQS DestQueueURL string JMESPath string Regex string // contains filtered or unexported fields }
Redrive is a simple strategy that moves messages from a source queue to a destination queue.
type RightPassthroughChooser ¶
type RightPassthroughChooser struct{}
RightPassthroughChooser passes all messages to the right
type Sinker ¶
Sinker is an interface that accepts an array of SQS messages and puts them somewhere. Where "somewhere" could be into another SQS queue, a file on disk, or whatever.
type WriterSink ¶
WriterSink will write SQS Message in the MessageOutput format to the Writer with the delimiter as a separator