Module: Webhookdb::Async
- Extended by:
- MethodUtilities
- Includes:
- Appydays::Configurable, Appydays::Loggable
- Defined in:
- lib/webhookdb/async.rb
Defined Under Namespace
Modules: Autoscaler, Job, ScheduledJob Classes: AuditLogger, JobLogger
Class Method Summary collapse
- ._require_jobs ⇒ Object
- ._setup_common ⇒ Object
- .open_web ⇒ Object
-
.setup_tests ⇒ Object
Set up for tests.
-
.setup_web ⇒ Object
Set up async for the web/client side of things.
-
.setup_workers ⇒ Object
Set up the worker process.
Methods included from MethodUtilities
attr_predicate, attr_predicate_accessor, singleton_attr_accessor, singleton_attr_reader, singleton_attr_writer, singleton_method_alias, singleton_predicate_accessor, singleton_predicate_reader
Class Method Details
._require_jobs ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'lib/webhookdb/async.rb', line 128 def self._require_jobs Amigo::DurableJob.replace_database_settings( loggers: [Webhookdb.logger], **Webhookdb::Dbutil., ) Gem.find_files(File.join("webhookdb/jobs/*.rb")).each do |path| require path end end |
._setup_common ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/webhookdb/async.rb', line 138 def self._setup_common raise "Async already setup, only call this once" if Amigo.structured_logging Amigo.structured_logging = true Amigo.log_callback = lambda { |j, lvl, msg, o| lg = j ? Appydays::Loggable[j] : Webhookdb::Async::JobLogger.logger lg.send(lvl, msg, o) } end |
.open_web ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/webhookdb/async.rb', line 82 def self.open_web u = URI(Webhookdb.api_url) u.user = self.web_username u.password = self.web_password u.path = "/sidekiq" `open #{u}` end |
.setup_tests ⇒ Object
Set up for tests. This performs common config and requires the jobs. It does not install the routing/auditing jobs, since those should only be installed at specific times.
121 122 123 124 125 126 |
# File 'lib/webhookdb/async.rb', line 121 def self.setup_tests return if Amigo.structured_logging # assume we are set up self._setup_common self._require_jobs return true end |
.setup_web ⇒ Object
Set up async for the web/client side of things. This performs common Amigo config, and sets up the routing/auditing jobs.
Note that we must also require all async jobs, since in some cases we may have sidekiq middleware that needs access to the actual job class, so it must be available.
97 98 99 100 101 102 |
# File 'lib/webhookdb/async.rb', line 97 def self.setup_web self._setup_common Amigo.install_amigo_jobs self._require_jobs return true end |
.setup_workers ⇒ Object
Set up the worker process. This peforms common Amigo config, sets up the routing/audit jobs (since jobs may publish to other jobs), requires the actual jobs, and starts the cron.
109 110 111 112 113 114 115 |
# File 'lib/webhookdb/async.rb', line 109 def self.setup_workers self._setup_common Amigo.install_amigo_jobs self._require_jobs Amigo.start_scheduler return true end |