Class: Chore::Queues::SQS::Publisher

Inherits:
Publisher
  • Object
show all
Defined in:
lib/chore/queues/sqs/publisher.rb

Overview

SQS Publisher, for writing messages to SQS from Chore

Constant Summary collapse

@@reset_next =
true

Constants inherited from Publisher

Publisher::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Publisher

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Publisher

publish

Constructor Details

#initialize(opts = {}) ⇒ Publisher

Returns a new instance of Publisher.

Parameters:

  • opts (Hash) (defaults to: {})

    Publisher options



11
12
13
14
15
# File 'lib/chore/queues/sqs/publisher.rb', line 11

def initialize(opts={})
  super
  @sqs_queues = {}
  @sqs_queue_urls = {}
end

Class Method Details

.reset_connection!Object

Sets a flag that instructs the publisher to reset the connection the next time it's used



29
30
31
# File 'lib/chore/queues/sqs/publisher.rb', line 29

def self.reset_connection!
  @@reset_next = true
end

Instance Method Details

#publish(queue_name, job) ⇒ struct Aws::SQS::Types::SendMessageResult

Publishes a message to an SQS queue

Parameters:

  • queue_name (String)

    Name of the SQS queue

  • job (Hash)

    Job instance definition, will be encoded to JSON

Returns:

  • (struct Aws::SQS::Types::SendMessageResult)


23
24
25
26
# File 'lib/chore/queues/sqs/publisher.rb', line 23

def publish(queue_name,job)
  queue = queue(queue_name)
  queue.send_message(message_body: encode_job(job))
end