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


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

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options


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

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


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

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