Class: MailRoom::Delivery::Sidekiq

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_room/delivery/sidekiq.rb

Overview

Sidekiq Delivery method

Author:

  • Douwe Maan

Defined Under Namespace

Classes: Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Sidekiq

Build a new delivery, hold the mailbox configuration


29
30
31
# File 'lib/mail_room/delivery/sidekiq.rb', line 29

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.


25
26
27
# File 'lib/mail_room/delivery/sidekiq.rb', line 25

def options
  @options
end

Instance Method Details

#deliver(message) ⇒ Object

deliver the message by pushing it onto the configured Sidekiq queue

Parameters:

  • message (String)

    the email message as a string, RFC822 format


35
36
37
38
39
40
41
42
# File 'lib/mail_room/delivery/sidekiq.rb', line 35

def deliver(message)
  item = item_for(message)

  client.lpush("queue:#{options.queue}", JSON.generate(item))

  @options.logger.info({ delivery_method: 'Sidekiq', action: 'message pushed' })
  true
end