Class: MailRunner::ManagerBot
- Inherits:
-
Object
- Object
- MailRunner::ManagerBot
- Extended by:
- BotHelpers
- Defined in:
- lib/mail_runner/head_manager_bot.rb
Instance Attribute Summary collapse
-
#archive ⇒ Object
Returns the value of attribute archive.
-
#mailbox ⇒ Object
used for testing.
-
#webhook ⇒ Object
Returns the value of attribute webhook.
-
#webhook_status ⇒ Object
Returns the value of attribute webhook_status.
Instance Method Summary collapse
- #archive_stack? ⇒ Boolean
- #archivist ⇒ Object
- #delayed_queue? ⇒ Boolean
- #delegate_archive_stack_processing ⇒ Object
- #delegate_delayed_queue_processing ⇒ Object
- #delegate_inbound_processing ⇒ Object
-
#inbound_manager ⇒ Object
Delegation Methods ####.
-
#initialize ⇒ ManagerBot
constructor
A new instance of ManagerBot.
- #parse_options(opts) ⇒ Object
- #queue_manager ⇒ Object
- #run ⇒ Object
- #test_options ⇒ Object
- #update_webhook_status(status) ⇒ Object
- #verify_and_set(opts) ⇒ Object
Constructor Details
#initialize ⇒ ManagerBot
Returns a new instance of ManagerBot.
25 26 27 28 29 30 |
# File 'lib/mail_runner/head_manager_bot.rb', line 25 def initialize @mailbox = nil @webhook = nil @archive = nil @webhook_status = nil end |
Instance Attribute Details
#archive ⇒ Object
Returns the value of attribute archive.
20 21 22 |
# File 'lib/mail_runner/head_manager_bot.rb', line 20 def archive @archive end |
#mailbox ⇒ Object
used for testing
18 19 20 |
# File 'lib/mail_runner/head_manager_bot.rb', line 18 def mailbox @mailbox end |
#webhook ⇒ Object
Returns the value of attribute webhook.
19 20 21 |
# File 'lib/mail_runner/head_manager_bot.rb', line 19 def webhook @webhook end |
#webhook_status ⇒ Object
Returns the value of attribute webhook_status.
21 22 23 |
# File 'lib/mail_runner/head_manager_bot.rb', line 21 def webhook_status @webhook_status end |
Instance Method Details
#archive_stack? ⇒ Boolean
112 113 114 |
# File 'lib/mail_runner/head_manager_bot.rb', line 112 def archive_stack? archivist.stack_height > 0 end |
#archivist ⇒ Object
108 109 110 |
# File 'lib/mail_runner/head_manager_bot.rb', line 108 def archivist MailRunner::ArchivistBot end |
#delayed_queue? ⇒ Boolean
96 97 98 |
# File 'lib/mail_runner/head_manager_bot.rb', line 96 def delayed_queue? queue_manager.queue_length > 0 end |
#delegate_archive_stack_processing ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/mail_runner/head_manager_bot.rb', line 116 def delegate_archive_stack_processing begin archivist.archive_stack rescue Exception => msg puts msg.inspect end end |
#delegate_delayed_queue_processing ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/mail_runner/head_manager_bot.rb', line 100 def delegate_delayed_queue_processing begin queue_manager.process_queue rescue Exception => msg puts msg.inspect end end |
#delegate_inbound_processing ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/mail_runner/head_manager_bot.rb', line 83 def delegate_inbound_processing begin inbound_manager.process_inbound(mailbox, webhook, archive) rescue Exception => msg puts msg.inspect end end |
#inbound_manager ⇒ Object
Delegation Methods ####
79 80 81 |
# File 'lib/mail_runner/head_manager_bot.rb', line 79 def inbound_manager MailRunner::InboundManagerBot end |
#parse_options(opts) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/mail_runner/head_manager_bot.rb', line 38 def (opts) BotHelpers::Tests.all_args_included?(opts) @mailbox = "/var/mail/#{opts[:mailbox]}" @webhook = opts[:webhook] @archive = opts[:archive].nil? ? nil : opts[:archive] end |
#queue_manager ⇒ Object
92 93 94 |
# File 'lib/mail_runner/head_manager_bot.rb', line 92 def queue_manager MailRunner::QueueManagerBot end |
#run ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/mail_runner/head_manager_bot.rb', line 56 def run BotHelpers::Helpers.print_monitoring_started_msg(self) $mad_statter.incr_stat("runner launched") while true delegate_inbound_processing if webhook_status == "down" BotHelpers::Tests.soft_test_webhook(self.webhook) elsif delayed_queue? delegate_delayed_queue_processing end if archive_stack? delegate_archive_stack_processing end sleep 5 end end |
#test_options ⇒ Object
50 51 52 53 54 |
# File 'lib/mail_runner/head_manager_bot.rb', line 50 def BotHelpers::Tests.test_mailbox(self.mailbox) BotHelpers::Tests.test_webhook(self.webhook) BotHelpers::Tests.test_archive(self.archive) unless self.archive.nil? end |
#update_webhook_status(status) ⇒ Object
46 47 48 |
# File 'lib/mail_runner/head_manager_bot.rb', line 46 def update_webhook_status(status) @webhook_status = status end |
#verify_and_set(opts) ⇒ Object
33 34 35 36 |
# File 'lib/mail_runner/head_manager_bot.rb', line 33 def verify_and_set(opts) (opts) end |