From bbf5ee8620318b15530a51fcd9258149bde83373 Mon Sep 17 00:00:00 2001 From: robacarp Date: Fri, 2 Feb 2024 23:30:59 +0000 Subject: [PATCH] deploy: 703a90a71d22c5e0495633e0af1c0b5bbd606c26 --- 404.html | 2 +- Mosquito.html | 2 +- Mosquito/Backend.html | 16 ++- Mosquito/Backend/ClassMethods.html | 10 +- Mosquito/Base.html | 8 +- Mosquito/Configuration.html | 16 ++- Mosquito/DoubleRun.html | 11 +- Mosquito/Id.html | 2 +- Mosquito/IrretrievableParameter.html | 11 +- Mosquito/Job.html | 191 +++++++++++++------------ Mosquito/Job/State.html | 22 ++- Mosquito/JobFailed.html | 11 +- Mosquito/JobRun.html | 16 ++- Mosquito/KeyBuilder.html | 8 +- Mosquito/Metadata.html | 16 ++- Mosquito/PeriodicJob.html | 41 +++++- Mosquito/PeriodicJobRun.html | 16 ++- Mosquito/Queue.html | 16 ++- Mosquito/QueuedJob.html | 41 +++++- Mosquito/RateLimiter.html | 10 +- Mosquito/RateLimiter/ClassMethods.html | 10 +- Mosquito/RedisBackend.html | 19 ++- Mosquito/Runnable.html | 10 +- Mosquito/Runnable/State.html | 22 ++- Mosquito/Runner.html | 8 +- Mosquito/Runners.html | 2 +- Mosquito/Runners/Coordinator.html | 16 ++- Mosquito/Runners/Executor.html | 22 ++- Mosquito/Runners/IdleWait.html | 10 +- Mosquito/Runners/Overseer.html | 25 +++- Mosquito/Runners/QueueList.html | 25 +++- Mosquito/Runners/RunAtMost.html | 10 +- Mosquito/ScheduledJob.html | 41 +++++- Mosquito/Scripts.html | 2 +- Mosquito/Serializers.html | 2 +- Mosquito/Serializers/Primitives.html | 10 +- Mosquito/TestBackend.html | 19 ++- Mosquito/TestBackend/EnqueuedJob.html | 19 ++- index.html | 2 +- index.json | 2 +- search-index.js | 2 +- 41 files changed, 513 insertions(+), 231 deletions(-) diff --git a/404.html b/404.html index 148f0efc..4148fd3f 100644 --- a/404.html +++ b/404.html @@ -4,7 +4,7 @@ - + diff --git a/Mosquito.html b/Mosquito.html index 1e647434..d351741e 100644 --- a/Mosquito.html +++ b/Mosquito.html @@ -4,7 +4,7 @@ - + diff --git a/Mosquito/Backend.html b/Mosquito/Backend.html index 5574403c..7725c353 100644 --- a/Mosquito/Backend.html +++ b/Mosquito/Backend.html @@ -4,7 +4,7 @@ - + @@ -421,6 +421,8 @@

+ +

- - diff --git a/Mosquito/Backend/ClassMethods.html b/Mosquito/Backend/ClassMethods.html index acb92a4c..54b91232 100644 --- a/Mosquito/Backend/ClassMethods.html +++ b/Mosquito/Backend/ClassMethods.html @@ -4,7 +4,7 @@ - + @@ -335,6 +335,8 @@

+ +

- -
@@ -430,6 +430,8 @@

+ +

- - diff --git a/Mosquito/Base.html b/Mosquito/Base.html index f210db25..915bbbb4 100644 --- a/Mosquito/Base.html +++ b/Mosquito/Base.html @@ -4,7 +4,7 @@ - + @@ -399,12 +399,18 @@

+ + + + + + diff --git a/Mosquito/Configuration.html b/Mosquito/Configuration.html index 8f93cbb0..2dbab4e5 100644 --- a/Mosquito/Configuration.html +++ b/Mosquito/Configuration.html @@ -4,7 +4,7 @@ - + @@ -337,6 +337,8 @@

+ +

- - diff --git a/Mosquito/DoubleRun.html b/Mosquito/DoubleRun.html index f9639906..6634f078 100644 --- a/Mosquito/DoubleRun.html +++ b/Mosquito/DoubleRun.html @@ -4,7 +4,7 @@ - + @@ -363,12 +363,18 @@

+ + + + + + @@ -379,6 +385,9 @@

+ + + diff --git a/Mosquito/Id.html b/Mosquito/Id.html index a26f2fbb..4de3b021 100644 --- a/Mosquito/Id.html +++ b/Mosquito/Id.html @@ -4,7 +4,7 @@ - + diff --git a/Mosquito/IrretrievableParameter.html b/Mosquito/IrretrievableParameter.html index 00588327..c0886bd8 100644 --- a/Mosquito/IrretrievableParameter.html +++ b/Mosquito/IrretrievableParameter.html @@ -4,7 +4,7 @@ - + @@ -363,12 +363,18 @@

+ + + + + + @@ -379,6 +385,9 @@

+ + + diff --git a/Mosquito/Job.html b/Mosquito/Job.html index 18db23de..6c4082f1 100644 --- a/Mosquito/Job.html +++ b/Mosquito/Job.html @@ -4,7 +4,7 @@ - + @@ -441,6 +441,37 @@

+

+ + + + Macro Summary +

+ + + +

-

- - - - Macro Summary -

- - - -
@@ -807,12 +807,18 @@

Instance methods inherited from module +

+ + + + Macro Detail +

+ +
+
+ + macro after(&block) + + # +
+ +
+
+ +
+
+ +
+
+ + macro before(&block) + + # +
+ +
+
+ +
+
+ +
+
+ + macro queue_name(name) + + # +
+ +
+ +

Easily override the queue for any job.

+
+ +
+
+ +
+
+ + + +

- -

- - - - Macro Detail -

- -
-
- - macro after(&block) - - # -
- -
-
- -
-
- -
-
- - macro before(&block) - - # -
- -
-
- -
-
- -
-
- - macro queue_name(name) - - # -
- -
- -

Easily override the queue for any job.

-
- -
-
- -
-
- - -

diff --git a/Mosquito/Job/State.html b/Mosquito/Job/State.html index 8e70552c..ffad9234 100644 --- a/Mosquito/Job/State.html +++ b/Mosquito/Job/State.html @@ -4,7 +4,7 @@ - + @@ -374,6 +374,8 @@

+ +

- - diff --git a/Mosquito/JobFailed.html b/Mosquito/JobFailed.html index 5af3d500..295694b0 100644 --- a/Mosquito/JobFailed.html +++ b/Mosquito/JobFailed.html @@ -4,7 +4,7 @@ - + @@ -363,12 +363,18 @@

+ + + + + + @@ -379,6 +385,9 @@

+ + + diff --git a/Mosquito/JobRun.html b/Mosquito/JobRun.html index b3a03b10..7e69b80e 100644 --- a/Mosquito/JobRun.html +++ b/Mosquito/JobRun.html @@ -4,7 +4,7 @@ - + @@ -419,6 +419,8 @@

+ +

- - diff --git a/Mosquito/KeyBuilder.html b/Mosquito/KeyBuilder.html index 90a2c3f5..f0e089ca 100644 --- a/Mosquito/KeyBuilder.html +++ b/Mosquito/KeyBuilder.html @@ -4,7 +4,7 @@ - + @@ -388,12 +388,18 @@

+ + + + + + diff --git a/Mosquito/Metadata.html b/Mosquito/Metadata.html index 97c75858..df0ec725 100644 --- a/Mosquito/Metadata.html +++ b/Mosquito/Metadata.html @@ -4,7 +4,7 @@ - + @@ -368,6 +368,8 @@

+ +

- - diff --git a/Mosquito/PeriodicJob.html b/Mosquito/PeriodicJob.html index aa40c679..86543d60 100644 --- a/Mosquito/PeriodicJob.html +++ b/Mosquito/PeriodicJob.html @@ -4,7 +4,7 @@ - + @@ -354,6 +354,8 @@

+ +

- - diff --git a/Mosquito/PeriodicJobRun.html b/Mosquito/PeriodicJobRun.html index d547151a..e7ff8b07 100644 --- a/Mosquito/PeriodicJobRun.html +++ b/Mosquito/PeriodicJobRun.html @@ -4,7 +4,7 @@ - + @@ -354,6 +354,8 @@

+ +

- - diff --git a/Mosquito/Queue.html b/Mosquito/Queue.html index ddcf81e8..f8b0ca8a 100644 --- a/Mosquito/Queue.html +++ b/Mosquito/Queue.html @@ -4,7 +4,7 @@ - + @@ -451,6 +451,8 @@

+ +

- - diff --git a/Mosquito/QueuedJob.html b/Mosquito/QueuedJob.html index 24903ad2..f0f6154e 100644 --- a/Mosquito/QueuedJob.html +++ b/Mosquito/QueuedJob.html @@ -4,7 +4,7 @@ - + @@ -337,6 +337,8 @@

+ +

- - diff --git a/Mosquito/RateLimiter.html b/Mosquito/RateLimiter.html index 170c50b8..8ed99278 100644 --- a/Mosquito/RateLimiter.html +++ b/Mosquito/RateLimiter.html @@ -4,7 +4,7 @@ - + @@ -335,6 +335,8 @@

+ +

- -
@@ -430,6 +430,8 @@

+ +

- - diff --git a/Mosquito/RateLimiter/ClassMethods.html b/Mosquito/RateLimiter/ClassMethods.html index 824b588c..5aa1b1ab 100644 --- a/Mosquito/RateLimiter/ClassMethods.html +++ b/Mosquito/RateLimiter/ClassMethods.html @@ -4,7 +4,7 @@ - + @@ -335,6 +335,8 @@

+ +

- -
@@ -388,6 +388,8 @@

+ +

- - diff --git a/Mosquito/RedisBackend.html b/Mosquito/RedisBackend.html index ee764258..c23f709c 100644 --- a/Mosquito/RedisBackend.html +++ b/Mosquito/RedisBackend.html @@ -4,7 +4,7 @@ - + @@ -493,6 +493,8 @@

+ +

- - diff --git a/Mosquito/Runnable.html b/Mosquito/Runnable.html index d7fbcb9c..e4c92af1 100644 --- a/Mosquito/Runnable.html +++ b/Mosquito/Runnable.html @@ -4,7 +4,7 @@ - + @@ -421,6 +421,8 @@

+ +

- -
@@ -512,6 +512,8 @@

+ +

- - diff --git a/Mosquito/Runnable/State.html b/Mosquito/Runnable/State.html index 1bb86d64..c6f11967 100644 --- a/Mosquito/Runnable/State.html +++ b/Mosquito/Runnable/State.html @@ -4,7 +4,7 @@ - + @@ -374,6 +374,8 @@

+ +

- - diff --git a/Mosquito/Runner.html b/Mosquito/Runner.html index b51a17aa..be1880b0 100644 --- a/Mosquito/Runner.html +++ b/Mosquito/Runner.html @@ -4,7 +4,7 @@ - + @@ -429,12 +429,18 @@

+ + + + + + diff --git a/Mosquito/Runners.html b/Mosquito/Runners.html index 686141f8..49e031ca 100644 --- a/Mosquito/Runners.html +++ b/Mosquito/Runners.html @@ -4,7 +4,7 @@ - + diff --git a/Mosquito/Runners/Coordinator.html b/Mosquito/Runners/Coordinator.html index 2ab535c1..314cbce2 100644 --- a/Mosquito/Runners/Coordinator.html +++ b/Mosquito/Runners/Coordinator.html @@ -4,7 +4,7 @@ - + @@ -389,6 +389,8 @@

+ +

- - diff --git a/Mosquito/Runners/Executor.html b/Mosquito/Runners/Executor.html index 84c0d19e..66bf522e 100644 --- a/Mosquito/Runners/Executor.html +++ b/Mosquito/Runners/Executor.html @@ -4,7 +4,7 @@ - + @@ -413,6 +413,8 @@

+ +

- - diff --git a/Mosquito/Runners/IdleWait.html b/Mosquito/Runners/IdleWait.html index afb2b123..05dd3d89 100644 --- a/Mosquito/Runners/IdleWait.html +++ b/Mosquito/Runners/IdleWait.html @@ -4,7 +4,7 @@ - + @@ -351,6 +351,8 @@

+ +

- -
@@ -381,6 +381,8 @@

+ +

- - diff --git a/Mosquito/Runners/Overseer.html b/Mosquito/Runners/Overseer.html index aa236c8a..e31aaa5f 100644 --- a/Mosquito/Runners/Overseer.html +++ b/Mosquito/Runners/Overseer.html @@ -4,7 +4,7 @@ - + @@ -409,6 +409,8 @@

+ +

- - diff --git a/Mosquito/Runners/QueueList.html b/Mosquito/Runners/QueueList.html index 9a39bc05..86bbc5c8 100644 --- a/Mosquito/Runners/QueueList.html +++ b/Mosquito/Runners/QueueList.html @@ -4,7 +4,7 @@ - + @@ -402,6 +402,8 @@

+ +

- - diff --git a/Mosquito/Runners/RunAtMost.html b/Mosquito/Runners/RunAtMost.html index 4a1ed458..1134c369 100644 --- a/Mosquito/Runners/RunAtMost.html +++ b/Mosquito/Runners/RunAtMost.html @@ -4,7 +4,7 @@ - + @@ -353,6 +353,8 @@

+ +

- -
@@ -383,6 +383,8 @@

+ +

- - diff --git a/Mosquito/ScheduledJob.html b/Mosquito/ScheduledJob.html index 9df8059d..5ed9cbdd 100644 --- a/Mosquito/ScheduledJob.html +++ b/Mosquito/ScheduledJob.html @@ -4,7 +4,7 @@ - + @@ -354,6 +354,8 @@

+ +

- - diff --git a/Mosquito/Scripts.html b/Mosquito/Scripts.html index f63128fa..b2825486 100644 --- a/Mosquito/Scripts.html +++ b/Mosquito/Scripts.html @@ -4,7 +4,7 @@ - + diff --git a/Mosquito/Serializers.html b/Mosquito/Serializers.html index 3c6d6078..b76352d2 100644 --- a/Mosquito/Serializers.html +++ b/Mosquito/Serializers.html @@ -4,7 +4,7 @@ - + diff --git a/Mosquito/Serializers/Primitives.html b/Mosquito/Serializers/Primitives.html index 8a5ffe23..42156580 100644 --- a/Mosquito/Serializers/Primitives.html +++ b/Mosquito/Serializers/Primitives.html @@ -4,7 +4,7 @@ - + @@ -349,6 +349,8 @@

+ +

- -
@@ -539,6 +539,8 @@

+ +

- - diff --git a/Mosquito/TestBackend.html b/Mosquito/TestBackend.html index cf229552..9db7dd8d 100644 --- a/Mosquito/TestBackend.html +++ b/Mosquito/TestBackend.html @@ -4,7 +4,7 @@ - + @@ -484,6 +484,8 @@

+ +

- - diff --git a/Mosquito/TestBackend/EnqueuedJob.html b/Mosquito/TestBackend/EnqueuedJob.html index 3cfab77d..824fdda6 100644 --- a/Mosquito/TestBackend/EnqueuedJob.html +++ b/Mosquito/TestBackend/EnqueuedJob.html @@ -4,7 +4,7 @@ - + @@ -371,6 +371,8 @@

+ +

- - diff --git a/index.html b/index.html index 379a2c83..db695025 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - + diff --git a/index.json b/index.json index 3ce6fbc9..00184fd5 100644 --- a/index.json +++ b/index.json @@ -1 +1 @@ -{"repository_name":"mosquito","body":"\"mosquito\"\n\n[![GitHub](https://img.shields.io/github/license/mosquito-cr/mosquito.svg?style=for-the-badge)](https://tldrlegal.com/license/mit-license)\n\n\n\nMosquito is a generic background job runner written primarily for Crystal. Significant inspiration from experience with the successes and failings many Ruby gems in this vein. Once compiled, a mosquito binary can start work in about 10 milliseconds.\n\nMosquito currently provides these features:\n\n- Delayed execution (`SendEmailJob.new(email: :welcome, address: user.email).enqueue(in: 3.minutes)`)\n- Scheduled / Periodic execution (`RunEveryHourJob.new`)\n- Job Storage in Redis\n- Automatic rescheduling of failed jobs\n- Progressively increasing delay of rescheduled failed jobs\n- Dead letter queue of jobs which have failed too many times\n- Rate limited jobs\n\nCurrent Limitations:\n- Visibility into a running job network and queue is limited. There is a working proof of concept [visualization API](https://github.com/mosquito-cr/mosquito/issues/90) and [bare-bones terminal application](https://github.com/mosquito-cr/tui-visualizer).\n\n## Project State\n\nThe Mosquito project is stable. A few folks are using Mosquito in production, and it's going okay.\n\nThere are some features which would be nice to have, but what is here is both tried and tested.\n\nIf you're using Mosquito, please [get in touch](https://github.com/mosquito-cr/mosquito/discussions) on the Discussion board or [on Crystal chat](https://crystal-lang.org/community/) with any questions, feature suggestions, or feedback.\n\n## Installation\n\nUpdate your `shard.yml` to include mosquito:\n\n```diff\ndependencies:\n+ mosquito:\n+ github: mosquito-cr/mosquito\n```\n\n## Usage\n\n### Step 1: Define a queued job\n\n```crystal\n# src/jobs/puts_job.cr\nclass PutsJob < Mosquito::QueuedJob\n param message : String\n\n def perform\n puts message\n end\nend\n```\n\n### Step 2: Trigger that job\n\n```crystal\n# src//.cr\nPutsJob.new(message: \"ohai background job\").enqueue\n```\n\n### Step 3: Run your worker to process the job\n\n```crystal\n# src/worker.cr\n\nMosquito.configure do |settings|\n settings.redis_url = ENV[\"REDIS_URL\"]\nend\n\nMosquito::Runner.start\n```\n\n```text\ncrystal run src/worker.cr\n```\n\n### Success\n\n```\n> crystal run src/worker.cr\n2017-11-06 17:07:29 - Mosquito is buzzing...\n2017-11-06 17:07:51 - Running task puts_job<...> from puts_job\n2017-11-06 17:07:51 - [PutsJob] ohai background job\n2017-11-06 17:07:51 - task puts_job<...> succeeded, took 0.0 seconds\n```\n\n[More information about queued jobs](https://mosquito-cr.github.io/manual/index.html#queued-jobs) in the manual.\n\n------\n\n## Periodic Jobs\n\nPeriodic jobs run according to a predefined period -- once an hour, etc.\n\nThis periodic job:\n```crystal\nclass PeriodicallyPutsJob < Mosquito::PeriodicJob\n run_every 1.minute\n\n def perform\n emotions = %w{happy sad angry optimistic political skeptical epuhoric}\n puts \"The time is now #{Time.local} and the wizard is feeling #{emotions.sample}\"\n end\nend\n```\n\nWould produce this output:\n```crystal\n2017-11-06 17:20:13 - Mosquito is buzzing...\n2017-11-06 17:20:13 - Queues: periodically_puts_job\n2017-11-06 17:20:13 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:20:13 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:20:13 and the wizard is feeling skeptical\n2017-11-06 17:20:13 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n2017-11-06 17:21:14 - Queues: periodically_puts_job\n2017-11-06 17:21:14 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:21:14 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:21:14 and the wizard is feeling optimistic\n2017-11-06 17:21:14 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n2017-11-06 17:22:15 - Queues: periodically_puts_job\n2017-11-06 17:22:15 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:22:15 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:22:15 and the wizard is feeling political\n2017-11-06 17:22:15 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n```\n\n[More information on periodic jobs](https://mosquito-cr.github.io/manual/index.html#periodic-jobs) in the manual.\n\n## Advanced usage\n\nFor more advanced topics, including [use with Lucky Framework](https://mosquito-cr.github.io/manual/lucky_framework.html), [throttling or rate limiting](https://mosquito-cr.github.io/manual/rate_limiting.html), check out the [full manual](https://mosquito-cr.github.io/manual).\n\n## Contributing\n\nContributions are welcome. Please fork the repository, commit changes on a branch, and then open a pull request.\n\n### Crystal Versions\n\nMosquito aims to be compatible with the latest Crystal release, and the [latest patch for all post-1.0 minor crystal versions](https://github.com/mosquito-cr/mosquito/blob/master/.github/workflows/ci.yml#L17).\n\nFor development purposes [you're encouraged to stay in sync with `.tool-versions`](https://github.com/mosquito-cr/mosquito/blob/master/.tool-versions).\n\n### Testing\n\nThis repository uses [minitest](https://github.com/ysbaddaden/minitest.cr) for testing. As a result, `crystal spec` doesn't do anything helpful. Do this instead:\n\n```\nmake test\n```\n\nIn lieu of `crystal spec` bells and whistles, Minitest provides a nice alternative to [running one test at a time instead of the whole suite](https://github.com/ysbaddaden/minitest.cr/pull/31).\n","program":{"html_id":"mosquito/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"mosquito","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"mosquito/Mosquito","path":"Mosquito.html","kind":"module","full_name":"Mosquito","name":"Mosquito","abstract":false,"locations":[{"filename":"src/mosquito.cr","line_number":5,"url":null},{"filename":"src/mosquito/backend.cr","line_number":1,"url":null},{"filename":"src/mosquito/base.cr","line_number":1,"url":null},{"filename":"src/mosquito/configuration.cr","line_number":1,"url":null},{"filename":"src/mosquito/exceptions.cr","line_number":1,"url":null},{"filename":"src/mosquito/job.cr","line_number":3,"url":null},{"filename":"src/mosquito/job_run.cr","line_number":1,"url":null},{"filename":"src/mosquito/key_builder.cr","line_number":1,"url":null},{"filename":"src/mosquito/metadata.cr","line_number":1,"url":null},{"filename":"src/mosquito/periodic_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/periodic_job_run.cr","line_number":1,"url":null},{"filename":"src/mosquito/queue.cr","line_number":1,"url":null},{"filename":"src/mosquito/queued_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/redis_backend.cr","line_number":4,"url":null},{"filename":"src/mosquito/runnable.cr","line_number":1,"url":null},{"filename":"src/mosquito/runner.cr","line_number":3,"url":null},{"filename":"src/mosquito/runners/run_at_most.cr","line_number":1,"url":null},{"filename":"src/mosquito/scheduled_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/test_backend.cr","line_number":1,"url":null},{"filename":"src/mosquito/version.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"1.0.2\""}],"class_methods":[{"html_id":"backend-class-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito.cr","line_number":6,"url":null},"def":{"name":"backend","visibility":"Public","body":"configuration.backend"}},{"html_id":"configuration-class-method","name":"configuration","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":2,"url":null},"def":{"name":"configuration","visibility":"Public","body":"@@configuration"}},{"html_id":"configure(&):Nil-class-method","name":"configure","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":4,"url":null},"def":{"name":"configure","yields":1,"block_arity":1,"return_type":"Nil","visibility":"Public","body":"yield configuration"}}],"types":[{"html_id":"mosquito/Mosquito/Backend","path":"Mosquito/Backend.html","kind":"class","full_name":"Mosquito::Backend","name":"Backend","abstract":true,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/backend.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"KEY_PREFIX","name":"KEY_PREFIX","value":"{\"mosquito\"}"},{"id":"QUEUES","name":"QUEUES","value":"[\"waiting\", \"scheduled\", \"pending\", \"dead\"] of ::String"}],"subclasses":[{"html_id":"mosquito/Mosquito/RedisBackend","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend"},{"html_id":"mosquito/Mosquito/TestBackend","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"build_key(*parts)-class-method","name":"build_key","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/backend.cr","line_number":11,"url":null},"def":{"name":"build_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"KeyBuilder.build(KEY_PREFIX, *parts)"}},{"html_id":"named(name)-class-method","name":"named","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/mosquito/backend.cr","line_number":7,"url":null},"def":{"name":"named","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"new(name)"}},{"html_id":"search_queues-class-method","name":"search_queues","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":50,"url":null},"def":{"name":"search_queues","visibility":"Public","body":"QUEUES.first(2)"}}],"constructors":[{"html_id":"new(name:String|Symbol)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"args_string":"(name : String | Symbol)","args_html":"(name : String | Symbol)","location":{"filename":"src/mosquito/backend.cr","line_number":21,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_key(*parts)-instance-method","name":"build_key","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/backend.cr","line_number":15,"url":null},"def":{"name":"build_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"self.class.build_key(*parts)"}},{"html_id":"dead_q-instance-method","name":"dead_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"dead_q","visibility":"Public","body":"build_key(\"dead\", name)"}},{"html_id":"delete(key:String,inttl=0):Nil-instance-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"args_string":"(key : String, in ttl = 0) : Nil","args_html":"(key : String, in ttl = 0) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":68,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"return_type":"Nil","visibility":"Public","body":"self.class.delete(key)"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":78,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":""}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":80,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":""}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run :
JobRun) : JobRun","location":{"filename":"src/mosquito/backend.cr","line_number":77,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":""}},{"html_id":"expires_in(key:String):Int64-instance-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":72,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"self.class.expires_in(key)"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/backend.cr","line_number":81,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":83,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"pending_q-instance-method","name":"pending_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"pending_q","visibility":"Public","body":"build_key(\"pending\", name)"}},{"html_id":"retrieve(key:String):Hash(String,String)-instance-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/backend.cr","line_number":64,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"self.class.retrieve(key)"}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/backend.cr","line_number":79,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":""}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/backend.cr","line_number":90,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"scheduled_q-instance-method","name":"scheduled_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"scheduled_q","visibility":"Public","body":"build_key(\"scheduled\", name)"}},{"html_id":"size(include_dead:Bool=true):Int64-instance-method","name":"size","abstract":true,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"args_string":"(include_dead : Bool = true) : Int64","args_html":"(include_dead : Bool = true) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":84,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-instance-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":60,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":"self.class.store(key, value)"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/backend.cr","line_number":82,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"waiting_q-instance-method","name":"waiting_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"waiting_q","visibility":"Public","body":"build_key(\"waiting\", name)"}}],"types":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","path":"Mosquito/Backend/ClassMethods.html","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/mosquito/backend.cr","line_number":25,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"instance_methods":[{"html_id":"delete(key:String,inttl:Int64=0):Nil-instance-method","name":"delete","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":31,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-instance-method","name":"delete","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":32,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"expires_in(key:String):Int64-instance-method","name":"expires_in","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":33,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":40,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"get(key:String,field:String):String|Nil-instance-method","name":"get","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/backend.cr","line_number":35,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-instance-method","name":"increment","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":38,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String):Int64-instance-method","name":"increment","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":37,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"list_queues:Array(String)-instance-method","name":"list_queues","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":28,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"list_runners:Array(String)-instance-method","name":"list_runners","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":29,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-instance-method","name":"lock?","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/backend.cr","line_number":43,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":""}},{"html_id":"retrieve(key:String):Hash(String,String)-instance-method","name":"retrieve","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/backend.cr","line_number":27,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":""}},{"html_id":"set(key:String,field:String,value:String):String-instance-method","name":"set","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/backend.cr","line_number":36,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-instance-method","name":"store","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":26,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"unlock(key:String,value:String):Nil-instance-method","name":"unlock","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":42,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":""}}]}]},{"html_id":"mosquito/Mosquito/Base","path":"Mosquito/Base.html","kind":"class","full_name":"Mosquito::Base","name":"Base","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/base.cr","line_number":4,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"job_for_type(type:String):Mosquito::Job.class-class-method","name":"job_for_type","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"}],"args_string":"(type : String) : Mosquito::Job.class","args_html":"(type : String) : Mosquito::Job.class","location":{"filename":"src/mosquito/base.cr","line_number":13,"url":null},"def":{"name":"job_for_type","args":[{"name":"type","external_name":"type","restriction":"String"}],"return_type":"Mosquito::Job.class","visibility":"Public","body":"begin\n @@mapping[type]\nrescue e : KeyError\n error = String.build do |s|\n s << \"Could not find a job class for type \\\"#{type}\\\", perhaps you forgot to register it?\\n\\nCurrent known types are:\\n\"\n @@mapping.each do |k, v|\n s << \"#{k}=>#{v}\\n\"\n end\n s << \"\\n\\n\"\n end\n raise(KeyError.new(error))\nend"}},{"html_id":"mapping-class-method","name":"mapping","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":5,"url":null},"def":{"name":"mapping","visibility":"Public","body":"@@mapping"}},{"html_id":"register_job(klass,*,to_run_atscheduled_time:Time)-class-method","name":"register_job","abstract":false,"args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"scheduled_time","external_name":"to_run_at","restriction":"Time"}],"args_string":"(klass, *, to_run_at scheduled_time : Time)","args_html":"(klass, *, to_run_at scheduled_time : Time)","location":{"filename":"src/mosquito/base.cr","line_number":36,"url":null},"def":{"name":"register_job","args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"scheduled_time","external_name":"to_run_at","restriction":"Time"}],"splat_index":1,"visibility":"Public","body":"position = @@timetable.index do\nend"}},{"html_id":"register_job_interval(klass,interval:Time::Span|Time::MonthSpan)-class-method","name":"register_job_interval","abstract":false,"args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"args_string":"(klass, interval : Time::Span | Time::MonthSpan)","args_html":"(klass, interval : Time::Span | Time::MonthSpan)","location":{"filename":"src/mosquito/base.cr","line_number":32,"url":null},"def":{"name":"register_job_interval","args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"visibility":"Public","body":"@@scheduled_job_runs << (PeriodicJobRun.new(klass, interval))"}},{"html_id":"register_job_mapping(string,klass)-class-method","name":"register_job_mapping","abstract":false,"args":[{"name":"string","external_name":"string","restriction":""},{"name":"klass","external_name":"klass","restriction":""}],"args_string":"(string, klass)","args_html":"(string, klass)","location":{"filename":"src/mosquito/base.cr","line_number":9,"url":null},"def":{"name":"register_job_mapping","args":[{"name":"string","external_name":"string","restriction":""},{"name":"klass","external_name":"klass","restriction":""}],"visibility":"Public","body":"@@mapping[string] = klass"}},{"html_id":"scheduled_job_runs-class-method","name":"scheduled_job_runs","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":6,"url":null},"def":{"name":"scheduled_job_runs","visibility":"Public","body":"@@scheduled_job_runs"}},{"html_id":"timetable-class-method","name":"timetable","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":7,"url":null},"def":{"name":"timetable","visibility":"Public","body":"@@timetable"}}]},{"html_id":"mosquito/Mosquito/Configuration","path":"Mosquito/Configuration.html","kind":"class","full_name":"Mosquito::Configuration","name":"Configuration","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/configuration.cr","line_number":8,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"backend:Mosquito::Backend.class-instance-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":20,"url":null},"def":{"name":"backend","return_type":"Mosquito::Backend.class","visibility":"Public","body":"@backend"}},{"html_id":"backend=(backend:Mosquito::Backend.class)-instance-method","name":"backend=","abstract":false,"args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend.class"}],"args_string":"(backend : Mosquito::Backend.class)","args_html":"(backend : Mosquito::Backend.class)","location":{"filename":"src/mosquito/configuration.cr","line_number":20,"url":null},"def":{"name":"backend=","args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend.class"}],"visibility":"Public","body":"@backend = backend"}},{"html_id":"failed_job_ttl:Int32-instance-method","name":"failed_job_ttl","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":13,"url":null},"def":{"name":"failed_job_ttl","return_type":"Int32","visibility":"Public","body":"@failed_job_ttl"}},{"html_id":"failed_job_ttl=(failed_job_ttl:Int32)-instance-method","name":"failed_job_ttl=","abstract":false,"args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"args_string":"(failed_job_ttl : Int32)","args_html":"(failed_job_ttl : Int32)","location":{"filename":"src/mosquito/configuration.cr","line_number":13,"url":null},"def":{"name":"failed_job_ttl=","args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@failed_job_ttl = failed_job_ttl"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":11,"url":null},"def":{"name":"idle_wait","return_type":"Time::Span","visibility":"Public","body":"@idle_wait"}},{"html_id":"idle_wait=(idle_wait:Time::Span)-instance-method","name":"idle_wait=","abstract":false,"args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"args_string":"(idle_wait : Time::Span)","args_html":"(idle_wait : Time::Span)","location":{"filename":"src/mosquito/configuration.cr","line_number":11,"url":null},"def":{"name":"idle_wait=","args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"visibility":"Public","body":"@idle_wait = idle_wait"}},{"html_id":"idle_wait=(time_span:Float)-instance-method","name":"idle_wait=","abstract":false,"args":[{"name":"time_span","external_name":"time_span","restriction":"Float"}],"args_string":"(time_span : Float)","args_html":"(time_span : Float)","location":{"filename":"src/mosquito/configuration.cr","line_number":24,"url":null},"def":{"name":"idle_wait=","args":[{"name":"time_span","external_name":"time_span","restriction":"Float"}],"visibility":"Public","body":"@idle_wait = time_span.seconds"}},{"html_id":"redis_url:String|Nil-instance-method","name":"redis_url","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":9,"url":null},"def":{"name":"redis_url","return_type":"String | ::Nil","visibility":"Public","body":"@redis_url"}},{"html_id":"redis_url=(redis_url:String|Nil)-instance-method","name":"redis_url=","abstract":false,"args":[{"name":"redis_url","external_name":"redis_url","restriction":"String | ::Nil"}],"args_string":"(redis_url : String | Nil)","args_html":"(redis_url : String | Nil)","location":{"filename":"src/mosquito/configuration.cr","line_number":9,"url":null},"def":{"name":"redis_url=","args":[{"name":"redis_url","external_name":"redis_url","restriction":"String | ::Nil"}],"visibility":"Public","body":"@redis_url = redis_url"}},{"html_id":"run_cron_scheduler:Bool-instance-method","name":"run_cron_scheduler","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":16,"url":null},"def":{"name":"run_cron_scheduler","return_type":"Bool","visibility":"Public","body":"@run_cron_scheduler"}},{"html_id":"run_cron_scheduler=(run_cron_scheduler:Bool)-instance-method","name":"run_cron_scheduler=","abstract":false,"args":[{"name":"run_cron_scheduler","external_name":"run_cron_scheduler","restriction":"Bool"}],"args_string":"(run_cron_scheduler : Bool)","args_html":"(run_cron_scheduler : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":16,"url":null},"def":{"name":"run_cron_scheduler=","args":[{"name":"run_cron_scheduler","external_name":"run_cron_scheduler","restriction":"Bool"}],"visibility":"Public","body":"@run_cron_scheduler = run_cron_scheduler"}},{"html_id":"run_from:Array(String)-instance-method","name":"run_from","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":19,"url":null},"def":{"name":"run_from","return_type":"Array(String)","visibility":"Public","body":"@run_from"}},{"html_id":"run_from=(run_from:Array(String))-instance-method","name":"run_from=","abstract":false,"args":[{"name":"run_from","external_name":"run_from","restriction":"Array(String)"}],"args_string":"(run_from : Array(String))","args_html":"(run_from : Array(String))","location":{"filename":"src/mosquito/configuration.cr","line_number":19,"url":null},"def":{"name":"run_from=","args":[{"name":"run_from","external_name":"run_from","restriction":"Array(String)"}],"visibility":"Public","body":"@run_from = run_from"}},{"html_id":"successful_job_ttl:Int32-instance-method","name":"successful_job_ttl","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":12,"url":null},"def":{"name":"successful_job_ttl","return_type":"Int32","visibility":"Public","body":"@successful_job_ttl"}},{"html_id":"successful_job_ttl=(successful_job_ttl:Int32)-instance-method","name":"successful_job_ttl=","abstract":false,"args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"args_string":"(successful_job_ttl : Int32)","args_html":"(successful_job_ttl : Int32)","location":{"filename":"src/mosquito/configuration.cr","line_number":12,"url":null},"def":{"name":"successful_job_ttl=","args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@successful_job_ttl = successful_job_ttl"}},{"html_id":"use_distributed_lock:Bool-instance-method","name":"use_distributed_lock","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":17,"url":null},"def":{"name":"use_distributed_lock","return_type":"Bool","visibility":"Public","body":"@use_distributed_lock"}},{"html_id":"use_distributed_lock=(use_distributed_lock:Bool)-instance-method","name":"use_distributed_lock=","abstract":false,"args":[{"name":"use_distributed_lock","external_name":"use_distributed_lock","restriction":"Bool"}],"args_string":"(use_distributed_lock : Bool)","args_html":"(use_distributed_lock : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":17,"url":null},"def":{"name":"use_distributed_lock=","args":[{"name":"use_distributed_lock","external_name":"use_distributed_lock","restriction":"Bool"}],"visibility":"Public","body":"@use_distributed_lock = use_distributed_lock"}},{"html_id":"validate-instance-method","name":"validate","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":28,"url":null},"def":{"name":"validate","visibility":"Public","body":"if @validated\n return\nend\n@validated = true\nif redis_url.nil?\n message = \"Mosquito cannot start because the redis connection string hasn't been provided.\\n\\nFor example, in your application config:\\n\\nMosquito.configure do |settings|\\n settings.redis_url = (ENV[\\\"REDIS_TLS_URL\\\"]? || ENV[\\\"REDIS_URL\\\"]? || \\\"redis://localhost:6379\\\")\\nend\\n\\nSee Also: https://github.com/mosquito-cr/mosquito#connecting-to-redis\"\n raise(message)\nend\n"}},{"html_id":"validated:Bool-instance-method","name":"validated","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":22,"url":null},"def":{"name":"validated","visibility":"Public","body":"@validated"}},{"html_id":"validated=(validated:Bool)-instance-method","name":"validated=","abstract":false,"args":[{"name":"validated","external_name":"validated","restriction":"::Bool"}],"args_string":"(validated : Bool)","args_html":"(validated : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":22,"url":null},"def":{"name":"validated=","args":[{"name":"validated","external_name":"validated","restriction":"::Bool"}],"visibility":"Public","body":"@validated = validated"}}]},{"html_id":"mosquito/Mosquito/DoubleRun","path":"Mosquito/DoubleRun.html","kind":"class","full_name":"Mosquito::DoubleRun","name":"DoubleRun","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":7,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job_run tries to run twice","summary":"

When a job_run tries to run twice

"},{"html_id":"mosquito/Mosquito/Id","path":"Mosquito/Id.html","kind":"alias","full_name":"Mosquito::Id","name":"Id","abstract":false,"locations":[{"filename":"src/mosquito/base.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":true,"aliased":"(Int32 | Int64)","aliased_html":"Int32 | Int64","const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"}},{"html_id":"mosquito/Mosquito/IrretrievableParameter","path":"Mosquito/IrretrievableParameter.html","kind":"class","full_name":"Mosquito::IrretrievableParameter","name":"IrretrievableParameter","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":11,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job contains a model_id parameter pointing to a database record but the database doesn't return anything for that id.","summary":"

When a job contains a model_id parameter pointing to a database record but the database doesn't return anything for that id.

"},{"html_id":"mosquito/Mosquito/Job","path":"Mosquito/Job.html","kind":"class","full_name":"Mosquito::Job","name":"Job","abstract":true,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job.cr","line_number":10,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"}],"subclasses":[{"html_id":"mosquito/Mosquito/PeriodicJob","kind":"class","full_name":"Mosquito::PeriodicJob","name":"PeriodicJob"},{"html_id":"mosquito/Mosquito/QueuedJob","kind":"class","full_name":"Mosquito::QueuedJob","name":"QueuedJob"},{"html_id":"mosquito/Mosquito/ScheduledJob","kind":"class","full_name":"Mosquito::ScheduledJob","name":"ScheduledJob"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A Job is a definition for work to be performed.\nJobs are pieces of code which run a JobRun.\n\n- Jobs prevent double execution of a job for a job_run\n- Jobs Rescue when a #perform method fails a job_run for any reason\n- Jobs can be rescheduleable","summary":"

A Job is a definition for work to be performed.

","class_methods":[{"html_id":"metadata:Metadata-class-method","name":"metadata","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":182,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"Metadata.new(metadata_key, readonly: true)"}},{"html_id":"metadata_key-class-method","name":"metadata_key","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":186,"url":null},"def":{"name":"metadata_key","visibility":"Public","body":"Mosquito.backend.build_key(\"job_metadata\", self.name.underscore)"}},{"html_id":"queue-class-method","name":"queue","doc":"The Queue this job uses to store job_runs.","summary":"

The Queue this job uses to store job_runs.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":60,"url":null},"def":{"name":"queue","visibility":"Public","body":"if queue_name.blank?\n Queue.new(\"default\")\nelse\n Queue.new(queue_name)\nend"}},{"html_id":"queue_name:String-class-method","name":"queue_name","doc":"The queue this job is assigned to.\nBy default every job has it's own named queue:\n\n- EmailTheUniverseJob.queue = \"email_the_universe\"","summary":"

The queue this job is assigned to.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":48,"url":null},"def":{"name":"queue_name","return_type":"String","visibility":"Public","body":"({{ @type.id }}).to_s.underscore"}}],"instance_methods":[{"html_id":"aborted?(*args,**options)-instance-method","name":"aborted?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"aborted?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.aborted?(*args, **options)"}},{"html_id":"aborted?(*args,**options,&)-instance-method","name":"aborted?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"aborted?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.aborted?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"after_hook-instance-method","name":"after_hook","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":103,"url":null},"def":{"name":"after_hook","visibility":"Public","body":""}},{"html_id":"before_hook-instance-method","name":"before_hook","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":99,"url":null},"def":{"name":"before_hook","visibility":"Public","body":""}},{"html_id":"exception:Exception|Nil-instance-method","name":"exception","doc":"When a job fails and raises an exception, it will be saved into this attribute.","summary":"

When a job fails and raises an exception, it will be saved into this attribute.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":36,"url":null},"def":{"name":"exception","return_type":"Exception | ::Nil","visibility":"Public","body":"@exception"}},{"html_id":"executed?(*args,**options)-instance-method","name":"executed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"executed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.executed?(*args, **options)"}},{"html_id":"executed?(*args,**options,&)-instance-method","name":"executed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"executed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.executed?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"fail(reason=\"\",*,retry:Bool=true)-instance-method","name":"fail","doc":"To be called from inside a #perform\nMarks this job as a failure. By default, if the job is a candidate for\nre-scheduling, it will be run again at a later time.","summary":"

To be called from inside a #perform Marks this job as a failure.

","abstract":false,"args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"retry","default_value":"true","external_name":"retry","restriction":"Bool"}],"args_string":"(reason = \"\", *, retry : Bool = true)","args_html":"(reason = "", *, retry : Bool = true)","location":{"filename":"src/mosquito/job.cr","line_number":144,"url":null},"def":{"name":"fail","args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"retry","default_value":"true","external_name":"retry","restriction":"Bool"}],"splat_index":1,"visibility":"Public","body":"@should_retry = @should_retry && retry\nraise(JobFailed.new(reason))\n"}},{"html_id":"failed?(*args,**options)-instance-method","name":"failed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"failed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.failed?(*args, **options)"}},{"html_id":"failed?(*args,**options,&)-instance-method","name":"failed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"failed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.failed?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"job_run_id:String|Nil-instance-method","name":"job_run_id","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":38,"url":null},"def":{"name":"job_run_id","return_type":"String | ::Nil","visibility":"Public","body":"@job_run_id"}},{"html_id":"job_run_id=(job_run_id:String|Nil)-instance-method","name":"job_run_id=","abstract":false,"args":[{"name":"job_run_id","external_name":"job_run_id","restriction":"String | ::Nil"}],"args_string":"(job_run_id : String | Nil)","args_html":"(job_run_id : String | Nil)","location":{"filename":"src/mosquito/job.cr","line_number":38,"url":null},"def":{"name":"job_run_id=","args":[{"name":"job_run_id","external_name":"job_run_id","restriction":"String | ::Nil"}],"visibility":"Public","body":"@job_run_id = job_run_id"}},{"html_id":"log(message)-instance-method","name":"log","abstract":false,"args":[{"name":"message","external_name":"message","restriction":""}],"args_string":"(message)","args_html":"(message)","location":{"filename":"src/mosquito/job.cr","line_number":27,"url":null},"def":{"name":"log","args":[{"name":"message","external_name":"message","restriction":""}],"visibility":"Public","body":"(::Log.for(self.class)).info do\n message\nend"}},{"html_id":"metadata:Metadata-instance-method","name":"metadata","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":176,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"@metadata || (@metadata = (Metadata.new(self.class.metadata_key)))"}},{"html_id":"perform-instance-method","name":"perform","doc":"abstract, override in a Job descendant to do something productive","summary":"

abstract, override in a Job descendant to do something productive

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":136,"url":null},"def":{"name":"perform","visibility":"Public","body":"Log.error do\n \"No job definition found for #{self.class.name}\"\nend\nfail\n"}},{"html_id":"reschedule_interval(retry_count:Int32):Time::Span-instance-method","name":"reschedule_interval","doc":"abstract, override if desired.\n\nFor a given retry count, how long should the delay between\njob attempts be?","summary":"

abstract, override if desired.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Time::Span","args_html":"(retry_count : Int32) : Time::Span","location":{"filename":"src/mosquito/job.cr","line_number":168,"url":null},"def":{"name":"reschedule_interval","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Time::Span","visibility":"Public","body":"2.seconds * (retry_count ** 2)"}},{"html_id":"rescheduleable?(retry_count:Int32):Bool-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nFor a given retry count, is this job rescheduleable?","summary":"

abstract, override if desired.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Bool","args_html":"(retry_count : Int32) : Bool","location":{"filename":"src/mosquito/job.cr","line_number":160,"url":null},"def":{"name":"rescheduleable?","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"rescheduleable? && retry_count < 5"}},{"html_id":"rescheduleable?:Bool-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":153,"url":null},"def":{"name":"rescheduleable?","return_type":"Bool","visibility":"Public","body":"true"}},{"html_id":"retry_later-instance-method","name":"retry_later","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":107,"url":null},"def":{"name":"retry_later","visibility":"Public","body":"fail"}},{"html_id":"run-instance-method","name":"run","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":74,"url":null},"def":{"name":"run","visibility":"Public","body":"begin\n begin\n before_hook\n rescue e : Exception\n Log.error(exception: e) do\n \"Before hook raised, job will not be executed\"\n end\n @state = State::Aborted\n return\n end\n @state = State::Running\n perform\n @state = State::Succeeded\nrescue e\n Log.warn(exception: e) do\n \"Job failed! Raised #{e.class}: #{e.message}\"\n end\n @exception = e\n @state = State::Failed\nensure\n after_hook\nend"}},{"html_id":"should_retry:Bool-instance-method","name":"should_retry","doc":"When a job run fails, should it be added to the retry queue?\nSee: #fail(retry: false)","summary":"

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":42,"url":null},"def":{"name":"should_retry","return_type":"Bool","visibility":"Public","body":"@should_retry"}},{"html_id":"should_retry=(should_retry:Bool)-instance-method","name":"should_retry=","doc":"When a job run fails, should it be added to the retry queue?\nSee: #fail(retry: false)","summary":"

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

","abstract":false,"args":[{"name":"should_retry","external_name":"should_retry","restriction":"Bool"}],"args_string":"(should_retry : Bool)","args_html":"(should_retry : Bool)","location":{"filename":"src/mosquito/job.cr","line_number":42,"url":null},"def":{"name":"should_retry=","args":[{"name":"should_retry","external_name":"should_retry","restriction":"Bool"}],"visibility":"Public","body":"@should_retry = should_retry"}},{"html_id":"state:Mosquito::Job::State-instance-method","name":"state","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":31,"url":null},"def":{"name":"state","visibility":"Public","body":"@state"}},{"html_id":"succeeded?(*args,**options)-instance-method","name":"succeeded?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"succeeded?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.succeeded?(*args, **options)"}},{"html_id":"succeeded?(*args,**options,&)-instance-method","name":"succeeded?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"succeeded?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.succeeded?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[{"html_id":"after(&block)-macro","name":"after","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":123,"url":null},"def":{"name":"after","block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" def after_hook\n \n{% if @type.methods.map(&.name).includes?((:after_hook).id) %}\n previous_def\n {% else %}\n super\n {% end %}\n\n\n \n{{ yield }}\n\n \nend\n \n"}},{"html_id":"before(&block)-macro","name":"before","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":111,"url":null},"def":{"name":"before","block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" def before_hook\n \n{% if @type.methods.map(&.name).includes?((:before_hook).id) %}\n previous_def\n {% else %}\n super\n {% end %}\n\n\n \n{{ yield }}\n\n \nend\n \n"}},{"html_id":"queue_name(name)-macro","name":"queue_name","doc":"Easily override the queue for any job.","summary":"

Easily override the queue for any job.

","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/mosquito/job.cr","line_number":53,"url":null},"def":{"name":"queue_name","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":" def self.queue_name : String\n \"\n{{ name.id }}\n\"\n \nend\n \n"}}],"types":[{"html_id":"mosquito/Mosquito/Job/State","path":"Mosquito/Job/State.html","kind":"enum","full_name":"Mosquito::Job::State","name":"State","abstract":false,"ancestors":[{"html_id":"mosquito/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"mosquito/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job.cr","line_number":15,"url":null}],"repository_name":"mosquito","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Initialization","name":"Initialization","value":"0"},{"id":"Running","name":"Running","value":"1"},{"id":"Succeeded","name":"Succeeded","value":"2"},{"id":"Failed","name":"Failed","value":"3"},{"id":"Aborted","name":"Aborted","value":"4"}],"namespace":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"instance_methods":[{"html_id":"aborted?-instance-method","name":"aborted?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":20,"url":null},"def":{"name":"aborted?","visibility":"Public","body":"self == Aborted"}},{"html_id":"executed?:Bool-instance-method","name":"executed?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":22,"url":null},"def":{"name":"executed?","return_type":"Bool","visibility":"Public","body":"succeeded? || failed?"}},{"html_id":"failed?-instance-method","name":"failed?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":19,"url":null},"def":{"name":"failed?","visibility":"Public","body":"self == Failed"}},{"html_id":"initialization?-instance-method","name":"initialization?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":16,"url":null},"def":{"name":"initialization?","visibility":"Public","body":"self == Initialization"}},{"html_id":"running?-instance-method","name":"running?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":17,"url":null},"def":{"name":"running?","visibility":"Public","body":"self == Running"}},{"html_id":"succeeded?-instance-method","name":"succeeded?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":18,"url":null},"def":{"name":"succeeded?","visibility":"Public","body":"self == Succeeded"}}]}]},{"html_id":"mosquito/Mosquito/JobFailed","path":"Mosquito/JobFailed.html","kind":"class","full_name":"Mosquito::JobFailed","name":"JobFailed","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job fails","summary":"

When a job fails

"},{"html_id":"mosquito/Mosquito/JobRun","path":"Mosquito/JobRun.html","kind":"class","full_name":"Mosquito::JobRun","name":"JobRun","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job_run.cr","line_number":11,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"CONFIG_KEY_PREFIX","name":"CONFIG_KEY_PREFIX","value":"\"job_run\""}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A JobRun is a unit of work which will be performed by a Job.\nJobRuns know how to:\n- store and retrieve their data to and from the datastore\n- figure out what Job class they match to\n- build an instance of that Job class and pass off the config data\n- Ask the job to run\n\nJobRun data is called `config` and is persisted in the backend under the key\n`mosquito:job_run:job_run_id`.","summary":"

A JobRun is a unit of work which will be performed by a Job.

","class_methods":[{"html_id":"config_key(*parts)-class-method","name":"config_key","doc":"The config key is the backend storage key for the metadata of this job_run.","summary":"

The config key is the backend storage key for the metadata of this job_run.

","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/job_run.cr","line_number":33,"url":null},"def":{"name":"config_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"Mosquito.backend.build_key(CONFIG_KEY_PREFIX, parts)"}},{"html_id":"retrieve(id:String)-class-method","name":"retrieve","doc":"Used to construct a job_run from the parameters stored in the backend.","summary":"

Used to construct a job_run from the parameters stored in the backend.

","abstract":false,"args":[{"name":"id","external_name":"id","restriction":"String"}],"args_string":"(id : String)","args_html":"(id : String)","location":{"filename":"src/mosquito/job_run.cr","line_number":117,"url":null},"def":{"name":"retrieve","args":[{"name":"id","external_name":"id","restriction":"String"}],"visibility":"Public","body":"fields = Mosquito.backend.retrieve(config_key(id))\nif name = fields.delete(\"type\")\nelse\n return\nend\nif timestamp = fields.delete(\"enqueue_time\")\nelse\n return\nend\nretry_count = ((fields.delete(\"retry_count\")) || 0).to_i\ninstance = new(name, Time.unix_ms(timestamp.to_i64), id, retry_count)\ninstance.config = fields\ninstance\n"}}],"constructors":[{"html_id":"new(type:String,enqueue_time:Time=Time.utc,id:String|Nil=nil,retry_count:Int32=0)-class-method","name":"new","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"enqueue_time","default_value":"Time.utc","external_name":"enqueue_time","restriction":"Time"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry_count","default_value":"0","external_name":"retry_count","restriction":"Int32"}],"args_string":"(type : String, enqueue_time : Time = Time.utc, id : String | Nil = nil, retry_count : Int32 = 0)","args_html":"(type : String, enqueue_time : Time = Time.utc, id : String | Nil = nil, retry_count : Int32 = 0)","location":{"filename":"src/mosquito/job_run.cr","line_number":41,"url":null},"def":{"name":"new","args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"enqueue_time","default_value":"Time.utc","external_name":"enqueue_time","restriction":"Time"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry_count","default_value":"0","external_name":"retry_count","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(type, enqueue_time, id, retry_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:self)-instance-method","name":"==","doc":"Returns `true` if this reference is the same as *other*. Invokes `same?`.","summary":"

Returns true if this reference is the same as other.

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self)","args_html":"(other : self)","location":{"filename":"src/mosquito/job_run.cr","line_number":140,"url":null},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"visibility":"Public","body":"id == self.id"}},{"html_id":"build_job:Mosquito::Job-instance-method","name":"build_job","doc":"Builds a Job instance from this job_run. Populates the job with config from\nthe backend.","summary":"

Builds a Job instance from this job_run.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":71,"url":null},"def":{"name":"build_job","return_type":"Mosquito::Job","visibility":"Public","body":"if job = @job\n return job\nend\n@job = instance = (Base.job_for_type(type)).new\nif instance.responds_to?(:vars_from)\n instance.vars_from(config)\nend\ninstance.job_run_id = id\ninstance\n"}},{"html_id":"config_key-instance-method","name":"config_key","doc":"The config key is the backend storage key for the metadata of this job_run.","summary":"

The config key is the backend storage key for the metadata of this job_run.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":28,"url":null},"def":{"name":"config_key","visibility":"Public","body":"self.class.config_key(id)"}},{"html_id":"delete(inttl=0)-instance-method","name":"delete","doc":"Deletes this job_run from the backend.\nOptionally, after a delay in seconds (handled by the backend).","summary":"

Deletes this job_run from the backend.

","abstract":false,"args":[{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"args_string":"(in ttl = 0)","args_html":"(in ttl = 0)","location":{"filename":"src/mosquito/job_run.cr","line_number":65,"url":null},"def":{"name":"delete","args":[{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"visibility":"Public","body":"Mosquito.backend.delete(config_key, ttl)"}},{"html_id":"enqueue_time:Time-instance-method","name":"enqueue_time","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":13,"url":null},"def":{"name":"enqueue_time","return_type":"Time","visibility":"Public","body":"@enqueue_time"}},{"html_id":"fail-instance-method","name":"fail","doc":"Fails this job run and make sure it's persisted as such.","summary":"

Fails this job run and make sure it's persisted as such.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":98,"url":null},"def":{"name":"fail","visibility":"Public","body":"@retry_count = @retry_count + 1\nstore\n"}},{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":14,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"job:Mosquito::Job|Nil-instance-method","name":"job","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":16,"url":null},"def":{"name":"job","return_type":"Mosquito::Job | ::Nil","visibility":"Public","body":"@job"}},{"html_id":"job!:Mosquito::Job-instance-method","name":"job!","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":18,"url":null},"def":{"name":"job!","return_type":"Mosquito::Job","visibility":"Public","body":"job || (raise(RuntimeError.new(\"No job yet retrieved for job_run.\")))"}},{"html_id":"reload:Nil-instance-method","name":"reload","doc":"Updates this job_run config from the backend.","summary":"

Updates this job_run config from the backend.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":131,"url":null},"def":{"name":"reload","return_type":"Nil","visibility":"Public","body":"config.merge!(Mosquito.backend.retrieve(config_key))\n@retry_count = config[\"retry_count\"].to_i\n"}},{"html_id":"reschedule_interval-instance-method","name":"reschedule_interval","doc":"For the current retry count, how long should a runner wait before retry?","summary":"

For the current retry count, how long should a runner wait before retry?

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":109,"url":null},"def":{"name":"reschedule_interval","visibility":"Public","body":"job!.reschedule_interval(@retry_count)"}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"For the current retry count, is the job rescheduleable?","summary":"

For the current retry count, is the job rescheduleable?

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":104,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"job!.rescheduleable?(@retry_count)"}},{"html_id":"retry_count:Int32-instance-method","name":"retry_count","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":15,"url":null},"def":{"name":"retry_count","visibility":"Public","body":"@retry_count"}},{"html_id":"run-instance-method","name":"run","doc":"Builds and runs the job with this job_run config.","summary":"

Builds and runs the job with this job_run config.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":87,"url":null},"def":{"name":"run","visibility":"Public","body":"instance = build_job\ninstance.run\nif executed? && failed?\n @retry_count = @retry_count + 1\n store\nend\n"}},{"html_id":"store-instance-method","name":"store","doc":"Stores this job run configuration and metadata in the backend.","summary":"

Stores this job run configuration and metadata in the backend.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":54,"url":null},"def":{"name":"store","visibility":"Public","body":"fields = config.dup\nfields[\"enqueue_time\"] = enqueue_time.to_unix_ms.to_s\nfields[\"type\"] = type\nfields[\"retry_count\"] = retry_count.to_s\nMosquito.backend.store(config_key, fields)\n"}},{"html_id":"to_s(io:IO)-instance-method","name":"to_s","doc":"Appends a short String representation of this object\nwhich includes its class name and its object address.\n\n```\nclass Person\n def initialize(@name : String, @age : Int32)\n end\nend\n\nPerson.new(\"John\", 32).to_s # => #\n```","summary":"

Appends a short String representation of this object which includes its class name and its object address.

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO)","args_html":"(io : IO)","location":{"filename":"src/mosquito/job_run.cr","line_number":136,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":"IO"}],"visibility":"Public","body":"\"#{type}<#{id}>\".to_s(io)"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":12,"url":null},"def":{"name":"type","visibility":"Public","body":"@type"}}]},{"html_id":"mosquito/Mosquito/KeyBuilder","path":"Mosquito/KeyBuilder.html","kind":"class","full_name":"Mosquito::KeyBuilder","name":"KeyBuilder","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/key_builder.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"KEY_SEPERATOR","name":"KEY_SEPERATOR","value":"\":\""}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"build(*parts)-class-method","name":"build","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/key_builder.cr","line_number":5,"url":null},"def":{"name":"build","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"id = [] of String\nparts.each do |part|\n case part\n when Symbol\n id << (build(part.to_s))\n when String\n id << part\n when Array\n part.each do |e|\n id << (build(e))\n end\n when Tuple\n part.to_a.each do |e|\n id << (build(e))\n end\n when Number\n id << part.to_s\n else\n raise(\"#{part.class} is not a keyable type\")\n end\nend\nid.flatten.join(KEY_SEPERATOR)\n"}}]},{"html_id":"mosquito/Mosquito/Metadata","path":"Mosquito/Metadata.html","kind":"class","full_name":"Mosquito::Metadata","name":"Metadata","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/metadata.cr","line_number":8,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"Provides a real-time metadata store. Data is not cached, which allows\nmultiple workers to operate on the same structures in real time.\n\nEach read or write incurs a round trip to the backend.\n\nKeys and values are always strings.","summary":"

Provides a real-time metadata store.

","constructors":[{"html_id":"new(root_key:String,readonly:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"root_key","external_name":"root_key","restriction":"String"},{"name":"readonly","default_value":"false","external_name":"readonly","restriction":"::Bool"}],"args_string":"(root_key : String, readonly : Bool = false)","args_html":"(root_key : String, readonly : Bool = false)","location":{"filename":"src/mosquito/metadata.cr","line_number":12,"url":null},"def":{"name":"new","args":[{"name":"root_key","external_name":"root_key","restriction":"String"},{"name":"readonly","default_value":"false","external_name":"readonly","restriction":"::Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(root_key, readonly)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[]=(key:String,value:String)-instance-method","name":"[]=","doc":"Writes a value to a key in the metadata.","summary":"

Writes a value to a key in the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String)","args_html":"(key : String, value : String)","location":{"filename":"src/mosquito/metadata.cr","line_number":36,"url":null},"def":{"name":"[]=","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.set(root_key, key, value)\n"}},{"html_id":"[]?(key:String):String|Nil-instance-method","name":"[]?","doc":"Reads a single key from the metadata.","summary":"

Reads a single key from the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : String | Nil","args_html":"(key : String) : String | Nil","location":{"filename":"src/mosquito/metadata.cr","line_number":31,"url":null},"def":{"name":"[]?","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":"Mosquito.backend.get(root_key, key)"}},{"html_id":"decrement(key)-instance-method","name":"decrement","doc":"Decrements a value in the metadata by 1.","summary":"

Decrements a value in the metadata by 1.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":54,"url":null},"def":{"name":"decrement","args":[{"name":"key","external_name":"key","restriction":""}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key, by: -1)\n"}},{"html_id":"delete(inttl:Time::Span):Nil-instance-method","name":"delete","doc":"Schedule this metadata to be deleted after a time span.","summary":"

Schedule this metadata to be deleted after a time span.

","abstract":false,"args":[{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(in ttl : Time::Span) : Nil","args_html":"(in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/metadata.cr","line_number":21,"url":null},"def":{"name":"delete","args":[{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":"Mosquito.backend.delete(root_key, in: ttl)"}},{"html_id":"delete:Nil-instance-method","name":"delete","doc":"Deletes this metadata immediately.","summary":"

Deletes this metadata immediately.

","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":16,"url":null},"def":{"name":"delete","return_type":"Nil","visibility":"Public","body":"Mosquito.backend.delete(root_key)"}},{"html_id":"increment(key,byincrement:Int32)-instance-method","name":"increment","doc":"Parametrically incruments a value in the metadata.","summary":"

Parametrically incruments a value in the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""},{"name":"increment","external_name":"by","restriction":"Int32"}],"args_string":"(key, by increment : Int32)","args_html":"(key, by increment : Int32)","location":{"filename":"src/mosquito/metadata.cr","line_number":48,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":""},{"name":"increment","external_name":"by","restriction":"Int32"}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key, by: increment)\n"}},{"html_id":"increment(key)-instance-method","name":"increment","doc":"Increments a value in the metadata by 1 by 1 by 1 by 1.","summary":"

Increments a value in the metadata by 1 by 1 by 1 by 1.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":42,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":""}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key)\n"}},{"html_id":"inspect(*args,**options)-instance-method","name":"inspect","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"inspect","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_h.inspect(*args, **options)"}},{"html_id":"inspect(*args,**options,&)-instance-method","name":"inspect","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"inspect","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_h.inspect(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"readonly?:Bool-instance-method","name":"readonly?","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":10,"url":null},"def":{"name":"readonly?","return_type":"Bool","visibility":"Public","body":"@readonly"}},{"html_id":"root_key:String-instance-method","name":"root_key","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":9,"url":null},"def":{"name":"root_key","return_type":"String","visibility":"Public","body":"@root_key"}},{"html_id":"root_key=(root_key:String)-instance-method","name":"root_key=","abstract":false,"args":[{"name":"root_key","external_name":"root_key","restriction":"String"}],"args_string":"(root_key : String)","args_html":"(root_key : String)","location":{"filename":"src/mosquito/metadata.cr","line_number":9,"url":null},"def":{"name":"root_key=","args":[{"name":"root_key","external_name":"root_key","restriction":"String"}],"visibility":"Public","body":"@root_key = root_key"}},{"html_id":"to_h:Hash(String,String)-instance-method","name":"to_h","doc":"Reads the metadata and returns it as a hash.","summary":"

Reads the metadata and returns it as a hash.

","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":26,"url":null},"def":{"name":"to_h","return_type":"Hash(String, String)","visibility":"Public","body":"Mosquito.backend.retrieve(root_key)"}},{"html_id":"to_s(*args,**options)-instance-method","name":"to_s","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"to_s","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_h.to_s(*args, **options)"}},{"html_id":"to_s(*args,**options,&)-instance-method","name":"to_s","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"to_s","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_h.to_s(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}]},{"html_id":"mosquito/Mosquito/PeriodicJob","path":"Mosquito/PeriodicJob.html","kind":"class","full_name":"Mosquito::PeriodicJob","name":"PeriodicJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/periodic_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":3,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_job_run-instance-method","name":"build_job_run","abstract":true,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":6,"url":null},"def":{"name":"build_job_run","visibility":"Public","body":""}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":28,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"false"}}]},{"html_id":"mosquito/Mosquito/PeriodicJobRun","path":"Mosquito/PeriodicJobRun.html","kind":"class","full_name":"Mosquito::PeriodicJobRun","name":"PeriodicJobRun","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/periodic_job_run.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new(class__arg0:::Mosquito::PeriodicJob.class,interval:Time::MonthSpan|Time::Span)-class-method","name":"new","abstract":false,"args":[{"name":"__arg0","external_name":"class","restriction":"::Mosquito::PeriodicJob.class"},{"name":"interval","external_name":"interval","restriction":"::Time::MonthSpan | ::Time::Span"}],"args_string":"(class __arg0 : ::Mosquito::PeriodicJob.class, interval : Time::MonthSpan | Time::Span)","args_html":"(class __arg0 : ::Mosquito::PeriodicJob.class, interval : Time::MonthSpan | Time::Span)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":40,"url":null},"def":{"name":"new","args":[{"name":"__arg0","external_name":"class","restriction":"::Mosquito::PeriodicJob.class"},{"name":"interval","external_name":"interval","restriction":"::Time::MonthSpan | ::Time::Span"}],"visibility":"Public","body":"_ = allocate\n_.initialize(__arg0, interval)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"class:Mosquito::PeriodicJob.class-instance-method","name":"class","doc":"Returns the **runtime** `Class` of an object.\n\n```\n1.class # => Int32\n\"hello\".class # => String\n```\n\nCompare it with `typeof`, which returns the **compile-time** type of an object:\n\n```\nrandom_value = rand # => 0.627423\nvalue = random_value < 0.5 ? 1 : \"hello\"\nvalue # => \"hello\"\nvalue.class # => String\ntypeof(value) # => Int32 | String\n```","summary":"

Returns the runtime Class of an object.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":3,"url":null},"def":{"name":"class","return_type":"Mosquito::PeriodicJob.class","visibility":"Public","body":"@class"}},{"html_id":"class=(class__arg0:Mosquito::PeriodicJob.class)-instance-method","name":"class=","abstract":false,"args":[{"name":"__arg0","external_name":"class","restriction":"Mosquito::PeriodicJob.class"}],"args_string":"(class __arg0 : Mosquito::PeriodicJob.class)","args_html":"(class __arg0 : Mosquito::PeriodicJob.class)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":3,"url":null},"def":{"name":"class=","args":[{"name":"__arg0","external_name":"class","restriction":"Mosquito::PeriodicJob.class"}],"visibility":"Public","body":"@class = __arg0"}},{"html_id":"execute-instance-method","name":"execute","doc":"Enqueues the job for execution","summary":"

Enqueues the job for execution

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":63,"url":null},"def":{"name":"execute","visibility":"Public","body":"job = @class.new\njob_run = job.build_job_run\njob_run.store\n@class.queue.enqueue(job_run)\n"}},{"html_id":"interval:Time::Span|Time::MonthSpan-instance-method","name":"interval","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":4,"url":null},"def":{"name":"interval","return_type":"Time::Span | Time::MonthSpan","visibility":"Public","body":"@interval"}},{"html_id":"interval=(interval:Time::Span|Time::MonthSpan)-instance-method","name":"interval=","abstract":false,"args":[{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"args_string":"(interval : Time::Span | Time::MonthSpan)","args_html":"(interval : Time::Span | Time::MonthSpan)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":4,"url":null},"def":{"name":"interval=","args":[{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"visibility":"Public","body":"@interval = interval"}},{"html_id":"last_executed_at-instance-method","name":"last_executed_at","doc":"The last executed timestamp, or \"never\" if it doesn't exist.","summary":"

The last executed timestamp, or "never" if it doesn't exist.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":16,"url":null},"def":{"name":"last_executed_at","visibility":"Public","body":"last_executed_at? || (Time.unix(0))"}},{"html_id":"last_executed_at=(time:Time)-instance-method","name":"last_executed_at=","doc":"Updates the last executed timestamp in the backend,\nand schedules the metadata for deletion after 3*interval\nseconds.\n\nFor Time::Span intervals, the TTL is set to 3 * interval.\nFor Time::MonthSpan intervals, the TTL is set to approximately 3 * interval.\n\nA month is approximated to 2635200 seconds, or 30.5 days.","summary":"

Updates the last executed timestamp in the backend, and schedules the metadata for deletion after 3*interval seconds.

","abstract":false,"args":[{"name":"time","external_name":"time","restriction":"Time"}],"args_string":"(time : Time)","args_html":"(time : Time)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":28,"url":null},"def":{"name":"last_executed_at=","args":[{"name":"time","external_name":"time","restriction":"Time"}],"visibility":"Public","body":"@metadata[\"last_executed_at\"] = time.to_unix.to_s\ncase interval_ = interval\nwhen Time::Span\n @metadata.delete(in: interval_ * 3)\nwhen Time::MonthSpan\n seconds_in_an_average_month = 2635200.seconds\n @metadata.delete(in: (seconds_in_an_average_month * interval_.value) * 3)\nend\n"}},{"html_id":"last_executed_at?-instance-method","name":"last_executed_at?","doc":"The last executed timestamp for this periodicjob tracked by the backend.","summary":"

The last executed timestamp for this periodicjob tracked by the backend.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":7,"url":null},"def":{"name":"last_executed_at?","visibility":"Public","body":"if timestamp = @metadata[\"last_executed_at\"]?\n Time.unix(timestamp.to_i)\nelse\n nil\nend"}},{"html_id":"try_to_execute:Bool-instance-method","name":"try_to_execute","doc":"Check the last executed timestamp against the current time,\nand enqueue the job if it's time to execute.","summary":"

Check the last executed timestamp against the current time, and enqueue the job if it's time to execute.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":46,"url":null},"def":{"name":"try_to_execute","return_type":"Bool","visibility":"Public","body":"now = Time.utc\nif (last_executed_at + interval) <= now\n execute\n self.last_executed_at = now\n true\nelse\n false\nend\n"}}]},{"html_id":"mosquito/Mosquito/Queue","path":"Mosquito/Queue.html","kind":"class","full_name":"Mosquito::Queue","name":"Queue","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/queue.cr","line_number":77,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A named Queue.\n\nNamed Queues exist and have 4 ordered lists: waiting, pending, scheduled, and dead.\n\n- The Waiting list is for jobs which need to be executed as soon as possible.\n- The Pending list is for jobs which are currently being executed.\n- The Scheduled list is indexed by execution time and holds jobs which need to be executed at a later time.\n- The Dead list is for jobs which have been retried too many times and are no longer viable.\n\nA job_run is represented in a queue by its id.\n\nA job_run flows through the queues in this manner:\n\n\n```text\n Time=0: JobRun does not exist yet, lists are empty\n\n Waiting Pending Scheduled Dead\n\n ---------------------------------\n Time=1: JobRun is enqueued\n\n Waiting Pending Scheduled Dead\n JobRun#1\n\n ---------------------------------\n Time=2: JobRun begins. JobRun is moved to pending and executed\n\n Waiting Pending Scheduled Dead\n JobRun#1\n\n ---------------------------------\n Time=3: JobRuns are Enqueued.\n\n Waiting Pending Scheduled Dead\n JobRun#2 JobRun#1\n JobRun#3\n\n ---------------------------------\n Time=4: JobRun succeeds, next job_run begins.\n\n Waiting Pending Scheduled Dead\n JobRun#3 JobRun#2\n\n ---------------------------------\n Time=5: JobRun fails and is scheduled for later, next job_run begins.\n\n Waiting Pending Scheduled Dead\n JobRun#3 t=7:JobRun#2\n\n ---------------------------------\n Time=6: JobRun succeeds. Nothing is executing.\n\n Waiting Pending Scheduled Dead\n t=7:JobRun#2\n\n ---------------------------------\n Time=7: Scheduled job_run is due and is moved to waiting. Nothing is executing.\n\n Waiting Pending Scheduled Dead\n JobRun#2\n\n ---------------------------------\n Time=8: JobRun begins executing (for the second time).\n\n Waiting Pending Scheduled Dead\n JobRun#2\n\n ---------------------------------\n Time=9: JobRun finished successfully. No more job_runs present.\n\n Waiting Pending Scheduled Dead\n\n```\n","summary":"

A named Queue.

","constructors":[{"html_id":"new(name:String)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"}],"args_string":"(name : String)","args_html":"(name : String)","location":{"filename":"src/mosquito/queue.cr","line_number":84,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:self):Bool-instance-method","name":"==","doc":"Returns `true` if this reference is the same as *other*. Invokes `same?`.","summary":"

Returns true if this reference is the same as other.

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : Bool","args_html":"(other : self) : Bool","location":{"filename":"src/mosquito/queue.cr","line_number":142,"url":null},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"Bool","visibility":"Public","body":"name == other.name"}},{"html_id":"backend:Mosquito::Backend-instance-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":80,"url":null},"def":{"name":"backend","return_type":"Mosquito::Backend","visibility":"Public","body":"@backend"}},{"html_id":"backend=(backend:Mosquito::Backend)-instance-method","name":"backend=","abstract":false,"args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend"}],"args_string":"(backend : Mosquito::Backend)","args_html":"(backend : Mosquito::Backend)","location":{"filename":"src/mosquito/queue.cr","line_number":80,"url":null},"def":{"name":"backend=","args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend"}],"visibility":"Public","body":"@backend = backend"}},{"html_id":"banish(job_run:JobRun)-instance-method","name":"banish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/queue.cr","line_number":128,"url":null},"def":{"name":"banish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"backend.finish(job_run)\nbackend.terminate(job_run)\n"}},{"html_id":"config_key:String-instance-method","name":"config_key","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":78,"url":null},"def":{"name":"config_key","visibility":"Public","body":"@config_key"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":104,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"if empty?\n return\nend\nif job_run = backend.dequeue\n job_run\nelse\n @empty = true\n nil\nend\n"}},{"html_id":"dequeue_scheduled:Array(JobRun)-instance-method","name":"dequeue_scheduled","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":120,"url":null},"def":{"name":"dequeue_scheduled","return_type":"Array(JobRun)","visibility":"Public","body":"backend.deschedule"}},{"html_id":"empty?:Bool-instance-method","name":"empty?","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":79,"url":null},"def":{"name":"empty?","return_type":"Bool","visibility":"Public","body":"@empty"}},{"html_id":"enqueue(job_run:JobRun,ininterval:Time::Span):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"interval","external_name":"in","restriction":"Time::Span"}],"args_string":"(job_run : JobRun, in interval : Time::Span) : JobRun","args_html":"(job_run : JobRun, in interval : Time::Span) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":95,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"interval","external_name":"in","restriction":"Time::Span"}],"return_type":"JobRun","visibility":"Public","body":"enqueue(job_run, at: interval.from_now)"}},{"html_id":"enqueue(job_run:JobRun,atexecute_time:Time):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execute_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at execute_time : Time) : JobRun","args_html":"(job_run : JobRun, at execute_time : Time) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":99,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execute_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"Log.trace do\n \"Enqueuing #{job_run} at #{execute_time}\"\nend\nbackend.schedule(job_run, execute_time)\n"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":90,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"Log.trace do\n \"Enqueuing #{job_run} for immediate execution\"\nend\nbackend.enqueue(job_run)\n"}},{"html_id":"flush-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":146,"url":null},"def":{"name":"flush","visibility":"Public","body":"backend.flush"}},{"html_id":"forget(job_run:JobRun)-instance-method","name":"forget","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/queue.cr","line_number":124,"url":null},"def":{"name":"forget","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"backend.finish(job_run)"}},{"html_id":"length:Int64-instance-method","name":"length","summary":"

DEPRECATED see #size

","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":138,"url":null},"def":{"name":"length","return_type":"Int64","visibility":"Public","body":"backend.size"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":78,"url":null},"def":{"name":"name","visibility":"Public","body":"@name"}},{"html_id":"reschedule(job_run:JobRun,execution_time)-instance-method","name":"reschedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execution_time","external_name":"execution_time","restriction":""}],"args_string":"(job_run : JobRun, execution_time)","args_html":"(job_run : JobRun, execution_time)","location":{"filename":"src/mosquito/queue.cr","line_number":115,"url":null},"def":{"name":"reschedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execution_time","external_name":"execution_time","restriction":""}],"visibility":"Public","body":"backend.finish(job_run)\nenqueue(job_run, at: execution_time)\n"}},{"html_id":"size:Int64-instance-method","name":"size","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":133,"url":null},"def":{"name":"size","return_type":"Int64","visibility":"Public","body":"backend.size"}}]},{"html_id":"mosquito/Mosquito/QueuedJob","path":"Mosquito/QueuedJob.html","kind":"class","full_name":"Mosquito::QueuedJob","name":"QueuedJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/queued_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"enqueue(indelay_interval:Time::Span):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"delay_interval","external_name":"in","restriction":"Time::Span"}],"args_string":"(in delay_interval : Time::Span) : JobRun","args_html":"(in delay_interval : Time::Span) : JobRun","location":{"filename":"src/mosquito/queued_job.cr","line_number":128,"url":null},"def":{"name":"enqueue","args":[{"name":"delay_interval","external_name":"in","restriction":"Time::Span"}],"return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run, in: delay_interval)\nend"}},{"html_id":"enqueue(atexecute_time:Time):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"execute_time","external_name":"at","restriction":"Time"}],"args_string":"(at execute_time : Time) : JobRun","args_html":"(at execute_time : Time) : JobRun","location":{"filename":"src/mosquito/queued_job.cr","line_number":135,"url":null},"def":{"name":"enqueue","args":[{"name":"execute_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run, at: execute_time)\nend"}},{"html_id":"enqueue:JobRun-instance-method","name":"enqueue","abstract":false,"location":{"filename":"src/mosquito/queued_job.cr","line_number":121,"url":null},"def":{"name":"enqueue","return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run)\nend"}}]},{"html_id":"mosquito/Mosquito/RateLimiter","path":"Mosquito/RateLimiter.html","kind":"module","full_name":"Mosquito::RateLimiter","name":"RateLimiter","abstract":false,"locations":[{"filename":"src/mosquito/rate_limiter.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"increment_run_count:Nil-instance-method","name":"increment_run_count","doc":"Increments the run counter.","summary":"

Increments the run counter.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":134,"url":null},"def":{"name":"increment_run_count","return_type":"Nil","visibility":"Public","body":"metadata.increment(\"run_count\", by: increment_run_count_by)"}},{"html_id":"increment_run_count_by:Int32-instance-method","name":"increment_run_count_by","doc":"How much the run counter should be incremented by.\nImplemented as a dynamic method so that it can easily be calculated by\nsome other metric, eg api calls to a third party library.","summary":"

How much the run counter should be incremented by.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":141,"url":null},"def":{"name":"increment_run_count_by","return_type":"Int32","visibility":"Public","body":"@@rate_limit_increment"}},{"html_id":"maxed_rate_for_window?:Bool-instance-method","name":"maxed_rate_for_window?","doc":"Has the run count exceeded the ceiling for the current window?","summary":"

Has the run count exceeded the ceiling for the current window?

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":97,"url":null},"def":{"name":"maxed_rate_for_window?","return_type":"Bool","visibility":"Public","body":"run_count = metadata[\"run_count\"]?.try(&.to_i)\nrun_count || (run_count = 0)\nrun_count >= @@rate_limit_ceiling\n"}},{"html_id":"metadata:Metadata-instance-method","name":"metadata","doc":"Storage hash for rate limit data.","summary":"

Storage hash for rate limit data.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":84,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"@rl_metadata || (@rl_metadata = self.class.metadata)"}},{"html_id":"rate_limited?:Bool-instance-method","name":"rate_limited?","doc":"Should this job be cancelled?\nIf not, update the rate limit metadata.","summary":"

Should this job be cancelled? If not, update the rate limit metadata.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":90,"url":null},"def":{"name":"rate_limited?","return_type":"Bool","visibility":"Public","body":"if @@rate_limit_ceiling < 0\n return false\nend\nif maxed_rate_for_window?\n return true\nend\nfalse\n"}},{"html_id":"reschedule_interval(retry_count:Int32):Time::Span-instance-method","name":"reschedule_interval","doc":"Configure the reschedule interval so that the job_run is not run again until it\nshould be allowed through the rate limiter.","summary":"

Configure the reschedule interval so that the job_run is not run again until it should be allowed through the rate limiter.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Time::Span","args_html":"(retry_count : Int32) : Time::Span","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":147,"url":null},"def":{"name":"reschedule_interval","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Time::Span","visibility":"Public","body":"if rate_limited? && (window_expiration = window_expires_at)\n next_window = window_expiration - Time.utc\n log(\"Rate limited: will run again in #{next_window}\")\n next_window\nelse\n super(retry_count)\nend"}},{"html_id":"rescheduleable?(retry_count:Int32):Bool-instance-method","name":"rescheduleable?","doc":"Configure the rescheduler to always retry if a job is rate limited.","summary":"

Configure the rescheduler to always retry if a job is rate limited.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Bool","args_html":"(retry_count : Int32) : Bool","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":158,"url":null},"def":{"name":"rescheduleable?","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if rate_limited?\n true\nelse\n super(retry_count)\nend"}},{"html_id":"update_window_start:Nil-instance-method","name":"update_window_start","doc":"Resets the run count and logs the start of window.","summary":"

Resets the run count and logs the start of window.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":124,"url":null},"def":{"name":"update_window_start","return_type":"Nil","visibility":"Public","body":"started_window = window_start || Time::UNIX_EPOCH\nnow = Time.utc\nif (now - started_window) > @@rate_limit_interval\n metadata[\"window_start\"] = now.to_unix.to_s\n metadata[\"run_count\"] = \"0\"\nend\n"}},{"html_id":"window_expires_at:Time|Nil-instance-method","name":"window_expires_at","doc":"When does the current rate limit window expire?\nReturns nil if the window is already expired.","summary":"

When does the current rate limit window expire? Returns nil if the window is already expired.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":112,"url":null},"def":{"name":"window_expires_at","return_type":"Time | ::Nil","visibility":"Public","body":"if started_window = window_start\nelse\n return nil\nend\nexpiration_time = started_window + @@rate_limit_interval\nif expiration_time < Time.utc\n nil\nelse\n expiration_time\nend\n"}},{"html_id":"window_start:Time|Nil-instance-method","name":"window_start","doc":"Calculates the start of the rate limit window.","summary":"

Calculates the start of the rate limit window.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":104,"url":null},"def":{"name":"window_start","return_type":"Time | ::Nil","visibility":"Public","body":"if start_time = metadata[\"window_start\"]?.try(&.to_i)\n Time.unix(start_time)\nend"}}],"types":[{"html_id":"mosquito/Mosquito/RateLimiter/ClassMethods","path":"Mosquito/RateLimiter/ClassMethods.html","kind":"module","full_name":"Mosquito::RateLimiter::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/mosquito/rate_limiter.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/RateLimiter","kind":"module","full_name":"Mosquito::RateLimiter","name":"RateLimiter"},"instance_methods":[{"html_id":"metadata:Metadata-instance-method","name":"metadata","doc":"Provides an instance of the metadata store used to track rate limit\nstats.","summary":"

Provides an instance of the metadata store used to track rate limit stats.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":53,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"Metadata.new(@@rate_limit_key)"}},{"html_id":"rate_limit_key-instance-method","name":"rate_limit_key","doc":"Resolves the key used to index the metadata store for this test.","summary":"

Resolves the key used to index the metadata store for this test.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":58,"url":null},"def":{"name":"rate_limit_key","visibility":"Public","body":"@@rate_limit_key"}},{"html_id":"rate_limit_stats:NamedTuple-instance-method","name":"rate_limit_stats","doc":"Statistics about the rate limiter, including both the configuration\nparameters and the run counts.","summary":"

Statistics about the rate limiter, including both the configuration parameters and the run counts.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":26,"url":null},"def":{"name":"rate_limit_stats","return_type":"NamedTuple","visibility":"Public","body":"meta = metadata\nwindow_start = if window_start_ = meta[\"window_start\"]?\n Time.unix(window_start_.to_i)\nelse\n Time::UNIX_EPOCH\nend\nrun_count = if run_count_ = meta[\"run_count\"]?\n run_count_.to_i\nelse\n 0\nend\n{interval: @@rate_limit_interval, key: @@rate_limit_key, increment: @@rate_limit_increment, limit: @@rate_limit_ceiling, window_start: window_start, run_count: run_count}\n"}},{"html_id":"throttle(*,limit:Int32=1,per:Time::Span=1.second,increment=1,key=self.name.underscore)-instance-method","name":"throttle","doc":"Configures rate limiting for this job.\n\n`limit` and `per` are used to control the run count and the window\nduration. Defaults to a limit of 1 run per second.\n\n`increment` is used to indicate how many \"hits\" against a single job is\nworth. Defaults to 1.\n\n`key` is used to combine rate limiting functions across multiple jobs.","summary":"

Configures rate limiting for this job.

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"limit","default_value":"1","external_name":"limit","restriction":"Int32"},{"name":"per","default_value":"1.second","external_name":"per","restriction":"Time::Span"},{"name":"increment","default_value":"1","external_name":"increment","restriction":""},{"name":"key","default_value":"self.name.underscore","external_name":"key","restriction":""}],"args_string":"(*, limit : Int32 = 1, per : Time::Span = 1.second, increment = 1, key = self.name.underscore)","args_html":"(*, limit : Int32 = 1, per : Time::Span = 1.second, increment = 1, key = self.name.underscore)","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":12,"url":null},"def":{"name":"throttle","args":[{"name":"","external_name":"","restriction":""},{"name":"limit","default_value":"1","external_name":"limit","restriction":"Int32"},{"name":"per","default_value":"1.second","external_name":"per","restriction":"Time::Span"},{"name":"increment","default_value":"1","external_name":"increment","restriction":""},{"name":"key","default_value":"self.name.underscore","external_name":"key","restriction":""}],"splat_index":0,"visibility":"Public","body":"@@rate_limit_ceiling = limit\n@@rate_limit_interval = per\n@@rate_limit_key = Mosquito.backend.build_key(\"rate_limit\", key)\n@@rate_limit_increment = increment\n"}}]}]},{"html_id":"mosquito/Mosquito/RedisBackend","path":"Mosquito/RedisBackend.html","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend","abstract":false,"superclass":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"ancestors":[{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/redis_backend.cr","line_number":35,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"LIST_OF_QUEUES_KEY","name":"LIST_OF_QUEUES_KEY","value":"\"queues\""},{"id":"Log","name":"Log","value":"::Log.for(self)"}],"extended_modules":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"delete(key:String,inttl:Int32=0):Nil-class-method","name":"delete","doc":"Overload required for crystal 1.1-1.2.\nSoft Deprecation isn't shown, but it's here so this will get cleaned up at some point.\n@[Deprecated(\"To be removed when support for 1.1 is dropped. See RedisBackend.delete(String, Int64).\")]","summary":"

Overload required for crystal 1.1-1.2.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int32"}],"args_string":"(key : String, in ttl : Int32 = 0) : Nil","args_html":"(key : String, in ttl : Int32 = 0) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":86,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int32"}],"return_type":"Nil","visibility":"Public","body":"delete(key, in: ttl.to_i64)"}},{"html_id":"delete(key:String,inttl:Int64=0):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":90,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":"if (ttl > 0)\n redis.expire(key, ttl)\nelse\n redis.del(key)\nend"}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":98,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":"delete(key, ttl.to_i)"}},{"html_id":"expires_in(key:String):Int64-class-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":119,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"redis.ttl(key)"}},{"html_id":"flush:Nil-class-method","name":"flush","doc":"is this even a good idea?","summary":"

is this even a good idea?

","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":140,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.flushdb"}},{"html_id":"get(key:String,field:String):String|Nil-class-method","name":"get","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":102,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":"(redis.hget(key, field)).as?(String)"}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":115,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":"(redis.hincrby(key, field, value)).as(Int64)"}},{"html_id":"increment(key:String,field:String):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":111,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"increment(key, field, by: 1)"}},{"html_id":"list_queues:Array(String)-class-method","name":"list_queues","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":123,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"key = build_key(LIST_OF_QUEUES_KEY)\nlist_queues = (redis.zrange(key, 0, -1)).as(Array)\nif list_queues.any?\nelse\n return [] of String\nend\nlist_queues.compact_map() do |__arg1|\n __arg1.as(String)\nend\n"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":132,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":"runner_prefix = \"mosquito:runners:\"\n(Redis.instance.keys(\"#{runner_prefix}*\")).map() do |__arg2|\n __arg2.as(String)\nend.map(&.sub(runner_prefix, \"\"))\n"}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-class-method","name":"lock?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/redis_backend.cr","line_number":144,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":"response = redis.set(key, value, ex: ttl.to_i, nx: true)\nresponse == \"OK\"\n"}},{"html_id":"redis-class-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":56,"url":null},"def":{"name":"redis","visibility":"Public","body":"load_scripts = @@connection.nil?\nconnection = @@connection || (@@connection = ::Redis::Client.new(URI.parse(Mosquito.configuration.redis_url.to_s)))\nif load_scripts\n Scripts.load(connection)\nend\nconnection\n"}},{"html_id":"remove_matching_key(*,keys=[]ofString,args=[]ofString,loadscripts=true)-class-method","name":"remove_matching_key","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"keys","default_value":"[] of String","external_name":"keys","restriction":""},{"name":"args","default_value":"[] of String","external_name":"args","restriction":""},{"name":"loadscripts","default_value":"true","external_name":"loadscripts","restriction":""}],"args_string":"(*, keys = [] of String, args = [] of String, loadscripts = true)","args_html":"(*, keys = [] of String, args = [] of String, loadscripts = true)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":40,"url":null},"def":{"name":"remove_matching_key","args":[{"name":"","external_name":"","restriction":""},{"name":"keys","default_value":"[] of String","external_name":"keys","restriction":""},{"name":"args","default_value":"[] of String","external_name":"args","restriction":""},{"name":"loadscripts","default_value":"true","external_name":"loadscripts","restriction":""}],"splat_index":0,"visibility":"Public","body":"begin\n script = \" if redis.call(\\\"get\\\",KEYS[1]) == ARGV[1] then\\n return redis.call(\\\"del\\\",KEYS[1])\\n else\\n return 0\\n end\"\n digest = Scripts.remove_matching_key\n redis.evalsha(digest, keys: keys, args: args)\nrescue exception : Redis::Error\n if exception.message.try(&.starts_with?(\"NOSCRIPT\"))\n else\n raise(exception)\n end\n if loadscripts\n else\n raise(exception)\n end\n (Log.for(\"remove_matching_key\")).warn do\n \"Redis Scripts have gone missing, reloading\"\n end\n Scripts.load(redis)\n remove_matching_key(keys: keys, args: args, loadscripts: false)\nend"}},{"html_id":"retrieve(key:String):Hash(String,String)-class-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":78,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"result = ((redis.hgetall(key)).as(Array)).map(&.to_s)\n(result.in_groups_of(2, \"\")).to_h\n"}},{"html_id":"set(key:String,field:String,value:String):String-class-method","name":"set","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/redis_backend.cr","line_number":106,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":"redis.hset(key, field, value)\nvalue\n"}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-class-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":74,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":"redis.hset(key, value)"}},{"html_id":"unlock(key:String,value:String):Nil-class-method","name":"unlock","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":149,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":"remove_matching_key(keys: [key], args: [value])"}}],"constructors":[{"html_id":"new(name:String|Symbol)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"args_string":"(name : String | Symbol)","args_html":"(name : String | Symbol)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":70,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":181,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"if id = redis.lmove(waiting_q, pending_q, :right, :left)\n JobRun.retrieve(id.to_s)\nend"}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":158,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":"time = Time.utc\noverdue_job_runs = (redis.zrangebyscore(scheduled_q, \"0\", time.to_unix_ms.to_s)).as(Array)\nif overdue_job_runs.any?\nelse\n return [] of JobRun\nend\noverdue_job_runs.compact_map do |job_run_id|\n redis.zrem(scheduled_q, job_run_id.to_s)\n JobRun.retrieve(job_run_id.as(String))\nend\n"}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":"key = dead_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg6|\n __arg6.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg7|\n __arg7.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for dead\")\n end\n end\nend\n"}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":"key = pending_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg4|\n __arg4.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg5|\n __arg5.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for pending\")\n end\n end\nend\n"}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":"key = scheduled_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg2|\n __arg2.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg3|\n __arg3.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for scheduled\")\n end\n end\nend\n"}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":"key = waiting_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg0|\n __arg0.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg1|\n __arg1.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for waiting\")\n end\n end\nend\n"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/redis_backend.cr","line_number":170,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"redis.pipeline do |pipe|\n pipe.lpush(waiting_q, job_run.id)\n pipe.zadd(build_key(LIST_OF_QUEUES_KEY), Time.utc.to_unix.to_s, name)\nend\njob_run\n"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":187,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"redis.lrem(pending_q, 0, job_run.id)"}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":195,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.del(waiting_q, pending_q, scheduled_q, dead_q)"}},{"html_id":"redis-instance-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":66,"url":null},"def":{"name":"redis","visibility":"Public","body":"self.class.redis"}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/redis_backend.cr","line_number":153,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"redis.zadd(scheduled_q, scheduled_time.to_unix_ms.to_s, job_run.id)\njob_run\n"}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":233,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":"(redis.zscore(scheduled_q, job_run.id)).as?(String)"}},{"html_id":"size(include_dead=true):Int64-instance-method","name":"size","abstract":false,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":""}],"args_string":"(include_dead = true) : Int64","args_html":"(include_dead = true) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":204,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":""}],"return_type":"Int64","visibility":"Public","body":"queues = [waiting_q, pending_q]\nif include_dead\n queues << dead_q\nend\nqueue_size = queues.map do |key|\n (redis.llen(key)).as(Int64)\nend.reduce do |sum, i|\n sum + i\nend\nscheduled_size = redis.zcount(scheduled_q, \"0\", \"+inf\")\nqueue_size + (scheduled_size.as(Int64))\n"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":191,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"redis.lpush(dead_q, job_run.id)"}}]},{"html_id":"mosquito/Mosquito/Runnable","path":"Mosquito/Runnable.html","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable","abstract":false,"locations":[{"filename":"src/mosquito/runnable.cr","line_number":64,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Executor","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor"},{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"Runnable implements a general purpose spawn/loop which carries a state\nenum.\n\n## Managing a Runnable\n\nThe primary purpose of Runnable is to cleanly abstract the details of\nspawning a thread, running a loop, and shutting down when asked.\n\nA service which manages a Runnable might look like this:\n\n```crystal\nrunnable = MyRunnable.new\n\n# This will spawn and return immediately.\nrunnable.start\n\nputs runnable.state # => State::Working\n\n# Some time later...\nshould_be_stopped = runnable.stop has_stopped =\nshould_be_stopped.receive\n```\n\n\n## Implementing a Runnable\n\nA runnable implementation needs to implement only two methods: #each_run\nand #runnable_name. In addition, pre_run and post_run are available for\nsetup and teardown.\n\nRunnable state is managed automatically through startup and shutdown, but\nwithin each_run it can be manually altered with `#state=`.\n\n### Example\n\n```crystal\nclass MyRunnable\n include Mosquito::Runnable\n\n # Optional\n def pre_run\n puts \"my runnable is starting\"\n end\n\n def each_run\n puts \"my runnable is running\"\n end\n\n # Optional\n def post_run\n puts \"my runnable has stopped\"\n end\n\n def runnable_name\n \"MyRunnable\"\n end\nend\n```\n\nImplementation details about what work should be done in the spawned fiber\nare placed in #each_run.\n","summary":"

Runnable implements a general purpose spawn/loop which carries a state enum.

","instance_methods":[{"html_id":"dead?:Bool-instance-method","name":"dead?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":106,"url":null},"def":{"name":"dead?","return_type":"Bool","visibility":"Public","body":"if fiber_ = fiber\n fiber_.dead?\nelse\n false\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"Implementation of what this Runnable should do on each cycle.\n\nTake care that @state is #running? at the end of the method\nunless it is finished and should exit.","summary":"

Implementation of what this Runnable should do on each cycle.

","abstract":true,"location":{"filename":"src/mosquito/runnable.cr","line_number":168,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"fiber:Fiber|Nil-instance-method","name":"fiber","doc":"After #run has been called this holds a reference to the Fiber\nwhich is used to check that the fiber is still running.","summary":"

After #run has been called this holds a reference to the Fiber which is used to check that the fiber is still running.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":96,"url":null},"def":{"name":"fiber","return_type":"Fiber | ::Nil","visibility":"Public","body":"@fiber"}},{"html_id":"my_name:String-instance-method","name":"my_name","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":98,"url":null},"def":{"name":"my_name","return_type":"String","visibility":"Public","body":"if (value = @my_name).nil?\n @my_name = (\"#{self.class.name.underscore.gsub(\"::\", \".\")}.#{self.object_id}\")\nelse\n value\nend"}},{"html_id":"post_run:Nil-instance-method","name":"post_run","doc":"Available to hook any teardown logic after the run loop.","summary":"

Available to hook any teardown logic after the run loop.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":174,"url":null},"def":{"name":"post_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"pre_run:Nil-instance-method","name":"pre_run","doc":"Available to hook a one time setup before the run loop.","summary":"

Available to hook a one time setup before the run loop.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":171,"url":null},"def":{"name":"pre_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"run-instance-method","name":"run","doc":"Start the Runnable, and capture the fiber to a property.\n\nThe spawned fiber will not return as long as state.running?.\n\nState can be altered internally or externally to cause it to exit\nbut the cleanest way to do that is to call #stop.","summary":"

Start the Runnable, and capture the fiber to a property.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":120,"url":null},"def":{"name":"run","visibility":"Public","body":"@fiber = spawn(name: my_name) do\n log = Log.for(my_name)\n log.info do\n runnable_name + \" is starting\"\n end\n self.state = State::Working\n pre_run\n while state.running?\n each_run\n end\n post_run\n self.state = State::Finished\nend"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":true,"location":{"filename":"src/mosquito/runnable.cr","line_number":162,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":""}},{"html_id":"state:State-instance-method","name":"state","doc":"Tracks the state of this runnable.\n\nInitially it will be `State::Starting`. After `#run` is called it will\nbe `State::Working`.\n\nWhen `#stop` is called it will be `State::Stopping`. After `#run` finishes,\nit will be `State::Finished`.\n\nIt is not necessary to set this manually, but it's available to an implementation\nif needed. See `Mosquito::Runners::Executor#state=` (source code) for an example.","summary":"

Tracks the state of this runnable.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":92,"url":null},"def":{"name":"state","return_type":"State","visibility":"Public","body":"@state"}},{"html_id":"stop:Channel(Bool)-instance-method","name":"stop","doc":"Request that the next time the run loop cycles it should exit instead.\nThe runnable doesn't exit immediately so #stop returns a notification\nchannel.\n\n#stop spawns a fiber which monitors the state and sends a bool in two\ncircumstances. It will stop waiting for the spawn to exit at 25 seconds.\nIf the spawn has actually stopped the notification channel will broadcast\na true, otherwise false.","summary":"

Request that the next time the run loop cycles it should exit instead.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":145,"url":null},"def":{"name":"stop","return_type":"Channel(Bool)","visibility":"Public","body":"if state.running?\n self.state = State::Stopping\nend\nnotifier = Channel(Bool).new\nspawn do\n start = Time.utc\n while state.stopping? && (Time.utc - start) < 25.seconds\n Fiber.yield\n end\n notifier.send(state.finished?)\n Log.info do\n runnable_name + \" has stopped\"\n end\nend\nnotifier\n"}}],"types":[{"html_id":"mosquito/Mosquito/Runnable/State","path":"Mosquito/Runnable/State.html","kind":"enum","full_name":"Mosquito::Runnable::State","name":"State","abstract":false,"ancestors":[{"html_id":"mosquito/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"mosquito/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runnable.cr","line_number":65,"url":null}],"repository_name":"mosquito","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Starting","name":"Starting","value":"0"},{"id":"Working","name":"Working","value":"1"},{"id":"Idle","name":"Idle","value":"2"},{"id":"Stopping","name":"Stopping","value":"3"},{"id":"Finished","name":"Finished","value":"4"}],"namespace":{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},"instance_methods":[{"html_id":"finished?-instance-method","name":"finished?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":70,"url":null},"def":{"name":"finished?","visibility":"Public","body":"self == Finished"}},{"html_id":"idle?-instance-method","name":"idle?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":68,"url":null},"def":{"name":"idle?","visibility":"Public","body":"self == Idle"}},{"html_id":"running?-instance-method","name":"running?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":72,"url":null},"def":{"name":"running?","visibility":"Public","body":"(starting? || working?) || idle?"}},{"html_id":"started?-instance-method","name":"started?","doc":"ie, not starting","summary":"

ie, not starting

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":77,"url":null},"def":{"name":"started?","visibility":"Public","body":"working? || idle?"}},{"html_id":"starting?-instance-method","name":"starting?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":66,"url":null},"def":{"name":"starting?","visibility":"Public","body":"self == Starting"}},{"html_id":"stopping?-instance-method","name":"stopping?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":69,"url":null},"def":{"name":"stopping?","visibility":"Public","body":"self == Stopping"}},{"html_id":"working?-instance-method","name":"working?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":67,"url":null},"def":{"name":"working?","visibility":"Public","body":"self == Working"}}]}]},{"html_id":"mosquito/Mosquito/Runner","path":"Mosquito/Runner.html","kind":"class","full_name":"Mosquito::Runner","name":"Runner","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runner.cr","line_number":34,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"This singleton class serves as a shorthand for starting and managing an Overseer.\n\nA minimal usage of Mosquito::Runner is:\n\n```\nrequire \"mosquito\"\n\n# When the process receives sigint, it'll notify the overseer to shut down gracefully.\ntrap(\"INT\") do\n Mosquito::Runner.stop(wait: true)\nend\n\n# Starts the overseer, and holds the thread captive.\nMosquito::Runner.start\n```\n\nIf for some reason you want to manage an overseer or group of overseers yourself, Mosquito::Runner can be omitted entirely:\n\n```crystal\nrequire \"mosquito\"\n\nmosquito = Mosquito::Overseer.new\n\n# Spawns a mosquito managed fiber and returns immediately\nmosquito.run\n\ntrap \"INT\" do\n mosquito.stop.receive\nend\n```","summary":"

This singleton class serves as a shorthand for starting and managing an Overseer.

","class_methods":[{"html_id":"start(spin=true)-class-method","name":"start","doc":"Start the mosquito runner.\n\nIf spin = true (default) the function will not return until the runner is\nshut down. Otherwise it will return immediately.\n","summary":"

Start the mosquito runner.

","abstract":false,"args":[{"name":"spin","default_value":"true","external_name":"spin","restriction":""}],"args_string":"(spin = true)","args_html":"(spin = true)","location":{"filename":"src/mosquito/runner.cr","line_number":42,"url":null},"def":{"name":"start","args":[{"name":"spin","default_value":"true","external_name":"spin","restriction":""}],"visibility":"Public","body":"Log.notice do\n \"Mosquito is buzzing...\"\nend\ninstance.run\nwhile spin && keep_running\n Fiber.yield\nend\n"}},{"html_id":"stop(wait=false)-class-method","name":"stop","doc":"Request the mosquito runner stop. The runner will not abort the current job\nbut it will not start any new jobs.\n\nSee `Mosquito::Runnable#stop`.","summary":"

Request the mosquito runner stop.

","abstract":false,"args":[{"name":"wait","default_value":"false","external_name":"wait","restriction":""}],"args_string":"(wait = false)","args_html":"(wait = false)","location":{"filename":"src/mosquito/runner.cr","line_number":60,"url":null},"def":{"name":"stop","args":[{"name":"wait","default_value":"false","external_name":"wait","restriction":""}],"visibility":"Public","body":"Log.notice do\n \"Mosquito is shutting down...\"\nend\nfinished_notifier = instance.stop\nif wait\n finished_notifier.receive\nend\n"}}]},{"html_id":"mosquito/Mosquito/Runners","path":"Mosquito/Runners.html","kind":"module","full_name":"Mosquito::Runners","name":"Runners","abstract":false,"locations":[{"filename":"src/mosquito/runners/coordinator.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/executor.cr","line_number":4,"url":null},{"filename":"src/mosquito/runners/idle_wait.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/overseer.cr","line_number":6,"url":null},{"filename":"src/mosquito/runners/queue_list.cr","line_number":5,"url":null},{"filename":"src/mosquito/runners/run_at_most.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"types":[{"html_id":"mosquito/Mosquito/Runners/Coordinator","path":"Mosquito/Runners/Coordinator.html","kind":"class","full_name":"Mosquito::Runners::Coordinator","name":"Coordinator","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/coordinator.cr","line_number":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"LockTTL","name":"LockTTL","value":"10.seconds"},{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"primer? loader? _scheduler_","summary":"

primer? loader? scheduler

","constructors":[{"html_id":"new(queue_list:Mosquito::Runners::QueueList)-class-method","name":"new","abstract":false,"args":[{"name":"queue_list","external_name":"queue_list","restriction":"::Mosquito::Runners::QueueList"}],"args_string":"(queue_list : Mosquito::Runners::QueueList)","args_html":"(queue_list : Mosquito::Runners::QueueList)","location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"queue_list","external_name":"queue_list","restriction":"::Mosquito::Runners::QueueList"}],"visibility":"Public","body":"_ = allocate\n_.initialize(queue_list)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"enqueue_delayed_jobs-instance-method","name":"enqueue_delayed_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":67,"url":null},"def":{"name":"enqueue_delayed_jobs","visibility":"Public","body":"queue_list.each do |q|\n overdue_jobs = q.dequeue_scheduled\n if overdue_jobs.any?\n else\n next\n end\n (Log.for(\"enqueue_delayed_jobs\")).info do\n \"#{overdue_jobs.size} delayed jobs ready in #{q.name}\"\n end\n overdue_jobs.each do |job_run|\n q.enqueue(job_run)\n end\nend"}},{"html_id":"enqueue_periodic_jobs-instance-method","name":"enqueue_periodic_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":61,"url":null},"def":{"name":"enqueue_periodic_jobs","visibility":"Public","body":"Base.scheduled_job_runs.each do |scheduled_job_run|\n enqueued = scheduled_job_run.try_to_execute\nend"}},{"html_id":"instance_id:String-instance-method","name":"instance_id","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":8,"url":null},"def":{"name":"instance_id","return_type":"String","visibility":"Public","body":"@instance_id"}},{"html_id":"lock_key:String-instance-method","name":"lock_key","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":7,"url":null},"def":{"name":"lock_key","return_type":"String","visibility":"Public","body":"@lock_key"}},{"html_id":"only_if_coordinator(&):Nil-instance-method","name":"only_if_coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":29,"url":null},"def":{"name":"only_if_coordinator","yields":0,"block_arity":0,"return_type":"Nil","visibility":"Public","body":"duration = 0.seconds\nif Mosquito.configuration.run_cron_scheduler\n yield\n if @emitted_scheduling_deprecation_runtime_message\n else\n Log.warn do\n \"Scheduling coordinator / CRON Scheduler has been manually activated. This behavior is deprecated in favor of distributed locking. See https://github.com/mosquito-cr/mosquito/pull/108 \"\n end\n @emitted_scheduling_deprecation_runtime_message = true\n end\n return\nend\nif Mosquito.configuration.use_distributed_lock\nelse\n return\nend\nif Mosquito.backend.lock?(lock_key, instance_id, LockTTL)\n Log.trace do\n \"Coordinator lock acquired\"\n end\n duration = Time.measure do\n yield\n end\n Mosquito.backend.unlock(lock_key, instance_id)\n Log.trace do\n \"Coordinator lock released\"\n end\nend\nif duration > LockTTL\nelse\n return\nend\nLog.warn do\n \"Coordination activities took longer than LockTTL (#{duration} > #{LockTTL}) \"\nend\n"}},{"html_id":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":9,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":18,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"Coordinator<#{object_id}>\""}},{"html_id":"schedule:Nil-instance-method","name":"schedule","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":22,"url":null},"def":{"name":"schedule","return_type":"Nil","visibility":"Public","body":"only_if_coordinator do\n enqueue_periodic_jobs\n enqueue_delayed_jobs\nend"}}]},{"html_id":"mosquito/Mosquito/Runners/Executor","path":"Mosquito/Runners/Executor.html","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/executor.cr","line_number":23,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"The executor is the center of work in Mosquito, and it's is the demarcation\npoint between Mosquito framework and application code. Above the Executor\nis entirely Mosquito, and below it is application code.\n\nAn Executor is responsible for hydrating Job classes with deserialized\nparameters and calling `Mosquito::Job#run` on them. It measures the time it\ntakes to run a job and provides detailed log messages about the current\nstatus.\n\nAn executor is a `Mosquito::Runnable` and should be interacted with according to\nthe Runnable API.\n\nTo build an executor, provide a job input channel and an idle bell channel. These\nchannels can be shared between all available executors.\n\nThe executor will ring the idle bell when it is ready to accept work and then wait\nfor work to show up on the job pipeline. After the job is finished it will ring the\nbell again and wait for more work.","summary":"

The executor is the center of work in Mosquito, and it's is the demarcation point between Mosquito framework and application code.

","constructors":[{"html_id":"new(job_pipeline:Channel(Tuple(Mosquito::JobRun,Mosquito::Queue)),idle_bell:Channel(Bool))-class-method","name":"new","abstract":false,"args":[{"name":"job_pipeline","external_name":"job_pipeline","restriction":"::Channel(::Tuple(::Mosquito::JobRun, ::Mosquito::Queue))"},{"name":"idle_bell","external_name":"idle_bell","restriction":"::Channel(::Bool)"}],"args_string":"(job_pipeline : Channel(Tuple(Mosquito::JobRun, Mosquito::Queue)), idle_bell : Channel(Bool))","args_html":"(job_pipeline : Channel(Tuple(Mosquito::JobRun, Mosquito::Queue)), idle_bell : Channel(Bool))","location":{"filename":"src/mosquito/runners/executor.cr","line_number":51,"url":null},"def":{"name":"new","args":[{"name":"job_pipeline","external_name":"job_pipeline","restriction":"::Channel(::Tuple(::Mosquito::JobRun, ::Mosquito::Queue))"},{"name":"idle_bell","external_name":"idle_bell","restriction":"::Channel(::Bool)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(job_pipeline, idle_bell)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"execute(job_run:JobRun,from_queueq:Queue)-instance-method","name":"execute","doc":"Runs a job from a Queue.\n\nExecution time is measured and logged, and the job is either forgotten\nor, if it fails, rescheduled.","summary":"

Runs a job from a Queue.

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"q","external_name":"from_queue","restriction":"Queue"}],"args_string":"(job_run : JobRun, from_queue q : Queue)","args_html":"(job_run : JobRun, from_queue q : Queue)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":85,"url":null},"def":{"name":"execute","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"q","external_name":"from_queue","restriction":"Queue"}],"visibility":"Public","body":"log.info do\n \"#{\"Starting:\".colorize.magenta} #{job_run} from #{q.name}\"\nend\nduration = Time.measure do\n job_run.run\nend.total_seconds\nif job_run.succeeded?\n log.info do\n \"#{\"Success:\".colorize.green} #{job_run} finished and took #{time_with_units(duration)}\"\n end\n q.forget(job_run)\n job_run.delete(in: successful_job_ttl)\nelse\n message = String::Builder.new\n message << \"Failure: \".colorize.red\n message << job_run\n message << \" failed, taking \"\n message << (time_with_units(duration))\n message << \" and \"\n if job_run.rescheduleable?\n next_execution = Time.utc + job_run.reschedule_interval\n q.reschedule(job_run, next_execution)\n message << \"will run again\".colorize.cyan\n message << \" in \"\n message << job_run.reschedule_interval\n message << \" (at \"\n message << next_execution\n message << \")\"\n log.warn do\n message.to_s\n end\n else\n q.banish(job_run)\n job_run.delete(in: failed_job_ttl)\n message << \"cannot be rescheduled\".colorize.yellow\n log.error do\n message.to_s\n end\n end\nend\n"}},{"html_id":"failed_job_ttl:Int32-instance-method","name":"failed_job_ttl","doc":"How long a job config is persisted after failure","summary":"

How long a job config is persisted after failure

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":34,"url":null},"def":{"name":"failed_job_ttl","return_type":"Int32","visibility":"Public","body":"if (value = @failed_job_ttl).nil?\n @failed_job_ttl = (Mosquito.configuration.failed_job_ttl)\nelse\n value\nend"}},{"html_id":"failed_job_ttl=(failed_job_ttl:Int32)-instance-method","name":"failed_job_ttl=","doc":"How long a job config is persisted after failure","summary":"

How long a job config is persisted after failure

","abstract":false,"args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"args_string":"(failed_job_ttl : Int32)","args_html":"(failed_job_ttl : Int32)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":34,"url":null},"def":{"name":"failed_job_ttl=","args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@failed_job_ttl = failed_job_ttl"}},{"html_id":"idle_bell:Channel(Bool)-instance-method","name":"idle_bell","doc":"Used to notify the overseer that this executor is idle.","summary":"

Used to notify the overseer that this executor is idle.

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":40,"url":null},"def":{"name":"idle_bell","return_type":"Channel(Bool)","visibility":"Public","body":"@idle_bell"}},{"html_id":"job_pipeline:Channel(Tuple(JobRun,Queue))-instance-method","name":"job_pipeline","doc":"Where work is received from the overseer.","summary":"

Where work is received from the overseer.

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":37,"url":null},"def":{"name":"job_pipeline","return_type":"Channel(Tuple(JobRun, Queue))","visibility":"Public","body":"@job_pipeline"}},{"html_id":"log:::Log-instance-method","name":"log","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":28,"url":null},"def":{"name":"log","return_type":"::Log","visibility":"Public","body":"@log"}},{"html_id":"successful_job_ttl:Int32-instance-method","name":"successful_job_ttl","doc":"How long a job config is persisted after success","summary":"

How long a job config is persisted after success

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":31,"url":null},"def":{"name":"successful_job_ttl","return_type":"Int32","visibility":"Public","body":"if (value = @successful_job_ttl).nil?\n @successful_job_ttl = (Mosquito.configuration.successful_job_ttl)\nelse\n value\nend"}},{"html_id":"successful_job_ttl=(successful_job_ttl:Int32)-instance-method","name":"successful_job_ttl=","doc":"How long a job config is persisted after success","summary":"

How long a job config is persisted after success

","abstract":false,"args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"args_string":"(successful_job_ttl : Int32)","args_html":"(successful_job_ttl : Int32)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":31,"url":null},"def":{"name":"successful_job_ttl=","args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@successful_job_ttl = successful_job_ttl"}}]},{"html_id":"mosquito/Mosquito/Runners/IdleWait","path":"Mosquito/Runners/IdleWait.html","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait","abstract":false,"locations":[{"filename":"src/mosquito/runners/idle_wait.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"instance_methods":[{"html_id":"with_idle_wait(idle_wait:Time::Span,&)-instance-method","name":"with_idle_wait","abstract":false,"args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"args_string":"(idle_wait : Time::Span, &)","args_html":"(idle_wait : Time::Span, &)","location":{"filename":"src/mosquito/runners/idle_wait.cr","line_number":3,"url":null},"def":{"name":"with_idle_wait","args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"yields":0,"block_arity":0,"visibility":"Public","body":"delta = Time.measure do\n yield\nend\nif delta < idle_wait\n sleep(idle_wait - delta)\nend\n"}}]},{"html_id":"mosquito/Mosquito/Runners/Overseer","path":"Mosquito/Runners/Overseer.html","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/overseer.cr","line_number":14,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"The Overseer is responsible for managing:\n- a `Coordinator`\n- an `Executor`\n- the `QueueList`\n- any idle state as configured\n\nAn overseer manages the loop that each thread or process runs.","summary":"

The Overseer is responsible for managing: - a Coordinator - an Executor - the QueueList - any idle state as configured

","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":39,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_executor:Executor-instance-method","name":"build_executor","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":52,"url":null},"def":{"name":"build_executor","return_type":"Executor","visibility":"Public","body":"Executor.new(work_handout, idle_notifier)"}},{"html_id":"check_for_deceased_runners:Nil-instance-method","name":"check_for_deceased_runners","doc":"If an executor dies, it's probably because a bug exists somewhere in Mosquito itself.\n\nWhen a job fails any exceptions are caught and logged. If a job causes something more\ncatastrophic we can try to recover by spawning a new executor.","summary":"

If an executor dies, it's probably because a bug exists somewhere in Mosquito itself.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":162,"url":null},"def":{"name":"check_for_deceased_runners","return_type":"Nil","visibility":"Public","body":"executors.select do |e|\n e.state.started?\nend.select(&.dead?).each do |dead_executor|\n Log.fatal do\n \" Executor #{dead_executor.runnable_name} died.\\n A new executor will be started.\"\n end\n executors.delete(dead_executor)\nend\n(executor_count - executors.size).times do\n executors << build_executor.tap(&.run)\nend\nif queue_list.dead?\n Log.fatal do\n \"QueueList has died, overseer will stop.\"\n end\n stop\nend\n"}},{"html_id":"coordinator:Mosquito::Runners::Coordinator-instance-method","name":"coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":23,"url":null},"def":{"name":"coordinator","visibility":"Public","body":"@coordinator"}},{"html_id":"dequeue_job?:Tuple(JobRun,Queue)|Nil-instance-method","name":"dequeue_job?","doc":"Weaknesses: This implementation sometimes starves queues because it doesn't\nround robin, prioritize queues, or anything else.","summary":"

Weaknesses: This implementation sometimes starves queues because it doesn't round robin, prioritize queues, or anything else.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":150,"url":null},"def":{"name":"dequeue_job?","return_type":"Tuple(JobRun, Queue) | ::Nil","visibility":"Public","body":"queue_list.each do |q|\n if job_run = q.dequeue\n return {job_run, q}\n end\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"The goal for the overseer is to:\n- Ensure that the coordinator gets run frequently to schedule delayed/periodic jobs.\n- Wait for an executor to be idle, and dequeue work if possible.\n- Monitor the executor pool for unexpected termination and respawn.","summary":"

The goal for the overseer is to: - Ensure that the coordinator gets run frequently to schedule delayed/periodic jobs.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":87,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":"coordinator.schedule\nif work_handout.closed? || idle_notifier.closed?\n Log.fatal do\n \"Executor communication channels closed, overseer will stop.\"\n end\n stop\n return\nend\nif queue_list.state.started?\nelse\n Log.debug do\n \"Waiting for the queue list to fetch possible queues\"\n end\n return\nend\nLog.trace do\n \"Waiting for an idle executor\"\nend\nall_executors_busy = true\nselect\nwhen @idle_notifier.receive\n Log.trace do\n \"Found an idle executor\"\n end\n all_executors_busy = false\nwhen timeout(idle_wait)\nend\n\ncase\nwhen all_executors_busy\n Log.trace do\n \"No idle executors\"\n end\nwhen next_job_run = dequeue_job?\n job_run, queue = next_job_run\n Log.trace do\n \"Dequeued job: #{job_run.id} #{queue.name}\"\n end\n work_handout.send(next_job_run)\nelse\n Log.trace do\n \"No job to dequeue\"\n end\n sleep\n spawn do\n @idle_notifier.send(true)\n end\nend\ncheck_for_deceased_runners\n"}},{"html_id":"executor_count:Int32-instance-method","name":"executor_count","doc":"The number of executors to start.","summary":"

The number of executors to start.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":33,"url":null},"def":{"name":"executor_count","visibility":"Public","body":"@executor_count"}},{"html_id":"executors:Array(Mosquito::Runners::Executor)-instance-method","name":"executors","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":22,"url":null},"def":{"name":"executors","visibility":"Public","body":"@executors"}},{"html_id":"idle_notifier:Channel(Bool)-instance-method","name":"idle_notifier","doc":"When an executor transitions to idle it will send a True here. The Overseer\nuses this as a signal to check the queues for more work.","summary":"

When an executor transitions to idle it will send a True here.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":30,"url":null},"def":{"name":"idle_notifier","visibility":"Public","body":"@idle_notifier"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":35,"url":null},"def":{"name":"idle_wait","return_type":"Time::Span","visibility":"Public","body":"if (value = @idle_wait).nil?\n @idle_wait = (Mosquito.configuration.idle_wait)\nelse\n value\nend"}},{"html_id":"post_run:Nil-instance-method","name":"post_run","doc":"Notify all subprocesses to stop, and wait until they do.","summary":"

Notify all subprocesses to stop, and wait until they do.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":73,"url":null},"def":{"name":"post_run","return_type":"Nil","visibility":"Public","body":"Log.info do\n \"Stopping #{@executors.size} executors.\"\nend\nstopped_notifiers = executors.map do |executor|\n executor.stop\nend\nwork_handout.close\nstopped_notifiers.each(&.receive)\nLog.info do\n \"All executors stopped.\"\nend\n"}},{"html_id":"pre_run:Nil-instance-method","name":"pre_run","doc":"Starts all the subprocesses.","summary":"

Starts all the subprocesses.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":66,"url":null},"def":{"name":"pre_run","return_type":"Nil","visibility":"Public","body":"Log.info do\n \"Starting #{@executors.size} executors.\"\nend\n@queue_list.run\n@executors.each(&.run)\n"}},{"html_id":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":56,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"Overseer<#{object_id}>\""}},{"html_id":"sleep-instance-method","name":"sleep","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":60,"url":null},"def":{"name":"sleep","visibility":"Public","body":"Log.trace do\n \"Going to sleep now for #{idle_wait}\"\nend\nsleep(idle_wait)\n"}},{"html_id":"work_handout:Channel({Mosquito::JobRun,Mosquito::Queue})-instance-method","name":"work_handout","doc":"The channel where job runs which have been dequeued are sent to executors.","summary":"

The channel where job runs which have been dequeued are sent to executors.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":26,"url":null},"def":{"name":"work_handout","visibility":"Public","body":"@work_handout"}}]},{"html_id":"mosquito/Mosquito/Runners/QueueList","path":"Mosquito/Runners/QueueList.html","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/queue_list.cr","line_number":7,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"QueueList handles searching the redis keyspace for named queues.","summary":"

QueueList handles searching the redis keyspace for named queues.

","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":16,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"each(*args,**options)-instance-method","name":"each","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":24,"url":null},"def":{"name":"each","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"@queues.shuffle.each(*args, **options)"}},{"html_id":"each(*args,**options,&)-instance-method","name":"each","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":24,"url":null},"def":{"name":"each","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"@queues.shuffle.each(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"Implementation of what this Runnable should do on each cycle.\n\nTake care that @state is #running? at the end of the method\nunless it is finished and should exit.","summary":"

Implementation of what this Runnable should do on each cycle.

","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":26,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":"with_idle_wait(1.seconds) do\n @state = State::Working\n candidate_queues = Mosquito.backend.list_queues.map do |name|\n Queue.new(name)\n end\n new_queue_list = filter_queues(candidate_queues)\n Log.notice do\n queues_which_were_expected_but_not_found = @queues - new_queue_list\n queues_which_have_never_been_seen = new_queue_list - @queues\n if queues_which_have_never_been_seen.size > 0\n \"found #{queues_which_have_never_been_seen.size} new queues: #{queues_which_have_never_been_seen.map(&.name).join(\", \")}\"\n end\n end\n @queues = new_queue_list\n @state = State::Idle\nend"}},{"html_id":"queues:Array(Queue)-instance-method","name":"queues","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":14,"url":null},"def":{"name":"queues","return_type":"Array(Queue)","visibility":"Public","body":"@queues"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":20,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"QueueList<#{object_id}>\""}}]},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","path":"Mosquito/Runners/RunAtMost.html","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost","abstract":false,"locations":[{"filename":"src/mosquito/runners/run_at_most.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Executor","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor"},{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"instance_methods":[{"html_id":"execution_timestamps-instance-method","name":"execution_timestamps","abstract":false,"location":{"filename":"src/mosquito/runners/run_at_most.cr","line_number":3,"url":null},"def":{"name":"execution_timestamps","visibility":"Public","body":"@execution_timestamps"}}]}]},{"html_id":"mosquito/Mosquito/ScheduledJob","path":"Mosquito/ScheduledJob.html","kind":"class","full_name":"Mosquito::ScheduledJob","name":"ScheduledJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/scheduled_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":3,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_job_run-instance-method","name":"build_job_run","abstract":true,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":6,"url":null},"def":{"name":"build_job_run","visibility":"Public","body":""}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":20,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"false"}}]},{"html_id":"mosquito/Mosquito/Scripts","path":"Mosquito/Scripts.html","kind":"module","full_name":"Mosquito::Scripts","name":"Scripts","abstract":false,"locations":[{"filename":"src/mosquito/redis_backend.cr","line_number":5,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SCRIPTS","name":"SCRIPTS","value":"{:remove_matching_key => \" if redis.call(\\\"get\\\",KEYS[1]) == ARGV[1] then\\n return redis.call(\\\"del\\\",KEYS[1])\\n else\\n return 0\\n end\"}"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"load(connection)-class-method","name":"load","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":""}],"args_string":"(connection)","args_html":"(connection)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":18,"url":null},"def":{"name":"load","args":[{"name":"connection","external_name":"connection","restriction":""}],"visibility":"Public","body":"SCRIPTS.each do |name, script|\n sha = @@script_sha[name] = connection.script_load(script)\n Log.info do\n \"loading script : #{name} => #{sha}\"\n end\nend"}},{"html_id":"remove_matching_key-class-method","name":"remove_matching_key","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":25,"url":null},"def":{"name":"remove_matching_key","visibility":"Public","body":"@@script_sha[:remove_matching_key]"}}]},{"html_id":"mosquito/Mosquito/Serializers","path":"Mosquito/Serializers.html","kind":"module","full_name":"Mosquito::Serializers","name":"Serializers","abstract":false,"locations":[{"filename":"src/mosquito/serializers/primitives.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"types":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","path":"Mosquito/Serializers/Primitives.html","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives","abstract":false,"locations":[{"filename":"src/mosquito/serializers/primitives.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"}],"namespace":{"html_id":"mosquito/Mosquito/Serializers","kind":"module","full_name":"Mosquito::Serializers","name":"Serializers"},"instance_methods":[{"html_id":"deserialize_bool(raw:String):Bool-instance-method","name":"deserialize_bool","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Bool","args_html":"(raw : String) : Bool","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":14,"url":null},"def":{"name":"deserialize_bool","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Bool","visibility":"Public","body":"raw == \"true\""}},{"html_id":"deserialize_char(raw:String):Char-instance-method","name":"deserialize_char","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Char","args_html":"(raw : String) : Char","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":26,"url":null},"def":{"name":"deserialize_char","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Char","visibility":"Public","body":"raw[0]"}},{"html_id":"deserialize_float32(raw:String):Float32|Nil-instance-method","name":"deserialize_float32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Float32 | Nil","args_html":"(raw : String) : Float32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_float32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Float32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_f32\nend"}},{"html_id":"deserialize_float64(raw:String):Float64|Nil-instance-method","name":"deserialize_float64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Float64 | Nil","args_html":"(raw : String) : Float64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_float64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Float64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_f64\nend"}},{"html_id":"deserialize_int128(raw:String):Int128|Nil-instance-method","name":"deserialize_int128","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int128 | Nil","args_html":"(raw : String) : Int128 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int128","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int128 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i128\nend"}},{"html_id":"deserialize_int16(raw:String):Int16|Nil-instance-method","name":"deserialize_int16","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int16 | Nil","args_html":"(raw : String) : Int16 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int16","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int16 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i16\nend"}},{"html_id":"deserialize_int32(raw:String):Int32|Nil-instance-method","name":"deserialize_int32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int32 | Nil","args_html":"(raw : String) : Int32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i32\nend"}},{"html_id":"deserialize_int64(raw:String):Int64|Nil-instance-method","name":"deserialize_int64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int64 | Nil","args_html":"(raw : String) : Int64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i64\nend"}},{"html_id":"deserialize_int8(raw:String):Int8|Nil-instance-method","name":"deserialize_int8","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int8 | Nil","args_html":"(raw : String) : Int8 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int8","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int8 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i8\nend"}},{"html_id":"deserialize_string(raw:String):String-instance-method","name":"deserialize_string","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : String","args_html":"(raw : String) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":6,"url":null},"def":{"name":"deserialize_string","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"String","visibility":"Public","body":"raw"}},{"html_id":"deserialize_u_int128(raw:String):UInt128|Nil-instance-method","name":"deserialize_u_int128","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt128 | Nil","args_html":"(raw : String) : UInt128 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int128","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt128 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u128\nend"}},{"html_id":"deserialize_u_int16(raw:String):UInt16|Nil-instance-method","name":"deserialize_u_int16","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt16 | Nil","args_html":"(raw : String) : UInt16 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int16","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt16 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u16\nend"}},{"html_id":"deserialize_u_int32(raw:String):UInt32|Nil-instance-method","name":"deserialize_u_int32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt32 | Nil","args_html":"(raw : String) : UInt32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u32\nend"}},{"html_id":"deserialize_u_int64(raw:String):UInt64|Nil-instance-method","name":"deserialize_u_int64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt64 | Nil","args_html":"(raw : String) : UInt64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u64\nend"}},{"html_id":"deserialize_u_int8(raw:String):UInt8|Nil-instance-method","name":"deserialize_u_int8","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt8 | Nil","args_html":"(raw : String) : UInt8 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int8","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt8 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u8\nend"}},{"html_id":"deserialize_uuid(raw:String):UUID-instance-method","name":"deserialize_uuid","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UUID","args_html":"(raw : String) : UUID","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":34,"url":null},"def":{"name":"deserialize_uuid","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UUID","visibility":"Public","body":"UUID.new(raw)"}},{"html_id":"serialize_bool(value:Bool):String-instance-method","name":"serialize_bool","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(value : Bool) : String","args_html":"(value : Bool) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":10,"url":null},"def":{"name":"serialize_bool","args":[{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_char(char:Char):String-instance-method","name":"serialize_char","abstract":false,"args":[{"name":"char","external_name":"char","restriction":"Char"}],"args_string":"(char : Char) : String","args_html":"(char : Char) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":22,"url":null},"def":{"name":"serialize_char","args":[{"name":"char","external_name":"char","restriction":"Char"}],"return_type":"String","visibility":"Public","body":"char.to_s"}},{"html_id":"serialize_float32(value):String-instance-method","name":"serialize_float32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_float32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_float64(value):String-instance-method","name":"serialize_float64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_float64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int128(value):String-instance-method","name":"serialize_int128","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int128","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int16(value):String-instance-method","name":"serialize_int16","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int16","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int32(value):String-instance-method","name":"serialize_int32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int64(value):String-instance-method","name":"serialize_int64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int8(value):String-instance-method","name":"serialize_int8","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int8","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_string(str:String):String-instance-method","name":"serialize_string","abstract":false,"args":[{"name":"str","external_name":"str","restriction":"String"}],"args_string":"(str : String) : String","args_html":"(str : String) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":2,"url":null},"def":{"name":"serialize_string","args":[{"name":"str","external_name":"str","restriction":"String"}],"return_type":"String","visibility":"Public","body":"str"}},{"html_id":"serialize_symbol(sym:Symbol):Nil-instance-method","name":"serialize_symbol","abstract":false,"args":[{"name":"sym","external_name":"sym","restriction":"Symbol"}],"args_string":"(sym : Symbol) : Nil","args_html":"(sym : Symbol) : Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":18,"url":null},"def":{"name":"serialize_symbol","args":[{"name":"sym","external_name":"sym","restriction":"Symbol"}],"return_type":"Nil","visibility":"Public","body":"raise(\"Symbols cannot be deserialized. Stringify your symbol first to pass it as a mosquito job parameter.\")"}},{"html_id":"serialize_u_int128(value):String-instance-method","name":"serialize_u_int128","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int128","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int16(value):String-instance-method","name":"serialize_u_int16","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int16","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int32(value):String-instance-method","name":"serialize_u_int32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int64(value):String-instance-method","name":"serialize_u_int64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int8(value):String-instance-method","name":"serialize_u_int8","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int8","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_uuid(uuid:UUID):String-instance-method","name":"serialize_uuid","abstract":false,"args":[{"name":"uuid","external_name":"uuid","restriction":"UUID"}],"args_string":"(uuid : UUID) : String","args_html":"(uuid : UUID) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":30,"url":null},"def":{"name":"serialize_uuid","args":[{"name":"uuid","external_name":"uuid","restriction":"UUID"}],"return_type":"String","visibility":"Public","body":"uuid.to_s"}}]}]},{"html_id":"mosquito/Mosquito/TestBackend","path":"Mosquito/TestBackend.html","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend","abstract":false,"superclass":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"ancestors":[{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/test_backend.cr","line_number":38,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"An in-memory noop backend desigend to be used in application testing.\n\nThe test mode backend simply makes a copy of job_runs at enqueue time and holds them in a class getter array.\n\nJob run id, config (aka parameters), and runtime class are kept in memory, and a truncate utility function is provided.\n\nActivate test mode configure the test backend like this:\n\n```\nMosquito.configure do |settings|\n settings.backend = Mosquito::TestBackend\nend\n```\n\nThen in your tests:\n\n```\ndescribe \"testing\" do\n it \"enqueues the job\" do\n # build and enqueue a job\n job_run = EchoJob.new(text: \"hello world\").enqueue\n\n # assert that the job was enqueued\n lastest_enqueued_job = Mosquito::TestBackend.enqueued_jobs.last\n\n # check the job config\n assert_equal \"hello world\", latest_enqueued_job.config[\"text\"]\n\n # check the job_id matches\n assert_equal job_run.id, latest_enqueued_job.id\n\n # optionally, truncate the history\n Mosquito::TestBackend.flush_enqueued_jobs!\n end\nend\n```","summary":"

An in-memory noop backend desigend to be used in application testing.

","class_methods":[{"html_id":"delete(key:String,inttl:Int64=0):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":54,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":57,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"enqueued_jobs-class-method","name":"enqueued_jobs","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":106,"url":null},"def":{"name":"enqueued_jobs","visibility":"Public","body":"@@enqueued_jobs"}},{"html_id":"enqueued_jobs=(enqueued_jobs:Array(Mosquito::TestBackend::EnqueuedJob))-class-method","name":"enqueued_jobs=","abstract":false,"args":[{"name":"enqueued_jobs","external_name":"enqueued_jobs","restriction":"::Array(::Mosquito::TestBackend::EnqueuedJob)"}],"args_string":"(enqueued_jobs : Array(Mosquito::TestBackend::EnqueuedJob))","args_html":"(enqueued_jobs : Array(Mosquito::TestBackend::EnqueuedJob))","location":{"filename":"src/mosquito/test_backend.cr","line_number":106,"url":null},"def":{"name":"enqueued_jobs=","args":[{"name":"enqueued_jobs","external_name":"enqueued_jobs","restriction":"::Array(::Mosquito::TestBackend::EnqueuedJob)"}],"visibility":"Public","body":"@@enqueued_jobs = enqueued_jobs"}},{"html_id":"expires_in(key:String):Int64-class-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":60,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"flush:Nil-class-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":79,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"flush_enqueued_jobs!-class-method","name":"flush_enqueued_jobs!","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":108,"url":null},"def":{"name":"flush_enqueued_jobs!","visibility":"Public","body":"@@enqueued_jobs = [] of EnqueuedJob"}},{"html_id":"get(key:String,field:String):String|Nil-class-method","name":"get","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":64,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":75,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"increment(key:String,field:String):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":71,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"list_queues:Array(String)-class-method","name":"list_queues","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":46,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":50,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-class-method","name":"lock?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/test_backend.cr","line_number":81,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":"false"}},{"html_id":"retrieve(key:String):Hash(String,String)-class-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/test_backend.cr","line_number":42,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"{} of String => String"}},{"html_id":"set(key:String,field:String,value:String):String-class-method","name":"set","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/test_backend.cr","line_number":67,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":"\"\""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-class-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":39,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"unlock(key:String,value:String):Nil-class-method","name":"unlock","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":85,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":""}}],"instance_methods":[{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":117,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"raise(\"Mosquito: attempted to dequeue a job from the testing backend.\")"}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":125,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":"raise(\"Mosquito: attempted to deschedule a job from the testing backend.\")"}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/test_backend.cr","line_number":112,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"@@enqueued_jobs << (EnqueuedJob.from(job_run))\njob_run\n"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":129,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":135,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/test_backend.cr","line_number":121,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"job_run"}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":148,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"size(include_dead:Bool=true):Int64-instance-method","name":"size","abstract":false,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"args_string":"(include_dead : Bool = true) : Int64","args_html":"(include_dead : Bool = true) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":138,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":132,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}}],"types":[{"html_id":"mosquito/Mosquito/TestBackend/EnqueuedJob","path":"Mosquito/TestBackend/EnqueuedJob.html","kind":"struct","full_name":"Mosquito::TestBackend::EnqueuedJob","name":"EnqueuedJob","abstract":false,"superclass":{"html_id":"mosquito/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"mosquito/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/test_backend.cr","line_number":88,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/TestBackend","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend"},"class_methods":[{"html_id":"from(job_run:JobRun)-class-method","name":"from","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":93,"url":null},"def":{"name":"from","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"job_class = Mosquito::Base.job_for_type(job_run.type)\nnew(job_run.id, job_class, job_run.config)\n"}}],"constructors":[{"html_id":"new(id:String,klass:::Mosquito::Job.class,config:Hash(String,String))-class-method","name":"new","abstract":false,"args":[{"name":"id","external_name":"id","restriction":"::String"},{"name":"klass","external_name":"klass","restriction":"::Mosquito::Job.class"},{"name":"config","external_name":"config","restriction":"::Hash(::String, ::String)"}],"args_string":"(id : String, klass : ::Mosquito::Job.class, config : Hash(String, String))","args_html":"(id : String, klass : ::Mosquito::Job.class, config : Hash(String, String))","location":{"filename":"src/mosquito/test_backend.cr","line_number":102,"url":null},"def":{"name":"new","args":[{"name":"id","external_name":"id","restriction":"::String"},{"name":"klass","external_name":"klass","restriction":"::Mosquito::Job.class"},{"name":"config","external_name":"config","restriction":"::Hash(::String, ::String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(id, klass, config)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"config:Hash(String,String)-instance-method","name":"config","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":91,"url":null},"def":{"name":"config","return_type":"Hash(String, String)","visibility":"Public","body":"@config"}},{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":89,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"klass:Mosquito::Job.class-instance-method","name":"klass","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":90,"url":null},"def":{"name":"klass","return_type":"Mosquito::Job.class","visibility":"Public","body":"@klass"}}]}]}]}]}} \ No newline at end of file +{"repository_name":"mosquito","body":"\"mosquito\"\n\n[![GitHub](https://img.shields.io/github/license/mosquito-cr/mosquito.svg?style=for-the-badge)](https://tldrlegal.com/license/mit-license)\n\n\n\nMosquito is a generic background job runner written primarily for Crystal. Significant inspiration from experience with the successes and failings many Ruby gems in this vein. Once compiled, a mosquito binary can start work in about 10 milliseconds.\n\nMosquito currently provides these features:\n\n- Delayed execution (`SendEmailJob.new(email: :welcome, address: user.email).enqueue(in: 3.minutes)`)\n- Scheduled / Periodic execution (`RunEveryHourJob.new`)\n- Job Storage in Redis\n- Automatic rescheduling of failed jobs\n- Progressively increasing delay of rescheduled failed jobs\n- Dead letter queue of jobs which have failed too many times\n- Rate limited jobs\n\nCurrent Limitations:\n- Visibility into a running job network and queue is limited. There is a working proof of concept [visualization API](https://github.com/mosquito-cr/mosquito/issues/90) and [bare-bones terminal application](https://github.com/mosquito-cr/tui-visualizer).\n\n## Project State\n\nThe Mosquito project is stable. A few folks are using Mosquito in production, and it's going okay.\n\nThere are some features which would be nice to have, but what is here is both tried and tested.\n\nIf you're using Mosquito, please [get in touch](https://github.com/mosquito-cr/mosquito/discussions) on the Discussion board or [on Crystal chat](https://crystal-lang.org/community/) with any questions, feature suggestions, or feedback.\n\n## Installation\n\nUpdate your `shard.yml` to include mosquito:\n\n```diff\ndependencies:\n+ mosquito:\n+ github: mosquito-cr/mosquito\n```\n\n## Usage\n\n### Step 1: Define a queued job\n\n```crystal\n# src/jobs/puts_job.cr\nclass PutsJob < Mosquito::QueuedJob\n param message : String\n\n def perform\n puts message\n end\nend\n```\n\n### Step 2: Trigger that job\n\n```crystal\n# src//.cr\nPutsJob.new(message: \"ohai background job\").enqueue\n```\n\n### Step 3: Run your worker to process the job\n\n```crystal\n# src/worker.cr\n\nMosquito.configure do |settings|\n settings.redis_url = ENV[\"REDIS_URL\"]\nend\n\nMosquito::Runner.start\n```\n\n```text\ncrystal run src/worker.cr\n```\n\n### Success\n\n```\n> crystal run src/worker.cr\n2017-11-06 17:07:29 - Mosquito is buzzing...\n2017-11-06 17:07:51 - Running task puts_job<...> from puts_job\n2017-11-06 17:07:51 - [PutsJob] ohai background job\n2017-11-06 17:07:51 - task puts_job<...> succeeded, took 0.0 seconds\n```\n\n[More information about queued jobs](https://mosquito-cr.github.io/manual/index.html#queued-jobs) in the manual.\n\n------\n\n## Periodic Jobs\n\nPeriodic jobs run according to a predefined period -- once an hour, etc.\n\nThis periodic job:\n```crystal\nclass PeriodicallyPutsJob < Mosquito::PeriodicJob\n run_every 1.minute\n\n def perform\n emotions = %w{happy sad angry optimistic political skeptical epuhoric}\n puts \"The time is now #{Time.local} and the wizard is feeling #{emotions.sample}\"\n end\nend\n```\n\nWould produce this output:\n```crystal\n2017-11-06 17:20:13 - Mosquito is buzzing...\n2017-11-06 17:20:13 - Queues: periodically_puts_job\n2017-11-06 17:20:13 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:20:13 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:20:13 and the wizard is feeling skeptical\n2017-11-06 17:20:13 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n2017-11-06 17:21:14 - Queues: periodically_puts_job\n2017-11-06 17:21:14 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:21:14 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:21:14 and the wizard is feeling optimistic\n2017-11-06 17:21:14 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n2017-11-06 17:22:15 - Queues: periodically_puts_job\n2017-11-06 17:22:15 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:22:15 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:22:15 and the wizard is feeling political\n2017-11-06 17:22:15 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n```\n\n[More information on periodic jobs](https://mosquito-cr.github.io/manual/index.html#periodic-jobs) in the manual.\n\n## Advanced usage\n\nFor more advanced topics, including [use with Lucky Framework](https://mosquito-cr.github.io/manual/lucky_framework.html), [throttling or rate limiting](https://mosquito-cr.github.io/manual/rate_limiting.html), check out the [full manual](https://mosquito-cr.github.io/manual).\n\n## Contributing\n\nContributions are welcome. Please fork the repository, commit changes on a branch, and then open a pull request.\n\n### Crystal Versions\n\nMosquito aims to be compatible with the latest Crystal release, and the [latest patch for all post-1.0 minor crystal versions](https://github.com/mosquito-cr/mosquito/blob/master/.github/workflows/ci.yml#L17).\n\nFor development purposes [you're encouraged to stay in sync with `.tool-versions`](https://github.com/mosquito-cr/mosquito/blob/master/.tool-versions).\n\n### Testing\n\nThis repository uses [minitest](https://github.com/ysbaddaden/minitest.cr) for testing. As a result, `crystal spec` doesn't do anything helpful. Do this instead:\n\n```\nmake test\n```\n\nIn lieu of `crystal spec` bells and whistles, Minitest provides a nice alternative to [running one test at a time instead of the whole suite](https://github.com/ysbaddaden/minitest.cr/pull/31).\n","program":{"html_id":"mosquito/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"mosquito","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"mosquito/Mosquito","path":"Mosquito.html","kind":"module","full_name":"Mosquito","name":"Mosquito","abstract":false,"locations":[{"filename":"src/mosquito.cr","line_number":5,"url":null},{"filename":"src/mosquito/backend.cr","line_number":1,"url":null},{"filename":"src/mosquito/base.cr","line_number":1,"url":null},{"filename":"src/mosquito/configuration.cr","line_number":1,"url":null},{"filename":"src/mosquito/exceptions.cr","line_number":1,"url":null},{"filename":"src/mosquito/job.cr","line_number":3,"url":null},{"filename":"src/mosquito/job_run.cr","line_number":1,"url":null},{"filename":"src/mosquito/key_builder.cr","line_number":1,"url":null},{"filename":"src/mosquito/metadata.cr","line_number":1,"url":null},{"filename":"src/mosquito/periodic_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/periodic_job_run.cr","line_number":1,"url":null},{"filename":"src/mosquito/queue.cr","line_number":1,"url":null},{"filename":"src/mosquito/queued_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/redis_backend.cr","line_number":4,"url":null},{"filename":"src/mosquito/runnable.cr","line_number":1,"url":null},{"filename":"src/mosquito/runner.cr","line_number":3,"url":null},{"filename":"src/mosquito/runners/run_at_most.cr","line_number":1,"url":null},{"filename":"src/mosquito/scheduled_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/test_backend.cr","line_number":1,"url":null},{"filename":"src/mosquito/version.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"1.0.2\""}],"class_methods":[{"html_id":"backend-class-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito.cr","line_number":6,"url":null},"def":{"name":"backend","visibility":"Public","body":"configuration.backend"}},{"html_id":"configuration-class-method","name":"configuration","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":2,"url":null},"def":{"name":"configuration","visibility":"Public","body":"@@configuration"}},{"html_id":"configure(&):Nil-class-method","name":"configure","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":4,"url":null},"def":{"name":"configure","yields":1,"block_arity":1,"return_type":"Nil","visibility":"Public","body":"yield configuration"}}],"types":[{"html_id":"mosquito/Mosquito/Backend","path":"Mosquito/Backend.html","kind":"class","full_name":"Mosquito::Backend","name":"Backend","abstract":true,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/backend.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"KEY_PREFIX","name":"KEY_PREFIX","value":"{\"mosquito\"}"},{"id":"QUEUES","name":"QUEUES","value":"[\"waiting\", \"scheduled\", \"pending\", \"dead\"] of ::String"}],"subclasses":[{"html_id":"mosquito/Mosquito/RedisBackend","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend"},{"html_id":"mosquito/Mosquito/TestBackend","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"build_key(*parts)-class-method","name":"build_key","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/backend.cr","line_number":11,"url":null},"def":{"name":"build_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"KeyBuilder.build(KEY_PREFIX, *parts)"}},{"html_id":"named(name)-class-method","name":"named","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/mosquito/backend.cr","line_number":7,"url":null},"def":{"name":"named","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"new(name)"}},{"html_id":"search_queues-class-method","name":"search_queues","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":50,"url":null},"def":{"name":"search_queues","visibility":"Public","body":"QUEUES.first(2)"}}],"constructors":[{"html_id":"new(name:String|Symbol)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"args_string":"(name : String | Symbol)","args_html":"(name : String | Symbol)","location":{"filename":"src/mosquito/backend.cr","line_number":21,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_key(*parts)-instance-method","name":"build_key","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/backend.cr","line_number":15,"url":null},"def":{"name":"build_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"self.class.build_key(*parts)"}},{"html_id":"dead_q-instance-method","name":"dead_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"dead_q","visibility":"Public","body":"build_key(\"dead\", name)"}},{"html_id":"delete(key:String,inttl=0):Nil-instance-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"args_string":"(key : String, in ttl = 0) : Nil","args_html":"(key : String, in ttl = 0) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":68,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"return_type":"Nil","visibility":"Public","body":"self.class.delete(key)"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":78,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":""}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":80,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":""}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/backend.cr","line_number":77,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":""}},{"html_id":"expires_in(key:String):Int64-instance-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":72,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"self.class.expires_in(key)"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/backend.cr","line_number":81,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":83,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"pending_q-instance-method","name":"pending_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"pending_q","visibility":"Public","body":"build_key(\"pending\", name)"}},{"html_id":"retrieve(key:String):Hash(String,String)-instance-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/backend.cr","line_number":64,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"self.class.retrieve(key)"}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/backend.cr","line_number":79,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":""}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/backend.cr","line_number":90,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"scheduled_q-instance-method","name":"scheduled_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"scheduled_q","visibility":"Public","body":"build_key(\"scheduled\", name)"}},{"html_id":"size(include_dead:Bool=true):Int64-instance-method","name":"size","abstract":true,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"args_string":"(include_dead : Bool = true) : Int64","args_html":"(include_dead : Bool = true) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":84,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-instance-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":60,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":"self.class.store(key, value)"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/backend.cr","line_number":82,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"waiting_q-instance-method","name":"waiting_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"waiting_q","visibility":"Public","body":"build_key(\"waiting\", name)"}}],"types":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","path":"Mosquito/Backend/ClassMethods.html","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/mosquito/backend.cr","line_number":25,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"instance_methods":[{"html_id":"delete(key:String,inttl:Int64=0):Nil-instance-method","name":"delete","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":31,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-instance-method","name":"delete","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":32,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"expires_in(key:String):Int64-instance-method","name":"expires_in","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":33,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":40,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"get(key:String,field:String):String|Nil-instance-method","name":"get","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/backend.cr","line_number":35,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-instance-method","name":"increment","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":38,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String):Int64-instance-method","name":"increment","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":37,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"list_queues:Array(String)-instance-method","name":"list_queues","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":28,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"list_runners:Array(String)-instance-method","name":"list_runners","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":29,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-instance-method","name":"lock?","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/backend.cr","line_number":43,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":""}},{"html_id":"retrieve(key:String):Hash(String,String)-instance-method","name":"retrieve","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/backend.cr","line_number":27,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":""}},{"html_id":"set(key:String,field:String,value:String):String-instance-method","name":"set","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/backend.cr","line_number":36,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-instance-method","name":"store","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":26,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"unlock(key:String,value:String):Nil-instance-method","name":"unlock","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":42,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":""}}]}]},{"html_id":"mosquito/Mosquito/Base","path":"Mosquito/Base.html","kind":"class","full_name":"Mosquito::Base","name":"Base","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/base.cr","line_number":4,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"job_for_type(type:String):Mosquito::Job.class-class-method","name":"job_for_type","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"}],"args_string":"(type : String) : Mosquito::Job.class","args_html":"(type : String) : Mosquito::Job.class","location":{"filename":"src/mosquito/base.cr","line_number":13,"url":null},"def":{"name":"job_for_type","args":[{"name":"type","external_name":"type","restriction":"String"}],"return_type":"Mosquito::Job.class","visibility":"Public","body":"begin\n @@mapping[type]\nrescue e : KeyError\n error = String.build do |s|\n s << \"Could not find a job class for type \\\"#{type}\\\", perhaps you forgot to register it?\\n\\nCurrent known types are:\\n\"\n @@mapping.each do |k, v|\n s << \"#{k}=>#{v}\\n\"\n end\n s << \"\\n\\n\"\n end\n raise(KeyError.new(error))\nend"}},{"html_id":"mapping-class-method","name":"mapping","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":5,"url":null},"def":{"name":"mapping","visibility":"Public","body":"@@mapping"}},{"html_id":"register_job(klass,*,to_run_atscheduled_time:Time)-class-method","name":"register_job","abstract":false,"args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"scheduled_time","external_name":"to_run_at","restriction":"Time"}],"args_string":"(klass, *, to_run_at scheduled_time : Time)","args_html":"(klass, *, to_run_at scheduled_time : Time)","location":{"filename":"src/mosquito/base.cr","line_number":36,"url":null},"def":{"name":"register_job","args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"scheduled_time","external_name":"to_run_at","restriction":"Time"}],"splat_index":1,"visibility":"Public","body":"position = @@timetable.index do\nend"}},{"html_id":"register_job_interval(klass,interval:Time::Span|Time::MonthSpan)-class-method","name":"register_job_interval","abstract":false,"args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"args_string":"(klass, interval : Time::Span | Time::MonthSpan)","args_html":"(klass, interval : Time::Span | Time::MonthSpan)","location":{"filename":"src/mosquito/base.cr","line_number":32,"url":null},"def":{"name":"register_job_interval","args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"visibility":"Public","body":"@@scheduled_job_runs << (PeriodicJobRun.new(klass, interval))"}},{"html_id":"register_job_mapping(string,klass)-class-method","name":"register_job_mapping","abstract":false,"args":[{"name":"string","external_name":"string","restriction":""},{"name":"klass","external_name":"klass","restriction":""}],"args_string":"(string, klass)","args_html":"(string, klass)","location":{"filename":"src/mosquito/base.cr","line_number":9,"url":null},"def":{"name":"register_job_mapping","args":[{"name":"string","external_name":"string","restriction":""},{"name":"klass","external_name":"klass","restriction":""}],"visibility":"Public","body":"@@mapping[string] = klass"}},{"html_id":"scheduled_job_runs-class-method","name":"scheduled_job_runs","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":6,"url":null},"def":{"name":"scheduled_job_runs","visibility":"Public","body":"@@scheduled_job_runs"}},{"html_id":"timetable-class-method","name":"timetable","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":7,"url":null},"def":{"name":"timetable","visibility":"Public","body":"@@timetable"}}]},{"html_id":"mosquito/Mosquito/Configuration","path":"Mosquito/Configuration.html","kind":"class","full_name":"Mosquito::Configuration","name":"Configuration","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/configuration.cr","line_number":8,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"backend:Mosquito::Backend.class-instance-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":20,"url":null},"def":{"name":"backend","return_type":"Mosquito::Backend.class","visibility":"Public","body":"@backend"}},{"html_id":"backend=(backend:Mosquito::Backend.class)-instance-method","name":"backend=","abstract":false,"args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend.class"}],"args_string":"(backend : Mosquito::Backend.class)","args_html":"(backend : Mosquito::Backend.class)","location":{"filename":"src/mosquito/configuration.cr","line_number":20,"url":null},"def":{"name":"backend=","args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend.class"}],"visibility":"Public","body":"@backend = backend"}},{"html_id":"failed_job_ttl:Int32-instance-method","name":"failed_job_ttl","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":13,"url":null},"def":{"name":"failed_job_ttl","return_type":"Int32","visibility":"Public","body":"@failed_job_ttl"}},{"html_id":"failed_job_ttl=(failed_job_ttl:Int32)-instance-method","name":"failed_job_ttl=","abstract":false,"args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"args_string":"(failed_job_ttl : Int32)","args_html":"(failed_job_ttl : Int32)","location":{"filename":"src/mosquito/configuration.cr","line_number":13,"url":null},"def":{"name":"failed_job_ttl=","args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@failed_job_ttl = failed_job_ttl"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":11,"url":null},"def":{"name":"idle_wait","return_type":"Time::Span","visibility":"Public","body":"@idle_wait"}},{"html_id":"idle_wait=(idle_wait:Time::Span)-instance-method","name":"idle_wait=","abstract":false,"args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"args_string":"(idle_wait : Time::Span)","args_html":"(idle_wait : Time::Span)","location":{"filename":"src/mosquito/configuration.cr","line_number":11,"url":null},"def":{"name":"idle_wait=","args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"visibility":"Public","body":"@idle_wait = idle_wait"}},{"html_id":"idle_wait=(time_span:Float)-instance-method","name":"idle_wait=","abstract":false,"args":[{"name":"time_span","external_name":"time_span","restriction":"Float"}],"args_string":"(time_span : Float)","args_html":"(time_span : Float)","location":{"filename":"src/mosquito/configuration.cr","line_number":24,"url":null},"def":{"name":"idle_wait=","args":[{"name":"time_span","external_name":"time_span","restriction":"Float"}],"visibility":"Public","body":"@idle_wait = time_span.seconds"}},{"html_id":"redis_url:String|Nil-instance-method","name":"redis_url","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":9,"url":null},"def":{"name":"redis_url","return_type":"String | ::Nil","visibility":"Public","body":"@redis_url"}},{"html_id":"redis_url=(redis_url:String|Nil)-instance-method","name":"redis_url=","abstract":false,"args":[{"name":"redis_url","external_name":"redis_url","restriction":"String | ::Nil"}],"args_string":"(redis_url : String | Nil)","args_html":"(redis_url : String | Nil)","location":{"filename":"src/mosquito/configuration.cr","line_number":9,"url":null},"def":{"name":"redis_url=","args":[{"name":"redis_url","external_name":"redis_url","restriction":"String | ::Nil"}],"visibility":"Public","body":"@redis_url = redis_url"}},{"html_id":"run_cron_scheduler:Bool-instance-method","name":"run_cron_scheduler","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":16,"url":null},"def":{"name":"run_cron_scheduler","return_type":"Bool","visibility":"Public","body":"@run_cron_scheduler"}},{"html_id":"run_cron_scheduler=(run_cron_scheduler:Bool)-instance-method","name":"run_cron_scheduler=","abstract":false,"args":[{"name":"run_cron_scheduler","external_name":"run_cron_scheduler","restriction":"Bool"}],"args_string":"(run_cron_scheduler : Bool)","args_html":"(run_cron_scheduler : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":16,"url":null},"def":{"name":"run_cron_scheduler=","args":[{"name":"run_cron_scheduler","external_name":"run_cron_scheduler","restriction":"Bool"}],"visibility":"Public","body":"@run_cron_scheduler = run_cron_scheduler"}},{"html_id":"run_from:Array(String)-instance-method","name":"run_from","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":19,"url":null},"def":{"name":"run_from","return_type":"Array(String)","visibility":"Public","body":"@run_from"}},{"html_id":"run_from=(run_from:Array(String))-instance-method","name":"run_from=","abstract":false,"args":[{"name":"run_from","external_name":"run_from","restriction":"Array(String)"}],"args_string":"(run_from : Array(String))","args_html":"(run_from : Array(String))","location":{"filename":"src/mosquito/configuration.cr","line_number":19,"url":null},"def":{"name":"run_from=","args":[{"name":"run_from","external_name":"run_from","restriction":"Array(String)"}],"visibility":"Public","body":"@run_from = run_from"}},{"html_id":"successful_job_ttl:Int32-instance-method","name":"successful_job_ttl","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":12,"url":null},"def":{"name":"successful_job_ttl","return_type":"Int32","visibility":"Public","body":"@successful_job_ttl"}},{"html_id":"successful_job_ttl=(successful_job_ttl:Int32)-instance-method","name":"successful_job_ttl=","abstract":false,"args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"args_string":"(successful_job_ttl : Int32)","args_html":"(successful_job_ttl : Int32)","location":{"filename":"src/mosquito/configuration.cr","line_number":12,"url":null},"def":{"name":"successful_job_ttl=","args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@successful_job_ttl = successful_job_ttl"}},{"html_id":"use_distributed_lock:Bool-instance-method","name":"use_distributed_lock","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":17,"url":null},"def":{"name":"use_distributed_lock","return_type":"Bool","visibility":"Public","body":"@use_distributed_lock"}},{"html_id":"use_distributed_lock=(use_distributed_lock:Bool)-instance-method","name":"use_distributed_lock=","abstract":false,"args":[{"name":"use_distributed_lock","external_name":"use_distributed_lock","restriction":"Bool"}],"args_string":"(use_distributed_lock : Bool)","args_html":"(use_distributed_lock : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":17,"url":null},"def":{"name":"use_distributed_lock=","args":[{"name":"use_distributed_lock","external_name":"use_distributed_lock","restriction":"Bool"}],"visibility":"Public","body":"@use_distributed_lock = use_distributed_lock"}},{"html_id":"validate-instance-method","name":"validate","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":28,"url":null},"def":{"name":"validate","visibility":"Public","body":"if @validated\n return\nend\n@validated = true\nif redis_url.nil?\n message = \"Mosquito cannot start because the redis connection string hasn't been provided.\\n\\nFor example, in your application config:\\n\\nMosquito.configure do |settings|\\n settings.redis_url = (ENV[\\\"REDIS_TLS_URL\\\"]? || ENV[\\\"REDIS_URL\\\"]? || \\\"redis://localhost:6379\\\")\\nend\\n\\nSee Also: https://github.com/mosquito-cr/mosquito#connecting-to-redis\"\n raise(message)\nend\n"}},{"html_id":"validated:Bool-instance-method","name":"validated","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":22,"url":null},"def":{"name":"validated","visibility":"Public","body":"@validated"}},{"html_id":"validated=(validated:Bool)-instance-method","name":"validated=","abstract":false,"args":[{"name":"validated","external_name":"validated","restriction":"::Bool"}],"args_string":"(validated : Bool)","args_html":"(validated : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":22,"url":null},"def":{"name":"validated=","args":[{"name":"validated","external_name":"validated","restriction":"::Bool"}],"visibility":"Public","body":"@validated = validated"}}]},{"html_id":"mosquito/Mosquito/DoubleRun","path":"Mosquito/DoubleRun.html","kind":"class","full_name":"Mosquito::DoubleRun","name":"DoubleRun","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":7,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job_run tries to run twice","summary":"

When a job_run tries to run twice

"},{"html_id":"mosquito/Mosquito/Id","path":"Mosquito/Id.html","kind":"alias","full_name":"Mosquito::Id","name":"Id","abstract":false,"locations":[{"filename":"src/mosquito/base.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":true,"aliased":"(Int32 | Int64)","aliased_html":"Int32 | Int64","const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"}},{"html_id":"mosquito/Mosquito/IrretrievableParameter","path":"Mosquito/IrretrievableParameter.html","kind":"class","full_name":"Mosquito::IrretrievableParameter","name":"IrretrievableParameter","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":11,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job contains a model_id parameter pointing to a database record but the database doesn't return anything for that id.","summary":"

When a job contains a model_id parameter pointing to a database record but the database doesn't return anything for that id.

"},{"html_id":"mosquito/Mosquito/Job","path":"Mosquito/Job.html","kind":"class","full_name":"Mosquito::Job","name":"Job","abstract":true,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job.cr","line_number":10,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"}],"subclasses":[{"html_id":"mosquito/Mosquito/PeriodicJob","kind":"class","full_name":"Mosquito::PeriodicJob","name":"PeriodicJob"},{"html_id":"mosquito/Mosquito/QueuedJob","kind":"class","full_name":"Mosquito::QueuedJob","name":"QueuedJob"},{"html_id":"mosquito/Mosquito/ScheduledJob","kind":"class","full_name":"Mosquito::ScheduledJob","name":"ScheduledJob"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A Job is a definition for work to be performed.\nJobs are pieces of code which run a JobRun.\n\n- Jobs prevent double execution of a job for a job_run\n- Jobs Rescue when a #perform method fails a job_run for any reason\n- Jobs can be rescheduleable","summary":"

A Job is a definition for work to be performed.

","class_methods":[{"html_id":"metadata:Metadata-class-method","name":"metadata","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":182,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"Metadata.new(metadata_key, readonly: true)"}},{"html_id":"metadata_key-class-method","name":"metadata_key","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":186,"url":null},"def":{"name":"metadata_key","visibility":"Public","body":"Mosquito.backend.build_key(\"job_metadata\", self.name.underscore)"}},{"html_id":"queue-class-method","name":"queue","doc":"The Queue this job uses to store job_runs.","summary":"

The Queue this job uses to store job_runs.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":60,"url":null},"def":{"name":"queue","visibility":"Public","body":"if queue_name.blank?\n Queue.new(\"default\")\nelse\n Queue.new(queue_name)\nend"}},{"html_id":"queue_name:String-class-method","name":"queue_name","doc":"The queue this job is assigned to.\nBy default every job has it's own named queue:\n\n- EmailTheUniverseJob.queue = \"email_the_universe\"","summary":"

The queue this job is assigned to.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":48,"url":null},"def":{"name":"queue_name","return_type":"String","visibility":"Public","body":"({{ @type.id }}).to_s.underscore"}}],"instance_methods":[{"html_id":"aborted?(*args,**options)-instance-method","name":"aborted?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"aborted?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.aborted?(*args, **options)"}},{"html_id":"aborted?(*args,**options,&)-instance-method","name":"aborted?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"aborted?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.aborted?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"after_hook-instance-method","name":"after_hook","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":103,"url":null},"def":{"name":"after_hook","visibility":"Public","body":""}},{"html_id":"before_hook-instance-method","name":"before_hook","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":99,"url":null},"def":{"name":"before_hook","visibility":"Public","body":""}},{"html_id":"exception:Exception|Nil-instance-method","name":"exception","doc":"When a job fails and raises an exception, it will be saved into this attribute.","summary":"

When a job fails and raises an exception, it will be saved into this attribute.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":36,"url":null},"def":{"name":"exception","return_type":"Exception | ::Nil","visibility":"Public","body":"@exception"}},{"html_id":"executed?(*args,**options)-instance-method","name":"executed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"executed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.executed?(*args, **options)"}},{"html_id":"executed?(*args,**options,&)-instance-method","name":"executed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"executed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.executed?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"fail(reason=\"\",*,retry:Bool=true)-instance-method","name":"fail","doc":"To be called from inside a #perform\nMarks this job as a failure. By default, if the job is a candidate for\nre-scheduling, it will be run again at a later time.","summary":"

To be called from inside a #perform Marks this job as a failure.

","abstract":false,"args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"retry","default_value":"true","external_name":"retry","restriction":"Bool"}],"args_string":"(reason = \"\", *, retry : Bool = true)","args_html":"(reason = "", *, retry : Bool = true)","location":{"filename":"src/mosquito/job.cr","line_number":144,"url":null},"def":{"name":"fail","args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"retry","default_value":"true","external_name":"retry","restriction":"Bool"}],"splat_index":1,"visibility":"Public","body":"@should_retry = @should_retry && retry\nraise(JobFailed.new(reason))\n"}},{"html_id":"failed?(*args,**options)-instance-method","name":"failed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"failed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.failed?(*args, **options)"}},{"html_id":"failed?(*args,**options,&)-instance-method","name":"failed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"failed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.failed?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"job_run_id:String|Nil-instance-method","name":"job_run_id","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":38,"url":null},"def":{"name":"job_run_id","return_type":"String | ::Nil","visibility":"Public","body":"@job_run_id"}},{"html_id":"job_run_id=(job_run_id:String|Nil)-instance-method","name":"job_run_id=","abstract":false,"args":[{"name":"job_run_id","external_name":"job_run_id","restriction":"String | ::Nil"}],"args_string":"(job_run_id : String | Nil)","args_html":"(job_run_id : String | Nil)","location":{"filename":"src/mosquito/job.cr","line_number":38,"url":null},"def":{"name":"job_run_id=","args":[{"name":"job_run_id","external_name":"job_run_id","restriction":"String | ::Nil"}],"visibility":"Public","body":"@job_run_id = job_run_id"}},{"html_id":"log(message)-instance-method","name":"log","abstract":false,"args":[{"name":"message","external_name":"message","restriction":""}],"args_string":"(message)","args_html":"(message)","location":{"filename":"src/mosquito/job.cr","line_number":27,"url":null},"def":{"name":"log","args":[{"name":"message","external_name":"message","restriction":""}],"visibility":"Public","body":"(::Log.for(self.class)).info do\n message\nend"}},{"html_id":"metadata:Metadata-instance-method","name":"metadata","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":176,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"@metadata || (@metadata = (Metadata.new(self.class.metadata_key)))"}},{"html_id":"perform-instance-method","name":"perform","doc":"abstract, override in a Job descendant to do something productive","summary":"

abstract, override in a Job descendant to do something productive

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":136,"url":null},"def":{"name":"perform","visibility":"Public","body":"Log.error do\n \"No job definition found for #{self.class.name}\"\nend\nfail\n"}},{"html_id":"reschedule_interval(retry_count:Int32):Time::Span-instance-method","name":"reschedule_interval","doc":"abstract, override if desired.\n\nFor a given retry count, how long should the delay between\njob attempts be?","summary":"

abstract, override if desired.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Time::Span","args_html":"(retry_count : Int32) : Time::Span","location":{"filename":"src/mosquito/job.cr","line_number":168,"url":null},"def":{"name":"reschedule_interval","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Time::Span","visibility":"Public","body":"2.seconds * (retry_count ** 2)"}},{"html_id":"rescheduleable?(retry_count:Int32):Bool-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nFor a given retry count, is this job rescheduleable?","summary":"

abstract, override if desired.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Bool","args_html":"(retry_count : Int32) : Bool","location":{"filename":"src/mosquito/job.cr","line_number":160,"url":null},"def":{"name":"rescheduleable?","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"rescheduleable? && retry_count < 5"}},{"html_id":"rescheduleable?:Bool-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":153,"url":null},"def":{"name":"rescheduleable?","return_type":"Bool","visibility":"Public","body":"true"}},{"html_id":"retry_later-instance-method","name":"retry_later","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":107,"url":null},"def":{"name":"retry_later","visibility":"Public","body":"fail"}},{"html_id":"run-instance-method","name":"run","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":74,"url":null},"def":{"name":"run","visibility":"Public","body":"begin\n begin\n before_hook\n rescue e : Exception\n Log.error(exception: e) do\n \"Before hook raised, job will not be executed\"\n end\n @state = State::Aborted\n return\n end\n @state = State::Running\n perform\n @state = State::Succeeded\nrescue e\n Log.warn(exception: e) do\n \"Job failed! Raised #{e.class}: #{e.message}\"\n end\n @exception = e\n @state = State::Failed\nensure\n after_hook\nend"}},{"html_id":"should_retry:Bool-instance-method","name":"should_retry","doc":"When a job run fails, should it be added to the retry queue?\nSee: #fail(retry: false)","summary":"

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":42,"url":null},"def":{"name":"should_retry","return_type":"Bool","visibility":"Public","body":"@should_retry"}},{"html_id":"should_retry=(should_retry:Bool)-instance-method","name":"should_retry=","doc":"When a job run fails, should it be added to the retry queue?\nSee: #fail(retry: false)","summary":"

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

","abstract":false,"args":[{"name":"should_retry","external_name":"should_retry","restriction":"Bool"}],"args_string":"(should_retry : Bool)","args_html":"(should_retry : Bool)","location":{"filename":"src/mosquito/job.cr","line_number":42,"url":null},"def":{"name":"should_retry=","args":[{"name":"should_retry","external_name":"should_retry","restriction":"Bool"}],"visibility":"Public","body":"@should_retry = should_retry"}},{"html_id":"state:Mosquito::Job::State-instance-method","name":"state","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":31,"url":null},"def":{"name":"state","visibility":"Public","body":"@state"}},{"html_id":"succeeded?(*args,**options)-instance-method","name":"succeeded?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"succeeded?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.succeeded?(*args, **options)"}},{"html_id":"succeeded?(*args,**options,&)-instance-method","name":"succeeded?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"succeeded?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.succeeded?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[{"html_id":"after(&block)-macro","name":"after","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":123,"url":null},"def":{"name":"after","block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" def after_hook\n \n{% if @type.methods.map(&.name).includes?((:after_hook).id) %}\n previous_def\n {% else %}\n super\n {% end %}\n\n\n \n{{ yield }}\n\n \nend\n \n"}},{"html_id":"before(&block)-macro","name":"before","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":111,"url":null},"def":{"name":"before","block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" def before_hook\n \n{% if @type.methods.map(&.name).includes?((:before_hook).id) %}\n previous_def\n {% else %}\n super\n {% end %}\n\n\n \n{{ yield }}\n\n \nend\n \n"}},{"html_id":"queue_name(name)-macro","name":"queue_name","doc":"Easily override the queue for any job.","summary":"

Easily override the queue for any job.

","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/mosquito/job.cr","line_number":53,"url":null},"def":{"name":"queue_name","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":" def self.queue_name : String\n \"\n{{ name.id }}\n\"\n \nend\n \n"}}],"types":[{"html_id":"mosquito/Mosquito/Job/State","path":"Mosquito/Job/State.html","kind":"enum","full_name":"Mosquito::Job::State","name":"State","abstract":false,"ancestors":[{"html_id":"mosquito/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"mosquito/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job.cr","line_number":15,"url":null}],"repository_name":"mosquito","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Initialization","name":"Initialization","value":"0"},{"id":"Running","name":"Running","value":"1"},{"id":"Succeeded","name":"Succeeded","value":"2"},{"id":"Failed","name":"Failed","value":"3"},{"id":"Aborted","name":"Aborted","value":"4"}],"namespace":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"instance_methods":[{"html_id":"aborted?-instance-method","name":"aborted?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":20,"url":null},"def":{"name":"aborted?","visibility":"Public","body":"self == Aborted"}},{"html_id":"executed?:Bool-instance-method","name":"executed?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":22,"url":null},"def":{"name":"executed?","return_type":"Bool","visibility":"Public","body":"succeeded? || failed?"}},{"html_id":"failed?-instance-method","name":"failed?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":19,"url":null},"def":{"name":"failed?","visibility":"Public","body":"self == Failed"}},{"html_id":"initialization?-instance-method","name":"initialization?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":16,"url":null},"def":{"name":"initialization?","visibility":"Public","body":"self == Initialization"}},{"html_id":"running?-instance-method","name":"running?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":17,"url":null},"def":{"name":"running?","visibility":"Public","body":"self == Running"}},{"html_id":"succeeded?-instance-method","name":"succeeded?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":18,"url":null},"def":{"name":"succeeded?","visibility":"Public","body":"self == Succeeded"}}]}]},{"html_id":"mosquito/Mosquito/JobFailed","path":"Mosquito/JobFailed.html","kind":"class","full_name":"Mosquito::JobFailed","name":"JobFailed","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job fails","summary":"

When a job fails

"},{"html_id":"mosquito/Mosquito/JobRun","path":"Mosquito/JobRun.html","kind":"class","full_name":"Mosquito::JobRun","name":"JobRun","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job_run.cr","line_number":11,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"CONFIG_KEY_PREFIX","name":"CONFIG_KEY_PREFIX","value":"\"job_run\""}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A JobRun is a unit of work which will be performed by a Job.\nJobRuns know how to:\n- store and retrieve their data to and from the datastore\n- figure out what Job class they match to\n- build an instance of that Job class and pass off the config data\n- Ask the job to run\n\nJobRun data is called `config` and is persisted in the backend under the key\n`mosquito:job_run:job_run_id`.","summary":"

A JobRun is a unit of work which will be performed by a Job.

","class_methods":[{"html_id":"config_key(*parts)-class-method","name":"config_key","doc":"The config key is the backend storage key for the metadata of this job_run.","summary":"

The config key is the backend storage key for the metadata of this job_run.

","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/job_run.cr","line_number":33,"url":null},"def":{"name":"config_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"Mosquito.backend.build_key(CONFIG_KEY_PREFIX, parts)"}},{"html_id":"retrieve(id:String)-class-method","name":"retrieve","doc":"Used to construct a job_run from the parameters stored in the backend.","summary":"

Used to construct a job_run from the parameters stored in the backend.

","abstract":false,"args":[{"name":"id","external_name":"id","restriction":"String"}],"args_string":"(id : String)","args_html":"(id : String)","location":{"filename":"src/mosquito/job_run.cr","line_number":117,"url":null},"def":{"name":"retrieve","args":[{"name":"id","external_name":"id","restriction":"String"}],"visibility":"Public","body":"fields = Mosquito.backend.retrieve(config_key(id))\nif name = fields.delete(\"type\")\nelse\n return\nend\nif timestamp = fields.delete(\"enqueue_time\")\nelse\n return\nend\nretry_count = ((fields.delete(\"retry_count\")) || 0).to_i\ninstance = new(name, Time.unix_ms(timestamp.to_i64), id, retry_count)\ninstance.config = fields\ninstance\n"}}],"constructors":[{"html_id":"new(type:String,enqueue_time:Time=Time.utc,id:String|Nil=nil,retry_count:Int32=0)-class-method","name":"new","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"enqueue_time","default_value":"Time.utc","external_name":"enqueue_time","restriction":"Time"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry_count","default_value":"0","external_name":"retry_count","restriction":"Int32"}],"args_string":"(type : String, enqueue_time : Time = Time.utc, id : String | Nil = nil, retry_count : Int32 = 0)","args_html":"(type : String, enqueue_time : Time = Time.utc, id : String | Nil = nil, retry_count : Int32 = 0)","location":{"filename":"src/mosquito/job_run.cr","line_number":41,"url":null},"def":{"name":"new","args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"enqueue_time","default_value":"Time.utc","external_name":"enqueue_time","restriction":"Time"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry_count","default_value":"0","external_name":"retry_count","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(type, enqueue_time, id, retry_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:self)-instance-method","name":"==","doc":"Returns `true` if this reference is the same as *other*. Invokes `same?`.","summary":"

Returns true if this reference is the same as other.

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self)","args_html":"(other : self)","location":{"filename":"src/mosquito/job_run.cr","line_number":140,"url":null},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"visibility":"Public","body":"id == self.id"}},{"html_id":"build_job:Mosquito::Job-instance-method","name":"build_job","doc":"Builds a Job instance from this job_run. Populates the job with config from\nthe backend.","summary":"

Builds a Job instance from this job_run.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":71,"url":null},"def":{"name":"build_job","return_type":"Mosquito::Job","visibility":"Public","body":"if job = @job\n return job\nend\n@job = instance = (Base.job_for_type(type)).new\nif instance.responds_to?(:vars_from)\n instance.vars_from(config)\nend\ninstance.job_run_id = id\ninstance\n"}},{"html_id":"config_key-instance-method","name":"config_key","doc":"The config key is the backend storage key for the metadata of this job_run.","summary":"

The config key is the backend storage key for the metadata of this job_run.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":28,"url":null},"def":{"name":"config_key","visibility":"Public","body":"self.class.config_key(id)"}},{"html_id":"delete(inttl=0)-instance-method","name":"delete","doc":"Deletes this job_run from the backend.\nOptionally, after a delay in seconds (handled by the backend).","summary":"

Deletes this job_run from the backend.

","abstract":false,"args":[{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"args_string":"(in ttl = 0)","args_html":"(in ttl = 0)","location":{"filename":"src/mosquito/job_run.cr","line_number":65,"url":null},"def":{"name":"delete","args":[{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"visibility":"Public","body":"Mosquito.backend.delete(config_key, ttl)"}},{"html_id":"enqueue_time:Time-instance-method","name":"enqueue_time","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":13,"url":null},"def":{"name":"enqueue_time","return_type":"Time","visibility":"Public","body":"@enqueue_time"}},{"html_id":"fail-instance-method","name":"fail","doc":"Fails this job run and make sure it's persisted as such.","summary":"

Fails this job run and make sure it's persisted as such.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":98,"url":null},"def":{"name":"fail","visibility":"Public","body":"@retry_count = @retry_count + 1\nstore\n"}},{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":14,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"job:Mosquito::Job|Nil-instance-method","name":"job","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":16,"url":null},"def":{"name":"job","return_type":"Mosquito::Job | ::Nil","visibility":"Public","body":"@job"}},{"html_id":"job!:Mosquito::Job-instance-method","name":"job!","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":18,"url":null},"def":{"name":"job!","return_type":"Mosquito::Job","visibility":"Public","body":"job || (raise(RuntimeError.new(\"No job yet retrieved for job_run.\")))"}},{"html_id":"reload:Nil-instance-method","name":"reload","doc":"Updates this job_run config from the backend.","summary":"

Updates this job_run config from the backend.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":131,"url":null},"def":{"name":"reload","return_type":"Nil","visibility":"Public","body":"config.merge!(Mosquito.backend.retrieve(config_key))\n@retry_count = config[\"retry_count\"].to_i\n"}},{"html_id":"reschedule_interval-instance-method","name":"reschedule_interval","doc":"For the current retry count, how long should a runner wait before retry?","summary":"

For the current retry count, how long should a runner wait before retry?

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":109,"url":null},"def":{"name":"reschedule_interval","visibility":"Public","body":"job!.reschedule_interval(@retry_count)"}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"For the current retry count, is the job rescheduleable?","summary":"

For the current retry count, is the job rescheduleable?

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":104,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"job!.rescheduleable?(@retry_count)"}},{"html_id":"retry_count:Int32-instance-method","name":"retry_count","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":15,"url":null},"def":{"name":"retry_count","visibility":"Public","body":"@retry_count"}},{"html_id":"run-instance-method","name":"run","doc":"Builds and runs the job with this job_run config.","summary":"

Builds and runs the job with this job_run config.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":87,"url":null},"def":{"name":"run","visibility":"Public","body":"instance = build_job\ninstance.run\nif executed? && failed?\n @retry_count = @retry_count + 1\n store\nend\n"}},{"html_id":"store-instance-method","name":"store","doc":"Stores this job run configuration and metadata in the backend.","summary":"

Stores this job run configuration and metadata in the backend.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":54,"url":null},"def":{"name":"store","visibility":"Public","body":"fields = config.dup\nfields[\"enqueue_time\"] = enqueue_time.to_unix_ms.to_s\nfields[\"type\"] = type\nfields[\"retry_count\"] = retry_count.to_s\nMosquito.backend.store(config_key, fields)\n"}},{"html_id":"to_s(io:IO)-instance-method","name":"to_s","doc":"Appends a short String representation of this object\nwhich includes its class name and its object address.\n\n```\nclass Person\n def initialize(@name : String, @age : Int32)\n end\nend\n\nPerson.new(\"John\", 32).to_s # => #\n```","summary":"

Appends a short String representation of this object which includes its class name and its object address.

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO)","args_html":"(io : IO)","location":{"filename":"src/mosquito/job_run.cr","line_number":136,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":"IO"}],"visibility":"Public","body":"\"#{type}<#{id}>\".to_s(io)"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":12,"url":null},"def":{"name":"type","visibility":"Public","body":"@type"}}]},{"html_id":"mosquito/Mosquito/KeyBuilder","path":"Mosquito/KeyBuilder.html","kind":"class","full_name":"Mosquito::KeyBuilder","name":"KeyBuilder","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/key_builder.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"KEY_SEPERATOR","name":"KEY_SEPERATOR","value":"\":\""}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"build(*parts)-class-method","name":"build","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/key_builder.cr","line_number":5,"url":null},"def":{"name":"build","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"id = [] of String\nparts.each do |part|\n case part\n when Symbol\n id << (build(part.to_s))\n when String\n id << part\n when Array\n part.each do |e|\n id << (build(e))\n end\n when Tuple\n part.to_a.each do |e|\n id << (build(e))\n end\n when Number\n id << part.to_s\n else\n raise(\"#{part.class} is not a keyable type\")\n end\nend\nid.flatten.join(KEY_SEPERATOR)\n"}}]},{"html_id":"mosquito/Mosquito/Metadata","path":"Mosquito/Metadata.html","kind":"class","full_name":"Mosquito::Metadata","name":"Metadata","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/metadata.cr","line_number":8,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"Provides a real-time metadata store. Data is not cached, which allows\nmultiple workers to operate on the same structures in real time.\n\nEach read or write incurs a round trip to the backend.\n\nKeys and values are always strings.","summary":"

Provides a real-time metadata store.

","constructors":[{"html_id":"new(root_key:String,readonly:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"root_key","external_name":"root_key","restriction":"String"},{"name":"readonly","default_value":"false","external_name":"readonly","restriction":"::Bool"}],"args_string":"(root_key : String, readonly : Bool = false)","args_html":"(root_key : String, readonly : Bool = false)","location":{"filename":"src/mosquito/metadata.cr","line_number":12,"url":null},"def":{"name":"new","args":[{"name":"root_key","external_name":"root_key","restriction":"String"},{"name":"readonly","default_value":"false","external_name":"readonly","restriction":"::Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(root_key, readonly)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[]=(key:String,value:String)-instance-method","name":"[]=","doc":"Writes a value to a key in the metadata.","summary":"

Writes a value to a key in the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String)","args_html":"(key : String, value : String)","location":{"filename":"src/mosquito/metadata.cr","line_number":36,"url":null},"def":{"name":"[]=","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.set(root_key, key, value)\n"}},{"html_id":"[]?(key:String):String|Nil-instance-method","name":"[]?","doc":"Reads a single key from the metadata.","summary":"

Reads a single key from the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : String | Nil","args_html":"(key : String) : String | Nil","location":{"filename":"src/mosquito/metadata.cr","line_number":31,"url":null},"def":{"name":"[]?","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":"Mosquito.backend.get(root_key, key)"}},{"html_id":"decrement(key)-instance-method","name":"decrement","doc":"Decrements a value in the metadata by 1.","summary":"

Decrements a value in the metadata by 1.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":54,"url":null},"def":{"name":"decrement","args":[{"name":"key","external_name":"key","restriction":""}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key, by: -1)\n"}},{"html_id":"delete(inttl:Time::Span):Nil-instance-method","name":"delete","doc":"Schedule this metadata to be deleted after a time span.","summary":"

Schedule this metadata to be deleted after a time span.

","abstract":false,"args":[{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(in ttl : Time::Span) : Nil","args_html":"(in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/metadata.cr","line_number":21,"url":null},"def":{"name":"delete","args":[{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":"Mosquito.backend.delete(root_key, in: ttl)"}},{"html_id":"delete:Nil-instance-method","name":"delete","doc":"Deletes this metadata immediately.","summary":"

Deletes this metadata immediately.

","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":16,"url":null},"def":{"name":"delete","return_type":"Nil","visibility":"Public","body":"Mosquito.backend.delete(root_key)"}},{"html_id":"increment(key,byincrement:Int32)-instance-method","name":"increment","doc":"Parametrically incruments a value in the metadata.","summary":"

Parametrically incruments a value in the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""},{"name":"increment","external_name":"by","restriction":"Int32"}],"args_string":"(key, by increment : Int32)","args_html":"(key, by increment : Int32)","location":{"filename":"src/mosquito/metadata.cr","line_number":48,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":""},{"name":"increment","external_name":"by","restriction":"Int32"}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key, by: increment)\n"}},{"html_id":"increment(key)-instance-method","name":"increment","doc":"Increments a value in the metadata by 1 by 1 by 1 by 1.","summary":"

Increments a value in the metadata by 1 by 1 by 1 by 1.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":42,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":""}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key)\n"}},{"html_id":"inspect(*args,**options)-instance-method","name":"inspect","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"inspect","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_h.inspect(*args, **options)"}},{"html_id":"inspect(*args,**options,&)-instance-method","name":"inspect","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"inspect","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_h.inspect(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"readonly?:Bool-instance-method","name":"readonly?","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":10,"url":null},"def":{"name":"readonly?","return_type":"Bool","visibility":"Public","body":"@readonly"}},{"html_id":"root_key:String-instance-method","name":"root_key","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":9,"url":null},"def":{"name":"root_key","return_type":"String","visibility":"Public","body":"@root_key"}},{"html_id":"root_key=(root_key:String)-instance-method","name":"root_key=","abstract":false,"args":[{"name":"root_key","external_name":"root_key","restriction":"String"}],"args_string":"(root_key : String)","args_html":"(root_key : String)","location":{"filename":"src/mosquito/metadata.cr","line_number":9,"url":null},"def":{"name":"root_key=","args":[{"name":"root_key","external_name":"root_key","restriction":"String"}],"visibility":"Public","body":"@root_key = root_key"}},{"html_id":"to_h:Hash(String,String)-instance-method","name":"to_h","doc":"Reads the metadata and returns it as a hash.","summary":"

Reads the metadata and returns it as a hash.

","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":26,"url":null},"def":{"name":"to_h","return_type":"Hash(String, String)","visibility":"Public","body":"Mosquito.backend.retrieve(root_key)"}},{"html_id":"to_s(*args,**options)-instance-method","name":"to_s","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"to_s","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_h.to_s(*args, **options)"}},{"html_id":"to_s(*args,**options,&)-instance-method","name":"to_s","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"to_s","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_h.to_s(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}]},{"html_id":"mosquito/Mosquito/PeriodicJob","path":"Mosquito/PeriodicJob.html","kind":"class","full_name":"Mosquito::PeriodicJob","name":"PeriodicJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/periodic_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":3,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_job_run-instance-method","name":"build_job_run","abstract":true,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":6,"url":null},"def":{"name":"build_job_run","visibility":"Public","body":""}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":28,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"false"}}]},{"html_id":"mosquito/Mosquito/PeriodicJobRun","path":"Mosquito/PeriodicJobRun.html","kind":"class","full_name":"Mosquito::PeriodicJobRun","name":"PeriodicJobRun","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/periodic_job_run.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new(class__arg0:::Mosquito::PeriodicJob.class,interval:Time::MonthSpan|Time::Span)-class-method","name":"new","abstract":false,"args":[{"name":"__arg0","external_name":"class","restriction":"::Mosquito::PeriodicJob.class"},{"name":"interval","external_name":"interval","restriction":"::Time::MonthSpan | ::Time::Span"}],"args_string":"(class __arg0 : ::Mosquito::PeriodicJob.class, interval : Time::MonthSpan | Time::Span)","args_html":"(class __arg0 : ::Mosquito::PeriodicJob.class, interval : Time::MonthSpan | Time::Span)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":40,"url":null},"def":{"name":"new","args":[{"name":"__arg0","external_name":"class","restriction":"::Mosquito::PeriodicJob.class"},{"name":"interval","external_name":"interval","restriction":"::Time::MonthSpan | ::Time::Span"}],"visibility":"Public","body":"_ = allocate\n_.initialize(__arg0, interval)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"class:Mosquito::PeriodicJob.class-instance-method","name":"class","doc":"Returns the **runtime** `Class` of an object.\n\n```\n1.class # => Int32\n\"hello\".class # => String\n```\n\nCompare it with `typeof`, which returns the **compile-time** type of an object:\n\n```\nrandom_value = rand # => 0.627423\nvalue = random_value < 0.5 ? 1 : \"hello\"\nvalue # => \"hello\"\nvalue.class # => String\ntypeof(value) # => Int32 | String\n```","summary":"

Returns the runtime Class of an object.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":3,"url":null},"def":{"name":"class","return_type":"Mosquito::PeriodicJob.class","visibility":"Public","body":"@class"}},{"html_id":"class=(class__arg0:Mosquito::PeriodicJob.class)-instance-method","name":"class=","abstract":false,"args":[{"name":"__arg0","external_name":"class","restriction":"Mosquito::PeriodicJob.class"}],"args_string":"(class __arg0 : Mosquito::PeriodicJob.class)","args_html":"(class __arg0 : Mosquito::PeriodicJob.class)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":3,"url":null},"def":{"name":"class=","args":[{"name":"__arg0","external_name":"class","restriction":"Mosquito::PeriodicJob.class"}],"visibility":"Public","body":"@class = __arg0"}},{"html_id":"execute-instance-method","name":"execute","doc":"Enqueues the job for execution","summary":"

Enqueues the job for execution

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":63,"url":null},"def":{"name":"execute","visibility":"Public","body":"job = @class.new\njob_run = job.build_job_run\njob_run.store\n@class.queue.enqueue(job_run)\n"}},{"html_id":"interval:Time::Span|Time::MonthSpan-instance-method","name":"interval","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":4,"url":null},"def":{"name":"interval","return_type":"Time::Span | Time::MonthSpan","visibility":"Public","body":"@interval"}},{"html_id":"interval=(interval:Time::Span|Time::MonthSpan)-instance-method","name":"interval=","abstract":false,"args":[{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"args_string":"(interval : Time::Span | Time::MonthSpan)","args_html":"(interval : Time::Span | Time::MonthSpan)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":4,"url":null},"def":{"name":"interval=","args":[{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"visibility":"Public","body":"@interval = interval"}},{"html_id":"last_executed_at-instance-method","name":"last_executed_at","doc":"The last executed timestamp, or \"never\" if it doesn't exist.","summary":"

The last executed timestamp, or "never" if it doesn't exist.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":16,"url":null},"def":{"name":"last_executed_at","visibility":"Public","body":"last_executed_at? || (Time.unix(0))"}},{"html_id":"last_executed_at=(time:Time)-instance-method","name":"last_executed_at=","doc":"Updates the last executed timestamp in the backend,\nand schedules the metadata for deletion after 3*interval\nseconds.\n\nFor Time::Span intervals, the TTL is set to 3 * interval.\nFor Time::MonthSpan intervals, the TTL is set to approximately 3 * interval.\n\nA month is approximated to 2635200 seconds, or 30.5 days.","summary":"

Updates the last executed timestamp in the backend, and schedules the metadata for deletion after 3*interval seconds.

","abstract":false,"args":[{"name":"time","external_name":"time","restriction":"Time"}],"args_string":"(time : Time)","args_html":"(time : Time)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":28,"url":null},"def":{"name":"last_executed_at=","args":[{"name":"time","external_name":"time","restriction":"Time"}],"visibility":"Public","body":"@metadata[\"last_executed_at\"] = time.to_unix.to_s\ncase interval_ = interval\nwhen Time::Span\n @metadata.delete(in: interval_ * 3)\nwhen Time::MonthSpan\n seconds_in_an_average_month = 2635200.seconds\n @metadata.delete(in: (seconds_in_an_average_month * interval_.value) * 3)\nend\n"}},{"html_id":"last_executed_at?-instance-method","name":"last_executed_at?","doc":"The last executed timestamp for this periodicjob tracked by the backend.","summary":"

The last executed timestamp for this periodicjob tracked by the backend.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":7,"url":null},"def":{"name":"last_executed_at?","visibility":"Public","body":"if timestamp = @metadata[\"last_executed_at\"]?\n Time.unix(timestamp.to_i)\nelse\n nil\nend"}},{"html_id":"try_to_execute:Bool-instance-method","name":"try_to_execute","doc":"Check the last executed timestamp against the current time,\nand enqueue the job if it's time to execute.","summary":"

Check the last executed timestamp against the current time, and enqueue the job if it's time to execute.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":46,"url":null},"def":{"name":"try_to_execute","return_type":"Bool","visibility":"Public","body":"now = Time.utc\nif (last_executed_at + interval) <= now\n execute\n self.last_executed_at = now\n true\nelse\n false\nend\n"}}]},{"html_id":"mosquito/Mosquito/Queue","path":"Mosquito/Queue.html","kind":"class","full_name":"Mosquito::Queue","name":"Queue","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/queue.cr","line_number":77,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A named Queue.\n\nNamed Queues exist and have 4 ordered lists: waiting, pending, scheduled, and dead.\n\n- The Waiting list is for jobs which need to be executed as soon as possible.\n- The Pending list is for jobs which are currently being executed.\n- The Scheduled list is indexed by execution time and holds jobs which need to be executed at a later time.\n- The Dead list is for jobs which have been retried too many times and are no longer viable.\n\nA job_run is represented in a queue by its id.\n\nA job_run flows through the queues in this manner:\n\n\n```text\n Time=0: JobRun does not exist yet, lists are empty\n\n Waiting Pending Scheduled Dead\n\n ---------------------------------\n Time=1: JobRun is enqueued\n\n Waiting Pending Scheduled Dead\n JobRun#1\n\n ---------------------------------\n Time=2: JobRun begins. JobRun is moved to pending and executed\n\n Waiting Pending Scheduled Dead\n JobRun#1\n\n ---------------------------------\n Time=3: JobRuns are Enqueued.\n\n Waiting Pending Scheduled Dead\n JobRun#2 JobRun#1\n JobRun#3\n\n ---------------------------------\n Time=4: JobRun succeeds, next job_run begins.\n\n Waiting Pending Scheduled Dead\n JobRun#3 JobRun#2\n\n ---------------------------------\n Time=5: JobRun fails and is scheduled for later, next job_run begins.\n\n Waiting Pending Scheduled Dead\n JobRun#3 t=7:JobRun#2\n\n ---------------------------------\n Time=6: JobRun succeeds. Nothing is executing.\n\n Waiting Pending Scheduled Dead\n t=7:JobRun#2\n\n ---------------------------------\n Time=7: Scheduled job_run is due and is moved to waiting. Nothing is executing.\n\n Waiting Pending Scheduled Dead\n JobRun#2\n\n ---------------------------------\n Time=8: JobRun begins executing (for the second time).\n\n Waiting Pending Scheduled Dead\n JobRun#2\n\n ---------------------------------\n Time=9: JobRun finished successfully. No more job_runs present.\n\n Waiting Pending Scheduled Dead\n\n```\n","summary":"

A named Queue.

","constructors":[{"html_id":"new(name:String)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"}],"args_string":"(name : String)","args_html":"(name : String)","location":{"filename":"src/mosquito/queue.cr","line_number":84,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:self):Bool-instance-method","name":"==","doc":"Returns `true` if this reference is the same as *other*. Invokes `same?`.","summary":"

Returns true if this reference is the same as other.

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : Bool","args_html":"(other : self) : Bool","location":{"filename":"src/mosquito/queue.cr","line_number":142,"url":null},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"Bool","visibility":"Public","body":"name == other.name"}},{"html_id":"backend:Mosquito::Backend-instance-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":80,"url":null},"def":{"name":"backend","return_type":"Mosquito::Backend","visibility":"Public","body":"@backend"}},{"html_id":"backend=(backend:Mosquito::Backend)-instance-method","name":"backend=","abstract":false,"args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend"}],"args_string":"(backend : Mosquito::Backend)","args_html":"(backend : Mosquito::Backend)","location":{"filename":"src/mosquito/queue.cr","line_number":80,"url":null},"def":{"name":"backend=","args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend"}],"visibility":"Public","body":"@backend = backend"}},{"html_id":"banish(job_run:JobRun)-instance-method","name":"banish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/queue.cr","line_number":128,"url":null},"def":{"name":"banish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"backend.finish(job_run)\nbackend.terminate(job_run)\n"}},{"html_id":"config_key:String-instance-method","name":"config_key","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":78,"url":null},"def":{"name":"config_key","visibility":"Public","body":"@config_key"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":104,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"if empty?\n return\nend\nif job_run = backend.dequeue\n job_run\nelse\n @empty = true\n nil\nend\n"}},{"html_id":"dequeue_scheduled:Array(JobRun)-instance-method","name":"dequeue_scheduled","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":120,"url":null},"def":{"name":"dequeue_scheduled","return_type":"Array(JobRun)","visibility":"Public","body":"backend.deschedule"}},{"html_id":"empty?:Bool-instance-method","name":"empty?","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":79,"url":null},"def":{"name":"empty?","return_type":"Bool","visibility":"Public","body":"@empty"}},{"html_id":"enqueue(job_run:JobRun,ininterval:Time::Span):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"interval","external_name":"in","restriction":"Time::Span"}],"args_string":"(job_run : JobRun, in interval : Time::Span) : JobRun","args_html":"(job_run : JobRun, in interval : Time::Span) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":95,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"interval","external_name":"in","restriction":"Time::Span"}],"return_type":"JobRun","visibility":"Public","body":"enqueue(job_run, at: interval.from_now)"}},{"html_id":"enqueue(job_run:JobRun,atexecute_time:Time):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execute_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at execute_time : Time) : JobRun","args_html":"(job_run : JobRun, at execute_time : Time) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":99,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execute_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"Log.trace do\n \"Enqueuing #{job_run} at #{execute_time}\"\nend\nbackend.schedule(job_run, execute_time)\n"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":90,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"Log.trace do\n \"Enqueuing #{job_run} for immediate execution\"\nend\nbackend.enqueue(job_run)\n"}},{"html_id":"flush-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":146,"url":null},"def":{"name":"flush","visibility":"Public","body":"backend.flush"}},{"html_id":"forget(job_run:JobRun)-instance-method","name":"forget","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/queue.cr","line_number":124,"url":null},"def":{"name":"forget","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"backend.finish(job_run)"}},{"html_id":"length:Int64-instance-method","name":"length","summary":"

DEPRECATED see #size

","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":138,"url":null},"def":{"name":"length","return_type":"Int64","visibility":"Public","body":"backend.size"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":78,"url":null},"def":{"name":"name","visibility":"Public","body":"@name"}},{"html_id":"reschedule(job_run:JobRun,execution_time)-instance-method","name":"reschedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execution_time","external_name":"execution_time","restriction":""}],"args_string":"(job_run : JobRun, execution_time)","args_html":"(job_run : JobRun, execution_time)","location":{"filename":"src/mosquito/queue.cr","line_number":115,"url":null},"def":{"name":"reschedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execution_time","external_name":"execution_time","restriction":""}],"visibility":"Public","body":"backend.finish(job_run)\nenqueue(job_run, at: execution_time)\n"}},{"html_id":"size:Int64-instance-method","name":"size","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":133,"url":null},"def":{"name":"size","return_type":"Int64","visibility":"Public","body":"backend.size"}}]},{"html_id":"mosquito/Mosquito/QueuedJob","path":"Mosquito/QueuedJob.html","kind":"class","full_name":"Mosquito::QueuedJob","name":"QueuedJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/queued_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"enqueue(indelay_interval:Time::Span):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"delay_interval","external_name":"in","restriction":"Time::Span"}],"args_string":"(in delay_interval : Time::Span) : JobRun","args_html":"(in delay_interval : Time::Span) : JobRun","location":{"filename":"src/mosquito/queued_job.cr","line_number":128,"url":null},"def":{"name":"enqueue","args":[{"name":"delay_interval","external_name":"in","restriction":"Time::Span"}],"return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run, in: delay_interval)\nend"}},{"html_id":"enqueue(atexecute_time:Time):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"execute_time","external_name":"at","restriction":"Time"}],"args_string":"(at execute_time : Time) : JobRun","args_html":"(at execute_time : Time) : JobRun","location":{"filename":"src/mosquito/queued_job.cr","line_number":135,"url":null},"def":{"name":"enqueue","args":[{"name":"execute_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run, at: execute_time)\nend"}},{"html_id":"enqueue:JobRun-instance-method","name":"enqueue","abstract":false,"location":{"filename":"src/mosquito/queued_job.cr","line_number":121,"url":null},"def":{"name":"enqueue","return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run)\nend"}}]},{"html_id":"mosquito/Mosquito/RateLimiter","path":"Mosquito/RateLimiter.html","kind":"module","full_name":"Mosquito::RateLimiter","name":"RateLimiter","abstract":false,"locations":[{"filename":"src/mosquito/rate_limiter.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"increment_run_count:Nil-instance-method","name":"increment_run_count","doc":"Increments the run counter.","summary":"

Increments the run counter.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":134,"url":null},"def":{"name":"increment_run_count","return_type":"Nil","visibility":"Public","body":"metadata.increment(\"run_count\", by: increment_run_count_by)"}},{"html_id":"increment_run_count_by:Int32-instance-method","name":"increment_run_count_by","doc":"How much the run counter should be incremented by.\nImplemented as a dynamic method so that it can easily be calculated by\nsome other metric, eg api calls to a third party library.","summary":"

How much the run counter should be incremented by.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":141,"url":null},"def":{"name":"increment_run_count_by","return_type":"Int32","visibility":"Public","body":"@@rate_limit_increment"}},{"html_id":"maxed_rate_for_window?:Bool-instance-method","name":"maxed_rate_for_window?","doc":"Has the run count exceeded the ceiling for the current window?","summary":"

Has the run count exceeded the ceiling for the current window?

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":97,"url":null},"def":{"name":"maxed_rate_for_window?","return_type":"Bool","visibility":"Public","body":"run_count = metadata[\"run_count\"]?.try(&.to_i)\nrun_count || (run_count = 0)\nrun_count >= @@rate_limit_ceiling\n"}},{"html_id":"metadata:Metadata-instance-method","name":"metadata","doc":"Storage hash for rate limit data.","summary":"

Storage hash for rate limit data.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":84,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"@rl_metadata || (@rl_metadata = self.class.metadata)"}},{"html_id":"rate_limited?:Bool-instance-method","name":"rate_limited?","doc":"Should this job be cancelled?\nIf not, update the rate limit metadata.","summary":"

Should this job be cancelled? If not, update the rate limit metadata.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":90,"url":null},"def":{"name":"rate_limited?","return_type":"Bool","visibility":"Public","body":"if @@rate_limit_ceiling < 0\n return false\nend\nif maxed_rate_for_window?\n return true\nend\nfalse\n"}},{"html_id":"reschedule_interval(retry_count:Int32):Time::Span-instance-method","name":"reschedule_interval","doc":"Configure the reschedule interval so that the job_run is not run again until it\nshould be allowed through the rate limiter.","summary":"

Configure the reschedule interval so that the job_run is not run again until it should be allowed through the rate limiter.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Time::Span","args_html":"(retry_count : Int32) : Time::Span","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":147,"url":null},"def":{"name":"reschedule_interval","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Time::Span","visibility":"Public","body":"if rate_limited? && (window_expiration = window_expires_at)\n next_window = window_expiration - Time.utc\n log(\"Rate limited: will run again in #{next_window}\")\n next_window\nelse\n super(retry_count)\nend"}},{"html_id":"rescheduleable?(retry_count:Int32):Bool-instance-method","name":"rescheduleable?","doc":"Configure the rescheduler to always retry if a job is rate limited.","summary":"

Configure the rescheduler to always retry if a job is rate limited.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Bool","args_html":"(retry_count : Int32) : Bool","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":158,"url":null},"def":{"name":"rescheduleable?","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if rate_limited?\n true\nelse\n super(retry_count)\nend"}},{"html_id":"update_window_start:Nil-instance-method","name":"update_window_start","doc":"Resets the run count and logs the start of window.","summary":"

Resets the run count and logs the start of window.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":124,"url":null},"def":{"name":"update_window_start","return_type":"Nil","visibility":"Public","body":"started_window = window_start || Time::UNIX_EPOCH\nnow = Time.utc\nif (now - started_window) > @@rate_limit_interval\n metadata[\"window_start\"] = now.to_unix.to_s\n metadata[\"run_count\"] = \"0\"\nend\n"}},{"html_id":"window_expires_at:Time|Nil-instance-method","name":"window_expires_at","doc":"When does the current rate limit window expire?\nReturns nil if the window is already expired.","summary":"

When does the current rate limit window expire? Returns nil if the window is already expired.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":112,"url":null},"def":{"name":"window_expires_at","return_type":"Time | ::Nil","visibility":"Public","body":"if started_window = window_start\nelse\n return nil\nend\nexpiration_time = started_window + @@rate_limit_interval\nif expiration_time < Time.utc\n nil\nelse\n expiration_time\nend\n"}},{"html_id":"window_start:Time|Nil-instance-method","name":"window_start","doc":"Calculates the start of the rate limit window.","summary":"

Calculates the start of the rate limit window.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":104,"url":null},"def":{"name":"window_start","return_type":"Time | ::Nil","visibility":"Public","body":"if start_time = metadata[\"window_start\"]?.try(&.to_i)\n Time.unix(start_time)\nend"}}],"types":[{"html_id":"mosquito/Mosquito/RateLimiter/ClassMethods","path":"Mosquito/RateLimiter/ClassMethods.html","kind":"module","full_name":"Mosquito::RateLimiter::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/mosquito/rate_limiter.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/RateLimiter","kind":"module","full_name":"Mosquito::RateLimiter","name":"RateLimiter"},"instance_methods":[{"html_id":"metadata:Metadata-instance-method","name":"metadata","doc":"Provides an instance of the metadata store used to track rate limit\nstats.","summary":"

Provides an instance of the metadata store used to track rate limit stats.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":53,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"Metadata.new(@@rate_limit_key)"}},{"html_id":"rate_limit_key-instance-method","name":"rate_limit_key","doc":"Resolves the key used to index the metadata store for this test.","summary":"

Resolves the key used to index the metadata store for this test.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":58,"url":null},"def":{"name":"rate_limit_key","visibility":"Public","body":"@@rate_limit_key"}},{"html_id":"rate_limit_stats:NamedTuple-instance-method","name":"rate_limit_stats","doc":"Statistics about the rate limiter, including both the configuration\nparameters and the run counts.","summary":"

Statistics about the rate limiter, including both the configuration parameters and the run counts.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":26,"url":null},"def":{"name":"rate_limit_stats","return_type":"NamedTuple","visibility":"Public","body":"meta = metadata\nwindow_start = if window_start_ = meta[\"window_start\"]?\n Time.unix(window_start_.to_i)\nelse\n Time::UNIX_EPOCH\nend\nrun_count = if run_count_ = meta[\"run_count\"]?\n run_count_.to_i\nelse\n 0\nend\n{interval: @@rate_limit_interval, key: @@rate_limit_key, increment: @@rate_limit_increment, limit: @@rate_limit_ceiling, window_start: window_start, run_count: run_count}\n"}},{"html_id":"throttle(*,limit:Int32=1,per:Time::Span=1.second,increment=1,key=self.name.underscore)-instance-method","name":"throttle","doc":"Configures rate limiting for this job.\n\n`limit` and `per` are used to control the run count and the window\nduration. Defaults to a limit of 1 run per second.\n\n`increment` is used to indicate how many \"hits\" against a single job is\nworth. Defaults to 1.\n\n`key` is used to combine rate limiting functions across multiple jobs.","summary":"

Configures rate limiting for this job.

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"limit","default_value":"1","external_name":"limit","restriction":"Int32"},{"name":"per","default_value":"1.second","external_name":"per","restriction":"Time::Span"},{"name":"increment","default_value":"1","external_name":"increment","restriction":""},{"name":"key","default_value":"self.name.underscore","external_name":"key","restriction":""}],"args_string":"(*, limit : Int32 = 1, per : Time::Span = 1.second, increment = 1, key = self.name.underscore)","args_html":"(*, limit : Int32 = 1, per : Time::Span = 1.second, increment = 1, key = self.name.underscore)","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":12,"url":null},"def":{"name":"throttle","args":[{"name":"","external_name":"","restriction":""},{"name":"limit","default_value":"1","external_name":"limit","restriction":"Int32"},{"name":"per","default_value":"1.second","external_name":"per","restriction":"Time::Span"},{"name":"increment","default_value":"1","external_name":"increment","restriction":""},{"name":"key","default_value":"self.name.underscore","external_name":"key","restriction":""}],"splat_index":0,"visibility":"Public","body":"@@rate_limit_ceiling = limit\n@@rate_limit_interval = per\n@@rate_limit_key = Mosquito.backend.build_key(\"rate_limit\", key)\n@@rate_limit_increment = increment\n"}}]}]},{"html_id":"mosquito/Mosquito/RedisBackend","path":"Mosquito/RedisBackend.html","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend","abstract":false,"superclass":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"ancestors":[{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/redis_backend.cr","line_number":35,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"LIST_OF_QUEUES_KEY","name":"LIST_OF_QUEUES_KEY","value":"\"queues\""},{"id":"Log","name":"Log","value":"::Log.for(self)"}],"extended_modules":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"delete(key:String,inttl:Int32=0):Nil-class-method","name":"delete","doc":"Overload required for crystal 1.1-1.2.\nSoft Deprecation isn't shown, but it's here so this will get cleaned up at some point.\n@[Deprecated(\"To be removed when support for 1.1 is dropped. See RedisBackend.delete(String, Int64).\")]","summary":"

Overload required for crystal 1.1-1.2.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int32"}],"args_string":"(key : String, in ttl : Int32 = 0) : Nil","args_html":"(key : String, in ttl : Int32 = 0) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":86,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int32"}],"return_type":"Nil","visibility":"Public","body":"delete(key, in: ttl.to_i64)"}},{"html_id":"delete(key:String,inttl:Int64=0):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":90,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":"if (ttl > 0)\n redis.expire(key, ttl)\nelse\n redis.del(key)\nend"}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":98,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":"delete(key, ttl.to_i)"}},{"html_id":"expires_in(key:String):Int64-class-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":119,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"redis.ttl(key)"}},{"html_id":"flush:Nil-class-method","name":"flush","doc":"is this even a good idea?","summary":"

is this even a good idea?

","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":140,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.flushdb"}},{"html_id":"get(key:String,field:String):String|Nil-class-method","name":"get","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":102,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":"(redis.hget(key, field)).as?(String)"}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":115,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":"(redis.hincrby(key, field, value)).as(Int64)"}},{"html_id":"increment(key:String,field:String):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":111,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"increment(key, field, by: 1)"}},{"html_id":"list_queues:Array(String)-class-method","name":"list_queues","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":123,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"key = build_key(LIST_OF_QUEUES_KEY)\nlist_queues = (redis.zrange(key, 0, -1)).as(Array)\nif list_queues.any?\nelse\n return [] of String\nend\nlist_queues.compact_map() do |__arg1|\n __arg1.as(String)\nend\n"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":132,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":"runner_prefix = \"mosquito:runners:\"\n(Redis.instance.keys(\"#{runner_prefix}*\")).map() do |__arg2|\n __arg2.as(String)\nend.map(&.sub(runner_prefix, \"\"))\n"}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-class-method","name":"lock?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/redis_backend.cr","line_number":144,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":"response = redis.set(key, value, ex: ttl.to_i, nx: true)\nresponse == \"OK\"\n"}},{"html_id":"redis-class-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":56,"url":null},"def":{"name":"redis","visibility":"Public","body":"load_scripts = @@connection.nil?\nconnection = @@connection || (@@connection = ::Redis::Client.new(URI.parse(Mosquito.configuration.redis_url.to_s)))\nif load_scripts\n Scripts.load(connection)\nend\nconnection\n"}},{"html_id":"remove_matching_key(*,keys=[]ofString,args=[]ofString,loadscripts=true)-class-method","name":"remove_matching_key","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"keys","default_value":"[] of String","external_name":"keys","restriction":""},{"name":"args","default_value":"[] of String","external_name":"args","restriction":""},{"name":"loadscripts","default_value":"true","external_name":"loadscripts","restriction":""}],"args_string":"(*, keys = [] of String, args = [] of String, loadscripts = true)","args_html":"(*, keys = [] of String, args = [] of String, loadscripts = true)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":40,"url":null},"def":{"name":"remove_matching_key","args":[{"name":"","external_name":"","restriction":""},{"name":"keys","default_value":"[] of String","external_name":"keys","restriction":""},{"name":"args","default_value":"[] of String","external_name":"args","restriction":""},{"name":"loadscripts","default_value":"true","external_name":"loadscripts","restriction":""}],"splat_index":0,"visibility":"Public","body":"begin\n script = \" if redis.call(\\\"get\\\",KEYS[1]) == ARGV[1] then\\n return redis.call(\\\"del\\\",KEYS[1])\\n else\\n return 0\\n end\"\n digest = Scripts.remove_matching_key\n redis.evalsha(digest, keys: keys, args: args)\nrescue exception : Redis::Error\n if exception.message.try(&.starts_with?(\"NOSCRIPT\"))\n else\n raise(exception)\n end\n if loadscripts\n else\n raise(exception)\n end\n (Log.for(\"remove_matching_key\")).warn do\n \"Redis Scripts have gone missing, reloading\"\n end\n Scripts.load(redis)\n remove_matching_key(keys: keys, args: args, loadscripts: false)\nend"}},{"html_id":"retrieve(key:String):Hash(String,String)-class-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":78,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"result = ((redis.hgetall(key)).as(Array)).map(&.to_s)\n(result.in_groups_of(2, \"\")).to_h\n"}},{"html_id":"set(key:String,field:String,value:String):String-class-method","name":"set","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/redis_backend.cr","line_number":106,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":"redis.hset(key, field, value)\nvalue\n"}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-class-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":74,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":"redis.hset(key, value)"}},{"html_id":"unlock(key:String,value:String):Nil-class-method","name":"unlock","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":149,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":"remove_matching_key(keys: [key], args: [value])"}}],"constructors":[{"html_id":"new(name:String|Symbol)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"args_string":"(name : String | Symbol)","args_html":"(name : String | Symbol)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":70,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":181,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"if id = redis.lmove(waiting_q, pending_q, :right, :left)\n JobRun.retrieve(id.to_s)\nend"}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":158,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":"time = Time.utc\noverdue_job_runs = (redis.zrangebyscore(scheduled_q, \"0\", time.to_unix_ms.to_s)).as(Array)\nif overdue_job_runs.any?\nelse\n return [] of JobRun\nend\noverdue_job_runs.compact_map do |job_run_id|\n redis.zrem(scheduled_q, job_run_id.to_s)\n JobRun.retrieve(job_run_id.as(String))\nend\n"}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":"key = dead_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg6|\n __arg6.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg7|\n __arg7.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for dead\")\n end\n end\nend\n"}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":"key = pending_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg4|\n __arg4.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg5|\n __arg5.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for pending\")\n end\n end\nend\n"}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":"key = scheduled_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg2|\n __arg2.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg3|\n __arg3.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for scheduled\")\n end\n end\nend\n"}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":"key = waiting_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg0|\n __arg0.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg1|\n __arg1.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for waiting\")\n end\n end\nend\n"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/redis_backend.cr","line_number":170,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"redis.pipeline do |pipe|\n pipe.lpush(waiting_q, job_run.id)\n pipe.zadd(build_key(LIST_OF_QUEUES_KEY), Time.utc.to_unix.to_s, name)\nend\njob_run\n"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":187,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"redis.lrem(pending_q, 0, job_run.id)"}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":195,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.del(waiting_q, pending_q, scheduled_q, dead_q)"}},{"html_id":"redis-instance-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":66,"url":null},"def":{"name":"redis","visibility":"Public","body":"self.class.redis"}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/redis_backend.cr","line_number":153,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"redis.zadd(scheduled_q, scheduled_time.to_unix_ms.to_s, job_run.id)\njob_run\n"}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":233,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":"(redis.zscore(scheduled_q, job_run.id)).as?(String)"}},{"html_id":"size(include_dead=true):Int64-instance-method","name":"size","abstract":false,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":""}],"args_string":"(include_dead = true) : Int64","args_html":"(include_dead = true) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":204,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":""}],"return_type":"Int64","visibility":"Public","body":"queues = [waiting_q, pending_q]\nif include_dead\n queues << dead_q\nend\nqueue_size = queues.map do |key|\n (redis.llen(key)).as(Int64)\nend.reduce do |sum, i|\n sum + i\nend\nscheduled_size = redis.zcount(scheduled_q, \"0\", \"+inf\")\nqueue_size + (scheduled_size.as(Int64))\n"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":191,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"redis.lpush(dead_q, job_run.id)"}}]},{"html_id":"mosquito/Mosquito/Runnable","path":"Mosquito/Runnable.html","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable","abstract":false,"locations":[{"filename":"src/mosquito/runnable.cr","line_number":64,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Executor","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor"},{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"Runnable implements a general purpose spawn/loop which carries a state\nenum.\n\n## Managing a Runnable\n\nThe primary purpose of Runnable is to cleanly abstract the details of\nspawning a thread, running a loop, and shutting down when asked.\n\nA service which manages a Runnable might look like this:\n\n```crystal\nrunnable = MyRunnable.new\n\n# This will spawn and return immediately.\nrunnable.start\n\nputs runnable.state # => State::Working\n\n# Some time later...\nshould_be_stopped = runnable.stop has_stopped =\nshould_be_stopped.receive\n```\n\n\n## Implementing a Runnable\n\nA runnable implementation needs to implement only two methods: #each_run\nand #runnable_name. In addition, pre_run and post_run are available for\nsetup and teardown.\n\nRunnable state is managed automatically through startup and shutdown, but\nwithin each_run it can be manually altered with `#state=`.\n\n### Example\n\n```crystal\nclass MyRunnable\n include Mosquito::Runnable\n\n # Optional\n def pre_run\n puts \"my runnable is starting\"\n end\n\n def each_run\n puts \"my runnable is running\"\n end\n\n # Optional\n def post_run\n puts \"my runnable has stopped\"\n end\n\n def runnable_name\n \"MyRunnable\"\n end\nend\n```\n\nImplementation details about what work should be done in the spawned fiber\nare placed in #each_run.\n","summary":"

Runnable implements a general purpose spawn/loop which carries a state enum.

","instance_methods":[{"html_id":"dead?:Bool-instance-method","name":"dead?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":106,"url":null},"def":{"name":"dead?","return_type":"Bool","visibility":"Public","body":"if fiber_ = fiber\n fiber_.dead?\nelse\n false\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"Implementation of what this Runnable should do on each cycle.\n\nTake care that @state is #running? at the end of the method\nunless it is finished and should exit.","summary":"

Implementation of what this Runnable should do on each cycle.

","abstract":true,"location":{"filename":"src/mosquito/runnable.cr","line_number":168,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"fiber:Fiber|Nil-instance-method","name":"fiber","doc":"After #run has been called this holds a reference to the Fiber\nwhich is used to check that the fiber is still running.","summary":"

After #run has been called this holds a reference to the Fiber which is used to check that the fiber is still running.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":96,"url":null},"def":{"name":"fiber","return_type":"Fiber | ::Nil","visibility":"Public","body":"@fiber"}},{"html_id":"my_name:String-instance-method","name":"my_name","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":98,"url":null},"def":{"name":"my_name","return_type":"String","visibility":"Public","body":"if (value = @my_name).nil?\n @my_name = (\"#{self.class.name.underscore.gsub(\"::\", \".\")}.#{self.object_id}\")\nelse\n value\nend"}},{"html_id":"post_run:Nil-instance-method","name":"post_run","doc":"Available to hook any teardown logic after the run loop.","summary":"

Available to hook any teardown logic after the run loop.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":174,"url":null},"def":{"name":"post_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"pre_run:Nil-instance-method","name":"pre_run","doc":"Available to hook a one time setup before the run loop.","summary":"

Available to hook a one time setup before the run loop.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":171,"url":null},"def":{"name":"pre_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"run-instance-method","name":"run","doc":"Start the Runnable, and capture the fiber to a property.\n\nThe spawned fiber will not return as long as state.running?.\n\nState can be altered internally or externally to cause it to exit\nbut the cleanest way to do that is to call #stop.","summary":"

Start the Runnable, and capture the fiber to a property.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":120,"url":null},"def":{"name":"run","visibility":"Public","body":"@fiber = spawn(name: my_name) do\n log = Log.for(my_name)\n log.info do\n runnable_name + \" is starting\"\n end\n self.state = State::Working\n pre_run\n while state.running?\n each_run\n end\n post_run\n self.state = State::Finished\nend"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":true,"location":{"filename":"src/mosquito/runnable.cr","line_number":162,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":""}},{"html_id":"state:State-instance-method","name":"state","doc":"Tracks the state of this runnable.\n\nInitially it will be `State::Starting`. After `#run` is called it will\nbe `State::Working`.\n\nWhen `#stop` is called it will be `State::Stopping`. After `#run` finishes,\nit will be `State::Finished`.\n\nIt is not necessary to set this manually, but it's available to an implementation\nif needed. See `Mosquito::Runners::Executor#state=` (source code) for an example.","summary":"

Tracks the state of this runnable.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":92,"url":null},"def":{"name":"state","return_type":"State","visibility":"Public","body":"@state"}},{"html_id":"stop:Channel(Bool)-instance-method","name":"stop","doc":"Request that the next time the run loop cycles it should exit instead.\nThe runnable doesn't exit immediately so #stop returns a notification\nchannel.\n\n#stop spawns a fiber which monitors the state and sends a bool in two\ncircumstances. It will stop waiting for the spawn to exit at 25 seconds.\nIf the spawn has actually stopped the notification channel will broadcast\na true, otherwise false.","summary":"

Request that the next time the run loop cycles it should exit instead.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":145,"url":null},"def":{"name":"stop","return_type":"Channel(Bool)","visibility":"Public","body":"if state.running?\n self.state = State::Stopping\nend\nnotifier = Channel(Bool).new\nspawn do\n start = Time.utc\n while state.stopping? && (Time.utc - start) < 25.seconds\n Fiber.yield\n end\n notifier.send(state.finished?)\n Log.info do\n runnable_name + \" has stopped\"\n end\nend\nnotifier\n"}}],"types":[{"html_id":"mosquito/Mosquito/Runnable/State","path":"Mosquito/Runnable/State.html","kind":"enum","full_name":"Mosquito::Runnable::State","name":"State","abstract":false,"ancestors":[{"html_id":"mosquito/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"mosquito/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runnable.cr","line_number":65,"url":null}],"repository_name":"mosquito","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Starting","name":"Starting","value":"0"},{"id":"Working","name":"Working","value":"1"},{"id":"Idle","name":"Idle","value":"2"},{"id":"Stopping","name":"Stopping","value":"3"},{"id":"Finished","name":"Finished","value":"4"}],"namespace":{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},"instance_methods":[{"html_id":"finished?-instance-method","name":"finished?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":70,"url":null},"def":{"name":"finished?","visibility":"Public","body":"self == Finished"}},{"html_id":"idle?-instance-method","name":"idle?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":68,"url":null},"def":{"name":"idle?","visibility":"Public","body":"self == Idle"}},{"html_id":"running?-instance-method","name":"running?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":72,"url":null},"def":{"name":"running?","visibility":"Public","body":"(starting? || working?) || idle?"}},{"html_id":"started?-instance-method","name":"started?","doc":"ie, not starting","summary":"

ie, not starting

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":77,"url":null},"def":{"name":"started?","visibility":"Public","body":"working? || idle?"}},{"html_id":"starting?-instance-method","name":"starting?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":66,"url":null},"def":{"name":"starting?","visibility":"Public","body":"self == Starting"}},{"html_id":"stopping?-instance-method","name":"stopping?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":69,"url":null},"def":{"name":"stopping?","visibility":"Public","body":"self == Stopping"}},{"html_id":"working?-instance-method","name":"working?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":67,"url":null},"def":{"name":"working?","visibility":"Public","body":"self == Working"}}]}]},{"html_id":"mosquito/Mosquito/Runner","path":"Mosquito/Runner.html","kind":"class","full_name":"Mosquito::Runner","name":"Runner","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runner.cr","line_number":34,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"This singleton class serves as a shorthand for starting and managing an Overseer.\n\nA minimal usage of Mosquito::Runner is:\n\n```\nrequire \"mosquito\"\n\n# When the process receives sigint, it'll notify the overseer to shut down gracefully.\ntrap(\"INT\") do\n Mosquito::Runner.stop(wait: true)\nend\n\n# Starts the overseer, and holds the thread captive.\nMosquito::Runner.start\n```\n\nIf for some reason you want to manage an overseer or group of overseers yourself, Mosquito::Runner can be omitted entirely:\n\n```crystal\nrequire \"mosquito\"\n\nmosquito = Mosquito::Overseer.new\n\n# Spawns a mosquito managed fiber and returns immediately\nmosquito.run\n\ntrap \"INT\" do\n mosquito.stop.receive\nend\n```","summary":"

This singleton class serves as a shorthand for starting and managing an Overseer.

","class_methods":[{"html_id":"start(spin=true)-class-method","name":"start","doc":"Start the mosquito runner.\n\nIf spin = true (default) the function will not return until the runner is\nshut down. Otherwise it will return immediately.\n","summary":"

Start the mosquito runner.

","abstract":false,"args":[{"name":"spin","default_value":"true","external_name":"spin","restriction":""}],"args_string":"(spin = true)","args_html":"(spin = true)","location":{"filename":"src/mosquito/runner.cr","line_number":42,"url":null},"def":{"name":"start","args":[{"name":"spin","default_value":"true","external_name":"spin","restriction":""}],"visibility":"Public","body":"Log.notice do\n \"Mosquito is buzzing...\"\nend\ninstance.run\nwhile spin && keep_running\n sleep(1)\nend\n"}},{"html_id":"stop(wait=false)-class-method","name":"stop","doc":"Request the mosquito runner stop. The runner will not abort the current job\nbut it will not start any new jobs.\n\nSee `Mosquito::Runnable#stop`.","summary":"

Request the mosquito runner stop.

","abstract":false,"args":[{"name":"wait","default_value":"false","external_name":"wait","restriction":""}],"args_string":"(wait = false)","args_html":"(wait = false)","location":{"filename":"src/mosquito/runner.cr","line_number":60,"url":null},"def":{"name":"stop","args":[{"name":"wait","default_value":"false","external_name":"wait","restriction":""}],"visibility":"Public","body":"Log.notice do\n \"Mosquito is shutting down...\"\nend\nfinished_notifier = instance.stop\nif wait\n finished_notifier.receive\nend\n"}}]},{"html_id":"mosquito/Mosquito/Runners","path":"Mosquito/Runners.html","kind":"module","full_name":"Mosquito::Runners","name":"Runners","abstract":false,"locations":[{"filename":"src/mosquito/runners/coordinator.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/executor.cr","line_number":4,"url":null},{"filename":"src/mosquito/runners/idle_wait.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/overseer.cr","line_number":6,"url":null},{"filename":"src/mosquito/runners/queue_list.cr","line_number":5,"url":null},{"filename":"src/mosquito/runners/run_at_most.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"types":[{"html_id":"mosquito/Mosquito/Runners/Coordinator","path":"Mosquito/Runners/Coordinator.html","kind":"class","full_name":"Mosquito::Runners::Coordinator","name":"Coordinator","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/coordinator.cr","line_number":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"LockTTL","name":"LockTTL","value":"10.seconds"},{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"primer? loader? _scheduler_","summary":"

primer? loader? scheduler

","constructors":[{"html_id":"new(queue_list:Mosquito::Runners::QueueList)-class-method","name":"new","abstract":false,"args":[{"name":"queue_list","external_name":"queue_list","restriction":"::Mosquito::Runners::QueueList"}],"args_string":"(queue_list : Mosquito::Runners::QueueList)","args_html":"(queue_list : Mosquito::Runners::QueueList)","location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"queue_list","external_name":"queue_list","restriction":"::Mosquito::Runners::QueueList"}],"visibility":"Public","body":"_ = allocate\n_.initialize(queue_list)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"enqueue_delayed_jobs-instance-method","name":"enqueue_delayed_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":67,"url":null},"def":{"name":"enqueue_delayed_jobs","visibility":"Public","body":"queue_list.each do |q|\n overdue_jobs = q.dequeue_scheduled\n if overdue_jobs.any?\n else\n next\n end\n (Log.for(\"enqueue_delayed_jobs\")).info do\n \"#{overdue_jobs.size} delayed jobs ready in #{q.name}\"\n end\n overdue_jobs.each do |job_run|\n q.enqueue(job_run)\n end\nend"}},{"html_id":"enqueue_periodic_jobs-instance-method","name":"enqueue_periodic_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":61,"url":null},"def":{"name":"enqueue_periodic_jobs","visibility":"Public","body":"Base.scheduled_job_runs.each do |scheduled_job_run|\n enqueued = scheduled_job_run.try_to_execute\nend"}},{"html_id":"instance_id:String-instance-method","name":"instance_id","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":8,"url":null},"def":{"name":"instance_id","return_type":"String","visibility":"Public","body":"@instance_id"}},{"html_id":"lock_key:String-instance-method","name":"lock_key","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":7,"url":null},"def":{"name":"lock_key","return_type":"String","visibility":"Public","body":"@lock_key"}},{"html_id":"only_if_coordinator(&):Nil-instance-method","name":"only_if_coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":29,"url":null},"def":{"name":"only_if_coordinator","yields":0,"block_arity":0,"return_type":"Nil","visibility":"Public","body":"duration = 0.seconds\nif Mosquito.configuration.run_cron_scheduler\n yield\n if @emitted_scheduling_deprecation_runtime_message\n else\n Log.warn do\n \"Scheduling coordinator / CRON Scheduler has been manually activated. This behavior is deprecated in favor of distributed locking. See https://github.com/mosquito-cr/mosquito/pull/108 \"\n end\n @emitted_scheduling_deprecation_runtime_message = true\n end\n return\nend\nif Mosquito.configuration.use_distributed_lock\nelse\n return\nend\nif Mosquito.backend.lock?(lock_key, instance_id, LockTTL)\n Log.trace do\n \"Coordinator lock acquired\"\n end\n duration = Time.measure do\n yield\n end\n Mosquito.backend.unlock(lock_key, instance_id)\n Log.trace do\n \"Coordinator lock released\"\n end\nend\nif duration > LockTTL\nelse\n return\nend\nLog.warn do\n \"Coordination activities took longer than LockTTL (#{duration} > #{LockTTL}) \"\nend\n"}},{"html_id":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":9,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":18,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"Coordinator<#{object_id}>\""}},{"html_id":"schedule:Nil-instance-method","name":"schedule","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":22,"url":null},"def":{"name":"schedule","return_type":"Nil","visibility":"Public","body":"only_if_coordinator do\n enqueue_periodic_jobs\n enqueue_delayed_jobs\nend"}}]},{"html_id":"mosquito/Mosquito/Runners/Executor","path":"Mosquito/Runners/Executor.html","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/executor.cr","line_number":23,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"The executor is the center of work in Mosquito, and it's is the demarcation\npoint between Mosquito framework and application code. Above the Executor\nis entirely Mosquito, and below it is application code.\n\nAn Executor is responsible for hydrating Job classes with deserialized\nparameters and calling `Mosquito::Job#run` on them. It measures the time it\ntakes to run a job and provides detailed log messages about the current\nstatus.\n\nAn executor is a `Mosquito::Runnable` and should be interacted with according to\nthe Runnable API.\n\nTo build an executor, provide a job input channel and an idle bell channel. These\nchannels can be shared between all available executors.\n\nThe executor will ring the idle bell when it is ready to accept work and then wait\nfor work to show up on the job pipeline. After the job is finished it will ring the\nbell again and wait for more work.","summary":"

The executor is the center of work in Mosquito, and it's is the demarcation point between Mosquito framework and application code.

","constructors":[{"html_id":"new(job_pipeline:Channel(Tuple(Mosquito::JobRun,Mosquito::Queue)),idle_bell:Channel(Bool))-class-method","name":"new","abstract":false,"args":[{"name":"job_pipeline","external_name":"job_pipeline","restriction":"::Channel(::Tuple(::Mosquito::JobRun, ::Mosquito::Queue))"},{"name":"idle_bell","external_name":"idle_bell","restriction":"::Channel(::Bool)"}],"args_string":"(job_pipeline : Channel(Tuple(Mosquito::JobRun, Mosquito::Queue)), idle_bell : Channel(Bool))","args_html":"(job_pipeline : Channel(Tuple(Mosquito::JobRun, Mosquito::Queue)), idle_bell : Channel(Bool))","location":{"filename":"src/mosquito/runners/executor.cr","line_number":51,"url":null},"def":{"name":"new","args":[{"name":"job_pipeline","external_name":"job_pipeline","restriction":"::Channel(::Tuple(::Mosquito::JobRun, ::Mosquito::Queue))"},{"name":"idle_bell","external_name":"idle_bell","restriction":"::Channel(::Bool)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(job_pipeline, idle_bell)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"execute(job_run:JobRun,from_queueq:Queue)-instance-method","name":"execute","doc":"Runs a job from a Queue.\n\nExecution time is measured and logged, and the job is either forgotten\nor, if it fails, rescheduled.","summary":"

Runs a job from a Queue.

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"q","external_name":"from_queue","restriction":"Queue"}],"args_string":"(job_run : JobRun, from_queue q : Queue)","args_html":"(job_run : JobRun, from_queue q : Queue)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":85,"url":null},"def":{"name":"execute","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"q","external_name":"from_queue","restriction":"Queue"}],"visibility":"Public","body":"log.info do\n \"#{\"Starting:\".colorize.magenta} #{job_run} from #{q.name}\"\nend\nduration = Time.measure do\n job_run.run\nend.total_seconds\nif job_run.succeeded?\n log.info do\n \"#{\"Success:\".colorize.green} #{job_run} finished and took #{time_with_units(duration)}\"\n end\n q.forget(job_run)\n job_run.delete(in: successful_job_ttl)\nelse\n message = String::Builder.new\n message << \"Failure: \".colorize.red\n message << job_run\n message << \" failed, taking \"\n message << (time_with_units(duration))\n message << \" and \"\n if job_run.rescheduleable?\n next_execution = Time.utc + job_run.reschedule_interval\n q.reschedule(job_run, next_execution)\n message << \"will run again\".colorize.cyan\n message << \" in \"\n message << job_run.reschedule_interval\n message << \" (at \"\n message << next_execution\n message << \")\"\n log.warn do\n message.to_s\n end\n else\n q.banish(job_run)\n job_run.delete(in: failed_job_ttl)\n message << \"cannot be rescheduled\".colorize.yellow\n log.error do\n message.to_s\n end\n end\nend\n"}},{"html_id":"failed_job_ttl:Int32-instance-method","name":"failed_job_ttl","doc":"How long a job config is persisted after failure","summary":"

How long a job config is persisted after failure

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":34,"url":null},"def":{"name":"failed_job_ttl","return_type":"Int32","visibility":"Public","body":"if (value = @failed_job_ttl).nil?\n @failed_job_ttl = (Mosquito.configuration.failed_job_ttl)\nelse\n value\nend"}},{"html_id":"failed_job_ttl=(failed_job_ttl:Int32)-instance-method","name":"failed_job_ttl=","doc":"How long a job config is persisted after failure","summary":"

How long a job config is persisted after failure

","abstract":false,"args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"args_string":"(failed_job_ttl : Int32)","args_html":"(failed_job_ttl : Int32)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":34,"url":null},"def":{"name":"failed_job_ttl=","args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@failed_job_ttl = failed_job_ttl"}},{"html_id":"idle_bell:Channel(Bool)-instance-method","name":"idle_bell","doc":"Used to notify the overseer that this executor is idle.","summary":"

Used to notify the overseer that this executor is idle.

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":40,"url":null},"def":{"name":"idle_bell","return_type":"Channel(Bool)","visibility":"Public","body":"@idle_bell"}},{"html_id":"job_pipeline:Channel(Tuple(JobRun,Queue))-instance-method","name":"job_pipeline","doc":"Where work is received from the overseer.","summary":"

Where work is received from the overseer.

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":37,"url":null},"def":{"name":"job_pipeline","return_type":"Channel(Tuple(JobRun, Queue))","visibility":"Public","body":"@job_pipeline"}},{"html_id":"log:::Log-instance-method","name":"log","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":28,"url":null},"def":{"name":"log","return_type":"::Log","visibility":"Public","body":"@log"}},{"html_id":"successful_job_ttl:Int32-instance-method","name":"successful_job_ttl","doc":"How long a job config is persisted after success","summary":"

How long a job config is persisted after success

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":31,"url":null},"def":{"name":"successful_job_ttl","return_type":"Int32","visibility":"Public","body":"if (value = @successful_job_ttl).nil?\n @successful_job_ttl = (Mosquito.configuration.successful_job_ttl)\nelse\n value\nend"}},{"html_id":"successful_job_ttl=(successful_job_ttl:Int32)-instance-method","name":"successful_job_ttl=","doc":"How long a job config is persisted after success","summary":"

How long a job config is persisted after success

","abstract":false,"args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"args_string":"(successful_job_ttl : Int32)","args_html":"(successful_job_ttl : Int32)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":31,"url":null},"def":{"name":"successful_job_ttl=","args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@successful_job_ttl = successful_job_ttl"}}]},{"html_id":"mosquito/Mosquito/Runners/IdleWait","path":"Mosquito/Runners/IdleWait.html","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait","abstract":false,"locations":[{"filename":"src/mosquito/runners/idle_wait.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"instance_methods":[{"html_id":"with_idle_wait(idle_wait:Time::Span,&)-instance-method","name":"with_idle_wait","abstract":false,"args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"args_string":"(idle_wait : Time::Span, &)","args_html":"(idle_wait : Time::Span, &)","location":{"filename":"src/mosquito/runners/idle_wait.cr","line_number":3,"url":null},"def":{"name":"with_idle_wait","args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"yields":0,"block_arity":0,"visibility":"Public","body":"delta = Time.measure do\n yield\nend\nif delta < idle_wait\n sleep(idle_wait - delta)\nend\n"}}]},{"html_id":"mosquito/Mosquito/Runners/Overseer","path":"Mosquito/Runners/Overseer.html","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/overseer.cr","line_number":14,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"The Overseer is responsible for managing:\n- a `Coordinator`\n- an `Executor`\n- the `QueueList`\n- any idle state as configured\n\nAn overseer manages the loop that each thread or process runs.","summary":"

The Overseer is responsible for managing: - a Coordinator - an Executor - the QueueList - any idle state as configured

","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":39,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_executor:Executor-instance-method","name":"build_executor","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":52,"url":null},"def":{"name":"build_executor","return_type":"Executor","visibility":"Public","body":"Executor.new(work_handout, idle_notifier)"}},{"html_id":"check_for_deceased_runners:Nil-instance-method","name":"check_for_deceased_runners","doc":"If an executor dies, it's probably because a bug exists somewhere in Mosquito itself.\n\nWhen a job fails any exceptions are caught and logged. If a job causes something more\ncatastrophic we can try to recover by spawning a new executor.","summary":"

If an executor dies, it's probably because a bug exists somewhere in Mosquito itself.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":162,"url":null},"def":{"name":"check_for_deceased_runners","return_type":"Nil","visibility":"Public","body":"executors.select do |e|\n e.state.started?\nend.select(&.dead?).each do |dead_executor|\n Log.fatal do\n \" Executor #{dead_executor.runnable_name} died.\\n A new executor will be started.\"\n end\n executors.delete(dead_executor)\nend\n(executor_count - executors.size).times do\n executors << build_executor.tap(&.run)\nend\nif queue_list.dead?\n Log.fatal do\n \"QueueList has died, overseer will stop.\"\n end\n stop\nend\n"}},{"html_id":"coordinator:Mosquito::Runners::Coordinator-instance-method","name":"coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":23,"url":null},"def":{"name":"coordinator","visibility":"Public","body":"@coordinator"}},{"html_id":"dequeue_job?:Tuple(JobRun,Queue)|Nil-instance-method","name":"dequeue_job?","doc":"Weaknesses: This implementation sometimes starves queues because it doesn't\nround robin, prioritize queues, or anything else.","summary":"

Weaknesses: This implementation sometimes starves queues because it doesn't round robin, prioritize queues, or anything else.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":150,"url":null},"def":{"name":"dequeue_job?","return_type":"Tuple(JobRun, Queue) | ::Nil","visibility":"Public","body":"queue_list.each do |q|\n if job_run = q.dequeue\n return {job_run, q}\n end\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"The goal for the overseer is to:\n- Ensure that the coordinator gets run frequently to schedule delayed/periodic jobs.\n- Wait for an executor to be idle, and dequeue work if possible.\n- Monitor the executor pool for unexpected termination and respawn.","summary":"

The goal for the overseer is to: - Ensure that the coordinator gets run frequently to schedule delayed/periodic jobs.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":87,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":"coordinator.schedule\nif work_handout.closed? || idle_notifier.closed?\n Log.fatal do\n \"Executor communication channels closed, overseer will stop.\"\n end\n stop\n return\nend\nif queue_list.state.started?\nelse\n Log.debug do\n \"Waiting for the queue list to fetch possible queues\"\n end\n return\nend\nLog.trace do\n \"Waiting for an idle executor\"\nend\nall_executors_busy = true\nselect\nwhen @idle_notifier.receive\n Log.trace do\n \"Found an idle executor\"\n end\n all_executors_busy = false\nwhen timeout(idle_wait)\nend\n\ncase\nwhen all_executors_busy\n Log.trace do\n \"No idle executors\"\n end\nwhen next_job_run = dequeue_job?\n job_run, queue = next_job_run\n Log.trace do\n \"Dequeued job: #{job_run.id} #{queue.name}\"\n end\n work_handout.send(next_job_run)\nelse\n Log.trace do\n \"No job to dequeue\"\n end\n sleep\n spawn do\n @idle_notifier.send(true)\n end\nend\ncheck_for_deceased_runners\n"}},{"html_id":"executor_count:Int32-instance-method","name":"executor_count","doc":"The number of executors to start.","summary":"

The number of executors to start.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":33,"url":null},"def":{"name":"executor_count","visibility":"Public","body":"@executor_count"}},{"html_id":"executors:Array(Mosquito::Runners::Executor)-instance-method","name":"executors","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":22,"url":null},"def":{"name":"executors","visibility":"Public","body":"@executors"}},{"html_id":"idle_notifier:Channel(Bool)-instance-method","name":"idle_notifier","doc":"When an executor transitions to idle it will send a True here. The Overseer\nuses this as a signal to check the queues for more work.","summary":"

When an executor transitions to idle it will send a True here.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":30,"url":null},"def":{"name":"idle_notifier","visibility":"Public","body":"@idle_notifier"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":35,"url":null},"def":{"name":"idle_wait","return_type":"Time::Span","visibility":"Public","body":"if (value = @idle_wait).nil?\n @idle_wait = (Mosquito.configuration.idle_wait)\nelse\n value\nend"}},{"html_id":"post_run:Nil-instance-method","name":"post_run","doc":"Notify all subprocesses to stop, and wait until they do.","summary":"

Notify all subprocesses to stop, and wait until they do.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":73,"url":null},"def":{"name":"post_run","return_type":"Nil","visibility":"Public","body":"Log.info do\n \"Stopping #{@executors.size} executors.\"\nend\nstopped_notifiers = executors.map do |executor|\n executor.stop\nend\nwork_handout.close\nstopped_notifiers.each(&.receive)\nLog.info do\n \"All executors stopped.\"\nend\n"}},{"html_id":"pre_run:Nil-instance-method","name":"pre_run","doc":"Starts all the subprocesses.","summary":"

Starts all the subprocesses.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":66,"url":null},"def":{"name":"pre_run","return_type":"Nil","visibility":"Public","body":"Log.info do\n \"Starting #{@executors.size} executors.\"\nend\n@queue_list.run\n@executors.each(&.run)\n"}},{"html_id":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":56,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"Overseer<#{object_id}>\""}},{"html_id":"sleep-instance-method","name":"sleep","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":60,"url":null},"def":{"name":"sleep","visibility":"Public","body":"Log.trace do\n \"Going to sleep now for #{idle_wait}\"\nend\nsleep(idle_wait)\n"}},{"html_id":"work_handout:Channel({Mosquito::JobRun,Mosquito::Queue})-instance-method","name":"work_handout","doc":"The channel where job runs which have been dequeued are sent to executors.","summary":"

The channel where job runs which have been dequeued are sent to executors.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":26,"url":null},"def":{"name":"work_handout","visibility":"Public","body":"@work_handout"}}]},{"html_id":"mosquito/Mosquito/Runners/QueueList","path":"Mosquito/Runners/QueueList.html","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/queue_list.cr","line_number":7,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"QueueList handles searching the redis keyspace for named queues.","summary":"

QueueList handles searching the redis keyspace for named queues.

","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":16,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"each(*args,**options)-instance-method","name":"each","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":24,"url":null},"def":{"name":"each","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"@queues.shuffle.each(*args, **options)"}},{"html_id":"each(*args,**options,&)-instance-method","name":"each","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":24,"url":null},"def":{"name":"each","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"@queues.shuffle.each(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"Implementation of what this Runnable should do on each cycle.\n\nTake care that @state is #running? at the end of the method\nunless it is finished and should exit.","summary":"

Implementation of what this Runnable should do on each cycle.

","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":26,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":"with_idle_wait(1.seconds) do\n @state = State::Working\n candidate_queues = Mosquito.backend.list_queues.map do |name|\n Queue.new(name)\n end\n new_queue_list = filter_queues(candidate_queues)\n Log.notice do\n queues_which_were_expected_but_not_found = @queues - new_queue_list\n queues_which_have_never_been_seen = new_queue_list - @queues\n if queues_which_have_never_been_seen.size > 0\n \"found #{queues_which_have_never_been_seen.size} new queues: #{queues_which_have_never_been_seen.map(&.name).join(\", \")}\"\n end\n end\n @queues = new_queue_list\n @state = State::Idle\nend"}},{"html_id":"queues:Array(Queue)-instance-method","name":"queues","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":14,"url":null},"def":{"name":"queues","return_type":"Array(Queue)","visibility":"Public","body":"@queues"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":20,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"QueueList<#{object_id}>\""}}]},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","path":"Mosquito/Runners/RunAtMost.html","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost","abstract":false,"locations":[{"filename":"src/mosquito/runners/run_at_most.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Executor","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor"},{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"instance_methods":[{"html_id":"execution_timestamps-instance-method","name":"execution_timestamps","abstract":false,"location":{"filename":"src/mosquito/runners/run_at_most.cr","line_number":3,"url":null},"def":{"name":"execution_timestamps","visibility":"Public","body":"@execution_timestamps"}}]}]},{"html_id":"mosquito/Mosquito/ScheduledJob","path":"Mosquito/ScheduledJob.html","kind":"class","full_name":"Mosquito::ScheduledJob","name":"ScheduledJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/scheduled_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":3,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_job_run-instance-method","name":"build_job_run","abstract":true,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":6,"url":null},"def":{"name":"build_job_run","visibility":"Public","body":""}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":20,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"false"}}]},{"html_id":"mosquito/Mosquito/Scripts","path":"Mosquito/Scripts.html","kind":"module","full_name":"Mosquito::Scripts","name":"Scripts","abstract":false,"locations":[{"filename":"src/mosquito/redis_backend.cr","line_number":5,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SCRIPTS","name":"SCRIPTS","value":"{:remove_matching_key => \" if redis.call(\\\"get\\\",KEYS[1]) == ARGV[1] then\\n return redis.call(\\\"del\\\",KEYS[1])\\n else\\n return 0\\n end\"}"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"load(connection)-class-method","name":"load","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":""}],"args_string":"(connection)","args_html":"(connection)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":18,"url":null},"def":{"name":"load","args":[{"name":"connection","external_name":"connection","restriction":""}],"visibility":"Public","body":"SCRIPTS.each do |name, script|\n sha = @@script_sha[name] = connection.script_load(script)\n Log.info do\n \"loading script : #{name} => #{sha}\"\n end\nend"}},{"html_id":"remove_matching_key-class-method","name":"remove_matching_key","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":25,"url":null},"def":{"name":"remove_matching_key","visibility":"Public","body":"@@script_sha[:remove_matching_key]"}}]},{"html_id":"mosquito/Mosquito/Serializers","path":"Mosquito/Serializers.html","kind":"module","full_name":"Mosquito::Serializers","name":"Serializers","abstract":false,"locations":[{"filename":"src/mosquito/serializers/primitives.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"types":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","path":"Mosquito/Serializers/Primitives.html","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives","abstract":false,"locations":[{"filename":"src/mosquito/serializers/primitives.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"}],"namespace":{"html_id":"mosquito/Mosquito/Serializers","kind":"module","full_name":"Mosquito::Serializers","name":"Serializers"},"instance_methods":[{"html_id":"deserialize_bool(raw:String):Bool-instance-method","name":"deserialize_bool","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Bool","args_html":"(raw : String) : Bool","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":14,"url":null},"def":{"name":"deserialize_bool","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Bool","visibility":"Public","body":"raw == \"true\""}},{"html_id":"deserialize_char(raw:String):Char-instance-method","name":"deserialize_char","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Char","args_html":"(raw : String) : Char","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":26,"url":null},"def":{"name":"deserialize_char","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Char","visibility":"Public","body":"raw[0]"}},{"html_id":"deserialize_float32(raw:String):Float32|Nil-instance-method","name":"deserialize_float32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Float32 | Nil","args_html":"(raw : String) : Float32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_float32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Float32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_f32\nend"}},{"html_id":"deserialize_float64(raw:String):Float64|Nil-instance-method","name":"deserialize_float64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Float64 | Nil","args_html":"(raw : String) : Float64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_float64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Float64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_f64\nend"}},{"html_id":"deserialize_int128(raw:String):Int128|Nil-instance-method","name":"deserialize_int128","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int128 | Nil","args_html":"(raw : String) : Int128 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int128","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int128 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i128\nend"}},{"html_id":"deserialize_int16(raw:String):Int16|Nil-instance-method","name":"deserialize_int16","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int16 | Nil","args_html":"(raw : String) : Int16 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int16","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int16 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i16\nend"}},{"html_id":"deserialize_int32(raw:String):Int32|Nil-instance-method","name":"deserialize_int32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int32 | Nil","args_html":"(raw : String) : Int32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i32\nend"}},{"html_id":"deserialize_int64(raw:String):Int64|Nil-instance-method","name":"deserialize_int64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int64 | Nil","args_html":"(raw : String) : Int64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i64\nend"}},{"html_id":"deserialize_int8(raw:String):Int8|Nil-instance-method","name":"deserialize_int8","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int8 | Nil","args_html":"(raw : String) : Int8 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int8","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int8 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i8\nend"}},{"html_id":"deserialize_string(raw:String):String-instance-method","name":"deserialize_string","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : String","args_html":"(raw : String) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":6,"url":null},"def":{"name":"deserialize_string","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"String","visibility":"Public","body":"raw"}},{"html_id":"deserialize_u_int128(raw:String):UInt128|Nil-instance-method","name":"deserialize_u_int128","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt128 | Nil","args_html":"(raw : String) : UInt128 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int128","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt128 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u128\nend"}},{"html_id":"deserialize_u_int16(raw:String):UInt16|Nil-instance-method","name":"deserialize_u_int16","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt16 | Nil","args_html":"(raw : String) : UInt16 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int16","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt16 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u16\nend"}},{"html_id":"deserialize_u_int32(raw:String):UInt32|Nil-instance-method","name":"deserialize_u_int32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt32 | Nil","args_html":"(raw : String) : UInt32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u32\nend"}},{"html_id":"deserialize_u_int64(raw:String):UInt64|Nil-instance-method","name":"deserialize_u_int64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt64 | Nil","args_html":"(raw : String) : UInt64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u64\nend"}},{"html_id":"deserialize_u_int8(raw:String):UInt8|Nil-instance-method","name":"deserialize_u_int8","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt8 | Nil","args_html":"(raw : String) : UInt8 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int8","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt8 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u8\nend"}},{"html_id":"deserialize_uuid(raw:String):UUID-instance-method","name":"deserialize_uuid","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UUID","args_html":"(raw : String) : UUID","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":34,"url":null},"def":{"name":"deserialize_uuid","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UUID","visibility":"Public","body":"UUID.new(raw)"}},{"html_id":"serialize_bool(value:Bool):String-instance-method","name":"serialize_bool","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(value : Bool) : String","args_html":"(value : Bool) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":10,"url":null},"def":{"name":"serialize_bool","args":[{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_char(char:Char):String-instance-method","name":"serialize_char","abstract":false,"args":[{"name":"char","external_name":"char","restriction":"Char"}],"args_string":"(char : Char) : String","args_html":"(char : Char) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":22,"url":null},"def":{"name":"serialize_char","args":[{"name":"char","external_name":"char","restriction":"Char"}],"return_type":"String","visibility":"Public","body":"char.to_s"}},{"html_id":"serialize_float32(value):String-instance-method","name":"serialize_float32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_float32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_float64(value):String-instance-method","name":"serialize_float64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_float64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int128(value):String-instance-method","name":"serialize_int128","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int128","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int16(value):String-instance-method","name":"serialize_int16","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int16","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int32(value):String-instance-method","name":"serialize_int32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int64(value):String-instance-method","name":"serialize_int64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int8(value):String-instance-method","name":"serialize_int8","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int8","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_string(str:String):String-instance-method","name":"serialize_string","abstract":false,"args":[{"name":"str","external_name":"str","restriction":"String"}],"args_string":"(str : String) : String","args_html":"(str : String) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":2,"url":null},"def":{"name":"serialize_string","args":[{"name":"str","external_name":"str","restriction":"String"}],"return_type":"String","visibility":"Public","body":"str"}},{"html_id":"serialize_symbol(sym:Symbol):Nil-instance-method","name":"serialize_symbol","abstract":false,"args":[{"name":"sym","external_name":"sym","restriction":"Symbol"}],"args_string":"(sym : Symbol) : Nil","args_html":"(sym : Symbol) : Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":18,"url":null},"def":{"name":"serialize_symbol","args":[{"name":"sym","external_name":"sym","restriction":"Symbol"}],"return_type":"Nil","visibility":"Public","body":"raise(\"Symbols cannot be deserialized. Stringify your symbol first to pass it as a mosquito job parameter.\")"}},{"html_id":"serialize_u_int128(value):String-instance-method","name":"serialize_u_int128","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int128","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int16(value):String-instance-method","name":"serialize_u_int16","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int16","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int32(value):String-instance-method","name":"serialize_u_int32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int64(value):String-instance-method","name":"serialize_u_int64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int8(value):String-instance-method","name":"serialize_u_int8","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int8","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_uuid(uuid:UUID):String-instance-method","name":"serialize_uuid","abstract":false,"args":[{"name":"uuid","external_name":"uuid","restriction":"UUID"}],"args_string":"(uuid : UUID) : String","args_html":"(uuid : UUID) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":30,"url":null},"def":{"name":"serialize_uuid","args":[{"name":"uuid","external_name":"uuid","restriction":"UUID"}],"return_type":"String","visibility":"Public","body":"uuid.to_s"}}]}]},{"html_id":"mosquito/Mosquito/TestBackend","path":"Mosquito/TestBackend.html","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend","abstract":false,"superclass":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"ancestors":[{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/test_backend.cr","line_number":38,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"An in-memory noop backend desigend to be used in application testing.\n\nThe test mode backend simply makes a copy of job_runs at enqueue time and holds them in a class getter array.\n\nJob run id, config (aka parameters), and runtime class are kept in memory, and a truncate utility function is provided.\n\nActivate test mode configure the test backend like this:\n\n```\nMosquito.configure do |settings|\n settings.backend = Mosquito::TestBackend\nend\n```\n\nThen in your tests:\n\n```\ndescribe \"testing\" do\n it \"enqueues the job\" do\n # build and enqueue a job\n job_run = EchoJob.new(text: \"hello world\").enqueue\n\n # assert that the job was enqueued\n lastest_enqueued_job = Mosquito::TestBackend.enqueued_jobs.last\n\n # check the job config\n assert_equal \"hello world\", latest_enqueued_job.config[\"text\"]\n\n # check the job_id matches\n assert_equal job_run.id, latest_enqueued_job.id\n\n # optionally, truncate the history\n Mosquito::TestBackend.flush_enqueued_jobs!\n end\nend\n```","summary":"

An in-memory noop backend desigend to be used in application testing.

","class_methods":[{"html_id":"delete(key:String,inttl:Int64=0):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":54,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":57,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"enqueued_jobs-class-method","name":"enqueued_jobs","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":106,"url":null},"def":{"name":"enqueued_jobs","visibility":"Public","body":"@@enqueued_jobs"}},{"html_id":"enqueued_jobs=(enqueued_jobs:Array(Mosquito::TestBackend::EnqueuedJob))-class-method","name":"enqueued_jobs=","abstract":false,"args":[{"name":"enqueued_jobs","external_name":"enqueued_jobs","restriction":"::Array(::Mosquito::TestBackend::EnqueuedJob)"}],"args_string":"(enqueued_jobs : Array(Mosquito::TestBackend::EnqueuedJob))","args_html":"(enqueued_jobs : Array(Mosquito::TestBackend::EnqueuedJob))","location":{"filename":"src/mosquito/test_backend.cr","line_number":106,"url":null},"def":{"name":"enqueued_jobs=","args":[{"name":"enqueued_jobs","external_name":"enqueued_jobs","restriction":"::Array(::Mosquito::TestBackend::EnqueuedJob)"}],"visibility":"Public","body":"@@enqueued_jobs = enqueued_jobs"}},{"html_id":"expires_in(key:String):Int64-class-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":60,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"flush:Nil-class-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":79,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"flush_enqueued_jobs!-class-method","name":"flush_enqueued_jobs!","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":108,"url":null},"def":{"name":"flush_enqueued_jobs!","visibility":"Public","body":"@@enqueued_jobs = [] of EnqueuedJob"}},{"html_id":"get(key:String,field:String):String|Nil-class-method","name":"get","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":64,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":75,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"increment(key:String,field:String):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":71,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"list_queues:Array(String)-class-method","name":"list_queues","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":46,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":50,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-class-method","name":"lock?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/test_backend.cr","line_number":81,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":"false"}},{"html_id":"retrieve(key:String):Hash(String,String)-class-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/test_backend.cr","line_number":42,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"{} of String => String"}},{"html_id":"set(key:String,field:String,value:String):String-class-method","name":"set","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/test_backend.cr","line_number":67,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":"\"\""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-class-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":39,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"unlock(key:String,value:String):Nil-class-method","name":"unlock","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":85,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":""}}],"instance_methods":[{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":117,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"raise(\"Mosquito: attempted to dequeue a job from the testing backend.\")"}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":125,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":"raise(\"Mosquito: attempted to deschedule a job from the testing backend.\")"}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/test_backend.cr","line_number":112,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"@@enqueued_jobs << (EnqueuedJob.from(job_run))\njob_run\n"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":129,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":135,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/test_backend.cr","line_number":121,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"job_run"}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":148,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"size(include_dead:Bool=true):Int64-instance-method","name":"size","abstract":false,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"args_string":"(include_dead : Bool = true) : Int64","args_html":"(include_dead : Bool = true) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":138,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":132,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}}],"types":[{"html_id":"mosquito/Mosquito/TestBackend/EnqueuedJob","path":"Mosquito/TestBackend/EnqueuedJob.html","kind":"struct","full_name":"Mosquito::TestBackend::EnqueuedJob","name":"EnqueuedJob","abstract":false,"superclass":{"html_id":"mosquito/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"mosquito/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/test_backend.cr","line_number":88,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/TestBackend","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend"},"class_methods":[{"html_id":"from(job_run:JobRun)-class-method","name":"from","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":93,"url":null},"def":{"name":"from","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"job_class = Mosquito::Base.job_for_type(job_run.type)\nnew(job_run.id, job_class, job_run.config)\n"}}],"constructors":[{"html_id":"new(id:String,klass:::Mosquito::Job.class,config:Hash(String,String))-class-method","name":"new","abstract":false,"args":[{"name":"id","external_name":"id","restriction":"::String"},{"name":"klass","external_name":"klass","restriction":"::Mosquito::Job.class"},{"name":"config","external_name":"config","restriction":"::Hash(::String, ::String)"}],"args_string":"(id : String, klass : ::Mosquito::Job.class, config : Hash(String, String))","args_html":"(id : String, klass : ::Mosquito::Job.class, config : Hash(String, String))","location":{"filename":"src/mosquito/test_backend.cr","line_number":102,"url":null},"def":{"name":"new","args":[{"name":"id","external_name":"id","restriction":"::String"},{"name":"klass","external_name":"klass","restriction":"::Mosquito::Job.class"},{"name":"config","external_name":"config","restriction":"::Hash(::String, ::String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(id, klass, config)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"config:Hash(String,String)-instance-method","name":"config","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":91,"url":null},"def":{"name":"config","return_type":"Hash(String, String)","visibility":"Public","body":"@config"}},{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":89,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"klass:Mosquito::Job.class-instance-method","name":"klass","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":90,"url":null},"def":{"name":"klass","return_type":"Mosquito::Job.class","visibility":"Public","body":"@klass"}}]}]}]}]}} \ No newline at end of file diff --git a/search-index.js b/search-index.js index 49d37e1b..e10e9f06 100644 --- a/search-index.js +++ b/search-index.js @@ -1 +1 @@ -crystal_doc_search_index_callback({"repository_name":"mosquito","body":"\"mosquito\"\n\n[![GitHub](https://img.shields.io/github/license/mosquito-cr/mosquito.svg?style=for-the-badge)](https://tldrlegal.com/license/mit-license)\n\n\n\nMosquito is a generic background job runner written primarily for Crystal. Significant inspiration from experience with the successes and failings many Ruby gems in this vein. Once compiled, a mosquito binary can start work in about 10 milliseconds.\n\nMosquito currently provides these features:\n\n- Delayed execution (`SendEmailJob.new(email: :welcome, address: user.email).enqueue(in: 3.minutes)`)\n- Scheduled / Periodic execution (`RunEveryHourJob.new`)\n- Job Storage in Redis\n- Automatic rescheduling of failed jobs\n- Progressively increasing delay of rescheduled failed jobs\n- Dead letter queue of jobs which have failed too many times\n- Rate limited jobs\n\nCurrent Limitations:\n- Visibility into a running job network and queue is limited. There is a working proof of concept [visualization API](https://github.com/mosquito-cr/mosquito/issues/90) and [bare-bones terminal application](https://github.com/mosquito-cr/tui-visualizer).\n\n## Project State\n\nThe Mosquito project is stable. A few folks are using Mosquito in production, and it's going okay.\n\nThere are some features which would be nice to have, but what is here is both tried and tested.\n\nIf you're using Mosquito, please [get in touch](https://github.com/mosquito-cr/mosquito/discussions) on the Discussion board or [on Crystal chat](https://crystal-lang.org/community/) with any questions, feature suggestions, or feedback.\n\n## Installation\n\nUpdate your `shard.yml` to include mosquito:\n\n```diff\ndependencies:\n+ mosquito:\n+ github: mosquito-cr/mosquito\n```\n\n## Usage\n\n### Step 1: Define a queued job\n\n```crystal\n# src/jobs/puts_job.cr\nclass PutsJob < Mosquito::QueuedJob\n param message : String\n\n def perform\n puts message\n end\nend\n```\n\n### Step 2: Trigger that job\n\n```crystal\n# src//.cr\nPutsJob.new(message: \"ohai background job\").enqueue\n```\n\n### Step 3: Run your worker to process the job\n\n```crystal\n# src/worker.cr\n\nMosquito.configure do |settings|\n settings.redis_url = ENV[\"REDIS_URL\"]\nend\n\nMosquito::Runner.start\n```\n\n```text\ncrystal run src/worker.cr\n```\n\n### Success\n\n```\n> crystal run src/worker.cr\n2017-11-06 17:07:29 - Mosquito is buzzing...\n2017-11-06 17:07:51 - Running task puts_job<...> from puts_job\n2017-11-06 17:07:51 - [PutsJob] ohai background job\n2017-11-06 17:07:51 - task puts_job<...> succeeded, took 0.0 seconds\n```\n\n[More information about queued jobs](https://mosquito-cr.github.io/manual/index.html#queued-jobs) in the manual.\n\n------\n\n## Periodic Jobs\n\nPeriodic jobs run according to a predefined period -- once an hour, etc.\n\nThis periodic job:\n```crystal\nclass PeriodicallyPutsJob < Mosquito::PeriodicJob\n run_every 1.minute\n\n def perform\n emotions = %w{happy sad angry optimistic political skeptical epuhoric}\n puts \"The time is now #{Time.local} and the wizard is feeling #{emotions.sample}\"\n end\nend\n```\n\nWould produce this output:\n```crystal\n2017-11-06 17:20:13 - Mosquito is buzzing...\n2017-11-06 17:20:13 - Queues: periodically_puts_job\n2017-11-06 17:20:13 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:20:13 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:20:13 and the wizard is feeling skeptical\n2017-11-06 17:20:13 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n2017-11-06 17:21:14 - Queues: periodically_puts_job\n2017-11-06 17:21:14 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:21:14 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:21:14 and the wizard is feeling optimistic\n2017-11-06 17:21:14 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n2017-11-06 17:22:15 - Queues: periodically_puts_job\n2017-11-06 17:22:15 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:22:15 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:22:15 and the wizard is feeling political\n2017-11-06 17:22:15 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n```\n\n[More information on periodic jobs](https://mosquito-cr.github.io/manual/index.html#periodic-jobs) in the manual.\n\n## Advanced usage\n\nFor more advanced topics, including [use with Lucky Framework](https://mosquito-cr.github.io/manual/lucky_framework.html), [throttling or rate limiting](https://mosquito-cr.github.io/manual/rate_limiting.html), check out the [full manual](https://mosquito-cr.github.io/manual).\n\n## Contributing\n\nContributions are welcome. Please fork the repository, commit changes on a branch, and then open a pull request.\n\n### Crystal Versions\n\nMosquito aims to be compatible with the latest Crystal release, and the [latest patch for all post-1.0 minor crystal versions](https://github.com/mosquito-cr/mosquito/blob/master/.github/workflows/ci.yml#L17).\n\nFor development purposes [you're encouraged to stay in sync with `.tool-versions`](https://github.com/mosquito-cr/mosquito/blob/master/.tool-versions).\n\n### Testing\n\nThis repository uses [minitest](https://github.com/ysbaddaden/minitest.cr) for testing. As a result, `crystal spec` doesn't do anything helpful. Do this instead:\n\n```\nmake test\n```\n\nIn lieu of `crystal spec` bells and whistles, Minitest provides a nice alternative to [running one test at a time instead of the whole suite](https://github.com/ysbaddaden/minitest.cr/pull/31).\n","program":{"html_id":"mosquito/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"mosquito","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"mosquito/Mosquito","path":"Mosquito.html","kind":"module","full_name":"Mosquito","name":"Mosquito","abstract":false,"locations":[{"filename":"src/mosquito.cr","line_number":5,"url":null},{"filename":"src/mosquito/backend.cr","line_number":1,"url":null},{"filename":"src/mosquito/base.cr","line_number":1,"url":null},{"filename":"src/mosquito/configuration.cr","line_number":1,"url":null},{"filename":"src/mosquito/exceptions.cr","line_number":1,"url":null},{"filename":"src/mosquito/job.cr","line_number":3,"url":null},{"filename":"src/mosquito/job_run.cr","line_number":1,"url":null},{"filename":"src/mosquito/key_builder.cr","line_number":1,"url":null},{"filename":"src/mosquito/metadata.cr","line_number":1,"url":null},{"filename":"src/mosquito/periodic_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/periodic_job_run.cr","line_number":1,"url":null},{"filename":"src/mosquito/queue.cr","line_number":1,"url":null},{"filename":"src/mosquito/queued_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/redis_backend.cr","line_number":4,"url":null},{"filename":"src/mosquito/runnable.cr","line_number":1,"url":null},{"filename":"src/mosquito/runner.cr","line_number":3,"url":null},{"filename":"src/mosquito/runners/run_at_most.cr","line_number":1,"url":null},{"filename":"src/mosquito/scheduled_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/test_backend.cr","line_number":1,"url":null},{"filename":"src/mosquito/version.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"1.0.2\""}],"class_methods":[{"html_id":"backend-class-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito.cr","line_number":6,"url":null},"def":{"name":"backend","visibility":"Public","body":"configuration.backend"}},{"html_id":"configuration-class-method","name":"configuration","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":2,"url":null},"def":{"name":"configuration","visibility":"Public","body":"@@configuration"}},{"html_id":"configure(&):Nil-class-method","name":"configure","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":4,"url":null},"def":{"name":"configure","yields":1,"block_arity":1,"return_type":"Nil","visibility":"Public","body":"yield configuration"}}],"types":[{"html_id":"mosquito/Mosquito/Backend","path":"Mosquito/Backend.html","kind":"class","full_name":"Mosquito::Backend","name":"Backend","abstract":true,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/backend.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"KEY_PREFIX","name":"KEY_PREFIX","value":"{\"mosquito\"}"},{"id":"QUEUES","name":"QUEUES","value":"[\"waiting\", \"scheduled\", \"pending\", \"dead\"] of ::String"}],"subclasses":[{"html_id":"mosquito/Mosquito/RedisBackend","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend"},{"html_id":"mosquito/Mosquito/TestBackend","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"build_key(*parts)-class-method","name":"build_key","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/backend.cr","line_number":11,"url":null},"def":{"name":"build_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"KeyBuilder.build(KEY_PREFIX, *parts)"}},{"html_id":"named(name)-class-method","name":"named","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/mosquito/backend.cr","line_number":7,"url":null},"def":{"name":"named","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"new(name)"}},{"html_id":"search_queues-class-method","name":"search_queues","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":50,"url":null},"def":{"name":"search_queues","visibility":"Public","body":"QUEUES.first(2)"}}],"constructors":[{"html_id":"new(name:String|Symbol)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"args_string":"(name : String | Symbol)","args_html":"(name : String | Symbol)","location":{"filename":"src/mosquito/backend.cr","line_number":21,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_key(*parts)-instance-method","name":"build_key","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/backend.cr","line_number":15,"url":null},"def":{"name":"build_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"self.class.build_key(*parts)"}},{"html_id":"dead_q-instance-method","name":"dead_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"dead_q","visibility":"Public","body":"build_key(\"dead\", name)"}},{"html_id":"delete(key:String,inttl=0):Nil-instance-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"args_string":"(key : String, in ttl = 0) : Nil","args_html":"(key : String, in ttl = 0) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":68,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"return_type":"Nil","visibility":"Public","body":"self.class.delete(key)"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":78,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":""}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":80,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":""}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/backend.cr","line_number":77,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":""}},{"html_id":"expires_in(key:String):Int64-instance-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":72,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"self.class.expires_in(key)"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/backend.cr","line_number":81,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":83,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"pending_q-instance-method","name":"pending_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"pending_q","visibility":"Public","body":"build_key(\"pending\", name)"}},{"html_id":"retrieve(key:String):Hash(String,String)-instance-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/backend.cr","line_number":64,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"self.class.retrieve(key)"}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/backend.cr","line_number":79,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":""}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/backend.cr","line_number":90,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"scheduled_q-instance-method","name":"scheduled_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"scheduled_q","visibility":"Public","body":"build_key(\"scheduled\", name)"}},{"html_id":"size(include_dead:Bool=true):Int64-instance-method","name":"size","abstract":true,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"args_string":"(include_dead : Bool = true) : Int64","args_html":"(include_dead : Bool = true) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":84,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-instance-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":60,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":"self.class.store(key, value)"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/backend.cr","line_number":82,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"waiting_q-instance-method","name":"waiting_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"waiting_q","visibility":"Public","body":"build_key(\"waiting\", name)"}}],"types":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","path":"Mosquito/Backend/ClassMethods.html","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/mosquito/backend.cr","line_number":25,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"instance_methods":[{"html_id":"delete(key:String,inttl:Int64=0):Nil-instance-method","name":"delete","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":31,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-instance-method","name":"delete","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":32,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"expires_in(key:String):Int64-instance-method","name":"expires_in","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":33,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":40,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"get(key:String,field:String):String|Nil-instance-method","name":"get","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/backend.cr","line_number":35,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-instance-method","name":"increment","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":38,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String):Int64-instance-method","name":"increment","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":37,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"list_queues:Array(String)-instance-method","name":"list_queues","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":28,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"list_runners:Array(String)-instance-method","name":"list_runners","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":29,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-instance-method","name":"lock?","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/backend.cr","line_number":43,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":""}},{"html_id":"retrieve(key:String):Hash(String,String)-instance-method","name":"retrieve","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/backend.cr","line_number":27,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":""}},{"html_id":"set(key:String,field:String,value:String):String-instance-method","name":"set","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/backend.cr","line_number":36,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-instance-method","name":"store","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":26,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"unlock(key:String,value:String):Nil-instance-method","name":"unlock","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":42,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":""}}]}]},{"html_id":"mosquito/Mosquito/Base","path":"Mosquito/Base.html","kind":"class","full_name":"Mosquito::Base","name":"Base","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/base.cr","line_number":4,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"job_for_type(type:String):Mosquito::Job.class-class-method","name":"job_for_type","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"}],"args_string":"(type : String) : Mosquito::Job.class","args_html":"(type : String) : Mosquito::Job.class","location":{"filename":"src/mosquito/base.cr","line_number":13,"url":null},"def":{"name":"job_for_type","args":[{"name":"type","external_name":"type","restriction":"String"}],"return_type":"Mosquito::Job.class","visibility":"Public","body":"begin\n @@mapping[type]\nrescue e : KeyError\n error = String.build do |s|\n s << \"Could not find a job class for type \\\"#{type}\\\", perhaps you forgot to register it?\\n\\nCurrent known types are:\\n\"\n @@mapping.each do |k, v|\n s << \"#{k}=>#{v}\\n\"\n end\n s << \"\\n\\n\"\n end\n raise(KeyError.new(error))\nend"}},{"html_id":"mapping-class-method","name":"mapping","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":5,"url":null},"def":{"name":"mapping","visibility":"Public","body":"@@mapping"}},{"html_id":"register_job(klass,*,to_run_atscheduled_time:Time)-class-method","name":"register_job","abstract":false,"args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"scheduled_time","external_name":"to_run_at","restriction":"Time"}],"args_string":"(klass, *, to_run_at scheduled_time : Time)","args_html":"(klass, *, to_run_at scheduled_time : Time)","location":{"filename":"src/mosquito/base.cr","line_number":36,"url":null},"def":{"name":"register_job","args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"scheduled_time","external_name":"to_run_at","restriction":"Time"}],"splat_index":1,"visibility":"Public","body":"position = @@timetable.index do\nend"}},{"html_id":"register_job_interval(klass,interval:Time::Span|Time::MonthSpan)-class-method","name":"register_job_interval","abstract":false,"args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"args_string":"(klass, interval : Time::Span | Time::MonthSpan)","args_html":"(klass, interval : Time::Span | Time::MonthSpan)","location":{"filename":"src/mosquito/base.cr","line_number":32,"url":null},"def":{"name":"register_job_interval","args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"visibility":"Public","body":"@@scheduled_job_runs << (PeriodicJobRun.new(klass, interval))"}},{"html_id":"register_job_mapping(string,klass)-class-method","name":"register_job_mapping","abstract":false,"args":[{"name":"string","external_name":"string","restriction":""},{"name":"klass","external_name":"klass","restriction":""}],"args_string":"(string, klass)","args_html":"(string, klass)","location":{"filename":"src/mosquito/base.cr","line_number":9,"url":null},"def":{"name":"register_job_mapping","args":[{"name":"string","external_name":"string","restriction":""},{"name":"klass","external_name":"klass","restriction":""}],"visibility":"Public","body":"@@mapping[string] = klass"}},{"html_id":"scheduled_job_runs-class-method","name":"scheduled_job_runs","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":6,"url":null},"def":{"name":"scheduled_job_runs","visibility":"Public","body":"@@scheduled_job_runs"}},{"html_id":"timetable-class-method","name":"timetable","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":7,"url":null},"def":{"name":"timetable","visibility":"Public","body":"@@timetable"}}]},{"html_id":"mosquito/Mosquito/Configuration","path":"Mosquito/Configuration.html","kind":"class","full_name":"Mosquito::Configuration","name":"Configuration","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/configuration.cr","line_number":8,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"backend:Mosquito::Backend.class-instance-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":20,"url":null},"def":{"name":"backend","return_type":"Mosquito::Backend.class","visibility":"Public","body":"@backend"}},{"html_id":"backend=(backend:Mosquito::Backend.class)-instance-method","name":"backend=","abstract":false,"args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend.class"}],"args_string":"(backend : Mosquito::Backend.class)","args_html":"(backend : Mosquito::Backend.class)","location":{"filename":"src/mosquito/configuration.cr","line_number":20,"url":null},"def":{"name":"backend=","args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend.class"}],"visibility":"Public","body":"@backend = backend"}},{"html_id":"failed_job_ttl:Int32-instance-method","name":"failed_job_ttl","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":13,"url":null},"def":{"name":"failed_job_ttl","return_type":"Int32","visibility":"Public","body":"@failed_job_ttl"}},{"html_id":"failed_job_ttl=(failed_job_ttl:Int32)-instance-method","name":"failed_job_ttl=","abstract":false,"args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"args_string":"(failed_job_ttl : Int32)","args_html":"(failed_job_ttl : Int32)","location":{"filename":"src/mosquito/configuration.cr","line_number":13,"url":null},"def":{"name":"failed_job_ttl=","args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@failed_job_ttl = failed_job_ttl"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":11,"url":null},"def":{"name":"idle_wait","return_type":"Time::Span","visibility":"Public","body":"@idle_wait"}},{"html_id":"idle_wait=(idle_wait:Time::Span)-instance-method","name":"idle_wait=","abstract":false,"args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"args_string":"(idle_wait : Time::Span)","args_html":"(idle_wait : Time::Span)","location":{"filename":"src/mosquito/configuration.cr","line_number":11,"url":null},"def":{"name":"idle_wait=","args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"visibility":"Public","body":"@idle_wait = idle_wait"}},{"html_id":"idle_wait=(time_span:Float)-instance-method","name":"idle_wait=","abstract":false,"args":[{"name":"time_span","external_name":"time_span","restriction":"Float"}],"args_string":"(time_span : Float)","args_html":"(time_span : Float)","location":{"filename":"src/mosquito/configuration.cr","line_number":24,"url":null},"def":{"name":"idle_wait=","args":[{"name":"time_span","external_name":"time_span","restriction":"Float"}],"visibility":"Public","body":"@idle_wait = time_span.seconds"}},{"html_id":"redis_url:String|Nil-instance-method","name":"redis_url","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":9,"url":null},"def":{"name":"redis_url","return_type":"String | ::Nil","visibility":"Public","body":"@redis_url"}},{"html_id":"redis_url=(redis_url:String|Nil)-instance-method","name":"redis_url=","abstract":false,"args":[{"name":"redis_url","external_name":"redis_url","restriction":"String | ::Nil"}],"args_string":"(redis_url : String | Nil)","args_html":"(redis_url : String | Nil)","location":{"filename":"src/mosquito/configuration.cr","line_number":9,"url":null},"def":{"name":"redis_url=","args":[{"name":"redis_url","external_name":"redis_url","restriction":"String | ::Nil"}],"visibility":"Public","body":"@redis_url = redis_url"}},{"html_id":"run_cron_scheduler:Bool-instance-method","name":"run_cron_scheduler","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":16,"url":null},"def":{"name":"run_cron_scheduler","return_type":"Bool","visibility":"Public","body":"@run_cron_scheduler"}},{"html_id":"run_cron_scheduler=(run_cron_scheduler:Bool)-instance-method","name":"run_cron_scheduler=","abstract":false,"args":[{"name":"run_cron_scheduler","external_name":"run_cron_scheduler","restriction":"Bool"}],"args_string":"(run_cron_scheduler : Bool)","args_html":"(run_cron_scheduler : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":16,"url":null},"def":{"name":"run_cron_scheduler=","args":[{"name":"run_cron_scheduler","external_name":"run_cron_scheduler","restriction":"Bool"}],"visibility":"Public","body":"@run_cron_scheduler = run_cron_scheduler"}},{"html_id":"run_from:Array(String)-instance-method","name":"run_from","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":19,"url":null},"def":{"name":"run_from","return_type":"Array(String)","visibility":"Public","body":"@run_from"}},{"html_id":"run_from=(run_from:Array(String))-instance-method","name":"run_from=","abstract":false,"args":[{"name":"run_from","external_name":"run_from","restriction":"Array(String)"}],"args_string":"(run_from : Array(String))","args_html":"(run_from : Array(String))","location":{"filename":"src/mosquito/configuration.cr","line_number":19,"url":null},"def":{"name":"run_from=","args":[{"name":"run_from","external_name":"run_from","restriction":"Array(String)"}],"visibility":"Public","body":"@run_from = run_from"}},{"html_id":"successful_job_ttl:Int32-instance-method","name":"successful_job_ttl","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":12,"url":null},"def":{"name":"successful_job_ttl","return_type":"Int32","visibility":"Public","body":"@successful_job_ttl"}},{"html_id":"successful_job_ttl=(successful_job_ttl:Int32)-instance-method","name":"successful_job_ttl=","abstract":false,"args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"args_string":"(successful_job_ttl : Int32)","args_html":"(successful_job_ttl : Int32)","location":{"filename":"src/mosquito/configuration.cr","line_number":12,"url":null},"def":{"name":"successful_job_ttl=","args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@successful_job_ttl = successful_job_ttl"}},{"html_id":"use_distributed_lock:Bool-instance-method","name":"use_distributed_lock","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":17,"url":null},"def":{"name":"use_distributed_lock","return_type":"Bool","visibility":"Public","body":"@use_distributed_lock"}},{"html_id":"use_distributed_lock=(use_distributed_lock:Bool)-instance-method","name":"use_distributed_lock=","abstract":false,"args":[{"name":"use_distributed_lock","external_name":"use_distributed_lock","restriction":"Bool"}],"args_string":"(use_distributed_lock : Bool)","args_html":"(use_distributed_lock : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":17,"url":null},"def":{"name":"use_distributed_lock=","args":[{"name":"use_distributed_lock","external_name":"use_distributed_lock","restriction":"Bool"}],"visibility":"Public","body":"@use_distributed_lock = use_distributed_lock"}},{"html_id":"validate-instance-method","name":"validate","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":28,"url":null},"def":{"name":"validate","visibility":"Public","body":"if @validated\n return\nend\n@validated = true\nif redis_url.nil?\n message = \"Mosquito cannot start because the redis connection string hasn't been provided.\\n\\nFor example, in your application config:\\n\\nMosquito.configure do |settings|\\n settings.redis_url = (ENV[\\\"REDIS_TLS_URL\\\"]? || ENV[\\\"REDIS_URL\\\"]? || \\\"redis://localhost:6379\\\")\\nend\\n\\nSee Also: https://github.com/mosquito-cr/mosquito#connecting-to-redis\"\n raise(message)\nend\n"}},{"html_id":"validated:Bool-instance-method","name":"validated","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":22,"url":null},"def":{"name":"validated","visibility":"Public","body":"@validated"}},{"html_id":"validated=(validated:Bool)-instance-method","name":"validated=","abstract":false,"args":[{"name":"validated","external_name":"validated","restriction":"::Bool"}],"args_string":"(validated : Bool)","args_html":"(validated : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":22,"url":null},"def":{"name":"validated=","args":[{"name":"validated","external_name":"validated","restriction":"::Bool"}],"visibility":"Public","body":"@validated = validated"}}]},{"html_id":"mosquito/Mosquito/DoubleRun","path":"Mosquito/DoubleRun.html","kind":"class","full_name":"Mosquito::DoubleRun","name":"DoubleRun","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":7,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job_run tries to run twice","summary":"

When a job_run tries to run twice

"},{"html_id":"mosquito/Mosquito/Id","path":"Mosquito/Id.html","kind":"alias","full_name":"Mosquito::Id","name":"Id","abstract":false,"locations":[{"filename":"src/mosquito/base.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":true,"aliased":"(Int32 | Int64)","aliased_html":"Int32 | Int64","const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"}},{"html_id":"mosquito/Mosquito/IrretrievableParameter","path":"Mosquito/IrretrievableParameter.html","kind":"class","full_name":"Mosquito::IrretrievableParameter","name":"IrretrievableParameter","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":11,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job contains a model_id parameter pointing to a database record but the database doesn't return anything for that id.","summary":"

When a job contains a model_id parameter pointing to a database record but the database doesn't return anything for that id.

"},{"html_id":"mosquito/Mosquito/Job","path":"Mosquito/Job.html","kind":"class","full_name":"Mosquito::Job","name":"Job","abstract":true,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job.cr","line_number":10,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"}],"subclasses":[{"html_id":"mosquito/Mosquito/PeriodicJob","kind":"class","full_name":"Mosquito::PeriodicJob","name":"PeriodicJob"},{"html_id":"mosquito/Mosquito/QueuedJob","kind":"class","full_name":"Mosquito::QueuedJob","name":"QueuedJob"},{"html_id":"mosquito/Mosquito/ScheduledJob","kind":"class","full_name":"Mosquito::ScheduledJob","name":"ScheduledJob"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A Job is a definition for work to be performed.\nJobs are pieces of code which run a JobRun.\n\n- Jobs prevent double execution of a job for a job_run\n- Jobs Rescue when a #perform method fails a job_run for any reason\n- Jobs can be rescheduleable","summary":"

A Job is a definition for work to be performed.

","class_methods":[{"html_id":"metadata:Metadata-class-method","name":"metadata","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":182,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"Metadata.new(metadata_key, readonly: true)"}},{"html_id":"metadata_key-class-method","name":"metadata_key","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":186,"url":null},"def":{"name":"metadata_key","visibility":"Public","body":"Mosquito.backend.build_key(\"job_metadata\", self.name.underscore)"}},{"html_id":"queue-class-method","name":"queue","doc":"The Queue this job uses to store job_runs.","summary":"

The Queue this job uses to store job_runs.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":60,"url":null},"def":{"name":"queue","visibility":"Public","body":"if queue_name.blank?\n Queue.new(\"default\")\nelse\n Queue.new(queue_name)\nend"}},{"html_id":"queue_name:String-class-method","name":"queue_name","doc":"The queue this job is assigned to.\nBy default every job has it's own named queue:\n\n- EmailTheUniverseJob.queue = \"email_the_universe\"","summary":"

The queue this job is assigned to.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":48,"url":null},"def":{"name":"queue_name","return_type":"String","visibility":"Public","body":"({{ @type.id }}).to_s.underscore"}}],"instance_methods":[{"html_id":"aborted?(*args,**options)-instance-method","name":"aborted?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"aborted?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.aborted?(*args, **options)"}},{"html_id":"aborted?(*args,**options,&)-instance-method","name":"aborted?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"aborted?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.aborted?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"after_hook-instance-method","name":"after_hook","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":103,"url":null},"def":{"name":"after_hook","visibility":"Public","body":""}},{"html_id":"before_hook-instance-method","name":"before_hook","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":99,"url":null},"def":{"name":"before_hook","visibility":"Public","body":""}},{"html_id":"exception:Exception|Nil-instance-method","name":"exception","doc":"When a job fails and raises an exception, it will be saved into this attribute.","summary":"

When a job fails and raises an exception, it will be saved into this attribute.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":36,"url":null},"def":{"name":"exception","return_type":"Exception | ::Nil","visibility":"Public","body":"@exception"}},{"html_id":"executed?(*args,**options)-instance-method","name":"executed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"executed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.executed?(*args, **options)"}},{"html_id":"executed?(*args,**options,&)-instance-method","name":"executed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"executed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.executed?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"fail(reason=\"\",*,retry:Bool=true)-instance-method","name":"fail","doc":"To be called from inside a #perform\nMarks this job as a failure. By default, if the job is a candidate for\nre-scheduling, it will be run again at a later time.","summary":"

To be called from inside a #perform Marks this job as a failure.

","abstract":false,"args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"retry","default_value":"true","external_name":"retry","restriction":"Bool"}],"args_string":"(reason = \"\", *, retry : Bool = true)","args_html":"(reason = "", *, retry : Bool = true)","location":{"filename":"src/mosquito/job.cr","line_number":144,"url":null},"def":{"name":"fail","args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"retry","default_value":"true","external_name":"retry","restriction":"Bool"}],"splat_index":1,"visibility":"Public","body":"@should_retry = @should_retry && retry\nraise(JobFailed.new(reason))\n"}},{"html_id":"failed?(*args,**options)-instance-method","name":"failed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"failed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.failed?(*args, **options)"}},{"html_id":"failed?(*args,**options,&)-instance-method","name":"failed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"failed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.failed?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"job_run_id:String|Nil-instance-method","name":"job_run_id","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":38,"url":null},"def":{"name":"job_run_id","return_type":"String | ::Nil","visibility":"Public","body":"@job_run_id"}},{"html_id":"job_run_id=(job_run_id:String|Nil)-instance-method","name":"job_run_id=","abstract":false,"args":[{"name":"job_run_id","external_name":"job_run_id","restriction":"String | ::Nil"}],"args_string":"(job_run_id : String | Nil)","args_html":"(job_run_id : String | Nil)","location":{"filename":"src/mosquito/job.cr","line_number":38,"url":null},"def":{"name":"job_run_id=","args":[{"name":"job_run_id","external_name":"job_run_id","restriction":"String | ::Nil"}],"visibility":"Public","body":"@job_run_id = job_run_id"}},{"html_id":"log(message)-instance-method","name":"log","abstract":false,"args":[{"name":"message","external_name":"message","restriction":""}],"args_string":"(message)","args_html":"(message)","location":{"filename":"src/mosquito/job.cr","line_number":27,"url":null},"def":{"name":"log","args":[{"name":"message","external_name":"message","restriction":""}],"visibility":"Public","body":"(::Log.for(self.class)).info do\n message\nend"}},{"html_id":"metadata:Metadata-instance-method","name":"metadata","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":176,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"@metadata || (@metadata = (Metadata.new(self.class.metadata_key)))"}},{"html_id":"perform-instance-method","name":"perform","doc":"abstract, override in a Job descendant to do something productive","summary":"

abstract, override in a Job descendant to do something productive

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":136,"url":null},"def":{"name":"perform","visibility":"Public","body":"Log.error do\n \"No job definition found for #{self.class.name}\"\nend\nfail\n"}},{"html_id":"reschedule_interval(retry_count:Int32):Time::Span-instance-method","name":"reschedule_interval","doc":"abstract, override if desired.\n\nFor a given retry count, how long should the delay between\njob attempts be?","summary":"

abstract, override if desired.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Time::Span","args_html":"(retry_count : Int32) : Time::Span","location":{"filename":"src/mosquito/job.cr","line_number":168,"url":null},"def":{"name":"reschedule_interval","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Time::Span","visibility":"Public","body":"2.seconds * (retry_count ** 2)"}},{"html_id":"rescheduleable?(retry_count:Int32):Bool-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nFor a given retry count, is this job rescheduleable?","summary":"

abstract, override if desired.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Bool","args_html":"(retry_count : Int32) : Bool","location":{"filename":"src/mosquito/job.cr","line_number":160,"url":null},"def":{"name":"rescheduleable?","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"rescheduleable? && retry_count < 5"}},{"html_id":"rescheduleable?:Bool-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":153,"url":null},"def":{"name":"rescheduleable?","return_type":"Bool","visibility":"Public","body":"true"}},{"html_id":"retry_later-instance-method","name":"retry_later","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":107,"url":null},"def":{"name":"retry_later","visibility":"Public","body":"fail"}},{"html_id":"run-instance-method","name":"run","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":74,"url":null},"def":{"name":"run","visibility":"Public","body":"begin\n begin\n before_hook\n rescue e : Exception\n Log.error(exception: e) do\n \"Before hook raised, job will not be executed\"\n end\n @state = State::Aborted\n return\n end\n @state = State::Running\n perform\n @state = State::Succeeded\nrescue e\n Log.warn(exception: e) do\n \"Job failed! Raised #{e.class}: #{e.message}\"\n end\n @exception = e\n @state = State::Failed\nensure\n after_hook\nend"}},{"html_id":"should_retry:Bool-instance-method","name":"should_retry","doc":"When a job run fails, should it be added to the retry queue?\nSee: #fail(retry: false)","summary":"

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":42,"url":null},"def":{"name":"should_retry","return_type":"Bool","visibility":"Public","body":"@should_retry"}},{"html_id":"should_retry=(should_retry:Bool)-instance-method","name":"should_retry=","doc":"When a job run fails, should it be added to the retry queue?\nSee: #fail(retry: false)","summary":"

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

","abstract":false,"args":[{"name":"should_retry","external_name":"should_retry","restriction":"Bool"}],"args_string":"(should_retry : Bool)","args_html":"(should_retry : Bool)","location":{"filename":"src/mosquito/job.cr","line_number":42,"url":null},"def":{"name":"should_retry=","args":[{"name":"should_retry","external_name":"should_retry","restriction":"Bool"}],"visibility":"Public","body":"@should_retry = should_retry"}},{"html_id":"state:Mosquito::Job::State-instance-method","name":"state","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":31,"url":null},"def":{"name":"state","visibility":"Public","body":"@state"}},{"html_id":"succeeded?(*args,**options)-instance-method","name":"succeeded?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"succeeded?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.succeeded?(*args, **options)"}},{"html_id":"succeeded?(*args,**options,&)-instance-method","name":"succeeded?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"succeeded?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.succeeded?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[{"html_id":"after(&block)-macro","name":"after","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":123,"url":null},"def":{"name":"after","block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" def after_hook\n \n{% if @type.methods.map(&.name).includes?((:after_hook).id) %}\n previous_def\n {% else %}\n super\n {% end %}\n\n\n \n{{ yield }}\n\n \nend\n \n"}},{"html_id":"before(&block)-macro","name":"before","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":111,"url":null},"def":{"name":"before","block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" def before_hook\n \n{% if @type.methods.map(&.name).includes?((:before_hook).id) %}\n previous_def\n {% else %}\n super\n {% end %}\n\n\n \n{{ yield }}\n\n \nend\n \n"}},{"html_id":"queue_name(name)-macro","name":"queue_name","doc":"Easily override the queue for any job.","summary":"

Easily override the queue for any job.

","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/mosquito/job.cr","line_number":53,"url":null},"def":{"name":"queue_name","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":" def self.queue_name : String\n \"\n{{ name.id }}\n\"\n \nend\n \n"}}],"types":[{"html_id":"mosquito/Mosquito/Job/State","path":"Mosquito/Job/State.html","kind":"enum","full_name":"Mosquito::Job::State","name":"State","abstract":false,"ancestors":[{"html_id":"mosquito/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"mosquito/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job.cr","line_number":15,"url":null}],"repository_name":"mosquito","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Initialization","name":"Initialization","value":"0"},{"id":"Running","name":"Running","value":"1"},{"id":"Succeeded","name":"Succeeded","value":"2"},{"id":"Failed","name":"Failed","value":"3"},{"id":"Aborted","name":"Aborted","value":"4"}],"namespace":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"instance_methods":[{"html_id":"aborted?-instance-method","name":"aborted?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":20,"url":null},"def":{"name":"aborted?","visibility":"Public","body":"self == Aborted"}},{"html_id":"executed?:Bool-instance-method","name":"executed?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":22,"url":null},"def":{"name":"executed?","return_type":"Bool","visibility":"Public","body":"succeeded? || failed?"}},{"html_id":"failed?-instance-method","name":"failed?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":19,"url":null},"def":{"name":"failed?","visibility":"Public","body":"self == Failed"}},{"html_id":"initialization?-instance-method","name":"initialization?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":16,"url":null},"def":{"name":"initialization?","visibility":"Public","body":"self == Initialization"}},{"html_id":"running?-instance-method","name":"running?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":17,"url":null},"def":{"name":"running?","visibility":"Public","body":"self == Running"}},{"html_id":"succeeded?-instance-method","name":"succeeded?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":18,"url":null},"def":{"name":"succeeded?","visibility":"Public","body":"self == Succeeded"}}]}]},{"html_id":"mosquito/Mosquito/JobFailed","path":"Mosquito/JobFailed.html","kind":"class","full_name":"Mosquito::JobFailed","name":"JobFailed","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job fails","summary":"

When a job fails

"},{"html_id":"mosquito/Mosquito/JobRun","path":"Mosquito/JobRun.html","kind":"class","full_name":"Mosquito::JobRun","name":"JobRun","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job_run.cr","line_number":11,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"CONFIG_KEY_PREFIX","name":"CONFIG_KEY_PREFIX","value":"\"job_run\""}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A JobRun is a unit of work which will be performed by a Job.\nJobRuns know how to:\n- store and retrieve their data to and from the datastore\n- figure out what Job class they match to\n- build an instance of that Job class and pass off the config data\n- Ask the job to run\n\nJobRun data is called `config` and is persisted in the backend under the key\n`mosquito:job_run:job_run_id`.","summary":"

A JobRun is a unit of work which will be performed by a Job.

","class_methods":[{"html_id":"config_key(*parts)-class-method","name":"config_key","doc":"The config key is the backend storage key for the metadata of this job_run.","summary":"

The config key is the backend storage key for the metadata of this job_run.

","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/job_run.cr","line_number":33,"url":null},"def":{"name":"config_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"Mosquito.backend.build_key(CONFIG_KEY_PREFIX, parts)"}},{"html_id":"retrieve(id:String)-class-method","name":"retrieve","doc":"Used to construct a job_run from the parameters stored in the backend.","summary":"

Used to construct a job_run from the parameters stored in the backend.

","abstract":false,"args":[{"name":"id","external_name":"id","restriction":"String"}],"args_string":"(id : String)","args_html":"(id : String)","location":{"filename":"src/mosquito/job_run.cr","line_number":117,"url":null},"def":{"name":"retrieve","args":[{"name":"id","external_name":"id","restriction":"String"}],"visibility":"Public","body":"fields = Mosquito.backend.retrieve(config_key(id))\nif name = fields.delete(\"type\")\nelse\n return\nend\nif timestamp = fields.delete(\"enqueue_time\")\nelse\n return\nend\nretry_count = ((fields.delete(\"retry_count\")) || 0).to_i\ninstance = new(name, Time.unix_ms(timestamp.to_i64), id, retry_count)\ninstance.config = fields\ninstance\n"}}],"constructors":[{"html_id":"new(type:String,enqueue_time:Time=Time.utc,id:String|Nil=nil,retry_count:Int32=0)-class-method","name":"new","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"enqueue_time","default_value":"Time.utc","external_name":"enqueue_time","restriction":"Time"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry_count","default_value":"0","external_name":"retry_count","restriction":"Int32"}],"args_string":"(type : String, enqueue_time : Time = Time.utc, id : String | Nil = nil, retry_count : Int32 = 0)","args_html":"(type : String, enqueue_time : Time = Time.utc, id : String | Nil = nil, retry_count : Int32 = 0)","location":{"filename":"src/mosquito/job_run.cr","line_number":41,"url":null},"def":{"name":"new","args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"enqueue_time","default_value":"Time.utc","external_name":"enqueue_time","restriction":"Time"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry_count","default_value":"0","external_name":"retry_count","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(type, enqueue_time, id, retry_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:self)-instance-method","name":"==","doc":"Returns `true` if this reference is the same as *other*. Invokes `same?`.","summary":"

Returns true if this reference is the same as other.

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self)","args_html":"(other : self)","location":{"filename":"src/mosquito/job_run.cr","line_number":140,"url":null},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"visibility":"Public","body":"id == self.id"}},{"html_id":"build_job:Mosquito::Job-instance-method","name":"build_job","doc":"Builds a Job instance from this job_run. Populates the job with config from\nthe backend.","summary":"

Builds a Job instance from this job_run.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":71,"url":null},"def":{"name":"build_job","return_type":"Mosquito::Job","visibility":"Public","body":"if job = @job\n return job\nend\n@job = instance = (Base.job_for_type(type)).new\nif instance.responds_to?(:vars_from)\n instance.vars_from(config)\nend\ninstance.job_run_id = id\ninstance\n"}},{"html_id":"config_key-instance-method","name":"config_key","doc":"The config key is the backend storage key for the metadata of this job_run.","summary":"

The config key is the backend storage key for the metadata of this job_run.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":28,"url":null},"def":{"name":"config_key","visibility":"Public","body":"self.class.config_key(id)"}},{"html_id":"delete(inttl=0)-instance-method","name":"delete","doc":"Deletes this job_run from the backend.\nOptionally, after a delay in seconds (handled by the backend).","summary":"

Deletes this job_run from the backend.

","abstract":false,"args":[{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"args_string":"(in ttl = 0)","args_html":"(in ttl = 0)","location":{"filename":"src/mosquito/job_run.cr","line_number":65,"url":null},"def":{"name":"delete","args":[{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"visibility":"Public","body":"Mosquito.backend.delete(config_key, ttl)"}},{"html_id":"enqueue_time:Time-instance-method","name":"enqueue_time","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":13,"url":null},"def":{"name":"enqueue_time","return_type":"Time","visibility":"Public","body":"@enqueue_time"}},{"html_id":"fail-instance-method","name":"fail","doc":"Fails this job run and make sure it's persisted as such.","summary":"

Fails this job run and make sure it's persisted as such.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":98,"url":null},"def":{"name":"fail","visibility":"Public","body":"@retry_count = @retry_count + 1\nstore\n"}},{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":14,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"job:Mosquito::Job|Nil-instance-method","name":"job","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":16,"url":null},"def":{"name":"job","return_type":"Mosquito::Job | ::Nil","visibility":"Public","body":"@job"}},{"html_id":"job!:Mosquito::Job-instance-method","name":"job!","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":18,"url":null},"def":{"name":"job!","return_type":"Mosquito::Job","visibility":"Public","body":"job || (raise(RuntimeError.new(\"No job yet retrieved for job_run.\")))"}},{"html_id":"reload:Nil-instance-method","name":"reload","doc":"Updates this job_run config from the backend.","summary":"

Updates this job_run config from the backend.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":131,"url":null},"def":{"name":"reload","return_type":"Nil","visibility":"Public","body":"config.merge!(Mosquito.backend.retrieve(config_key))\n@retry_count = config[\"retry_count\"].to_i\n"}},{"html_id":"reschedule_interval-instance-method","name":"reschedule_interval","doc":"For the current retry count, how long should a runner wait before retry?","summary":"

For the current retry count, how long should a runner wait before retry?

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":109,"url":null},"def":{"name":"reschedule_interval","visibility":"Public","body":"job!.reschedule_interval(@retry_count)"}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"For the current retry count, is the job rescheduleable?","summary":"

For the current retry count, is the job rescheduleable?

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":104,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"job!.rescheduleable?(@retry_count)"}},{"html_id":"retry_count:Int32-instance-method","name":"retry_count","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":15,"url":null},"def":{"name":"retry_count","visibility":"Public","body":"@retry_count"}},{"html_id":"run-instance-method","name":"run","doc":"Builds and runs the job with this job_run config.","summary":"

Builds and runs the job with this job_run config.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":87,"url":null},"def":{"name":"run","visibility":"Public","body":"instance = build_job\ninstance.run\nif executed? && failed?\n @retry_count = @retry_count + 1\n store\nend\n"}},{"html_id":"store-instance-method","name":"store","doc":"Stores this job run configuration and metadata in the backend.","summary":"

Stores this job run configuration and metadata in the backend.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":54,"url":null},"def":{"name":"store","visibility":"Public","body":"fields = config.dup\nfields[\"enqueue_time\"] = enqueue_time.to_unix_ms.to_s\nfields[\"type\"] = type\nfields[\"retry_count\"] = retry_count.to_s\nMosquito.backend.store(config_key, fields)\n"}},{"html_id":"to_s(io:IO)-instance-method","name":"to_s","doc":"Appends a short String representation of this object\nwhich includes its class name and its object address.\n\n```\nclass Person\n def initialize(@name : String, @age : Int32)\n end\nend\n\nPerson.new(\"John\", 32).to_s # => #\n```","summary":"

Appends a short String representation of this object which includes its class name and its object address.

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO)","args_html":"(io : IO)","location":{"filename":"src/mosquito/job_run.cr","line_number":136,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":"IO"}],"visibility":"Public","body":"\"#{type}<#{id}>\".to_s(io)"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":12,"url":null},"def":{"name":"type","visibility":"Public","body":"@type"}}]},{"html_id":"mosquito/Mosquito/KeyBuilder","path":"Mosquito/KeyBuilder.html","kind":"class","full_name":"Mosquito::KeyBuilder","name":"KeyBuilder","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/key_builder.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"KEY_SEPERATOR","name":"KEY_SEPERATOR","value":"\":\""}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"build(*parts)-class-method","name":"build","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/key_builder.cr","line_number":5,"url":null},"def":{"name":"build","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"id = [] of String\nparts.each do |part|\n case part\n when Symbol\n id << (build(part.to_s))\n when String\n id << part\n when Array\n part.each do |e|\n id << (build(e))\n end\n when Tuple\n part.to_a.each do |e|\n id << (build(e))\n end\n when Number\n id << part.to_s\n else\n raise(\"#{part.class} is not a keyable type\")\n end\nend\nid.flatten.join(KEY_SEPERATOR)\n"}}]},{"html_id":"mosquito/Mosquito/Metadata","path":"Mosquito/Metadata.html","kind":"class","full_name":"Mosquito::Metadata","name":"Metadata","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/metadata.cr","line_number":8,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"Provides a real-time metadata store. Data is not cached, which allows\nmultiple workers to operate on the same structures in real time.\n\nEach read or write incurs a round trip to the backend.\n\nKeys and values are always strings.","summary":"

Provides a real-time metadata store.

","constructors":[{"html_id":"new(root_key:String,readonly:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"root_key","external_name":"root_key","restriction":"String"},{"name":"readonly","default_value":"false","external_name":"readonly","restriction":"::Bool"}],"args_string":"(root_key : String, readonly : Bool = false)","args_html":"(root_key : String, readonly : Bool = false)","location":{"filename":"src/mosquito/metadata.cr","line_number":12,"url":null},"def":{"name":"new","args":[{"name":"root_key","external_name":"root_key","restriction":"String"},{"name":"readonly","default_value":"false","external_name":"readonly","restriction":"::Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(root_key, readonly)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[]=(key:String,value:String)-instance-method","name":"[]=","doc":"Writes a value to a key in the metadata.","summary":"

Writes a value to a key in the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String)","args_html":"(key : String, value : String)","location":{"filename":"src/mosquito/metadata.cr","line_number":36,"url":null},"def":{"name":"[]=","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.set(root_key, key, value)\n"}},{"html_id":"[]?(key:String):String|Nil-instance-method","name":"[]?","doc":"Reads a single key from the metadata.","summary":"

Reads a single key from the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : String | Nil","args_html":"(key : String) : String | Nil","location":{"filename":"src/mosquito/metadata.cr","line_number":31,"url":null},"def":{"name":"[]?","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":"Mosquito.backend.get(root_key, key)"}},{"html_id":"decrement(key)-instance-method","name":"decrement","doc":"Decrements a value in the metadata by 1.","summary":"

Decrements a value in the metadata by 1.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":54,"url":null},"def":{"name":"decrement","args":[{"name":"key","external_name":"key","restriction":""}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key, by: -1)\n"}},{"html_id":"delete(inttl:Time::Span):Nil-instance-method","name":"delete","doc":"Schedule this metadata to be deleted after a time span.","summary":"

Schedule this metadata to be deleted after a time span.

","abstract":false,"args":[{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(in ttl : Time::Span) : Nil","args_html":"(in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/metadata.cr","line_number":21,"url":null},"def":{"name":"delete","args":[{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":"Mosquito.backend.delete(root_key, in: ttl)"}},{"html_id":"delete:Nil-instance-method","name":"delete","doc":"Deletes this metadata immediately.","summary":"

Deletes this metadata immediately.

","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":16,"url":null},"def":{"name":"delete","return_type":"Nil","visibility":"Public","body":"Mosquito.backend.delete(root_key)"}},{"html_id":"increment(key,byincrement:Int32)-instance-method","name":"increment","doc":"Parametrically incruments a value in the metadata.","summary":"

Parametrically incruments a value in the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""},{"name":"increment","external_name":"by","restriction":"Int32"}],"args_string":"(key, by increment : Int32)","args_html":"(key, by increment : Int32)","location":{"filename":"src/mosquito/metadata.cr","line_number":48,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":""},{"name":"increment","external_name":"by","restriction":"Int32"}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key, by: increment)\n"}},{"html_id":"increment(key)-instance-method","name":"increment","doc":"Increments a value in the metadata by 1 by 1 by 1 by 1.","summary":"

Increments a value in the metadata by 1 by 1 by 1 by 1.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":42,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":""}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key)\n"}},{"html_id":"inspect(*args,**options)-instance-method","name":"inspect","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"inspect","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_h.inspect(*args, **options)"}},{"html_id":"inspect(*args,**options,&)-instance-method","name":"inspect","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"inspect","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_h.inspect(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"readonly?:Bool-instance-method","name":"readonly?","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":10,"url":null},"def":{"name":"readonly?","return_type":"Bool","visibility":"Public","body":"@readonly"}},{"html_id":"root_key:String-instance-method","name":"root_key","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":9,"url":null},"def":{"name":"root_key","return_type":"String","visibility":"Public","body":"@root_key"}},{"html_id":"root_key=(root_key:String)-instance-method","name":"root_key=","abstract":false,"args":[{"name":"root_key","external_name":"root_key","restriction":"String"}],"args_string":"(root_key : String)","args_html":"(root_key : String)","location":{"filename":"src/mosquito/metadata.cr","line_number":9,"url":null},"def":{"name":"root_key=","args":[{"name":"root_key","external_name":"root_key","restriction":"String"}],"visibility":"Public","body":"@root_key = root_key"}},{"html_id":"to_h:Hash(String,String)-instance-method","name":"to_h","doc":"Reads the metadata and returns it as a hash.","summary":"

Reads the metadata and returns it as a hash.

","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":26,"url":null},"def":{"name":"to_h","return_type":"Hash(String, String)","visibility":"Public","body":"Mosquito.backend.retrieve(root_key)"}},{"html_id":"to_s(*args,**options)-instance-method","name":"to_s","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"to_s","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_h.to_s(*args, **options)"}},{"html_id":"to_s(*args,**options,&)-instance-method","name":"to_s","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"to_s","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_h.to_s(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}]},{"html_id":"mosquito/Mosquito/PeriodicJob","path":"Mosquito/PeriodicJob.html","kind":"class","full_name":"Mosquito::PeriodicJob","name":"PeriodicJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/periodic_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":3,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_job_run-instance-method","name":"build_job_run","abstract":true,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":6,"url":null},"def":{"name":"build_job_run","visibility":"Public","body":""}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":28,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"false"}}]},{"html_id":"mosquito/Mosquito/PeriodicJobRun","path":"Mosquito/PeriodicJobRun.html","kind":"class","full_name":"Mosquito::PeriodicJobRun","name":"PeriodicJobRun","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/periodic_job_run.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new(class__arg0:::Mosquito::PeriodicJob.class,interval:Time::MonthSpan|Time::Span)-class-method","name":"new","abstract":false,"args":[{"name":"__arg0","external_name":"class","restriction":"::Mosquito::PeriodicJob.class"},{"name":"interval","external_name":"interval","restriction":"::Time::MonthSpan | ::Time::Span"}],"args_string":"(class __arg0 : ::Mosquito::PeriodicJob.class, interval : Time::MonthSpan | Time::Span)","args_html":"(class __arg0 : ::Mosquito::PeriodicJob.class, interval : Time::MonthSpan | Time::Span)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":40,"url":null},"def":{"name":"new","args":[{"name":"__arg0","external_name":"class","restriction":"::Mosquito::PeriodicJob.class"},{"name":"interval","external_name":"interval","restriction":"::Time::MonthSpan | ::Time::Span"}],"visibility":"Public","body":"_ = allocate\n_.initialize(__arg0, interval)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"class:Mosquito::PeriodicJob.class-instance-method","name":"class","doc":"Returns the **runtime** `Class` of an object.\n\n```\n1.class # => Int32\n\"hello\".class # => String\n```\n\nCompare it with `typeof`, which returns the **compile-time** type of an object:\n\n```\nrandom_value = rand # => 0.627423\nvalue = random_value < 0.5 ? 1 : \"hello\"\nvalue # => \"hello\"\nvalue.class # => String\ntypeof(value) # => Int32 | String\n```","summary":"

Returns the runtime Class of an object.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":3,"url":null},"def":{"name":"class","return_type":"Mosquito::PeriodicJob.class","visibility":"Public","body":"@class"}},{"html_id":"class=(class__arg0:Mosquito::PeriodicJob.class)-instance-method","name":"class=","abstract":false,"args":[{"name":"__arg0","external_name":"class","restriction":"Mosquito::PeriodicJob.class"}],"args_string":"(class __arg0 : Mosquito::PeriodicJob.class)","args_html":"(class __arg0 : Mosquito::PeriodicJob.class)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":3,"url":null},"def":{"name":"class=","args":[{"name":"__arg0","external_name":"class","restriction":"Mosquito::PeriodicJob.class"}],"visibility":"Public","body":"@class = __arg0"}},{"html_id":"execute-instance-method","name":"execute","doc":"Enqueues the job for execution","summary":"

Enqueues the job for execution

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":63,"url":null},"def":{"name":"execute","visibility":"Public","body":"job = @class.new\njob_run = job.build_job_run\njob_run.store\n@class.queue.enqueue(job_run)\n"}},{"html_id":"interval:Time::Span|Time::MonthSpan-instance-method","name":"interval","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":4,"url":null},"def":{"name":"interval","return_type":"Time::Span | Time::MonthSpan","visibility":"Public","body":"@interval"}},{"html_id":"interval=(interval:Time::Span|Time::MonthSpan)-instance-method","name":"interval=","abstract":false,"args":[{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"args_string":"(interval : Time::Span | Time::MonthSpan)","args_html":"(interval : Time::Span | Time::MonthSpan)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":4,"url":null},"def":{"name":"interval=","args":[{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"visibility":"Public","body":"@interval = interval"}},{"html_id":"last_executed_at-instance-method","name":"last_executed_at","doc":"The last executed timestamp, or \"never\" if it doesn't exist.","summary":"

The last executed timestamp, or "never" if it doesn't exist.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":16,"url":null},"def":{"name":"last_executed_at","visibility":"Public","body":"last_executed_at? || (Time.unix(0))"}},{"html_id":"last_executed_at=(time:Time)-instance-method","name":"last_executed_at=","doc":"Updates the last executed timestamp in the backend,\nand schedules the metadata for deletion after 3*interval\nseconds.\n\nFor Time::Span intervals, the TTL is set to 3 * interval.\nFor Time::MonthSpan intervals, the TTL is set to approximately 3 * interval.\n\nA month is approximated to 2635200 seconds, or 30.5 days.","summary":"

Updates the last executed timestamp in the backend, and schedules the metadata for deletion after 3*interval seconds.

","abstract":false,"args":[{"name":"time","external_name":"time","restriction":"Time"}],"args_string":"(time : Time)","args_html":"(time : Time)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":28,"url":null},"def":{"name":"last_executed_at=","args":[{"name":"time","external_name":"time","restriction":"Time"}],"visibility":"Public","body":"@metadata[\"last_executed_at\"] = time.to_unix.to_s\ncase interval_ = interval\nwhen Time::Span\n @metadata.delete(in: interval_ * 3)\nwhen Time::MonthSpan\n seconds_in_an_average_month = 2635200.seconds\n @metadata.delete(in: (seconds_in_an_average_month * interval_.value) * 3)\nend\n"}},{"html_id":"last_executed_at?-instance-method","name":"last_executed_at?","doc":"The last executed timestamp for this periodicjob tracked by the backend.","summary":"

The last executed timestamp for this periodicjob tracked by the backend.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":7,"url":null},"def":{"name":"last_executed_at?","visibility":"Public","body":"if timestamp = @metadata[\"last_executed_at\"]?\n Time.unix(timestamp.to_i)\nelse\n nil\nend"}},{"html_id":"try_to_execute:Bool-instance-method","name":"try_to_execute","doc":"Check the last executed timestamp against the current time,\nand enqueue the job if it's time to execute.","summary":"

Check the last executed timestamp against the current time, and enqueue the job if it's time to execute.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":46,"url":null},"def":{"name":"try_to_execute","return_type":"Bool","visibility":"Public","body":"now = Time.utc\nif (last_executed_at + interval) <= now\n execute\n self.last_executed_at = now\n true\nelse\n false\nend\n"}}]},{"html_id":"mosquito/Mosquito/Queue","path":"Mosquito/Queue.html","kind":"class","full_name":"Mosquito::Queue","name":"Queue","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/queue.cr","line_number":77,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A named Queue.\n\nNamed Queues exist and have 4 ordered lists: waiting, pending, scheduled, and dead.\n\n- The Waiting list is for jobs which need to be executed as soon as possible.\n- The Pending list is for jobs which are currently being executed.\n- The Scheduled list is indexed by execution time and holds jobs which need to be executed at a later time.\n- The Dead list is for jobs which have been retried too many times and are no longer viable.\n\nA job_run is represented in a queue by its id.\n\nA job_run flows through the queues in this manner:\n\n\n```text\n Time=0: JobRun does not exist yet, lists are empty\n\n Waiting Pending Scheduled Dead\n\n ---------------------------------\n Time=1: JobRun is enqueued\n\n Waiting Pending Scheduled Dead\n JobRun#1\n\n ---------------------------------\n Time=2: JobRun begins. JobRun is moved to pending and executed\n\n Waiting Pending Scheduled Dead\n JobRun#1\n\n ---------------------------------\n Time=3: JobRuns are Enqueued.\n\n Waiting Pending Scheduled Dead\n JobRun#2 JobRun#1\n JobRun#3\n\n ---------------------------------\n Time=4: JobRun succeeds, next job_run begins.\n\n Waiting Pending Scheduled Dead\n JobRun#3 JobRun#2\n\n ---------------------------------\n Time=5: JobRun fails and is scheduled for later, next job_run begins.\n\n Waiting Pending Scheduled Dead\n JobRun#3 t=7:JobRun#2\n\n ---------------------------------\n Time=6: JobRun succeeds. Nothing is executing.\n\n Waiting Pending Scheduled Dead\n t=7:JobRun#2\n\n ---------------------------------\n Time=7: Scheduled job_run is due and is moved to waiting. Nothing is executing.\n\n Waiting Pending Scheduled Dead\n JobRun#2\n\n ---------------------------------\n Time=8: JobRun begins executing (for the second time).\n\n Waiting Pending Scheduled Dead\n JobRun#2\n\n ---------------------------------\n Time=9: JobRun finished successfully. No more job_runs present.\n\n Waiting Pending Scheduled Dead\n\n```\n","summary":"

A named Queue.

","constructors":[{"html_id":"new(name:String)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"}],"args_string":"(name : String)","args_html":"(name : String)","location":{"filename":"src/mosquito/queue.cr","line_number":84,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:self):Bool-instance-method","name":"==","doc":"Returns `true` if this reference is the same as *other*. Invokes `same?`.","summary":"

Returns true if this reference is the same as other.

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : Bool","args_html":"(other : self) : Bool","location":{"filename":"src/mosquito/queue.cr","line_number":142,"url":null},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"Bool","visibility":"Public","body":"name == other.name"}},{"html_id":"backend:Mosquito::Backend-instance-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":80,"url":null},"def":{"name":"backend","return_type":"Mosquito::Backend","visibility":"Public","body":"@backend"}},{"html_id":"backend=(backend:Mosquito::Backend)-instance-method","name":"backend=","abstract":false,"args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend"}],"args_string":"(backend : Mosquito::Backend)","args_html":"(backend : Mosquito::Backend)","location":{"filename":"src/mosquito/queue.cr","line_number":80,"url":null},"def":{"name":"backend=","args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend"}],"visibility":"Public","body":"@backend = backend"}},{"html_id":"banish(job_run:JobRun)-instance-method","name":"banish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/queue.cr","line_number":128,"url":null},"def":{"name":"banish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"backend.finish(job_run)\nbackend.terminate(job_run)\n"}},{"html_id":"config_key:String-instance-method","name":"config_key","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":78,"url":null},"def":{"name":"config_key","visibility":"Public","body":"@config_key"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":104,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"if empty?\n return\nend\nif job_run = backend.dequeue\n job_run\nelse\n @empty = true\n nil\nend\n"}},{"html_id":"dequeue_scheduled:Array(JobRun)-instance-method","name":"dequeue_scheduled","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":120,"url":null},"def":{"name":"dequeue_scheduled","return_type":"Array(JobRun)","visibility":"Public","body":"backend.deschedule"}},{"html_id":"empty?:Bool-instance-method","name":"empty?","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":79,"url":null},"def":{"name":"empty?","return_type":"Bool","visibility":"Public","body":"@empty"}},{"html_id":"enqueue(job_run:JobRun,ininterval:Time::Span):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"interval","external_name":"in","restriction":"Time::Span"}],"args_string":"(job_run : JobRun, in interval : Time::Span) : JobRun","args_html":"(job_run : JobRun, in interval : Time::Span) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":95,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"interval","external_name":"in","restriction":"Time::Span"}],"return_type":"JobRun","visibility":"Public","body":"enqueue(job_run, at: interval.from_now)"}},{"html_id":"enqueue(job_run:JobRun,atexecute_time:Time):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execute_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at execute_time : Time) : JobRun","args_html":"(job_run : JobRun, at execute_time : Time) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":99,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execute_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"Log.trace do\n \"Enqueuing #{job_run} at #{execute_time}\"\nend\nbackend.schedule(job_run, execute_time)\n"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":90,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"Log.trace do\n \"Enqueuing #{job_run} for immediate execution\"\nend\nbackend.enqueue(job_run)\n"}},{"html_id":"flush-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":146,"url":null},"def":{"name":"flush","visibility":"Public","body":"backend.flush"}},{"html_id":"forget(job_run:JobRun)-instance-method","name":"forget","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/queue.cr","line_number":124,"url":null},"def":{"name":"forget","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"backend.finish(job_run)"}},{"html_id":"length:Int64-instance-method","name":"length","summary":"

DEPRECATED see #size

","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":138,"url":null},"def":{"name":"length","return_type":"Int64","visibility":"Public","body":"backend.size"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":78,"url":null},"def":{"name":"name","visibility":"Public","body":"@name"}},{"html_id":"reschedule(job_run:JobRun,execution_time)-instance-method","name":"reschedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execution_time","external_name":"execution_time","restriction":""}],"args_string":"(job_run : JobRun, execution_time)","args_html":"(job_run : JobRun, execution_time)","location":{"filename":"src/mosquito/queue.cr","line_number":115,"url":null},"def":{"name":"reschedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execution_time","external_name":"execution_time","restriction":""}],"visibility":"Public","body":"backend.finish(job_run)\nenqueue(job_run, at: execution_time)\n"}},{"html_id":"size:Int64-instance-method","name":"size","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":133,"url":null},"def":{"name":"size","return_type":"Int64","visibility":"Public","body":"backend.size"}}]},{"html_id":"mosquito/Mosquito/QueuedJob","path":"Mosquito/QueuedJob.html","kind":"class","full_name":"Mosquito::QueuedJob","name":"QueuedJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/queued_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"enqueue(indelay_interval:Time::Span):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"delay_interval","external_name":"in","restriction":"Time::Span"}],"args_string":"(in delay_interval : Time::Span) : JobRun","args_html":"(in delay_interval : Time::Span) : JobRun","location":{"filename":"src/mosquito/queued_job.cr","line_number":128,"url":null},"def":{"name":"enqueue","args":[{"name":"delay_interval","external_name":"in","restriction":"Time::Span"}],"return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run, in: delay_interval)\nend"}},{"html_id":"enqueue(atexecute_time:Time):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"execute_time","external_name":"at","restriction":"Time"}],"args_string":"(at execute_time : Time) : JobRun","args_html":"(at execute_time : Time) : JobRun","location":{"filename":"src/mosquito/queued_job.cr","line_number":135,"url":null},"def":{"name":"enqueue","args":[{"name":"execute_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run, at: execute_time)\nend"}},{"html_id":"enqueue:JobRun-instance-method","name":"enqueue","abstract":false,"location":{"filename":"src/mosquito/queued_job.cr","line_number":121,"url":null},"def":{"name":"enqueue","return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run)\nend"}}]},{"html_id":"mosquito/Mosquito/RateLimiter","path":"Mosquito/RateLimiter.html","kind":"module","full_name":"Mosquito::RateLimiter","name":"RateLimiter","abstract":false,"locations":[{"filename":"src/mosquito/rate_limiter.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"increment_run_count:Nil-instance-method","name":"increment_run_count","doc":"Increments the run counter.","summary":"

Increments the run counter.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":134,"url":null},"def":{"name":"increment_run_count","return_type":"Nil","visibility":"Public","body":"metadata.increment(\"run_count\", by: increment_run_count_by)"}},{"html_id":"increment_run_count_by:Int32-instance-method","name":"increment_run_count_by","doc":"How much the run counter should be incremented by.\nImplemented as a dynamic method so that it can easily be calculated by\nsome other metric, eg api calls to a third party library.","summary":"

How much the run counter should be incremented by.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":141,"url":null},"def":{"name":"increment_run_count_by","return_type":"Int32","visibility":"Public","body":"@@rate_limit_increment"}},{"html_id":"maxed_rate_for_window?:Bool-instance-method","name":"maxed_rate_for_window?","doc":"Has the run count exceeded the ceiling for the current window?","summary":"

Has the run count exceeded the ceiling for the current window?

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":97,"url":null},"def":{"name":"maxed_rate_for_window?","return_type":"Bool","visibility":"Public","body":"run_count = metadata[\"run_count\"]?.try(&.to_i)\nrun_count || (run_count = 0)\nrun_count >= @@rate_limit_ceiling\n"}},{"html_id":"metadata:Metadata-instance-method","name":"metadata","doc":"Storage hash for rate limit data.","summary":"

Storage hash for rate limit data.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":84,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"@rl_metadata || (@rl_metadata = self.class.metadata)"}},{"html_id":"rate_limited?:Bool-instance-method","name":"rate_limited?","doc":"Should this job be cancelled?\nIf not, update the rate limit metadata.","summary":"

Should this job be cancelled? If not, update the rate limit metadata.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":90,"url":null},"def":{"name":"rate_limited?","return_type":"Bool","visibility":"Public","body":"if @@rate_limit_ceiling < 0\n return false\nend\nif maxed_rate_for_window?\n return true\nend\nfalse\n"}},{"html_id":"reschedule_interval(retry_count:Int32):Time::Span-instance-method","name":"reschedule_interval","doc":"Configure the reschedule interval so that the job_run is not run again until it\nshould be allowed through the rate limiter.","summary":"

Configure the reschedule interval so that the job_run is not run again until it should be allowed through the rate limiter.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Time::Span","args_html":"(retry_count : Int32) : Time::Span","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":147,"url":null},"def":{"name":"reschedule_interval","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Time::Span","visibility":"Public","body":"if rate_limited? && (window_expiration = window_expires_at)\n next_window = window_expiration - Time.utc\n log(\"Rate limited: will run again in #{next_window}\")\n next_window\nelse\n super(retry_count)\nend"}},{"html_id":"rescheduleable?(retry_count:Int32):Bool-instance-method","name":"rescheduleable?","doc":"Configure the rescheduler to always retry if a job is rate limited.","summary":"

Configure the rescheduler to always retry if a job is rate limited.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Bool","args_html":"(retry_count : Int32) : Bool","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":158,"url":null},"def":{"name":"rescheduleable?","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if rate_limited?\n true\nelse\n super(retry_count)\nend"}},{"html_id":"update_window_start:Nil-instance-method","name":"update_window_start","doc":"Resets the run count and logs the start of window.","summary":"

Resets the run count and logs the start of window.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":124,"url":null},"def":{"name":"update_window_start","return_type":"Nil","visibility":"Public","body":"started_window = window_start || Time::UNIX_EPOCH\nnow = Time.utc\nif (now - started_window) > @@rate_limit_interval\n metadata[\"window_start\"] = now.to_unix.to_s\n metadata[\"run_count\"] = \"0\"\nend\n"}},{"html_id":"window_expires_at:Time|Nil-instance-method","name":"window_expires_at","doc":"When does the current rate limit window expire?\nReturns nil if the window is already expired.","summary":"

When does the current rate limit window expire? Returns nil if the window is already expired.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":112,"url":null},"def":{"name":"window_expires_at","return_type":"Time | ::Nil","visibility":"Public","body":"if started_window = window_start\nelse\n return nil\nend\nexpiration_time = started_window + @@rate_limit_interval\nif expiration_time < Time.utc\n nil\nelse\n expiration_time\nend\n"}},{"html_id":"window_start:Time|Nil-instance-method","name":"window_start","doc":"Calculates the start of the rate limit window.","summary":"

Calculates the start of the rate limit window.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":104,"url":null},"def":{"name":"window_start","return_type":"Time | ::Nil","visibility":"Public","body":"if start_time = metadata[\"window_start\"]?.try(&.to_i)\n Time.unix(start_time)\nend"}}],"types":[{"html_id":"mosquito/Mosquito/RateLimiter/ClassMethods","path":"Mosquito/RateLimiter/ClassMethods.html","kind":"module","full_name":"Mosquito::RateLimiter::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/mosquito/rate_limiter.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/RateLimiter","kind":"module","full_name":"Mosquito::RateLimiter","name":"RateLimiter"},"instance_methods":[{"html_id":"metadata:Metadata-instance-method","name":"metadata","doc":"Provides an instance of the metadata store used to track rate limit\nstats.","summary":"

Provides an instance of the metadata store used to track rate limit stats.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":53,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"Metadata.new(@@rate_limit_key)"}},{"html_id":"rate_limit_key-instance-method","name":"rate_limit_key","doc":"Resolves the key used to index the metadata store for this test.","summary":"

Resolves the key used to index the metadata store for this test.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":58,"url":null},"def":{"name":"rate_limit_key","visibility":"Public","body":"@@rate_limit_key"}},{"html_id":"rate_limit_stats:NamedTuple-instance-method","name":"rate_limit_stats","doc":"Statistics about the rate limiter, including both the configuration\nparameters and the run counts.","summary":"

Statistics about the rate limiter, including both the configuration parameters and the run counts.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":26,"url":null},"def":{"name":"rate_limit_stats","return_type":"NamedTuple","visibility":"Public","body":"meta = metadata\nwindow_start = if window_start_ = meta[\"window_start\"]?\n Time.unix(window_start_.to_i)\nelse\n Time::UNIX_EPOCH\nend\nrun_count = if run_count_ = meta[\"run_count\"]?\n run_count_.to_i\nelse\n 0\nend\n{interval: @@rate_limit_interval, key: @@rate_limit_key, increment: @@rate_limit_increment, limit: @@rate_limit_ceiling, window_start: window_start, run_count: run_count}\n"}},{"html_id":"throttle(*,limit:Int32=1,per:Time::Span=1.second,increment=1,key=self.name.underscore)-instance-method","name":"throttle","doc":"Configures rate limiting for this job.\n\n`limit` and `per` are used to control the run count and the window\nduration. Defaults to a limit of 1 run per second.\n\n`increment` is used to indicate how many \"hits\" against a single job is\nworth. Defaults to 1.\n\n`key` is used to combine rate limiting functions across multiple jobs.","summary":"

Configures rate limiting for this job.

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"limit","default_value":"1","external_name":"limit","restriction":"Int32"},{"name":"per","default_value":"1.second","external_name":"per","restriction":"Time::Span"},{"name":"increment","default_value":"1","external_name":"increment","restriction":""},{"name":"key","default_value":"self.name.underscore","external_name":"key","restriction":""}],"args_string":"(*, limit : Int32 = 1, per : Time::Span = 1.second, increment = 1, key = self.name.underscore)","args_html":"(*, limit : Int32 = 1, per : Time::Span = 1.second, increment = 1, key = self.name.underscore)","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":12,"url":null},"def":{"name":"throttle","args":[{"name":"","external_name":"","restriction":""},{"name":"limit","default_value":"1","external_name":"limit","restriction":"Int32"},{"name":"per","default_value":"1.second","external_name":"per","restriction":"Time::Span"},{"name":"increment","default_value":"1","external_name":"increment","restriction":""},{"name":"key","default_value":"self.name.underscore","external_name":"key","restriction":""}],"splat_index":0,"visibility":"Public","body":"@@rate_limit_ceiling = limit\n@@rate_limit_interval = per\n@@rate_limit_key = Mosquito.backend.build_key(\"rate_limit\", key)\n@@rate_limit_increment = increment\n"}}]}]},{"html_id":"mosquito/Mosquito/RedisBackend","path":"Mosquito/RedisBackend.html","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend","abstract":false,"superclass":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"ancestors":[{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/redis_backend.cr","line_number":35,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"LIST_OF_QUEUES_KEY","name":"LIST_OF_QUEUES_KEY","value":"\"queues\""},{"id":"Log","name":"Log","value":"::Log.for(self)"}],"extended_modules":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"delete(key:String,inttl:Int32=0):Nil-class-method","name":"delete","doc":"Overload required for crystal 1.1-1.2.\nSoft Deprecation isn't shown, but it's here so this will get cleaned up at some point.\n@[Deprecated(\"To be removed when support for 1.1 is dropped. See RedisBackend.delete(String, Int64).\")]","summary":"

Overload required for crystal 1.1-1.2.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int32"}],"args_string":"(key : String, in ttl : Int32 = 0) : Nil","args_html":"(key : String, in ttl : Int32 = 0) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":86,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int32"}],"return_type":"Nil","visibility":"Public","body":"delete(key, in: ttl.to_i64)"}},{"html_id":"delete(key:String,inttl:Int64=0):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":90,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":"if (ttl > 0)\n redis.expire(key, ttl)\nelse\n redis.del(key)\nend"}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":98,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":"delete(key, ttl.to_i)"}},{"html_id":"expires_in(key:String):Int64-class-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":119,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"redis.ttl(key)"}},{"html_id":"flush:Nil-class-method","name":"flush","doc":"is this even a good idea?","summary":"

is this even a good idea?

","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":140,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.flushdb"}},{"html_id":"get(key:String,field:String):String|Nil-class-method","name":"get","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":102,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":"(redis.hget(key, field)).as?(String)"}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":115,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":"(redis.hincrby(key, field, value)).as(Int64)"}},{"html_id":"increment(key:String,field:String):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":111,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"increment(key, field, by: 1)"}},{"html_id":"list_queues:Array(String)-class-method","name":"list_queues","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":123,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"key = build_key(LIST_OF_QUEUES_KEY)\nlist_queues = (redis.zrange(key, 0, -1)).as(Array)\nif list_queues.any?\nelse\n return [] of String\nend\nlist_queues.compact_map() do |__arg1|\n __arg1.as(String)\nend\n"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":132,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":"runner_prefix = \"mosquito:runners:\"\n(Redis.instance.keys(\"#{runner_prefix}*\")).map() do |__arg2|\n __arg2.as(String)\nend.map(&.sub(runner_prefix, \"\"))\n"}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-class-method","name":"lock?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/redis_backend.cr","line_number":144,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":"response = redis.set(key, value, ex: ttl.to_i, nx: true)\nresponse == \"OK\"\n"}},{"html_id":"redis-class-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":56,"url":null},"def":{"name":"redis","visibility":"Public","body":"load_scripts = @@connection.nil?\nconnection = @@connection || (@@connection = ::Redis::Client.new(URI.parse(Mosquito.configuration.redis_url.to_s)))\nif load_scripts\n Scripts.load(connection)\nend\nconnection\n"}},{"html_id":"remove_matching_key(*,keys=[]ofString,args=[]ofString,loadscripts=true)-class-method","name":"remove_matching_key","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"keys","default_value":"[] of String","external_name":"keys","restriction":""},{"name":"args","default_value":"[] of String","external_name":"args","restriction":""},{"name":"loadscripts","default_value":"true","external_name":"loadscripts","restriction":""}],"args_string":"(*, keys = [] of String, args = [] of String, loadscripts = true)","args_html":"(*, keys = [] of String, args = [] of String, loadscripts = true)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":40,"url":null},"def":{"name":"remove_matching_key","args":[{"name":"","external_name":"","restriction":""},{"name":"keys","default_value":"[] of String","external_name":"keys","restriction":""},{"name":"args","default_value":"[] of String","external_name":"args","restriction":""},{"name":"loadscripts","default_value":"true","external_name":"loadscripts","restriction":""}],"splat_index":0,"visibility":"Public","body":"begin\n script = \" if redis.call(\\\"get\\\",KEYS[1]) == ARGV[1] then\\n return redis.call(\\\"del\\\",KEYS[1])\\n else\\n return 0\\n end\"\n digest = Scripts.remove_matching_key\n redis.evalsha(digest, keys: keys, args: args)\nrescue exception : Redis::Error\n if exception.message.try(&.starts_with?(\"NOSCRIPT\"))\n else\n raise(exception)\n end\n if loadscripts\n else\n raise(exception)\n end\n (Log.for(\"remove_matching_key\")).warn do\n \"Redis Scripts have gone missing, reloading\"\n end\n Scripts.load(redis)\n remove_matching_key(keys: keys, args: args, loadscripts: false)\nend"}},{"html_id":"retrieve(key:String):Hash(String,String)-class-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":78,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"result = ((redis.hgetall(key)).as(Array)).map(&.to_s)\n(result.in_groups_of(2, \"\")).to_h\n"}},{"html_id":"set(key:String,field:String,value:String):String-class-method","name":"set","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/redis_backend.cr","line_number":106,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":"redis.hset(key, field, value)\nvalue\n"}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-class-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":74,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":"redis.hset(key, value)"}},{"html_id":"unlock(key:String,value:String):Nil-class-method","name":"unlock","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":149,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":"remove_matching_key(keys: [key], args: [value])"}}],"constructors":[{"html_id":"new(name:String|Symbol)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"args_string":"(name : String | Symbol)","args_html":"(name : String | Symbol)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":70,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":181,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"if id = redis.lmove(waiting_q, pending_q, :right, :left)\n JobRun.retrieve(id.to_s)\nend"}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":158,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":"time = Time.utc\noverdue_job_runs = (redis.zrangebyscore(scheduled_q, \"0\", time.to_unix_ms.to_s)).as(Array)\nif overdue_job_runs.any?\nelse\n return [] of JobRun\nend\noverdue_job_runs.compact_map do |job_run_id|\n redis.zrem(scheduled_q, job_run_id.to_s)\n JobRun.retrieve(job_run_id.as(String))\nend\n"}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":"key = dead_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg6|\n __arg6.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg7|\n __arg7.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for dead\")\n end\n end\nend\n"}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":"key = pending_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg4|\n __arg4.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg5|\n __arg5.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for pending\")\n end\n end\nend\n"}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":"key = scheduled_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg2|\n __arg2.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg3|\n __arg3.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for scheduled\")\n end\n end\nend\n"}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":"key = waiting_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg0|\n __arg0.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg1|\n __arg1.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for waiting\")\n end\n end\nend\n"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/redis_backend.cr","line_number":170,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"redis.pipeline do |pipe|\n pipe.lpush(waiting_q, job_run.id)\n pipe.zadd(build_key(LIST_OF_QUEUES_KEY), Time.utc.to_unix.to_s, name)\nend\njob_run\n"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":187,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"redis.lrem(pending_q, 0, job_run.id)"}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":195,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.del(waiting_q, pending_q, scheduled_q, dead_q)"}},{"html_id":"redis-instance-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":66,"url":null},"def":{"name":"redis","visibility":"Public","body":"self.class.redis"}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/redis_backend.cr","line_number":153,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"redis.zadd(scheduled_q, scheduled_time.to_unix_ms.to_s, job_run.id)\njob_run\n"}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":233,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":"(redis.zscore(scheduled_q, job_run.id)).as?(String)"}},{"html_id":"size(include_dead=true):Int64-instance-method","name":"size","abstract":false,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":""}],"args_string":"(include_dead = true) : Int64","args_html":"(include_dead = true) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":204,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":""}],"return_type":"Int64","visibility":"Public","body":"queues = [waiting_q, pending_q]\nif include_dead\n queues << dead_q\nend\nqueue_size = queues.map do |key|\n (redis.llen(key)).as(Int64)\nend.reduce do |sum, i|\n sum + i\nend\nscheduled_size = redis.zcount(scheduled_q, \"0\", \"+inf\")\nqueue_size + (scheduled_size.as(Int64))\n"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":191,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"redis.lpush(dead_q, job_run.id)"}}]},{"html_id":"mosquito/Mosquito/Runnable","path":"Mosquito/Runnable.html","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable","abstract":false,"locations":[{"filename":"src/mosquito/runnable.cr","line_number":64,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Executor","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor"},{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"Runnable implements a general purpose spawn/loop which carries a state\nenum.\n\n## Managing a Runnable\n\nThe primary purpose of Runnable is to cleanly abstract the details of\nspawning a thread, running a loop, and shutting down when asked.\n\nA service which manages a Runnable might look like this:\n\n```crystal\nrunnable = MyRunnable.new\n\n# This will spawn and return immediately.\nrunnable.start\n\nputs runnable.state # => State::Working\n\n# Some time later...\nshould_be_stopped = runnable.stop has_stopped =\nshould_be_stopped.receive\n```\n\n\n## Implementing a Runnable\n\nA runnable implementation needs to implement only two methods: #each_run\nand #runnable_name. In addition, pre_run and post_run are available for\nsetup and teardown.\n\nRunnable state is managed automatically through startup and shutdown, but\nwithin each_run it can be manually altered with `#state=`.\n\n### Example\n\n```crystal\nclass MyRunnable\n include Mosquito::Runnable\n\n # Optional\n def pre_run\n puts \"my runnable is starting\"\n end\n\n def each_run\n puts \"my runnable is running\"\n end\n\n # Optional\n def post_run\n puts \"my runnable has stopped\"\n end\n\n def runnable_name\n \"MyRunnable\"\n end\nend\n```\n\nImplementation details about what work should be done in the spawned fiber\nare placed in #each_run.\n","summary":"

Runnable implements a general purpose spawn/loop which carries a state enum.

","instance_methods":[{"html_id":"dead?:Bool-instance-method","name":"dead?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":106,"url":null},"def":{"name":"dead?","return_type":"Bool","visibility":"Public","body":"if fiber_ = fiber\n fiber_.dead?\nelse\n false\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"Implementation of what this Runnable should do on each cycle.\n\nTake care that @state is #running? at the end of the method\nunless it is finished and should exit.","summary":"

Implementation of what this Runnable should do on each cycle.

","abstract":true,"location":{"filename":"src/mosquito/runnable.cr","line_number":168,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"fiber:Fiber|Nil-instance-method","name":"fiber","doc":"After #run has been called this holds a reference to the Fiber\nwhich is used to check that the fiber is still running.","summary":"

After #run has been called this holds a reference to the Fiber which is used to check that the fiber is still running.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":96,"url":null},"def":{"name":"fiber","return_type":"Fiber | ::Nil","visibility":"Public","body":"@fiber"}},{"html_id":"my_name:String-instance-method","name":"my_name","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":98,"url":null},"def":{"name":"my_name","return_type":"String","visibility":"Public","body":"if (value = @my_name).nil?\n @my_name = (\"#{self.class.name.underscore.gsub(\"::\", \".\")}.#{self.object_id}\")\nelse\n value\nend"}},{"html_id":"post_run:Nil-instance-method","name":"post_run","doc":"Available to hook any teardown logic after the run loop.","summary":"

Available to hook any teardown logic after the run loop.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":174,"url":null},"def":{"name":"post_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"pre_run:Nil-instance-method","name":"pre_run","doc":"Available to hook a one time setup before the run loop.","summary":"

Available to hook a one time setup before the run loop.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":171,"url":null},"def":{"name":"pre_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"run-instance-method","name":"run","doc":"Start the Runnable, and capture the fiber to a property.\n\nThe spawned fiber will not return as long as state.running?.\n\nState can be altered internally or externally to cause it to exit\nbut the cleanest way to do that is to call #stop.","summary":"

Start the Runnable, and capture the fiber to a property.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":120,"url":null},"def":{"name":"run","visibility":"Public","body":"@fiber = spawn(name: my_name) do\n log = Log.for(my_name)\n log.info do\n runnable_name + \" is starting\"\n end\n self.state = State::Working\n pre_run\n while state.running?\n each_run\n end\n post_run\n self.state = State::Finished\nend"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":true,"location":{"filename":"src/mosquito/runnable.cr","line_number":162,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":""}},{"html_id":"state:State-instance-method","name":"state","doc":"Tracks the state of this runnable.\n\nInitially it will be `State::Starting`. After `#run` is called it will\nbe `State::Working`.\n\nWhen `#stop` is called it will be `State::Stopping`. After `#run` finishes,\nit will be `State::Finished`.\n\nIt is not necessary to set this manually, but it's available to an implementation\nif needed. See `Mosquito::Runners::Executor#state=` (source code) for an example.","summary":"

Tracks the state of this runnable.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":92,"url":null},"def":{"name":"state","return_type":"State","visibility":"Public","body":"@state"}},{"html_id":"stop:Channel(Bool)-instance-method","name":"stop","doc":"Request that the next time the run loop cycles it should exit instead.\nThe runnable doesn't exit immediately so #stop returns a notification\nchannel.\n\n#stop spawns a fiber which monitors the state and sends a bool in two\ncircumstances. It will stop waiting for the spawn to exit at 25 seconds.\nIf the spawn has actually stopped the notification channel will broadcast\na true, otherwise false.","summary":"

Request that the next time the run loop cycles it should exit instead.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":145,"url":null},"def":{"name":"stop","return_type":"Channel(Bool)","visibility":"Public","body":"if state.running?\n self.state = State::Stopping\nend\nnotifier = Channel(Bool).new\nspawn do\n start = Time.utc\n while state.stopping? && (Time.utc - start) < 25.seconds\n Fiber.yield\n end\n notifier.send(state.finished?)\n Log.info do\n runnable_name + \" has stopped\"\n end\nend\nnotifier\n"}}],"types":[{"html_id":"mosquito/Mosquito/Runnable/State","path":"Mosquito/Runnable/State.html","kind":"enum","full_name":"Mosquito::Runnable::State","name":"State","abstract":false,"ancestors":[{"html_id":"mosquito/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"mosquito/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runnable.cr","line_number":65,"url":null}],"repository_name":"mosquito","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Starting","name":"Starting","value":"0"},{"id":"Working","name":"Working","value":"1"},{"id":"Idle","name":"Idle","value":"2"},{"id":"Stopping","name":"Stopping","value":"3"},{"id":"Finished","name":"Finished","value":"4"}],"namespace":{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},"instance_methods":[{"html_id":"finished?-instance-method","name":"finished?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":70,"url":null},"def":{"name":"finished?","visibility":"Public","body":"self == Finished"}},{"html_id":"idle?-instance-method","name":"idle?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":68,"url":null},"def":{"name":"idle?","visibility":"Public","body":"self == Idle"}},{"html_id":"running?-instance-method","name":"running?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":72,"url":null},"def":{"name":"running?","visibility":"Public","body":"(starting? || working?) || idle?"}},{"html_id":"started?-instance-method","name":"started?","doc":"ie, not starting","summary":"

ie, not starting

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":77,"url":null},"def":{"name":"started?","visibility":"Public","body":"working? || idle?"}},{"html_id":"starting?-instance-method","name":"starting?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":66,"url":null},"def":{"name":"starting?","visibility":"Public","body":"self == Starting"}},{"html_id":"stopping?-instance-method","name":"stopping?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":69,"url":null},"def":{"name":"stopping?","visibility":"Public","body":"self == Stopping"}},{"html_id":"working?-instance-method","name":"working?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":67,"url":null},"def":{"name":"working?","visibility":"Public","body":"self == Working"}}]}]},{"html_id":"mosquito/Mosquito/Runner","path":"Mosquito/Runner.html","kind":"class","full_name":"Mosquito::Runner","name":"Runner","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runner.cr","line_number":34,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"This singleton class serves as a shorthand for starting and managing an Overseer.\n\nA minimal usage of Mosquito::Runner is:\n\n```\nrequire \"mosquito\"\n\n# When the process receives sigint, it'll notify the overseer to shut down gracefully.\ntrap(\"INT\") do\n Mosquito::Runner.stop(wait: true)\nend\n\n# Starts the overseer, and holds the thread captive.\nMosquito::Runner.start\n```\n\nIf for some reason you want to manage an overseer or group of overseers yourself, Mosquito::Runner can be omitted entirely:\n\n```crystal\nrequire \"mosquito\"\n\nmosquito = Mosquito::Overseer.new\n\n# Spawns a mosquito managed fiber and returns immediately\nmosquito.run\n\ntrap \"INT\" do\n mosquito.stop.receive\nend\n```","summary":"

This singleton class serves as a shorthand for starting and managing an Overseer.

","class_methods":[{"html_id":"start(spin=true)-class-method","name":"start","doc":"Start the mosquito runner.\n\nIf spin = true (default) the function will not return until the runner is\nshut down. Otherwise it will return immediately.\n","summary":"

Start the mosquito runner.

","abstract":false,"args":[{"name":"spin","default_value":"true","external_name":"spin","restriction":""}],"args_string":"(spin = true)","args_html":"(spin = true)","location":{"filename":"src/mosquito/runner.cr","line_number":42,"url":null},"def":{"name":"start","args":[{"name":"spin","default_value":"true","external_name":"spin","restriction":""}],"visibility":"Public","body":"Log.notice do\n \"Mosquito is buzzing...\"\nend\ninstance.run\nwhile spin && keep_running\n Fiber.yield\nend\n"}},{"html_id":"stop(wait=false)-class-method","name":"stop","doc":"Request the mosquito runner stop. The runner will not abort the current job\nbut it will not start any new jobs.\n\nSee `Mosquito::Runnable#stop`.","summary":"

Request the mosquito runner stop.

","abstract":false,"args":[{"name":"wait","default_value":"false","external_name":"wait","restriction":""}],"args_string":"(wait = false)","args_html":"(wait = false)","location":{"filename":"src/mosquito/runner.cr","line_number":60,"url":null},"def":{"name":"stop","args":[{"name":"wait","default_value":"false","external_name":"wait","restriction":""}],"visibility":"Public","body":"Log.notice do\n \"Mosquito is shutting down...\"\nend\nfinished_notifier = instance.stop\nif wait\n finished_notifier.receive\nend\n"}}]},{"html_id":"mosquito/Mosquito/Runners","path":"Mosquito/Runners.html","kind":"module","full_name":"Mosquito::Runners","name":"Runners","abstract":false,"locations":[{"filename":"src/mosquito/runners/coordinator.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/executor.cr","line_number":4,"url":null},{"filename":"src/mosquito/runners/idle_wait.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/overseer.cr","line_number":6,"url":null},{"filename":"src/mosquito/runners/queue_list.cr","line_number":5,"url":null},{"filename":"src/mosquito/runners/run_at_most.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"types":[{"html_id":"mosquito/Mosquito/Runners/Coordinator","path":"Mosquito/Runners/Coordinator.html","kind":"class","full_name":"Mosquito::Runners::Coordinator","name":"Coordinator","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/coordinator.cr","line_number":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"LockTTL","name":"LockTTL","value":"10.seconds"},{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"primer? loader? _scheduler_","summary":"

primer? loader? scheduler

","constructors":[{"html_id":"new(queue_list:Mosquito::Runners::QueueList)-class-method","name":"new","abstract":false,"args":[{"name":"queue_list","external_name":"queue_list","restriction":"::Mosquito::Runners::QueueList"}],"args_string":"(queue_list : Mosquito::Runners::QueueList)","args_html":"(queue_list : Mosquito::Runners::QueueList)","location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"queue_list","external_name":"queue_list","restriction":"::Mosquito::Runners::QueueList"}],"visibility":"Public","body":"_ = allocate\n_.initialize(queue_list)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"enqueue_delayed_jobs-instance-method","name":"enqueue_delayed_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":67,"url":null},"def":{"name":"enqueue_delayed_jobs","visibility":"Public","body":"queue_list.each do |q|\n overdue_jobs = q.dequeue_scheduled\n if overdue_jobs.any?\n else\n next\n end\n (Log.for(\"enqueue_delayed_jobs\")).info do\n \"#{overdue_jobs.size} delayed jobs ready in #{q.name}\"\n end\n overdue_jobs.each do |job_run|\n q.enqueue(job_run)\n end\nend"}},{"html_id":"enqueue_periodic_jobs-instance-method","name":"enqueue_periodic_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":61,"url":null},"def":{"name":"enqueue_periodic_jobs","visibility":"Public","body":"Base.scheduled_job_runs.each do |scheduled_job_run|\n enqueued = scheduled_job_run.try_to_execute\nend"}},{"html_id":"instance_id:String-instance-method","name":"instance_id","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":8,"url":null},"def":{"name":"instance_id","return_type":"String","visibility":"Public","body":"@instance_id"}},{"html_id":"lock_key:String-instance-method","name":"lock_key","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":7,"url":null},"def":{"name":"lock_key","return_type":"String","visibility":"Public","body":"@lock_key"}},{"html_id":"only_if_coordinator(&):Nil-instance-method","name":"only_if_coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":29,"url":null},"def":{"name":"only_if_coordinator","yields":0,"block_arity":0,"return_type":"Nil","visibility":"Public","body":"duration = 0.seconds\nif Mosquito.configuration.run_cron_scheduler\n yield\n if @emitted_scheduling_deprecation_runtime_message\n else\n Log.warn do\n \"Scheduling coordinator / CRON Scheduler has been manually activated. This behavior is deprecated in favor of distributed locking. See https://github.com/mosquito-cr/mosquito/pull/108 \"\n end\n @emitted_scheduling_deprecation_runtime_message = true\n end\n return\nend\nif Mosquito.configuration.use_distributed_lock\nelse\n return\nend\nif Mosquito.backend.lock?(lock_key, instance_id, LockTTL)\n Log.trace do\n \"Coordinator lock acquired\"\n end\n duration = Time.measure do\n yield\n end\n Mosquito.backend.unlock(lock_key, instance_id)\n Log.trace do\n \"Coordinator lock released\"\n end\nend\nif duration > LockTTL\nelse\n return\nend\nLog.warn do\n \"Coordination activities took longer than LockTTL (#{duration} > #{LockTTL}) \"\nend\n"}},{"html_id":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":9,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":18,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"Coordinator<#{object_id}>\""}},{"html_id":"schedule:Nil-instance-method","name":"schedule","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":22,"url":null},"def":{"name":"schedule","return_type":"Nil","visibility":"Public","body":"only_if_coordinator do\n enqueue_periodic_jobs\n enqueue_delayed_jobs\nend"}}]},{"html_id":"mosquito/Mosquito/Runners/Executor","path":"Mosquito/Runners/Executor.html","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/executor.cr","line_number":23,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"The executor is the center of work in Mosquito, and it's is the demarcation\npoint between Mosquito framework and application code. Above the Executor\nis entirely Mosquito, and below it is application code.\n\nAn Executor is responsible for hydrating Job classes with deserialized\nparameters and calling `Mosquito::Job#run` on them. It measures the time it\ntakes to run a job and provides detailed log messages about the current\nstatus.\n\nAn executor is a `Mosquito::Runnable` and should be interacted with according to\nthe Runnable API.\n\nTo build an executor, provide a job input channel and an idle bell channel. These\nchannels can be shared between all available executors.\n\nThe executor will ring the idle bell when it is ready to accept work and then wait\nfor work to show up on the job pipeline. After the job is finished it will ring the\nbell again and wait for more work.","summary":"

The executor is the center of work in Mosquito, and it's is the demarcation point between Mosquito framework and application code.

","constructors":[{"html_id":"new(job_pipeline:Channel(Tuple(Mosquito::JobRun,Mosquito::Queue)),idle_bell:Channel(Bool))-class-method","name":"new","abstract":false,"args":[{"name":"job_pipeline","external_name":"job_pipeline","restriction":"::Channel(::Tuple(::Mosquito::JobRun, ::Mosquito::Queue))"},{"name":"idle_bell","external_name":"idle_bell","restriction":"::Channel(::Bool)"}],"args_string":"(job_pipeline : Channel(Tuple(Mosquito::JobRun, Mosquito::Queue)), idle_bell : Channel(Bool))","args_html":"(job_pipeline : Channel(Tuple(Mosquito::JobRun, Mosquito::Queue)), idle_bell : Channel(Bool))","location":{"filename":"src/mosquito/runners/executor.cr","line_number":51,"url":null},"def":{"name":"new","args":[{"name":"job_pipeline","external_name":"job_pipeline","restriction":"::Channel(::Tuple(::Mosquito::JobRun, ::Mosquito::Queue))"},{"name":"idle_bell","external_name":"idle_bell","restriction":"::Channel(::Bool)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(job_pipeline, idle_bell)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"execute(job_run:JobRun,from_queueq:Queue)-instance-method","name":"execute","doc":"Runs a job from a Queue.\n\nExecution time is measured and logged, and the job is either forgotten\nor, if it fails, rescheduled.","summary":"

Runs a job from a Queue.

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"q","external_name":"from_queue","restriction":"Queue"}],"args_string":"(job_run : JobRun, from_queue q : Queue)","args_html":"(job_run : JobRun, from_queue q : Queue)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":85,"url":null},"def":{"name":"execute","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"q","external_name":"from_queue","restriction":"Queue"}],"visibility":"Public","body":"log.info do\n \"#{\"Starting:\".colorize.magenta} #{job_run} from #{q.name}\"\nend\nduration = Time.measure do\n job_run.run\nend.total_seconds\nif job_run.succeeded?\n log.info do\n \"#{\"Success:\".colorize.green} #{job_run} finished and took #{time_with_units(duration)}\"\n end\n q.forget(job_run)\n job_run.delete(in: successful_job_ttl)\nelse\n message = String::Builder.new\n message << \"Failure: \".colorize.red\n message << job_run\n message << \" failed, taking \"\n message << (time_with_units(duration))\n message << \" and \"\n if job_run.rescheduleable?\n next_execution = Time.utc + job_run.reschedule_interval\n q.reschedule(job_run, next_execution)\n message << \"will run again\".colorize.cyan\n message << \" in \"\n message << job_run.reschedule_interval\n message << \" (at \"\n message << next_execution\n message << \")\"\n log.warn do\n message.to_s\n end\n else\n q.banish(job_run)\n job_run.delete(in: failed_job_ttl)\n message << \"cannot be rescheduled\".colorize.yellow\n log.error do\n message.to_s\n end\n end\nend\n"}},{"html_id":"failed_job_ttl:Int32-instance-method","name":"failed_job_ttl","doc":"How long a job config is persisted after failure","summary":"

How long a job config is persisted after failure

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":34,"url":null},"def":{"name":"failed_job_ttl","return_type":"Int32","visibility":"Public","body":"if (value = @failed_job_ttl).nil?\n @failed_job_ttl = (Mosquito.configuration.failed_job_ttl)\nelse\n value\nend"}},{"html_id":"failed_job_ttl=(failed_job_ttl:Int32)-instance-method","name":"failed_job_ttl=","doc":"How long a job config is persisted after failure","summary":"

How long a job config is persisted after failure

","abstract":false,"args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"args_string":"(failed_job_ttl : Int32)","args_html":"(failed_job_ttl : Int32)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":34,"url":null},"def":{"name":"failed_job_ttl=","args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@failed_job_ttl = failed_job_ttl"}},{"html_id":"idle_bell:Channel(Bool)-instance-method","name":"idle_bell","doc":"Used to notify the overseer that this executor is idle.","summary":"

Used to notify the overseer that this executor is idle.

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":40,"url":null},"def":{"name":"idle_bell","return_type":"Channel(Bool)","visibility":"Public","body":"@idle_bell"}},{"html_id":"job_pipeline:Channel(Tuple(JobRun,Queue))-instance-method","name":"job_pipeline","doc":"Where work is received from the overseer.","summary":"

Where work is received from the overseer.

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":37,"url":null},"def":{"name":"job_pipeline","return_type":"Channel(Tuple(JobRun, Queue))","visibility":"Public","body":"@job_pipeline"}},{"html_id":"log:::Log-instance-method","name":"log","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":28,"url":null},"def":{"name":"log","return_type":"::Log","visibility":"Public","body":"@log"}},{"html_id":"successful_job_ttl:Int32-instance-method","name":"successful_job_ttl","doc":"How long a job config is persisted after success","summary":"

How long a job config is persisted after success

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":31,"url":null},"def":{"name":"successful_job_ttl","return_type":"Int32","visibility":"Public","body":"if (value = @successful_job_ttl).nil?\n @successful_job_ttl = (Mosquito.configuration.successful_job_ttl)\nelse\n value\nend"}},{"html_id":"successful_job_ttl=(successful_job_ttl:Int32)-instance-method","name":"successful_job_ttl=","doc":"How long a job config is persisted after success","summary":"

How long a job config is persisted after success

","abstract":false,"args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"args_string":"(successful_job_ttl : Int32)","args_html":"(successful_job_ttl : Int32)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":31,"url":null},"def":{"name":"successful_job_ttl=","args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@successful_job_ttl = successful_job_ttl"}}]},{"html_id":"mosquito/Mosquito/Runners/IdleWait","path":"Mosquito/Runners/IdleWait.html","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait","abstract":false,"locations":[{"filename":"src/mosquito/runners/idle_wait.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"instance_methods":[{"html_id":"with_idle_wait(idle_wait:Time::Span,&)-instance-method","name":"with_idle_wait","abstract":false,"args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"args_string":"(idle_wait : Time::Span, &)","args_html":"(idle_wait : Time::Span, &)","location":{"filename":"src/mosquito/runners/idle_wait.cr","line_number":3,"url":null},"def":{"name":"with_idle_wait","args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"yields":0,"block_arity":0,"visibility":"Public","body":"delta = Time.measure do\n yield\nend\nif delta < idle_wait\n sleep(idle_wait - delta)\nend\n"}}]},{"html_id":"mosquito/Mosquito/Runners/Overseer","path":"Mosquito/Runners/Overseer.html","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/overseer.cr","line_number":14,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"The Overseer is responsible for managing:\n- a `Coordinator`\n- an `Executor`\n- the `QueueList`\n- any idle state as configured\n\nAn overseer manages the loop that each thread or process runs.","summary":"

The Overseer is responsible for managing: - a Coordinator - an Executor - the QueueList - any idle state as configured

","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":39,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_executor:Executor-instance-method","name":"build_executor","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":52,"url":null},"def":{"name":"build_executor","return_type":"Executor","visibility":"Public","body":"Executor.new(work_handout, idle_notifier)"}},{"html_id":"check_for_deceased_runners:Nil-instance-method","name":"check_for_deceased_runners","doc":"If an executor dies, it's probably because a bug exists somewhere in Mosquito itself.\n\nWhen a job fails any exceptions are caught and logged. If a job causes something more\ncatastrophic we can try to recover by spawning a new executor.","summary":"

If an executor dies, it's probably because a bug exists somewhere in Mosquito itself.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":162,"url":null},"def":{"name":"check_for_deceased_runners","return_type":"Nil","visibility":"Public","body":"executors.select do |e|\n e.state.started?\nend.select(&.dead?).each do |dead_executor|\n Log.fatal do\n \" Executor #{dead_executor.runnable_name} died.\\n A new executor will be started.\"\n end\n executors.delete(dead_executor)\nend\n(executor_count - executors.size).times do\n executors << build_executor.tap(&.run)\nend\nif queue_list.dead?\n Log.fatal do\n \"QueueList has died, overseer will stop.\"\n end\n stop\nend\n"}},{"html_id":"coordinator:Mosquito::Runners::Coordinator-instance-method","name":"coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":23,"url":null},"def":{"name":"coordinator","visibility":"Public","body":"@coordinator"}},{"html_id":"dequeue_job?:Tuple(JobRun,Queue)|Nil-instance-method","name":"dequeue_job?","doc":"Weaknesses: This implementation sometimes starves queues because it doesn't\nround robin, prioritize queues, or anything else.","summary":"

Weaknesses: This implementation sometimes starves queues because it doesn't round robin, prioritize queues, or anything else.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":150,"url":null},"def":{"name":"dequeue_job?","return_type":"Tuple(JobRun, Queue) | ::Nil","visibility":"Public","body":"queue_list.each do |q|\n if job_run = q.dequeue\n return {job_run, q}\n end\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"The goal for the overseer is to:\n- Ensure that the coordinator gets run frequently to schedule delayed/periodic jobs.\n- Wait for an executor to be idle, and dequeue work if possible.\n- Monitor the executor pool for unexpected termination and respawn.","summary":"

The goal for the overseer is to: - Ensure that the coordinator gets run frequently to schedule delayed/periodic jobs.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":87,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":"coordinator.schedule\nif work_handout.closed? || idle_notifier.closed?\n Log.fatal do\n \"Executor communication channels closed, overseer will stop.\"\n end\n stop\n return\nend\nif queue_list.state.started?\nelse\n Log.debug do\n \"Waiting for the queue list to fetch possible queues\"\n end\n return\nend\nLog.trace do\n \"Waiting for an idle executor\"\nend\nall_executors_busy = true\nselect\nwhen @idle_notifier.receive\n Log.trace do\n \"Found an idle executor\"\n end\n all_executors_busy = false\nwhen timeout(idle_wait)\nend\n\ncase\nwhen all_executors_busy\n Log.trace do\n \"No idle executors\"\n end\nwhen next_job_run = dequeue_job?\n job_run, queue = next_job_run\n Log.trace do\n \"Dequeued job: #{job_run.id} #{queue.name}\"\n end\n work_handout.send(next_job_run)\nelse\n Log.trace do\n \"No job to dequeue\"\n end\n sleep\n spawn do\n @idle_notifier.send(true)\n end\nend\ncheck_for_deceased_runners\n"}},{"html_id":"executor_count:Int32-instance-method","name":"executor_count","doc":"The number of executors to start.","summary":"

The number of executors to start.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":33,"url":null},"def":{"name":"executor_count","visibility":"Public","body":"@executor_count"}},{"html_id":"executors:Array(Mosquito::Runners::Executor)-instance-method","name":"executors","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":22,"url":null},"def":{"name":"executors","visibility":"Public","body":"@executors"}},{"html_id":"idle_notifier:Channel(Bool)-instance-method","name":"idle_notifier","doc":"When an executor transitions to idle it will send a True here. The Overseer\nuses this as a signal to check the queues for more work.","summary":"

When an executor transitions to idle it will send a True here.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":30,"url":null},"def":{"name":"idle_notifier","visibility":"Public","body":"@idle_notifier"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":35,"url":null},"def":{"name":"idle_wait","return_type":"Time::Span","visibility":"Public","body":"if (value = @idle_wait).nil?\n @idle_wait = (Mosquito.configuration.idle_wait)\nelse\n value\nend"}},{"html_id":"post_run:Nil-instance-method","name":"post_run","doc":"Notify all subprocesses to stop, and wait until they do.","summary":"

Notify all subprocesses to stop, and wait until they do.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":73,"url":null},"def":{"name":"post_run","return_type":"Nil","visibility":"Public","body":"Log.info do\n \"Stopping #{@executors.size} executors.\"\nend\nstopped_notifiers = executors.map do |executor|\n executor.stop\nend\nwork_handout.close\nstopped_notifiers.each(&.receive)\nLog.info do\n \"All executors stopped.\"\nend\n"}},{"html_id":"pre_run:Nil-instance-method","name":"pre_run","doc":"Starts all the subprocesses.","summary":"

Starts all the subprocesses.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":66,"url":null},"def":{"name":"pre_run","return_type":"Nil","visibility":"Public","body":"Log.info do\n \"Starting #{@executors.size} executors.\"\nend\n@queue_list.run\n@executors.each(&.run)\n"}},{"html_id":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":56,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"Overseer<#{object_id}>\""}},{"html_id":"sleep-instance-method","name":"sleep","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":60,"url":null},"def":{"name":"sleep","visibility":"Public","body":"Log.trace do\n \"Going to sleep now for #{idle_wait}\"\nend\nsleep(idle_wait)\n"}},{"html_id":"work_handout:Channel({Mosquito::JobRun,Mosquito::Queue})-instance-method","name":"work_handout","doc":"The channel where job runs which have been dequeued are sent to executors.","summary":"

The channel where job runs which have been dequeued are sent to executors.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":26,"url":null},"def":{"name":"work_handout","visibility":"Public","body":"@work_handout"}}]},{"html_id":"mosquito/Mosquito/Runners/QueueList","path":"Mosquito/Runners/QueueList.html","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/queue_list.cr","line_number":7,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"QueueList handles searching the redis keyspace for named queues.","summary":"

QueueList handles searching the redis keyspace for named queues.

","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":16,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"each(*args,**options)-instance-method","name":"each","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":24,"url":null},"def":{"name":"each","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"@queues.shuffle.each(*args, **options)"}},{"html_id":"each(*args,**options,&)-instance-method","name":"each","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":24,"url":null},"def":{"name":"each","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"@queues.shuffle.each(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"Implementation of what this Runnable should do on each cycle.\n\nTake care that @state is #running? at the end of the method\nunless it is finished and should exit.","summary":"

Implementation of what this Runnable should do on each cycle.

","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":26,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":"with_idle_wait(1.seconds) do\n @state = State::Working\n candidate_queues = Mosquito.backend.list_queues.map do |name|\n Queue.new(name)\n end\n new_queue_list = filter_queues(candidate_queues)\n Log.notice do\n queues_which_were_expected_but_not_found = @queues - new_queue_list\n queues_which_have_never_been_seen = new_queue_list - @queues\n if queues_which_have_never_been_seen.size > 0\n \"found #{queues_which_have_never_been_seen.size} new queues: #{queues_which_have_never_been_seen.map(&.name).join(\", \")}\"\n end\n end\n @queues = new_queue_list\n @state = State::Idle\nend"}},{"html_id":"queues:Array(Queue)-instance-method","name":"queues","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":14,"url":null},"def":{"name":"queues","return_type":"Array(Queue)","visibility":"Public","body":"@queues"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":20,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"QueueList<#{object_id}>\""}}]},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","path":"Mosquito/Runners/RunAtMost.html","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost","abstract":false,"locations":[{"filename":"src/mosquito/runners/run_at_most.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Executor","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor"},{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"instance_methods":[{"html_id":"execution_timestamps-instance-method","name":"execution_timestamps","abstract":false,"location":{"filename":"src/mosquito/runners/run_at_most.cr","line_number":3,"url":null},"def":{"name":"execution_timestamps","visibility":"Public","body":"@execution_timestamps"}}]}]},{"html_id":"mosquito/Mosquito/ScheduledJob","path":"Mosquito/ScheduledJob.html","kind":"class","full_name":"Mosquito::ScheduledJob","name":"ScheduledJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/scheduled_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":3,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_job_run-instance-method","name":"build_job_run","abstract":true,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":6,"url":null},"def":{"name":"build_job_run","visibility":"Public","body":""}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":20,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"false"}}]},{"html_id":"mosquito/Mosquito/Scripts","path":"Mosquito/Scripts.html","kind":"module","full_name":"Mosquito::Scripts","name":"Scripts","abstract":false,"locations":[{"filename":"src/mosquito/redis_backend.cr","line_number":5,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SCRIPTS","name":"SCRIPTS","value":"{:remove_matching_key => \" if redis.call(\\\"get\\\",KEYS[1]) == ARGV[1] then\\n return redis.call(\\\"del\\\",KEYS[1])\\n else\\n return 0\\n end\"}"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"load(connection)-class-method","name":"load","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":""}],"args_string":"(connection)","args_html":"(connection)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":18,"url":null},"def":{"name":"load","args":[{"name":"connection","external_name":"connection","restriction":""}],"visibility":"Public","body":"SCRIPTS.each do |name, script|\n sha = @@script_sha[name] = connection.script_load(script)\n Log.info do\n \"loading script : #{name} => #{sha}\"\n end\nend"}},{"html_id":"remove_matching_key-class-method","name":"remove_matching_key","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":25,"url":null},"def":{"name":"remove_matching_key","visibility":"Public","body":"@@script_sha[:remove_matching_key]"}}]},{"html_id":"mosquito/Mosquito/Serializers","path":"Mosquito/Serializers.html","kind":"module","full_name":"Mosquito::Serializers","name":"Serializers","abstract":false,"locations":[{"filename":"src/mosquito/serializers/primitives.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"types":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","path":"Mosquito/Serializers/Primitives.html","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives","abstract":false,"locations":[{"filename":"src/mosquito/serializers/primitives.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"}],"namespace":{"html_id":"mosquito/Mosquito/Serializers","kind":"module","full_name":"Mosquito::Serializers","name":"Serializers"},"instance_methods":[{"html_id":"deserialize_bool(raw:String):Bool-instance-method","name":"deserialize_bool","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Bool","args_html":"(raw : String) : Bool","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":14,"url":null},"def":{"name":"deserialize_bool","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Bool","visibility":"Public","body":"raw == \"true\""}},{"html_id":"deserialize_char(raw:String):Char-instance-method","name":"deserialize_char","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Char","args_html":"(raw : String) : Char","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":26,"url":null},"def":{"name":"deserialize_char","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Char","visibility":"Public","body":"raw[0]"}},{"html_id":"deserialize_float32(raw:String):Float32|Nil-instance-method","name":"deserialize_float32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Float32 | Nil","args_html":"(raw : String) : Float32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_float32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Float32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_f32\nend"}},{"html_id":"deserialize_float64(raw:String):Float64|Nil-instance-method","name":"deserialize_float64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Float64 | Nil","args_html":"(raw : String) : Float64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_float64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Float64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_f64\nend"}},{"html_id":"deserialize_int128(raw:String):Int128|Nil-instance-method","name":"deserialize_int128","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int128 | Nil","args_html":"(raw : String) : Int128 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int128","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int128 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i128\nend"}},{"html_id":"deserialize_int16(raw:String):Int16|Nil-instance-method","name":"deserialize_int16","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int16 | Nil","args_html":"(raw : String) : Int16 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int16","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int16 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i16\nend"}},{"html_id":"deserialize_int32(raw:String):Int32|Nil-instance-method","name":"deserialize_int32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int32 | Nil","args_html":"(raw : String) : Int32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i32\nend"}},{"html_id":"deserialize_int64(raw:String):Int64|Nil-instance-method","name":"deserialize_int64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int64 | Nil","args_html":"(raw : String) : Int64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i64\nend"}},{"html_id":"deserialize_int8(raw:String):Int8|Nil-instance-method","name":"deserialize_int8","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int8 | Nil","args_html":"(raw : String) : Int8 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int8","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int8 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i8\nend"}},{"html_id":"deserialize_string(raw:String):String-instance-method","name":"deserialize_string","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : String","args_html":"(raw : String) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":6,"url":null},"def":{"name":"deserialize_string","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"String","visibility":"Public","body":"raw"}},{"html_id":"deserialize_u_int128(raw:String):UInt128|Nil-instance-method","name":"deserialize_u_int128","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt128 | Nil","args_html":"(raw : String) : UInt128 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int128","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt128 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u128\nend"}},{"html_id":"deserialize_u_int16(raw:String):UInt16|Nil-instance-method","name":"deserialize_u_int16","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt16 | Nil","args_html":"(raw : String) : UInt16 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int16","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt16 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u16\nend"}},{"html_id":"deserialize_u_int32(raw:String):UInt32|Nil-instance-method","name":"deserialize_u_int32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt32 | Nil","args_html":"(raw : String) : UInt32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u32\nend"}},{"html_id":"deserialize_u_int64(raw:String):UInt64|Nil-instance-method","name":"deserialize_u_int64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt64 | Nil","args_html":"(raw : String) : UInt64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u64\nend"}},{"html_id":"deserialize_u_int8(raw:String):UInt8|Nil-instance-method","name":"deserialize_u_int8","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt8 | Nil","args_html":"(raw : String) : UInt8 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int8","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt8 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u8\nend"}},{"html_id":"deserialize_uuid(raw:String):UUID-instance-method","name":"deserialize_uuid","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UUID","args_html":"(raw : String) : UUID","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":34,"url":null},"def":{"name":"deserialize_uuid","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UUID","visibility":"Public","body":"UUID.new(raw)"}},{"html_id":"serialize_bool(value:Bool):String-instance-method","name":"serialize_bool","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(value : Bool) : String","args_html":"(value : Bool) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":10,"url":null},"def":{"name":"serialize_bool","args":[{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_char(char:Char):String-instance-method","name":"serialize_char","abstract":false,"args":[{"name":"char","external_name":"char","restriction":"Char"}],"args_string":"(char : Char) : String","args_html":"(char : Char) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":22,"url":null},"def":{"name":"serialize_char","args":[{"name":"char","external_name":"char","restriction":"Char"}],"return_type":"String","visibility":"Public","body":"char.to_s"}},{"html_id":"serialize_float32(value):String-instance-method","name":"serialize_float32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_float32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_float64(value):String-instance-method","name":"serialize_float64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_float64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int128(value):String-instance-method","name":"serialize_int128","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int128","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int16(value):String-instance-method","name":"serialize_int16","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int16","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int32(value):String-instance-method","name":"serialize_int32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int64(value):String-instance-method","name":"serialize_int64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int8(value):String-instance-method","name":"serialize_int8","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int8","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_string(str:String):String-instance-method","name":"serialize_string","abstract":false,"args":[{"name":"str","external_name":"str","restriction":"String"}],"args_string":"(str : String) : String","args_html":"(str : String) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":2,"url":null},"def":{"name":"serialize_string","args":[{"name":"str","external_name":"str","restriction":"String"}],"return_type":"String","visibility":"Public","body":"str"}},{"html_id":"serialize_symbol(sym:Symbol):Nil-instance-method","name":"serialize_symbol","abstract":false,"args":[{"name":"sym","external_name":"sym","restriction":"Symbol"}],"args_string":"(sym : Symbol) : Nil","args_html":"(sym : Symbol) : Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":18,"url":null},"def":{"name":"serialize_symbol","args":[{"name":"sym","external_name":"sym","restriction":"Symbol"}],"return_type":"Nil","visibility":"Public","body":"raise(\"Symbols cannot be deserialized. Stringify your symbol first to pass it as a mosquito job parameter.\")"}},{"html_id":"serialize_u_int128(value):String-instance-method","name":"serialize_u_int128","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int128","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int16(value):String-instance-method","name":"serialize_u_int16","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int16","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int32(value):String-instance-method","name":"serialize_u_int32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int64(value):String-instance-method","name":"serialize_u_int64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int8(value):String-instance-method","name":"serialize_u_int8","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int8","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_uuid(uuid:UUID):String-instance-method","name":"serialize_uuid","abstract":false,"args":[{"name":"uuid","external_name":"uuid","restriction":"UUID"}],"args_string":"(uuid : UUID) : String","args_html":"(uuid : UUID) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":30,"url":null},"def":{"name":"serialize_uuid","args":[{"name":"uuid","external_name":"uuid","restriction":"UUID"}],"return_type":"String","visibility":"Public","body":"uuid.to_s"}}]}]},{"html_id":"mosquito/Mosquito/TestBackend","path":"Mosquito/TestBackend.html","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend","abstract":false,"superclass":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"ancestors":[{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/test_backend.cr","line_number":38,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"An in-memory noop backend desigend to be used in application testing.\n\nThe test mode backend simply makes a copy of job_runs at enqueue time and holds them in a class getter array.\n\nJob run id, config (aka parameters), and runtime class are kept in memory, and a truncate utility function is provided.\n\nActivate test mode configure the test backend like this:\n\n```\nMosquito.configure do |settings|\n settings.backend = Mosquito::TestBackend\nend\n```\n\nThen in your tests:\n\n```\ndescribe \"testing\" do\n it \"enqueues the job\" do\n # build and enqueue a job\n job_run = EchoJob.new(text: \"hello world\").enqueue\n\n # assert that the job was enqueued\n lastest_enqueued_job = Mosquito::TestBackend.enqueued_jobs.last\n\n # check the job config\n assert_equal \"hello world\", latest_enqueued_job.config[\"text\"]\n\n # check the job_id matches\n assert_equal job_run.id, latest_enqueued_job.id\n\n # optionally, truncate the history\n Mosquito::TestBackend.flush_enqueued_jobs!\n end\nend\n```","summary":"

An in-memory noop backend desigend to be used in application testing.

","class_methods":[{"html_id":"delete(key:String,inttl:Int64=0):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":54,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":57,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"enqueued_jobs-class-method","name":"enqueued_jobs","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":106,"url":null},"def":{"name":"enqueued_jobs","visibility":"Public","body":"@@enqueued_jobs"}},{"html_id":"enqueued_jobs=(enqueued_jobs:Array(Mosquito::TestBackend::EnqueuedJob))-class-method","name":"enqueued_jobs=","abstract":false,"args":[{"name":"enqueued_jobs","external_name":"enqueued_jobs","restriction":"::Array(::Mosquito::TestBackend::EnqueuedJob)"}],"args_string":"(enqueued_jobs : Array(Mosquito::TestBackend::EnqueuedJob))","args_html":"(enqueued_jobs : Array(Mosquito::TestBackend::EnqueuedJob))","location":{"filename":"src/mosquito/test_backend.cr","line_number":106,"url":null},"def":{"name":"enqueued_jobs=","args":[{"name":"enqueued_jobs","external_name":"enqueued_jobs","restriction":"::Array(::Mosquito::TestBackend::EnqueuedJob)"}],"visibility":"Public","body":"@@enqueued_jobs = enqueued_jobs"}},{"html_id":"expires_in(key:String):Int64-class-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":60,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"flush:Nil-class-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":79,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"flush_enqueued_jobs!-class-method","name":"flush_enqueued_jobs!","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":108,"url":null},"def":{"name":"flush_enqueued_jobs!","visibility":"Public","body":"@@enqueued_jobs = [] of EnqueuedJob"}},{"html_id":"get(key:String,field:String):String|Nil-class-method","name":"get","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":64,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":75,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"increment(key:String,field:String):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":71,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"list_queues:Array(String)-class-method","name":"list_queues","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":46,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":50,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-class-method","name":"lock?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/test_backend.cr","line_number":81,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":"false"}},{"html_id":"retrieve(key:String):Hash(String,String)-class-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/test_backend.cr","line_number":42,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"{} of String => String"}},{"html_id":"set(key:String,field:String,value:String):String-class-method","name":"set","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/test_backend.cr","line_number":67,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":"\"\""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-class-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":39,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"unlock(key:String,value:String):Nil-class-method","name":"unlock","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":85,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":""}}],"instance_methods":[{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":117,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"raise(\"Mosquito: attempted to dequeue a job from the testing backend.\")"}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":125,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":"raise(\"Mosquito: attempted to deschedule a job from the testing backend.\")"}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/test_backend.cr","line_number":112,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"@@enqueued_jobs << (EnqueuedJob.from(job_run))\njob_run\n"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":129,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":135,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/test_backend.cr","line_number":121,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"job_run"}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":148,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"size(include_dead:Bool=true):Int64-instance-method","name":"size","abstract":false,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"args_string":"(include_dead : Bool = true) : Int64","args_html":"(include_dead : Bool = true) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":138,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":132,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}}],"types":[{"html_id":"mosquito/Mosquito/TestBackend/EnqueuedJob","path":"Mosquito/TestBackend/EnqueuedJob.html","kind":"struct","full_name":"Mosquito::TestBackend::EnqueuedJob","name":"EnqueuedJob","abstract":false,"superclass":{"html_id":"mosquito/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"mosquito/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/test_backend.cr","line_number":88,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/TestBackend","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend"},"class_methods":[{"html_id":"from(job_run:JobRun)-class-method","name":"from","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":93,"url":null},"def":{"name":"from","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"job_class = Mosquito::Base.job_for_type(job_run.type)\nnew(job_run.id, job_class, job_run.config)\n"}}],"constructors":[{"html_id":"new(id:String,klass:::Mosquito::Job.class,config:Hash(String,String))-class-method","name":"new","abstract":false,"args":[{"name":"id","external_name":"id","restriction":"::String"},{"name":"klass","external_name":"klass","restriction":"::Mosquito::Job.class"},{"name":"config","external_name":"config","restriction":"::Hash(::String, ::String)"}],"args_string":"(id : String, klass : ::Mosquito::Job.class, config : Hash(String, String))","args_html":"(id : String, klass : ::Mosquito::Job.class, config : Hash(String, String))","location":{"filename":"src/mosquito/test_backend.cr","line_number":102,"url":null},"def":{"name":"new","args":[{"name":"id","external_name":"id","restriction":"::String"},{"name":"klass","external_name":"klass","restriction":"::Mosquito::Job.class"},{"name":"config","external_name":"config","restriction":"::Hash(::String, ::String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(id, klass, config)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"config:Hash(String,String)-instance-method","name":"config","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":91,"url":null},"def":{"name":"config","return_type":"Hash(String, String)","visibility":"Public","body":"@config"}},{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":89,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"klass:Mosquito::Job.class-instance-method","name":"klass","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":90,"url":null},"def":{"name":"klass","return_type":"Mosquito::Job.class","visibility":"Public","body":"@klass"}}]}]}]}]}}) \ No newline at end of file +crystal_doc_search_index_callback({"repository_name":"mosquito","body":"\"mosquito\"\n\n[![GitHub](https://img.shields.io/github/license/mosquito-cr/mosquito.svg?style=for-the-badge)](https://tldrlegal.com/license/mit-license)\n\n\n\nMosquito is a generic background job runner written primarily for Crystal. Significant inspiration from experience with the successes and failings many Ruby gems in this vein. Once compiled, a mosquito binary can start work in about 10 milliseconds.\n\nMosquito currently provides these features:\n\n- Delayed execution (`SendEmailJob.new(email: :welcome, address: user.email).enqueue(in: 3.minutes)`)\n- Scheduled / Periodic execution (`RunEveryHourJob.new`)\n- Job Storage in Redis\n- Automatic rescheduling of failed jobs\n- Progressively increasing delay of rescheduled failed jobs\n- Dead letter queue of jobs which have failed too many times\n- Rate limited jobs\n\nCurrent Limitations:\n- Visibility into a running job network and queue is limited. There is a working proof of concept [visualization API](https://github.com/mosquito-cr/mosquito/issues/90) and [bare-bones terminal application](https://github.com/mosquito-cr/tui-visualizer).\n\n## Project State\n\nThe Mosquito project is stable. A few folks are using Mosquito in production, and it's going okay.\n\nThere are some features which would be nice to have, but what is here is both tried and tested.\n\nIf you're using Mosquito, please [get in touch](https://github.com/mosquito-cr/mosquito/discussions) on the Discussion board or [on Crystal chat](https://crystal-lang.org/community/) with any questions, feature suggestions, or feedback.\n\n## Installation\n\nUpdate your `shard.yml` to include mosquito:\n\n```diff\ndependencies:\n+ mosquito:\n+ github: mosquito-cr/mosquito\n```\n\n## Usage\n\n### Step 1: Define a queued job\n\n```crystal\n# src/jobs/puts_job.cr\nclass PutsJob < Mosquito::QueuedJob\n param message : String\n\n def perform\n puts message\n end\nend\n```\n\n### Step 2: Trigger that job\n\n```crystal\n# src//.cr\nPutsJob.new(message: \"ohai background job\").enqueue\n```\n\n### Step 3: Run your worker to process the job\n\n```crystal\n# src/worker.cr\n\nMosquito.configure do |settings|\n settings.redis_url = ENV[\"REDIS_URL\"]\nend\n\nMosquito::Runner.start\n```\n\n```text\ncrystal run src/worker.cr\n```\n\n### Success\n\n```\n> crystal run src/worker.cr\n2017-11-06 17:07:29 - Mosquito is buzzing...\n2017-11-06 17:07:51 - Running task puts_job<...> from puts_job\n2017-11-06 17:07:51 - [PutsJob] ohai background job\n2017-11-06 17:07:51 - task puts_job<...> succeeded, took 0.0 seconds\n```\n\n[More information about queued jobs](https://mosquito-cr.github.io/manual/index.html#queued-jobs) in the manual.\n\n------\n\n## Periodic Jobs\n\nPeriodic jobs run according to a predefined period -- once an hour, etc.\n\nThis periodic job:\n```crystal\nclass PeriodicallyPutsJob < Mosquito::PeriodicJob\n run_every 1.minute\n\n def perform\n emotions = %w{happy sad angry optimistic political skeptical epuhoric}\n puts \"The time is now #{Time.local} and the wizard is feeling #{emotions.sample}\"\n end\nend\n```\n\nWould produce this output:\n```crystal\n2017-11-06 17:20:13 - Mosquito is buzzing...\n2017-11-06 17:20:13 - Queues: periodically_puts_job\n2017-11-06 17:20:13 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:20:13 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:20:13 and the wizard is feeling skeptical\n2017-11-06 17:20:13 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n2017-11-06 17:21:14 - Queues: periodically_puts_job\n2017-11-06 17:21:14 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:21:14 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:21:14 and the wizard is feeling optimistic\n2017-11-06 17:21:14 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n2017-11-06 17:22:15 - Queues: periodically_puts_job\n2017-11-06 17:22:15 - Running task periodically_puts_job<...> from periodically_puts_job\n2017-11-06 17:22:15 - [PeriodicallyPutsJob] The time is now 2017-11-06 17:22:15 and the wizard is feeling political\n2017-11-06 17:22:15 - task periodically_puts_job<...> succeeded, took 0.0 seconds\n```\n\n[More information on periodic jobs](https://mosquito-cr.github.io/manual/index.html#periodic-jobs) in the manual.\n\n## Advanced usage\n\nFor more advanced topics, including [use with Lucky Framework](https://mosquito-cr.github.io/manual/lucky_framework.html), [throttling or rate limiting](https://mosquito-cr.github.io/manual/rate_limiting.html), check out the [full manual](https://mosquito-cr.github.io/manual).\n\n## Contributing\n\nContributions are welcome. Please fork the repository, commit changes on a branch, and then open a pull request.\n\n### Crystal Versions\n\nMosquito aims to be compatible with the latest Crystal release, and the [latest patch for all post-1.0 minor crystal versions](https://github.com/mosquito-cr/mosquito/blob/master/.github/workflows/ci.yml#L17).\n\nFor development purposes [you're encouraged to stay in sync with `.tool-versions`](https://github.com/mosquito-cr/mosquito/blob/master/.tool-versions).\n\n### Testing\n\nThis repository uses [minitest](https://github.com/ysbaddaden/minitest.cr) for testing. As a result, `crystal spec` doesn't do anything helpful. Do this instead:\n\n```\nmake test\n```\n\nIn lieu of `crystal spec` bells and whistles, Minitest provides a nice alternative to [running one test at a time instead of the whole suite](https://github.com/ysbaddaden/minitest.cr/pull/31).\n","program":{"html_id":"mosquito/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"mosquito","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"mosquito/Mosquito","path":"Mosquito.html","kind":"module","full_name":"Mosquito","name":"Mosquito","abstract":false,"locations":[{"filename":"src/mosquito.cr","line_number":5,"url":null},{"filename":"src/mosquito/backend.cr","line_number":1,"url":null},{"filename":"src/mosquito/base.cr","line_number":1,"url":null},{"filename":"src/mosquito/configuration.cr","line_number":1,"url":null},{"filename":"src/mosquito/exceptions.cr","line_number":1,"url":null},{"filename":"src/mosquito/job.cr","line_number":3,"url":null},{"filename":"src/mosquito/job_run.cr","line_number":1,"url":null},{"filename":"src/mosquito/key_builder.cr","line_number":1,"url":null},{"filename":"src/mosquito/metadata.cr","line_number":1,"url":null},{"filename":"src/mosquito/periodic_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/periodic_job_run.cr","line_number":1,"url":null},{"filename":"src/mosquito/queue.cr","line_number":1,"url":null},{"filename":"src/mosquito/queued_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/redis_backend.cr","line_number":4,"url":null},{"filename":"src/mosquito/runnable.cr","line_number":1,"url":null},{"filename":"src/mosquito/runner.cr","line_number":3,"url":null},{"filename":"src/mosquito/runners/run_at_most.cr","line_number":1,"url":null},{"filename":"src/mosquito/scheduled_job.cr","line_number":1,"url":null},{"filename":"src/mosquito/test_backend.cr","line_number":1,"url":null},{"filename":"src/mosquito/version.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"1.0.2\""}],"class_methods":[{"html_id":"backend-class-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito.cr","line_number":6,"url":null},"def":{"name":"backend","visibility":"Public","body":"configuration.backend"}},{"html_id":"configuration-class-method","name":"configuration","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":2,"url":null},"def":{"name":"configuration","visibility":"Public","body":"@@configuration"}},{"html_id":"configure(&):Nil-class-method","name":"configure","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":4,"url":null},"def":{"name":"configure","yields":1,"block_arity":1,"return_type":"Nil","visibility":"Public","body":"yield configuration"}}],"types":[{"html_id":"mosquito/Mosquito/Backend","path":"Mosquito/Backend.html","kind":"class","full_name":"Mosquito::Backend","name":"Backend","abstract":true,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/backend.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"KEY_PREFIX","name":"KEY_PREFIX","value":"{\"mosquito\"}"},{"id":"QUEUES","name":"QUEUES","value":"[\"waiting\", \"scheduled\", \"pending\", \"dead\"] of ::String"}],"subclasses":[{"html_id":"mosquito/Mosquito/RedisBackend","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend"},{"html_id":"mosquito/Mosquito/TestBackend","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"build_key(*parts)-class-method","name":"build_key","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/backend.cr","line_number":11,"url":null},"def":{"name":"build_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"KeyBuilder.build(KEY_PREFIX, *parts)"}},{"html_id":"named(name)-class-method","name":"named","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/mosquito/backend.cr","line_number":7,"url":null},"def":{"name":"named","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"new(name)"}},{"html_id":"search_queues-class-method","name":"search_queues","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":50,"url":null},"def":{"name":"search_queues","visibility":"Public","body":"QUEUES.first(2)"}}],"constructors":[{"html_id":"new(name:String|Symbol)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"args_string":"(name : String | Symbol)","args_html":"(name : String | Symbol)","location":{"filename":"src/mosquito/backend.cr","line_number":21,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_key(*parts)-instance-method","name":"build_key","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/backend.cr","line_number":15,"url":null},"def":{"name":"build_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"self.class.build_key(*parts)"}},{"html_id":"dead_q-instance-method","name":"dead_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"dead_q","visibility":"Public","body":"build_key(\"dead\", name)"}},{"html_id":"delete(key:String,inttl=0):Nil-instance-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"args_string":"(key : String, in ttl = 0) : Nil","args_html":"(key : String, in ttl = 0) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":68,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"return_type":"Nil","visibility":"Public","body":"self.class.delete(key)"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":78,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":""}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":80,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":""}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":86,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/backend.cr","line_number":77,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":""}},{"html_id":"expires_in(key:String):Int64-instance-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":72,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"self.class.expires_in(key)"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/backend.cr","line_number":81,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":83,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"pending_q-instance-method","name":"pending_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"pending_q","visibility":"Public","body":"build_key(\"pending\", name)"}},{"html_id":"retrieve(key:String):Hash(String,String)-instance-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/backend.cr","line_number":64,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"self.class.retrieve(key)"}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/backend.cr","line_number":79,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":""}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/backend.cr","line_number":90,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"scheduled_q-instance-method","name":"scheduled_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"scheduled_q","visibility":"Public","body":"build_key(\"scheduled\", name)"}},{"html_id":"size(include_dead:Bool=true):Int64-instance-method","name":"size","abstract":true,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"args_string":"(include_dead : Bool = true) : Int64","args_html":"(include_dead : Bool = true) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":84,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-instance-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":60,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":"self.class.store(key, value)"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":true,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/backend.cr","line_number":82,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"waiting_q-instance-method","name":"waiting_q","abstract":false,"location":{"filename":"src/mosquito/backend.cr","line_number":54,"url":null},"def":{"name":"waiting_q","visibility":"Public","body":"build_key(\"waiting\", name)"}}],"types":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","path":"Mosquito/Backend/ClassMethods.html","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/mosquito/backend.cr","line_number":25,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"instance_methods":[{"html_id":"delete(key:String,inttl:Int64=0):Nil-instance-method","name":"delete","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":31,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-instance-method","name":"delete","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":32,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"expires_in(key:String):Int64-instance-method","name":"expires_in","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":33,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":40,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"get(key:String,field:String):String|Nil-instance-method","name":"get","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/backend.cr","line_number":35,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-instance-method","name":"increment","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":38,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String):Int64-instance-method","name":"increment","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/backend.cr","line_number":37,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":""}},{"html_id":"list_queues:Array(String)-instance-method","name":"list_queues","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":28,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"list_runners:Array(String)-instance-method","name":"list_runners","abstract":true,"location":{"filename":"src/mosquito/backend.cr","line_number":29,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-instance-method","name":"lock?","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/backend.cr","line_number":43,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":""}},{"html_id":"retrieve(key:String):Hash(String,String)-instance-method","name":"retrieve","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/backend.cr","line_number":27,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":""}},{"html_id":"set(key:String,field:String,value:String):String-instance-method","name":"set","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/backend.cr","line_number":36,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-instance-method","name":"store","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":26,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"unlock(key:String,value:String):Nil-instance-method","name":"unlock","abstract":true,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/backend.cr","line_number":42,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":""}}]}]},{"html_id":"mosquito/Mosquito/Base","path":"Mosquito/Base.html","kind":"class","full_name":"Mosquito::Base","name":"Base","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/base.cr","line_number":4,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"job_for_type(type:String):Mosquito::Job.class-class-method","name":"job_for_type","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"}],"args_string":"(type : String) : Mosquito::Job.class","args_html":"(type : String) : Mosquito::Job.class","location":{"filename":"src/mosquito/base.cr","line_number":13,"url":null},"def":{"name":"job_for_type","args":[{"name":"type","external_name":"type","restriction":"String"}],"return_type":"Mosquito::Job.class","visibility":"Public","body":"begin\n @@mapping[type]\nrescue e : KeyError\n error = String.build do |s|\n s << \"Could not find a job class for type \\\"#{type}\\\", perhaps you forgot to register it?\\n\\nCurrent known types are:\\n\"\n @@mapping.each do |k, v|\n s << \"#{k}=>#{v}\\n\"\n end\n s << \"\\n\\n\"\n end\n raise(KeyError.new(error))\nend"}},{"html_id":"mapping-class-method","name":"mapping","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":5,"url":null},"def":{"name":"mapping","visibility":"Public","body":"@@mapping"}},{"html_id":"register_job(klass,*,to_run_atscheduled_time:Time)-class-method","name":"register_job","abstract":false,"args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"scheduled_time","external_name":"to_run_at","restriction":"Time"}],"args_string":"(klass, *, to_run_at scheduled_time : Time)","args_html":"(klass, *, to_run_at scheduled_time : Time)","location":{"filename":"src/mosquito/base.cr","line_number":36,"url":null},"def":{"name":"register_job","args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"scheduled_time","external_name":"to_run_at","restriction":"Time"}],"splat_index":1,"visibility":"Public","body":"position = @@timetable.index do\nend"}},{"html_id":"register_job_interval(klass,interval:Time::Span|Time::MonthSpan)-class-method","name":"register_job_interval","abstract":false,"args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"args_string":"(klass, interval : Time::Span | Time::MonthSpan)","args_html":"(klass, interval : Time::Span | Time::MonthSpan)","location":{"filename":"src/mosquito/base.cr","line_number":32,"url":null},"def":{"name":"register_job_interval","args":[{"name":"klass","external_name":"klass","restriction":""},{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"visibility":"Public","body":"@@scheduled_job_runs << (PeriodicJobRun.new(klass, interval))"}},{"html_id":"register_job_mapping(string,klass)-class-method","name":"register_job_mapping","abstract":false,"args":[{"name":"string","external_name":"string","restriction":""},{"name":"klass","external_name":"klass","restriction":""}],"args_string":"(string, klass)","args_html":"(string, klass)","location":{"filename":"src/mosquito/base.cr","line_number":9,"url":null},"def":{"name":"register_job_mapping","args":[{"name":"string","external_name":"string","restriction":""},{"name":"klass","external_name":"klass","restriction":""}],"visibility":"Public","body":"@@mapping[string] = klass"}},{"html_id":"scheduled_job_runs-class-method","name":"scheduled_job_runs","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":6,"url":null},"def":{"name":"scheduled_job_runs","visibility":"Public","body":"@@scheduled_job_runs"}},{"html_id":"timetable-class-method","name":"timetable","abstract":false,"location":{"filename":"src/mosquito/base.cr","line_number":7,"url":null},"def":{"name":"timetable","visibility":"Public","body":"@@timetable"}}]},{"html_id":"mosquito/Mosquito/Configuration","path":"Mosquito/Configuration.html","kind":"class","full_name":"Mosquito::Configuration","name":"Configuration","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/configuration.cr","line_number":8,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"backend:Mosquito::Backend.class-instance-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":20,"url":null},"def":{"name":"backend","return_type":"Mosquito::Backend.class","visibility":"Public","body":"@backend"}},{"html_id":"backend=(backend:Mosquito::Backend.class)-instance-method","name":"backend=","abstract":false,"args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend.class"}],"args_string":"(backend : Mosquito::Backend.class)","args_html":"(backend : Mosquito::Backend.class)","location":{"filename":"src/mosquito/configuration.cr","line_number":20,"url":null},"def":{"name":"backend=","args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend.class"}],"visibility":"Public","body":"@backend = backend"}},{"html_id":"failed_job_ttl:Int32-instance-method","name":"failed_job_ttl","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":13,"url":null},"def":{"name":"failed_job_ttl","return_type":"Int32","visibility":"Public","body":"@failed_job_ttl"}},{"html_id":"failed_job_ttl=(failed_job_ttl:Int32)-instance-method","name":"failed_job_ttl=","abstract":false,"args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"args_string":"(failed_job_ttl : Int32)","args_html":"(failed_job_ttl : Int32)","location":{"filename":"src/mosquito/configuration.cr","line_number":13,"url":null},"def":{"name":"failed_job_ttl=","args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@failed_job_ttl = failed_job_ttl"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":11,"url":null},"def":{"name":"idle_wait","return_type":"Time::Span","visibility":"Public","body":"@idle_wait"}},{"html_id":"idle_wait=(idle_wait:Time::Span)-instance-method","name":"idle_wait=","abstract":false,"args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"args_string":"(idle_wait : Time::Span)","args_html":"(idle_wait : Time::Span)","location":{"filename":"src/mosquito/configuration.cr","line_number":11,"url":null},"def":{"name":"idle_wait=","args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"visibility":"Public","body":"@idle_wait = idle_wait"}},{"html_id":"idle_wait=(time_span:Float)-instance-method","name":"idle_wait=","abstract":false,"args":[{"name":"time_span","external_name":"time_span","restriction":"Float"}],"args_string":"(time_span : Float)","args_html":"(time_span : Float)","location":{"filename":"src/mosquito/configuration.cr","line_number":24,"url":null},"def":{"name":"idle_wait=","args":[{"name":"time_span","external_name":"time_span","restriction":"Float"}],"visibility":"Public","body":"@idle_wait = time_span.seconds"}},{"html_id":"redis_url:String|Nil-instance-method","name":"redis_url","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":9,"url":null},"def":{"name":"redis_url","return_type":"String | ::Nil","visibility":"Public","body":"@redis_url"}},{"html_id":"redis_url=(redis_url:String|Nil)-instance-method","name":"redis_url=","abstract":false,"args":[{"name":"redis_url","external_name":"redis_url","restriction":"String | ::Nil"}],"args_string":"(redis_url : String | Nil)","args_html":"(redis_url : String | Nil)","location":{"filename":"src/mosquito/configuration.cr","line_number":9,"url":null},"def":{"name":"redis_url=","args":[{"name":"redis_url","external_name":"redis_url","restriction":"String | ::Nil"}],"visibility":"Public","body":"@redis_url = redis_url"}},{"html_id":"run_cron_scheduler:Bool-instance-method","name":"run_cron_scheduler","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":16,"url":null},"def":{"name":"run_cron_scheduler","return_type":"Bool","visibility":"Public","body":"@run_cron_scheduler"}},{"html_id":"run_cron_scheduler=(run_cron_scheduler:Bool)-instance-method","name":"run_cron_scheduler=","abstract":false,"args":[{"name":"run_cron_scheduler","external_name":"run_cron_scheduler","restriction":"Bool"}],"args_string":"(run_cron_scheduler : Bool)","args_html":"(run_cron_scheduler : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":16,"url":null},"def":{"name":"run_cron_scheduler=","args":[{"name":"run_cron_scheduler","external_name":"run_cron_scheduler","restriction":"Bool"}],"visibility":"Public","body":"@run_cron_scheduler = run_cron_scheduler"}},{"html_id":"run_from:Array(String)-instance-method","name":"run_from","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":19,"url":null},"def":{"name":"run_from","return_type":"Array(String)","visibility":"Public","body":"@run_from"}},{"html_id":"run_from=(run_from:Array(String))-instance-method","name":"run_from=","abstract":false,"args":[{"name":"run_from","external_name":"run_from","restriction":"Array(String)"}],"args_string":"(run_from : Array(String))","args_html":"(run_from : Array(String))","location":{"filename":"src/mosquito/configuration.cr","line_number":19,"url":null},"def":{"name":"run_from=","args":[{"name":"run_from","external_name":"run_from","restriction":"Array(String)"}],"visibility":"Public","body":"@run_from = run_from"}},{"html_id":"successful_job_ttl:Int32-instance-method","name":"successful_job_ttl","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":12,"url":null},"def":{"name":"successful_job_ttl","return_type":"Int32","visibility":"Public","body":"@successful_job_ttl"}},{"html_id":"successful_job_ttl=(successful_job_ttl:Int32)-instance-method","name":"successful_job_ttl=","abstract":false,"args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"args_string":"(successful_job_ttl : Int32)","args_html":"(successful_job_ttl : Int32)","location":{"filename":"src/mosquito/configuration.cr","line_number":12,"url":null},"def":{"name":"successful_job_ttl=","args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@successful_job_ttl = successful_job_ttl"}},{"html_id":"use_distributed_lock:Bool-instance-method","name":"use_distributed_lock","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":17,"url":null},"def":{"name":"use_distributed_lock","return_type":"Bool","visibility":"Public","body":"@use_distributed_lock"}},{"html_id":"use_distributed_lock=(use_distributed_lock:Bool)-instance-method","name":"use_distributed_lock=","abstract":false,"args":[{"name":"use_distributed_lock","external_name":"use_distributed_lock","restriction":"Bool"}],"args_string":"(use_distributed_lock : Bool)","args_html":"(use_distributed_lock : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":17,"url":null},"def":{"name":"use_distributed_lock=","args":[{"name":"use_distributed_lock","external_name":"use_distributed_lock","restriction":"Bool"}],"visibility":"Public","body":"@use_distributed_lock = use_distributed_lock"}},{"html_id":"validate-instance-method","name":"validate","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":28,"url":null},"def":{"name":"validate","visibility":"Public","body":"if @validated\n return\nend\n@validated = true\nif redis_url.nil?\n message = \"Mosquito cannot start because the redis connection string hasn't been provided.\\n\\nFor example, in your application config:\\n\\nMosquito.configure do |settings|\\n settings.redis_url = (ENV[\\\"REDIS_TLS_URL\\\"]? || ENV[\\\"REDIS_URL\\\"]? || \\\"redis://localhost:6379\\\")\\nend\\n\\nSee Also: https://github.com/mosquito-cr/mosquito#connecting-to-redis\"\n raise(message)\nend\n"}},{"html_id":"validated:Bool-instance-method","name":"validated","abstract":false,"location":{"filename":"src/mosquito/configuration.cr","line_number":22,"url":null},"def":{"name":"validated","visibility":"Public","body":"@validated"}},{"html_id":"validated=(validated:Bool)-instance-method","name":"validated=","abstract":false,"args":[{"name":"validated","external_name":"validated","restriction":"::Bool"}],"args_string":"(validated : Bool)","args_html":"(validated : Bool)","location":{"filename":"src/mosquito/configuration.cr","line_number":22,"url":null},"def":{"name":"validated=","args":[{"name":"validated","external_name":"validated","restriction":"::Bool"}],"visibility":"Public","body":"@validated = validated"}}]},{"html_id":"mosquito/Mosquito/DoubleRun","path":"Mosquito/DoubleRun.html","kind":"class","full_name":"Mosquito::DoubleRun","name":"DoubleRun","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":7,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job_run tries to run twice","summary":"

When a job_run tries to run twice

"},{"html_id":"mosquito/Mosquito/Id","path":"Mosquito/Id.html","kind":"alias","full_name":"Mosquito::Id","name":"Id","abstract":false,"locations":[{"filename":"src/mosquito/base.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":true,"aliased":"(Int32 | Int64)","aliased_html":"Int32 | Int64","const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"}},{"html_id":"mosquito/Mosquito/IrretrievableParameter","path":"Mosquito/IrretrievableParameter.html","kind":"class","full_name":"Mosquito::IrretrievableParameter","name":"IrretrievableParameter","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":11,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job contains a model_id parameter pointing to a database record but the database doesn't return anything for that id.","summary":"

When a job contains a model_id parameter pointing to a database record but the database doesn't return anything for that id.

"},{"html_id":"mosquito/Mosquito/Job","path":"Mosquito/Job.html","kind":"class","full_name":"Mosquito::Job","name":"Job","abstract":true,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job.cr","line_number":10,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"}],"subclasses":[{"html_id":"mosquito/Mosquito/PeriodicJob","kind":"class","full_name":"Mosquito::PeriodicJob","name":"PeriodicJob"},{"html_id":"mosquito/Mosquito/QueuedJob","kind":"class","full_name":"Mosquito::QueuedJob","name":"QueuedJob"},{"html_id":"mosquito/Mosquito/ScheduledJob","kind":"class","full_name":"Mosquito::ScheduledJob","name":"ScheduledJob"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A Job is a definition for work to be performed.\nJobs are pieces of code which run a JobRun.\n\n- Jobs prevent double execution of a job for a job_run\n- Jobs Rescue when a #perform method fails a job_run for any reason\n- Jobs can be rescheduleable","summary":"

A Job is a definition for work to be performed.

","class_methods":[{"html_id":"metadata:Metadata-class-method","name":"metadata","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":182,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"Metadata.new(metadata_key, readonly: true)"}},{"html_id":"metadata_key-class-method","name":"metadata_key","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":186,"url":null},"def":{"name":"metadata_key","visibility":"Public","body":"Mosquito.backend.build_key(\"job_metadata\", self.name.underscore)"}},{"html_id":"queue-class-method","name":"queue","doc":"The Queue this job uses to store job_runs.","summary":"

The Queue this job uses to store job_runs.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":60,"url":null},"def":{"name":"queue","visibility":"Public","body":"if queue_name.blank?\n Queue.new(\"default\")\nelse\n Queue.new(queue_name)\nend"}},{"html_id":"queue_name:String-class-method","name":"queue_name","doc":"The queue this job is assigned to.\nBy default every job has it's own named queue:\n\n- EmailTheUniverseJob.queue = \"email_the_universe\"","summary":"

The queue this job is assigned to.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":48,"url":null},"def":{"name":"queue_name","return_type":"String","visibility":"Public","body":"({{ @type.id }}).to_s.underscore"}}],"instance_methods":[{"html_id":"aborted?(*args,**options)-instance-method","name":"aborted?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"aborted?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.aborted?(*args, **options)"}},{"html_id":"aborted?(*args,**options,&)-instance-method","name":"aborted?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"aborted?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.aborted?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"after_hook-instance-method","name":"after_hook","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":103,"url":null},"def":{"name":"after_hook","visibility":"Public","body":""}},{"html_id":"before_hook-instance-method","name":"before_hook","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":99,"url":null},"def":{"name":"before_hook","visibility":"Public","body":""}},{"html_id":"exception:Exception|Nil-instance-method","name":"exception","doc":"When a job fails and raises an exception, it will be saved into this attribute.","summary":"

When a job fails and raises an exception, it will be saved into this attribute.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":36,"url":null},"def":{"name":"exception","return_type":"Exception | ::Nil","visibility":"Public","body":"@exception"}},{"html_id":"executed?(*args,**options)-instance-method","name":"executed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"executed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.executed?(*args, **options)"}},{"html_id":"executed?(*args,**options,&)-instance-method","name":"executed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"executed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.executed?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"fail(reason=\"\",*,retry:Bool=true)-instance-method","name":"fail","doc":"To be called from inside a #perform\nMarks this job as a failure. By default, if the job is a candidate for\nre-scheduling, it will be run again at a later time.","summary":"

To be called from inside a #perform Marks this job as a failure.

","abstract":false,"args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"retry","default_value":"true","external_name":"retry","restriction":"Bool"}],"args_string":"(reason = \"\", *, retry : Bool = true)","args_html":"(reason = "", *, retry : Bool = true)","location":{"filename":"src/mosquito/job.cr","line_number":144,"url":null},"def":{"name":"fail","args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""},{"name":"","external_name":"","restriction":""},{"name":"retry","default_value":"true","external_name":"retry","restriction":"Bool"}],"splat_index":1,"visibility":"Public","body":"@should_retry = @should_retry && retry\nraise(JobFailed.new(reason))\n"}},{"html_id":"failed?(*args,**options)-instance-method","name":"failed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"failed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.failed?(*args, **options)"}},{"html_id":"failed?(*args,**options,&)-instance-method","name":"failed?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"failed?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.failed?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"job_run_id:String|Nil-instance-method","name":"job_run_id","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":38,"url":null},"def":{"name":"job_run_id","return_type":"String | ::Nil","visibility":"Public","body":"@job_run_id"}},{"html_id":"job_run_id=(job_run_id:String|Nil)-instance-method","name":"job_run_id=","abstract":false,"args":[{"name":"job_run_id","external_name":"job_run_id","restriction":"String | ::Nil"}],"args_string":"(job_run_id : String | Nil)","args_html":"(job_run_id : String | Nil)","location":{"filename":"src/mosquito/job.cr","line_number":38,"url":null},"def":{"name":"job_run_id=","args":[{"name":"job_run_id","external_name":"job_run_id","restriction":"String | ::Nil"}],"visibility":"Public","body":"@job_run_id = job_run_id"}},{"html_id":"log(message)-instance-method","name":"log","abstract":false,"args":[{"name":"message","external_name":"message","restriction":""}],"args_string":"(message)","args_html":"(message)","location":{"filename":"src/mosquito/job.cr","line_number":27,"url":null},"def":{"name":"log","args":[{"name":"message","external_name":"message","restriction":""}],"visibility":"Public","body":"(::Log.for(self.class)).info do\n message\nend"}},{"html_id":"metadata:Metadata-instance-method","name":"metadata","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":176,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"@metadata || (@metadata = (Metadata.new(self.class.metadata_key)))"}},{"html_id":"perform-instance-method","name":"perform","doc":"abstract, override in a Job descendant to do something productive","summary":"

abstract, override in a Job descendant to do something productive

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":136,"url":null},"def":{"name":"perform","visibility":"Public","body":"Log.error do\n \"No job definition found for #{self.class.name}\"\nend\nfail\n"}},{"html_id":"reschedule_interval(retry_count:Int32):Time::Span-instance-method","name":"reschedule_interval","doc":"abstract, override if desired.\n\nFor a given retry count, how long should the delay between\njob attempts be?","summary":"

abstract, override if desired.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Time::Span","args_html":"(retry_count : Int32) : Time::Span","location":{"filename":"src/mosquito/job.cr","line_number":168,"url":null},"def":{"name":"reschedule_interval","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Time::Span","visibility":"Public","body":"2.seconds * (retry_count ** 2)"}},{"html_id":"rescheduleable?(retry_count:Int32):Bool-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nFor a given retry count, is this job rescheduleable?","summary":"

abstract, override if desired.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Bool","args_html":"(retry_count : Int32) : Bool","location":{"filename":"src/mosquito/job.cr","line_number":160,"url":null},"def":{"name":"rescheduleable?","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"rescheduleable? && retry_count < 5"}},{"html_id":"rescheduleable?:Bool-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":153,"url":null},"def":{"name":"rescheduleable?","return_type":"Bool","visibility":"Public","body":"true"}},{"html_id":"retry_later-instance-method","name":"retry_later","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":107,"url":null},"def":{"name":"retry_later","visibility":"Public","body":"fail"}},{"html_id":"run-instance-method","name":"run","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":74,"url":null},"def":{"name":"run","visibility":"Public","body":"begin\n begin\n before_hook\n rescue e : Exception\n Log.error(exception: e) do\n \"Before hook raised, job will not be executed\"\n end\n @state = State::Aborted\n return\n end\n @state = State::Running\n perform\n @state = State::Succeeded\nrescue e\n Log.warn(exception: e) do\n \"Job failed! Raised #{e.class}: #{e.message}\"\n end\n @exception = e\n @state = State::Failed\nensure\n after_hook\nend"}},{"html_id":"should_retry:Bool-instance-method","name":"should_retry","doc":"When a job run fails, should it be added to the retry queue?\nSee: #fail(retry: false)","summary":"

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":42,"url":null},"def":{"name":"should_retry","return_type":"Bool","visibility":"Public","body":"@should_retry"}},{"html_id":"should_retry=(should_retry:Bool)-instance-method","name":"should_retry=","doc":"When a job run fails, should it be added to the retry queue?\nSee: #fail(retry: false)","summary":"

When a job run fails, should it be added to the retry queue? See: #fail(retry: false)

","abstract":false,"args":[{"name":"should_retry","external_name":"should_retry","restriction":"Bool"}],"args_string":"(should_retry : Bool)","args_html":"(should_retry : Bool)","location":{"filename":"src/mosquito/job.cr","line_number":42,"url":null},"def":{"name":"should_retry=","args":[{"name":"should_retry","external_name":"should_retry","restriction":"Bool"}],"visibility":"Public","body":"@should_retry = should_retry"}},{"html_id":"state:Mosquito::Job::State-instance-method","name":"state","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":31,"url":null},"def":{"name":"state","visibility":"Public","body":"@state"}},{"html_id":"succeeded?(*args,**options)-instance-method","name":"succeeded?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"succeeded?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"state.succeeded?(*args, **options)"}},{"html_id":"succeeded?(*args,**options,&)-instance-method","name":"succeeded?","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/job.cr","line_number":33,"url":null},"def":{"name":"succeeded?","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"state.succeeded?(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[{"html_id":"after(&block)-macro","name":"after","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":123,"url":null},"def":{"name":"after","block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" def after_hook\n \n{% if @type.methods.map(&.name).includes?((:after_hook).id) %}\n previous_def\n {% else %}\n super\n {% end %}\n\n\n \n{{ yield }}\n\n \nend\n \n"}},{"html_id":"before(&block)-macro","name":"before","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":111,"url":null},"def":{"name":"before","block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" def before_hook\n \n{% if @type.methods.map(&.name).includes?((:before_hook).id) %}\n previous_def\n {% else %}\n super\n {% end %}\n\n\n \n{{ yield }}\n\n \nend\n \n"}},{"html_id":"queue_name(name)-macro","name":"queue_name","doc":"Easily override the queue for any job.","summary":"

Easily override the queue for any job.

","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/mosquito/job.cr","line_number":53,"url":null},"def":{"name":"queue_name","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":" def self.queue_name : String\n \"\n{{ name.id }}\n\"\n \nend\n \n"}}],"types":[{"html_id":"mosquito/Mosquito/Job/State","path":"Mosquito/Job/State.html","kind":"enum","full_name":"Mosquito::Job::State","name":"State","abstract":false,"ancestors":[{"html_id":"mosquito/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"mosquito/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job.cr","line_number":15,"url":null}],"repository_name":"mosquito","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Initialization","name":"Initialization","value":"0"},{"id":"Running","name":"Running","value":"1"},{"id":"Succeeded","name":"Succeeded","value":"2"},{"id":"Failed","name":"Failed","value":"3"},{"id":"Aborted","name":"Aborted","value":"4"}],"namespace":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"instance_methods":[{"html_id":"aborted?-instance-method","name":"aborted?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":20,"url":null},"def":{"name":"aborted?","visibility":"Public","body":"self == Aborted"}},{"html_id":"executed?:Bool-instance-method","name":"executed?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":22,"url":null},"def":{"name":"executed?","return_type":"Bool","visibility":"Public","body":"succeeded? || failed?"}},{"html_id":"failed?-instance-method","name":"failed?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":19,"url":null},"def":{"name":"failed?","visibility":"Public","body":"self == Failed"}},{"html_id":"initialization?-instance-method","name":"initialization?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":16,"url":null},"def":{"name":"initialization?","visibility":"Public","body":"self == Initialization"}},{"html_id":"running?-instance-method","name":"running?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":17,"url":null},"def":{"name":"running?","visibility":"Public","body":"self == Running"}},{"html_id":"succeeded?-instance-method","name":"succeeded?","abstract":false,"location":{"filename":"src/mosquito/job.cr","line_number":18,"url":null},"def":{"name":"succeeded?","visibility":"Public","body":"self == Succeeded"}}]}]},{"html_id":"mosquito/Mosquito/JobFailed","path":"Mosquito/JobFailed.html","kind":"class","full_name":"Mosquito::JobFailed","name":"JobFailed","abstract":false,"superclass":{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"mosquito/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/exceptions.cr","line_number":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"When a job fails","summary":"

When a job fails

"},{"html_id":"mosquito/Mosquito/JobRun","path":"Mosquito/JobRun.html","kind":"class","full_name":"Mosquito::JobRun","name":"JobRun","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/job_run.cr","line_number":11,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"CONFIG_KEY_PREFIX","name":"CONFIG_KEY_PREFIX","value":"\"job_run\""}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A JobRun is a unit of work which will be performed by a Job.\nJobRuns know how to:\n- store and retrieve their data to and from the datastore\n- figure out what Job class they match to\n- build an instance of that Job class and pass off the config data\n- Ask the job to run\n\nJobRun data is called `config` and is persisted in the backend under the key\n`mosquito:job_run:job_run_id`.","summary":"

A JobRun is a unit of work which will be performed by a Job.

","class_methods":[{"html_id":"config_key(*parts)-class-method","name":"config_key","doc":"The config key is the backend storage key for the metadata of this job_run.","summary":"

The config key is the backend storage key for the metadata of this job_run.

","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/job_run.cr","line_number":33,"url":null},"def":{"name":"config_key","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"Mosquito.backend.build_key(CONFIG_KEY_PREFIX, parts)"}},{"html_id":"retrieve(id:String)-class-method","name":"retrieve","doc":"Used to construct a job_run from the parameters stored in the backend.","summary":"

Used to construct a job_run from the parameters stored in the backend.

","abstract":false,"args":[{"name":"id","external_name":"id","restriction":"String"}],"args_string":"(id : String)","args_html":"(id : String)","location":{"filename":"src/mosquito/job_run.cr","line_number":117,"url":null},"def":{"name":"retrieve","args":[{"name":"id","external_name":"id","restriction":"String"}],"visibility":"Public","body":"fields = Mosquito.backend.retrieve(config_key(id))\nif name = fields.delete(\"type\")\nelse\n return\nend\nif timestamp = fields.delete(\"enqueue_time\")\nelse\n return\nend\nretry_count = ((fields.delete(\"retry_count\")) || 0).to_i\ninstance = new(name, Time.unix_ms(timestamp.to_i64), id, retry_count)\ninstance.config = fields\ninstance\n"}}],"constructors":[{"html_id":"new(type:String,enqueue_time:Time=Time.utc,id:String|Nil=nil,retry_count:Int32=0)-class-method","name":"new","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"enqueue_time","default_value":"Time.utc","external_name":"enqueue_time","restriction":"Time"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry_count","default_value":"0","external_name":"retry_count","restriction":"Int32"}],"args_string":"(type : String, enqueue_time : Time = Time.utc, id : String | Nil = nil, retry_count : Int32 = 0)","args_html":"(type : String, enqueue_time : Time = Time.utc, id : String | Nil = nil, retry_count : Int32 = 0)","location":{"filename":"src/mosquito/job_run.cr","line_number":41,"url":null},"def":{"name":"new","args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"enqueue_time","default_value":"Time.utc","external_name":"enqueue_time","restriction":"Time"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry_count","default_value":"0","external_name":"retry_count","restriction":"Int32"}],"visibility":"Public","body":"_ = allocate\n_.initialize(type, enqueue_time, id, retry_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:self)-instance-method","name":"==","doc":"Returns `true` if this reference is the same as *other*. Invokes `same?`.","summary":"

Returns true if this reference is the same as other.

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self)","args_html":"(other : self)","location":{"filename":"src/mosquito/job_run.cr","line_number":140,"url":null},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"visibility":"Public","body":"id == self.id"}},{"html_id":"build_job:Mosquito::Job-instance-method","name":"build_job","doc":"Builds a Job instance from this job_run. Populates the job with config from\nthe backend.","summary":"

Builds a Job instance from this job_run.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":71,"url":null},"def":{"name":"build_job","return_type":"Mosquito::Job","visibility":"Public","body":"if job = @job\n return job\nend\n@job = instance = (Base.job_for_type(type)).new\nif instance.responds_to?(:vars_from)\n instance.vars_from(config)\nend\ninstance.job_run_id = id\ninstance\n"}},{"html_id":"config_key-instance-method","name":"config_key","doc":"The config key is the backend storage key for the metadata of this job_run.","summary":"

The config key is the backend storage key for the metadata of this job_run.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":28,"url":null},"def":{"name":"config_key","visibility":"Public","body":"self.class.config_key(id)"}},{"html_id":"delete(inttl=0)-instance-method","name":"delete","doc":"Deletes this job_run from the backend.\nOptionally, after a delay in seconds (handled by the backend).","summary":"

Deletes this job_run from the backend.

","abstract":false,"args":[{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"args_string":"(in ttl = 0)","args_html":"(in ttl = 0)","location":{"filename":"src/mosquito/job_run.cr","line_number":65,"url":null},"def":{"name":"delete","args":[{"name":"ttl","default_value":"0","external_name":"in","restriction":""}],"visibility":"Public","body":"Mosquito.backend.delete(config_key, ttl)"}},{"html_id":"enqueue_time:Time-instance-method","name":"enqueue_time","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":13,"url":null},"def":{"name":"enqueue_time","return_type":"Time","visibility":"Public","body":"@enqueue_time"}},{"html_id":"fail-instance-method","name":"fail","doc":"Fails this job run and make sure it's persisted as such.","summary":"

Fails this job run and make sure it's persisted as such.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":98,"url":null},"def":{"name":"fail","visibility":"Public","body":"@retry_count = @retry_count + 1\nstore\n"}},{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":14,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"job:Mosquito::Job|Nil-instance-method","name":"job","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":16,"url":null},"def":{"name":"job","return_type":"Mosquito::Job | ::Nil","visibility":"Public","body":"@job"}},{"html_id":"job!:Mosquito::Job-instance-method","name":"job!","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":18,"url":null},"def":{"name":"job!","return_type":"Mosquito::Job","visibility":"Public","body":"job || (raise(RuntimeError.new(\"No job yet retrieved for job_run.\")))"}},{"html_id":"reload:Nil-instance-method","name":"reload","doc":"Updates this job_run config from the backend.","summary":"

Updates this job_run config from the backend.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":131,"url":null},"def":{"name":"reload","return_type":"Nil","visibility":"Public","body":"config.merge!(Mosquito.backend.retrieve(config_key))\n@retry_count = config[\"retry_count\"].to_i\n"}},{"html_id":"reschedule_interval-instance-method","name":"reschedule_interval","doc":"For the current retry count, how long should a runner wait before retry?","summary":"

For the current retry count, how long should a runner wait before retry?

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":109,"url":null},"def":{"name":"reschedule_interval","visibility":"Public","body":"job!.reschedule_interval(@retry_count)"}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"For the current retry count, is the job rescheduleable?","summary":"

For the current retry count, is the job rescheduleable?

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":104,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"job!.rescheduleable?(@retry_count)"}},{"html_id":"retry_count:Int32-instance-method","name":"retry_count","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":15,"url":null},"def":{"name":"retry_count","visibility":"Public","body":"@retry_count"}},{"html_id":"run-instance-method","name":"run","doc":"Builds and runs the job with this job_run config.","summary":"

Builds and runs the job with this job_run config.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":87,"url":null},"def":{"name":"run","visibility":"Public","body":"instance = build_job\ninstance.run\nif executed? && failed?\n @retry_count = @retry_count + 1\n store\nend\n"}},{"html_id":"store-instance-method","name":"store","doc":"Stores this job run configuration and metadata in the backend.","summary":"

Stores this job run configuration and metadata in the backend.

","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":54,"url":null},"def":{"name":"store","visibility":"Public","body":"fields = config.dup\nfields[\"enqueue_time\"] = enqueue_time.to_unix_ms.to_s\nfields[\"type\"] = type\nfields[\"retry_count\"] = retry_count.to_s\nMosquito.backend.store(config_key, fields)\n"}},{"html_id":"to_s(io:IO)-instance-method","name":"to_s","doc":"Appends a short String representation of this object\nwhich includes its class name and its object address.\n\n```\nclass Person\n def initialize(@name : String, @age : Int32)\n end\nend\n\nPerson.new(\"John\", 32).to_s # => #\n```","summary":"

Appends a short String representation of this object which includes its class name and its object address.

","abstract":false,"args":[{"name":"io","external_name":"io","restriction":"IO"}],"args_string":"(io : IO)","args_html":"(io : IO)","location":{"filename":"src/mosquito/job_run.cr","line_number":136,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":"IO"}],"visibility":"Public","body":"\"#{type}<#{id}>\".to_s(io)"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/mosquito/job_run.cr","line_number":12,"url":null},"def":{"name":"type","visibility":"Public","body":"@type"}}]},{"html_id":"mosquito/Mosquito/KeyBuilder","path":"Mosquito/KeyBuilder.html","kind":"class","full_name":"Mosquito::KeyBuilder","name":"KeyBuilder","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/key_builder.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"KEY_SEPERATOR","name":"KEY_SEPERATOR","value":"\":\""}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"build(*parts)-class-method","name":"build","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/mosquito/key_builder.cr","line_number":5,"url":null},"def":{"name":"build","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"id = [] of String\nparts.each do |part|\n case part\n when Symbol\n id << (build(part.to_s))\n when String\n id << part\n when Array\n part.each do |e|\n id << (build(e))\n end\n when Tuple\n part.to_a.each do |e|\n id << (build(e))\n end\n when Number\n id << part.to_s\n else\n raise(\"#{part.class} is not a keyable type\")\n end\nend\nid.flatten.join(KEY_SEPERATOR)\n"}}]},{"html_id":"mosquito/Mosquito/Metadata","path":"Mosquito/Metadata.html","kind":"class","full_name":"Mosquito::Metadata","name":"Metadata","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/metadata.cr","line_number":8,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"Provides a real-time metadata store. Data is not cached, which allows\nmultiple workers to operate on the same structures in real time.\n\nEach read or write incurs a round trip to the backend.\n\nKeys and values are always strings.","summary":"

Provides a real-time metadata store.

","constructors":[{"html_id":"new(root_key:String,readonly:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"root_key","external_name":"root_key","restriction":"String"},{"name":"readonly","default_value":"false","external_name":"readonly","restriction":"::Bool"}],"args_string":"(root_key : String, readonly : Bool = false)","args_html":"(root_key : String, readonly : Bool = false)","location":{"filename":"src/mosquito/metadata.cr","line_number":12,"url":null},"def":{"name":"new","args":[{"name":"root_key","external_name":"root_key","restriction":"String"},{"name":"readonly","default_value":"false","external_name":"readonly","restriction":"::Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(root_key, readonly)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[]=(key:String,value:String)-instance-method","name":"[]=","doc":"Writes a value to a key in the metadata.","summary":"

Writes a value to a key in the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String)","args_html":"(key : String, value : String)","location":{"filename":"src/mosquito/metadata.cr","line_number":36,"url":null},"def":{"name":"[]=","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.set(root_key, key, value)\n"}},{"html_id":"[]?(key:String):String|Nil-instance-method","name":"[]?","doc":"Reads a single key from the metadata.","summary":"

Reads a single key from the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : String | Nil","args_html":"(key : String) : String | Nil","location":{"filename":"src/mosquito/metadata.cr","line_number":31,"url":null},"def":{"name":"[]?","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":"Mosquito.backend.get(root_key, key)"}},{"html_id":"decrement(key)-instance-method","name":"decrement","doc":"Decrements a value in the metadata by 1.","summary":"

Decrements a value in the metadata by 1.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":54,"url":null},"def":{"name":"decrement","args":[{"name":"key","external_name":"key","restriction":""}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key, by: -1)\n"}},{"html_id":"delete(inttl:Time::Span):Nil-instance-method","name":"delete","doc":"Schedule this metadata to be deleted after a time span.","summary":"

Schedule this metadata to be deleted after a time span.

","abstract":false,"args":[{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(in ttl : Time::Span) : Nil","args_html":"(in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/metadata.cr","line_number":21,"url":null},"def":{"name":"delete","args":[{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":"Mosquito.backend.delete(root_key, in: ttl)"}},{"html_id":"delete:Nil-instance-method","name":"delete","doc":"Deletes this metadata immediately.","summary":"

Deletes this metadata immediately.

","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":16,"url":null},"def":{"name":"delete","return_type":"Nil","visibility":"Public","body":"Mosquito.backend.delete(root_key)"}},{"html_id":"increment(key,byincrement:Int32)-instance-method","name":"increment","doc":"Parametrically incruments a value in the metadata.","summary":"

Parametrically incruments a value in the metadata.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""},{"name":"increment","external_name":"by","restriction":"Int32"}],"args_string":"(key, by increment : Int32)","args_html":"(key, by increment : Int32)","location":{"filename":"src/mosquito/metadata.cr","line_number":48,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":""},{"name":"increment","external_name":"by","restriction":"Int32"}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key, by: increment)\n"}},{"html_id":"increment(key)-instance-method","name":"increment","doc":"Increments a value in the metadata by 1 by 1 by 1 by 1.","summary":"

Increments a value in the metadata by 1 by 1 by 1 by 1.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":42,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":""}],"visibility":"Public","body":"if readonly?\n raise(RuntimeError.new(\"Cannot write to metadata, readonly=true\"))\nend\nMosquito.backend.increment(root_key, key)\n"}},{"html_id":"inspect(*args,**options)-instance-method","name":"inspect","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"inspect","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_h.inspect(*args, **options)"}},{"html_id":"inspect(*args,**options,&)-instance-method","name":"inspect","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"inspect","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_h.inspect(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"readonly?:Bool-instance-method","name":"readonly?","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":10,"url":null},"def":{"name":"readonly?","return_type":"Bool","visibility":"Public","body":"@readonly"}},{"html_id":"root_key:String-instance-method","name":"root_key","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":9,"url":null},"def":{"name":"root_key","return_type":"String","visibility":"Public","body":"@root_key"}},{"html_id":"root_key=(root_key:String)-instance-method","name":"root_key=","abstract":false,"args":[{"name":"root_key","external_name":"root_key","restriction":"String"}],"args_string":"(root_key : String)","args_html":"(root_key : String)","location":{"filename":"src/mosquito/metadata.cr","line_number":9,"url":null},"def":{"name":"root_key=","args":[{"name":"root_key","external_name":"root_key","restriction":"String"}],"visibility":"Public","body":"@root_key = root_key"}},{"html_id":"to_h:Hash(String,String)-instance-method","name":"to_h","doc":"Reads the metadata and returns it as a hash.","summary":"

Reads the metadata and returns it as a hash.

","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":26,"url":null},"def":{"name":"to_h","return_type":"Hash(String, String)","visibility":"Public","body":"Mosquito.backend.retrieve(root_key)"}},{"html_id":"to_s(*args,**options)-instance-method","name":"to_s","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"to_s","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"to_h.to_s(*args, **options)"}},{"html_id":"to_s(*args,**options,&)-instance-method","name":"to_s","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/metadata.cr","line_number":59,"url":null},"def":{"name":"to_s","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"to_h.to_s(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}]},{"html_id":"mosquito/Mosquito/PeriodicJob","path":"Mosquito/PeriodicJob.html","kind":"class","full_name":"Mosquito::PeriodicJob","name":"PeriodicJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/periodic_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":3,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_job_run-instance-method","name":"build_job_run","abstract":true,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":6,"url":null},"def":{"name":"build_job_run","visibility":"Public","body":""}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job.cr","line_number":28,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"false"}}]},{"html_id":"mosquito/Mosquito/PeriodicJobRun","path":"Mosquito/PeriodicJobRun.html","kind":"class","full_name":"Mosquito::PeriodicJobRun","name":"PeriodicJobRun","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/periodic_job_run.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new(class__arg0:::Mosquito::PeriodicJob.class,interval:Time::MonthSpan|Time::Span)-class-method","name":"new","abstract":false,"args":[{"name":"__arg0","external_name":"class","restriction":"::Mosquito::PeriodicJob.class"},{"name":"interval","external_name":"interval","restriction":"::Time::MonthSpan | ::Time::Span"}],"args_string":"(class __arg0 : ::Mosquito::PeriodicJob.class, interval : Time::MonthSpan | Time::Span)","args_html":"(class __arg0 : ::Mosquito::PeriodicJob.class, interval : Time::MonthSpan | Time::Span)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":40,"url":null},"def":{"name":"new","args":[{"name":"__arg0","external_name":"class","restriction":"::Mosquito::PeriodicJob.class"},{"name":"interval","external_name":"interval","restriction":"::Time::MonthSpan | ::Time::Span"}],"visibility":"Public","body":"_ = allocate\n_.initialize(__arg0, interval)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"class:Mosquito::PeriodicJob.class-instance-method","name":"class","doc":"Returns the **runtime** `Class` of an object.\n\n```\n1.class # => Int32\n\"hello\".class # => String\n```\n\nCompare it with `typeof`, which returns the **compile-time** type of an object:\n\n```\nrandom_value = rand # => 0.627423\nvalue = random_value < 0.5 ? 1 : \"hello\"\nvalue # => \"hello\"\nvalue.class # => String\ntypeof(value) # => Int32 | String\n```","summary":"

Returns the runtime Class of an object.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":3,"url":null},"def":{"name":"class","return_type":"Mosquito::PeriodicJob.class","visibility":"Public","body":"@class"}},{"html_id":"class=(class__arg0:Mosquito::PeriodicJob.class)-instance-method","name":"class=","abstract":false,"args":[{"name":"__arg0","external_name":"class","restriction":"Mosquito::PeriodicJob.class"}],"args_string":"(class __arg0 : Mosquito::PeriodicJob.class)","args_html":"(class __arg0 : Mosquito::PeriodicJob.class)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":3,"url":null},"def":{"name":"class=","args":[{"name":"__arg0","external_name":"class","restriction":"Mosquito::PeriodicJob.class"}],"visibility":"Public","body":"@class = __arg0"}},{"html_id":"execute-instance-method","name":"execute","doc":"Enqueues the job for execution","summary":"

Enqueues the job for execution

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":63,"url":null},"def":{"name":"execute","visibility":"Public","body":"job = @class.new\njob_run = job.build_job_run\njob_run.store\n@class.queue.enqueue(job_run)\n"}},{"html_id":"interval:Time::Span|Time::MonthSpan-instance-method","name":"interval","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":4,"url":null},"def":{"name":"interval","return_type":"Time::Span | Time::MonthSpan","visibility":"Public","body":"@interval"}},{"html_id":"interval=(interval:Time::Span|Time::MonthSpan)-instance-method","name":"interval=","abstract":false,"args":[{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"args_string":"(interval : Time::Span | Time::MonthSpan)","args_html":"(interval : Time::Span | Time::MonthSpan)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":4,"url":null},"def":{"name":"interval=","args":[{"name":"interval","external_name":"interval","restriction":"Time::Span | Time::MonthSpan"}],"visibility":"Public","body":"@interval = interval"}},{"html_id":"last_executed_at-instance-method","name":"last_executed_at","doc":"The last executed timestamp, or \"never\" if it doesn't exist.","summary":"

The last executed timestamp, or "never" if it doesn't exist.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":16,"url":null},"def":{"name":"last_executed_at","visibility":"Public","body":"last_executed_at? || (Time.unix(0))"}},{"html_id":"last_executed_at=(time:Time)-instance-method","name":"last_executed_at=","doc":"Updates the last executed timestamp in the backend,\nand schedules the metadata for deletion after 3*interval\nseconds.\n\nFor Time::Span intervals, the TTL is set to 3 * interval.\nFor Time::MonthSpan intervals, the TTL is set to approximately 3 * interval.\n\nA month is approximated to 2635200 seconds, or 30.5 days.","summary":"

Updates the last executed timestamp in the backend, and schedules the metadata for deletion after 3*interval seconds.

","abstract":false,"args":[{"name":"time","external_name":"time","restriction":"Time"}],"args_string":"(time : Time)","args_html":"(time : Time)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":28,"url":null},"def":{"name":"last_executed_at=","args":[{"name":"time","external_name":"time","restriction":"Time"}],"visibility":"Public","body":"@metadata[\"last_executed_at\"] = time.to_unix.to_s\ncase interval_ = interval\nwhen Time::Span\n @metadata.delete(in: interval_ * 3)\nwhen Time::MonthSpan\n seconds_in_an_average_month = 2635200.seconds\n @metadata.delete(in: (seconds_in_an_average_month * interval_.value) * 3)\nend\n"}},{"html_id":"last_executed_at?-instance-method","name":"last_executed_at?","doc":"The last executed timestamp for this periodicjob tracked by the backend.","summary":"

The last executed timestamp for this periodicjob tracked by the backend.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":7,"url":null},"def":{"name":"last_executed_at?","visibility":"Public","body":"if timestamp = @metadata[\"last_executed_at\"]?\n Time.unix(timestamp.to_i)\nelse\n nil\nend"}},{"html_id":"try_to_execute:Bool-instance-method","name":"try_to_execute","doc":"Check the last executed timestamp against the current time,\nand enqueue the job if it's time to execute.","summary":"

Check the last executed timestamp against the current time, and enqueue the job if it's time to execute.

","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":46,"url":null},"def":{"name":"try_to_execute","return_type":"Bool","visibility":"Public","body":"now = Time.utc\nif (last_executed_at + interval) <= now\n execute\n self.last_executed_at = now\n true\nelse\n false\nend\n"}}]},{"html_id":"mosquito/Mosquito/Queue","path":"Mosquito/Queue.html","kind":"class","full_name":"Mosquito::Queue","name":"Queue","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/queue.cr","line_number":77,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"A named Queue.\n\nNamed Queues exist and have 4 ordered lists: waiting, pending, scheduled, and dead.\n\n- The Waiting list is for jobs which need to be executed as soon as possible.\n- The Pending list is for jobs which are currently being executed.\n- The Scheduled list is indexed by execution time and holds jobs which need to be executed at a later time.\n- The Dead list is for jobs which have been retried too many times and are no longer viable.\n\nA job_run is represented in a queue by its id.\n\nA job_run flows through the queues in this manner:\n\n\n```text\n Time=0: JobRun does not exist yet, lists are empty\n\n Waiting Pending Scheduled Dead\n\n ---------------------------------\n Time=1: JobRun is enqueued\n\n Waiting Pending Scheduled Dead\n JobRun#1\n\n ---------------------------------\n Time=2: JobRun begins. JobRun is moved to pending and executed\n\n Waiting Pending Scheduled Dead\n JobRun#1\n\n ---------------------------------\n Time=3: JobRuns are Enqueued.\n\n Waiting Pending Scheduled Dead\n JobRun#2 JobRun#1\n JobRun#3\n\n ---------------------------------\n Time=4: JobRun succeeds, next job_run begins.\n\n Waiting Pending Scheduled Dead\n JobRun#3 JobRun#2\n\n ---------------------------------\n Time=5: JobRun fails and is scheduled for later, next job_run begins.\n\n Waiting Pending Scheduled Dead\n JobRun#3 t=7:JobRun#2\n\n ---------------------------------\n Time=6: JobRun succeeds. Nothing is executing.\n\n Waiting Pending Scheduled Dead\n t=7:JobRun#2\n\n ---------------------------------\n Time=7: Scheduled job_run is due and is moved to waiting. Nothing is executing.\n\n Waiting Pending Scheduled Dead\n JobRun#2\n\n ---------------------------------\n Time=8: JobRun begins executing (for the second time).\n\n Waiting Pending Scheduled Dead\n JobRun#2\n\n ---------------------------------\n Time=9: JobRun finished successfully. No more job_runs present.\n\n Waiting Pending Scheduled Dead\n\n```\n","summary":"

A named Queue.

","constructors":[{"html_id":"new(name:String)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"}],"args_string":"(name : String)","args_html":"(name : String)","location":{"filename":"src/mosquito/queue.cr","line_number":84,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(other:self):Bool-instance-method","name":"==","doc":"Returns `true` if this reference is the same as *other*. Invokes `same?`.","summary":"

Returns true if this reference is the same as other.

","abstract":false,"args":[{"name":"other","external_name":"other","restriction":"self"}],"args_string":"(other : self) : Bool","args_html":"(other : self) : Bool","location":{"filename":"src/mosquito/queue.cr","line_number":142,"url":null},"def":{"name":"==","args":[{"name":"other","external_name":"other","restriction":"self"}],"return_type":"Bool","visibility":"Public","body":"name == other.name"}},{"html_id":"backend:Mosquito::Backend-instance-method","name":"backend","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":80,"url":null},"def":{"name":"backend","return_type":"Mosquito::Backend","visibility":"Public","body":"@backend"}},{"html_id":"backend=(backend:Mosquito::Backend)-instance-method","name":"backend=","abstract":false,"args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend"}],"args_string":"(backend : Mosquito::Backend)","args_html":"(backend : Mosquito::Backend)","location":{"filename":"src/mosquito/queue.cr","line_number":80,"url":null},"def":{"name":"backend=","args":[{"name":"backend","external_name":"backend","restriction":"Mosquito::Backend"}],"visibility":"Public","body":"@backend = backend"}},{"html_id":"banish(job_run:JobRun)-instance-method","name":"banish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/queue.cr","line_number":128,"url":null},"def":{"name":"banish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"backend.finish(job_run)\nbackend.terminate(job_run)\n"}},{"html_id":"config_key:String-instance-method","name":"config_key","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":78,"url":null},"def":{"name":"config_key","visibility":"Public","body":"@config_key"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":104,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"if empty?\n return\nend\nif job_run = backend.dequeue\n job_run\nelse\n @empty = true\n nil\nend\n"}},{"html_id":"dequeue_scheduled:Array(JobRun)-instance-method","name":"dequeue_scheduled","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":120,"url":null},"def":{"name":"dequeue_scheduled","return_type":"Array(JobRun)","visibility":"Public","body":"backend.deschedule"}},{"html_id":"empty?:Bool-instance-method","name":"empty?","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":79,"url":null},"def":{"name":"empty?","return_type":"Bool","visibility":"Public","body":"@empty"}},{"html_id":"enqueue(job_run:JobRun,ininterval:Time::Span):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"interval","external_name":"in","restriction":"Time::Span"}],"args_string":"(job_run : JobRun, in interval : Time::Span) : JobRun","args_html":"(job_run : JobRun, in interval : Time::Span) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":95,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"interval","external_name":"in","restriction":"Time::Span"}],"return_type":"JobRun","visibility":"Public","body":"enqueue(job_run, at: interval.from_now)"}},{"html_id":"enqueue(job_run:JobRun,atexecute_time:Time):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execute_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at execute_time : Time) : JobRun","args_html":"(job_run : JobRun, at execute_time : Time) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":99,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execute_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"Log.trace do\n \"Enqueuing #{job_run} at #{execute_time}\"\nend\nbackend.schedule(job_run, execute_time)\n"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/queue.cr","line_number":90,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"Log.trace do\n \"Enqueuing #{job_run} for immediate execution\"\nend\nbackend.enqueue(job_run)\n"}},{"html_id":"flush-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":146,"url":null},"def":{"name":"flush","visibility":"Public","body":"backend.flush"}},{"html_id":"forget(job_run:JobRun)-instance-method","name":"forget","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/queue.cr","line_number":124,"url":null},"def":{"name":"forget","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"backend.finish(job_run)"}},{"html_id":"length:Int64-instance-method","name":"length","summary":"

DEPRECATED see #size

","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":138,"url":null},"def":{"name":"length","return_type":"Int64","visibility":"Public","body":"backend.size"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":78,"url":null},"def":{"name":"name","visibility":"Public","body":"@name"}},{"html_id":"reschedule(job_run:JobRun,execution_time)-instance-method","name":"reschedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execution_time","external_name":"execution_time","restriction":""}],"args_string":"(job_run : JobRun, execution_time)","args_html":"(job_run : JobRun, execution_time)","location":{"filename":"src/mosquito/queue.cr","line_number":115,"url":null},"def":{"name":"reschedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"execution_time","external_name":"execution_time","restriction":""}],"visibility":"Public","body":"backend.finish(job_run)\nenqueue(job_run, at: execution_time)\n"}},{"html_id":"size:Int64-instance-method","name":"size","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":133,"url":null},"def":{"name":"size","return_type":"Int64","visibility":"Public","body":"backend.size"}}]},{"html_id":"mosquito/Mosquito/QueuedJob","path":"Mosquito/QueuedJob.html","kind":"class","full_name":"Mosquito::QueuedJob","name":"QueuedJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/queued_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"enqueue(indelay_interval:Time::Span):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"delay_interval","external_name":"in","restriction":"Time::Span"}],"args_string":"(in delay_interval : Time::Span) : JobRun","args_html":"(in delay_interval : Time::Span) : JobRun","location":{"filename":"src/mosquito/queued_job.cr","line_number":128,"url":null},"def":{"name":"enqueue","args":[{"name":"delay_interval","external_name":"in","restriction":"Time::Span"}],"return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run, in: delay_interval)\nend"}},{"html_id":"enqueue(atexecute_time:Time):JobRun-instance-method","name":"enqueue","abstract":false,"args":[{"name":"execute_time","external_name":"at","restriction":"Time"}],"args_string":"(at execute_time : Time) : JobRun","args_html":"(at execute_time : Time) : JobRun","location":{"filename":"src/mosquito/queued_job.cr","line_number":135,"url":null},"def":{"name":"enqueue","args":[{"name":"execute_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run, at: execute_time)\nend"}},{"html_id":"enqueue:JobRun-instance-method","name":"enqueue","abstract":false,"location":{"filename":"src/mosquito/queued_job.cr","line_number":121,"url":null},"def":{"name":"enqueue","return_type":"JobRun","visibility":"Public","body":"build_job_run.tap do |job_run|\n job_run.store\n self.class.queue.enqueue(job_run)\nend"}}]},{"html_id":"mosquito/Mosquito/RateLimiter","path":"Mosquito/RateLimiter.html","kind":"module","full_name":"Mosquito::RateLimiter","name":"RateLimiter","abstract":false,"locations":[{"filename":"src/mosquito/rate_limiter.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"instance_methods":[{"html_id":"increment_run_count:Nil-instance-method","name":"increment_run_count","doc":"Increments the run counter.","summary":"

Increments the run counter.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":134,"url":null},"def":{"name":"increment_run_count","return_type":"Nil","visibility":"Public","body":"metadata.increment(\"run_count\", by: increment_run_count_by)"}},{"html_id":"increment_run_count_by:Int32-instance-method","name":"increment_run_count_by","doc":"How much the run counter should be incremented by.\nImplemented as a dynamic method so that it can easily be calculated by\nsome other metric, eg api calls to a third party library.","summary":"

How much the run counter should be incremented by.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":141,"url":null},"def":{"name":"increment_run_count_by","return_type":"Int32","visibility":"Public","body":"@@rate_limit_increment"}},{"html_id":"maxed_rate_for_window?:Bool-instance-method","name":"maxed_rate_for_window?","doc":"Has the run count exceeded the ceiling for the current window?","summary":"

Has the run count exceeded the ceiling for the current window?

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":97,"url":null},"def":{"name":"maxed_rate_for_window?","return_type":"Bool","visibility":"Public","body":"run_count = metadata[\"run_count\"]?.try(&.to_i)\nrun_count || (run_count = 0)\nrun_count >= @@rate_limit_ceiling\n"}},{"html_id":"metadata:Metadata-instance-method","name":"metadata","doc":"Storage hash for rate limit data.","summary":"

Storage hash for rate limit data.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":84,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"@rl_metadata || (@rl_metadata = self.class.metadata)"}},{"html_id":"rate_limited?:Bool-instance-method","name":"rate_limited?","doc":"Should this job be cancelled?\nIf not, update the rate limit metadata.","summary":"

Should this job be cancelled? If not, update the rate limit metadata.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":90,"url":null},"def":{"name":"rate_limited?","return_type":"Bool","visibility":"Public","body":"if @@rate_limit_ceiling < 0\n return false\nend\nif maxed_rate_for_window?\n return true\nend\nfalse\n"}},{"html_id":"reschedule_interval(retry_count:Int32):Time::Span-instance-method","name":"reschedule_interval","doc":"Configure the reschedule interval so that the job_run is not run again until it\nshould be allowed through the rate limiter.","summary":"

Configure the reschedule interval so that the job_run is not run again until it should be allowed through the rate limiter.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Time::Span","args_html":"(retry_count : Int32) : Time::Span","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":147,"url":null},"def":{"name":"reschedule_interval","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Time::Span","visibility":"Public","body":"if rate_limited? && (window_expiration = window_expires_at)\n next_window = window_expiration - Time.utc\n log(\"Rate limited: will run again in #{next_window}\")\n next_window\nelse\n super(retry_count)\nend"}},{"html_id":"rescheduleable?(retry_count:Int32):Bool-instance-method","name":"rescheduleable?","doc":"Configure the rescheduler to always retry if a job is rate limited.","summary":"

Configure the rescheduler to always retry if a job is rate limited.

","abstract":false,"args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"args_string":"(retry_count : Int32) : Bool","args_html":"(retry_count : Int32) : Bool","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":158,"url":null},"def":{"name":"rescheduleable?","args":[{"name":"retry_count","external_name":"retry_count","restriction":"Int32"}],"return_type":"Bool","visibility":"Public","body":"if rate_limited?\n true\nelse\n super(retry_count)\nend"}},{"html_id":"update_window_start:Nil-instance-method","name":"update_window_start","doc":"Resets the run count and logs the start of window.","summary":"

Resets the run count and logs the start of window.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":124,"url":null},"def":{"name":"update_window_start","return_type":"Nil","visibility":"Public","body":"started_window = window_start || Time::UNIX_EPOCH\nnow = Time.utc\nif (now - started_window) > @@rate_limit_interval\n metadata[\"window_start\"] = now.to_unix.to_s\n metadata[\"run_count\"] = \"0\"\nend\n"}},{"html_id":"window_expires_at:Time|Nil-instance-method","name":"window_expires_at","doc":"When does the current rate limit window expire?\nReturns nil if the window is already expired.","summary":"

When does the current rate limit window expire? Returns nil if the window is already expired.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":112,"url":null},"def":{"name":"window_expires_at","return_type":"Time | ::Nil","visibility":"Public","body":"if started_window = window_start\nelse\n return nil\nend\nexpiration_time = started_window + @@rate_limit_interval\nif expiration_time < Time.utc\n nil\nelse\n expiration_time\nend\n"}},{"html_id":"window_start:Time|Nil-instance-method","name":"window_start","doc":"Calculates the start of the rate limit window.","summary":"

Calculates the start of the rate limit window.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":104,"url":null},"def":{"name":"window_start","return_type":"Time | ::Nil","visibility":"Public","body":"if start_time = metadata[\"window_start\"]?.try(&.to_i)\n Time.unix(start_time)\nend"}}],"types":[{"html_id":"mosquito/Mosquito/RateLimiter/ClassMethods","path":"Mosquito/RateLimiter/ClassMethods.html","kind":"module","full_name":"Mosquito::RateLimiter::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/mosquito/rate_limiter.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/RateLimiter","kind":"module","full_name":"Mosquito::RateLimiter","name":"RateLimiter"},"instance_methods":[{"html_id":"metadata:Metadata-instance-method","name":"metadata","doc":"Provides an instance of the metadata store used to track rate limit\nstats.","summary":"

Provides an instance of the metadata store used to track rate limit stats.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":53,"url":null},"def":{"name":"metadata","return_type":"Metadata","visibility":"Public","body":"Metadata.new(@@rate_limit_key)"}},{"html_id":"rate_limit_key-instance-method","name":"rate_limit_key","doc":"Resolves the key used to index the metadata store for this test.","summary":"

Resolves the key used to index the metadata store for this test.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":58,"url":null},"def":{"name":"rate_limit_key","visibility":"Public","body":"@@rate_limit_key"}},{"html_id":"rate_limit_stats:NamedTuple-instance-method","name":"rate_limit_stats","doc":"Statistics about the rate limiter, including both the configuration\nparameters and the run counts.","summary":"

Statistics about the rate limiter, including both the configuration parameters and the run counts.

","abstract":false,"location":{"filename":"src/mosquito/rate_limiter.cr","line_number":26,"url":null},"def":{"name":"rate_limit_stats","return_type":"NamedTuple","visibility":"Public","body":"meta = metadata\nwindow_start = if window_start_ = meta[\"window_start\"]?\n Time.unix(window_start_.to_i)\nelse\n Time::UNIX_EPOCH\nend\nrun_count = if run_count_ = meta[\"run_count\"]?\n run_count_.to_i\nelse\n 0\nend\n{interval: @@rate_limit_interval, key: @@rate_limit_key, increment: @@rate_limit_increment, limit: @@rate_limit_ceiling, window_start: window_start, run_count: run_count}\n"}},{"html_id":"throttle(*,limit:Int32=1,per:Time::Span=1.second,increment=1,key=self.name.underscore)-instance-method","name":"throttle","doc":"Configures rate limiting for this job.\n\n`limit` and `per` are used to control the run count and the window\nduration. Defaults to a limit of 1 run per second.\n\n`increment` is used to indicate how many \"hits\" against a single job is\nworth. Defaults to 1.\n\n`key` is used to combine rate limiting functions across multiple jobs.","summary":"

Configures rate limiting for this job.

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"limit","default_value":"1","external_name":"limit","restriction":"Int32"},{"name":"per","default_value":"1.second","external_name":"per","restriction":"Time::Span"},{"name":"increment","default_value":"1","external_name":"increment","restriction":""},{"name":"key","default_value":"self.name.underscore","external_name":"key","restriction":""}],"args_string":"(*, limit : Int32 = 1, per : Time::Span = 1.second, increment = 1, key = self.name.underscore)","args_html":"(*, limit : Int32 = 1, per : Time::Span = 1.second, increment = 1, key = self.name.underscore)","location":{"filename":"src/mosquito/rate_limiter.cr","line_number":12,"url":null},"def":{"name":"throttle","args":[{"name":"","external_name":"","restriction":""},{"name":"limit","default_value":"1","external_name":"limit","restriction":"Int32"},{"name":"per","default_value":"1.second","external_name":"per","restriction":"Time::Span"},{"name":"increment","default_value":"1","external_name":"increment","restriction":""},{"name":"key","default_value":"self.name.underscore","external_name":"key","restriction":""}],"splat_index":0,"visibility":"Public","body":"@@rate_limit_ceiling = limit\n@@rate_limit_interval = per\n@@rate_limit_key = Mosquito.backend.build_key(\"rate_limit\", key)\n@@rate_limit_increment = increment\n"}}]}]},{"html_id":"mosquito/Mosquito/RedisBackend","path":"Mosquito/RedisBackend.html","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend","abstract":false,"superclass":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"ancestors":[{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/redis_backend.cr","line_number":35,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"LIST_OF_QUEUES_KEY","name":"LIST_OF_QUEUES_KEY","value":"\"queues\""},{"id":"Log","name":"Log","value":"::Log.for(self)"}],"extended_modules":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"delete(key:String,inttl:Int32=0):Nil-class-method","name":"delete","doc":"Overload required for crystal 1.1-1.2.\nSoft Deprecation isn't shown, but it's here so this will get cleaned up at some point.\n@[Deprecated(\"To be removed when support for 1.1 is dropped. See RedisBackend.delete(String, Int64).\")]","summary":"

Overload required for crystal 1.1-1.2.

","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int32"}],"args_string":"(key : String, in ttl : Int32 = 0) : Nil","args_html":"(key : String, in ttl : Int32 = 0) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":86,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int32"}],"return_type":"Nil","visibility":"Public","body":"delete(key, in: ttl.to_i64)"}},{"html_id":"delete(key:String,inttl:Int64=0):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":90,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":"if (ttl > 0)\n redis.expire(key, ttl)\nelse\n redis.del(key)\nend"}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":98,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":"delete(key, ttl.to_i)"}},{"html_id":"expires_in(key:String):Int64-class-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":119,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"redis.ttl(key)"}},{"html_id":"flush:Nil-class-method","name":"flush","doc":"is this even a good idea?","summary":"

is this even a good idea?

","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":140,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.flushdb"}},{"html_id":"get(key:String,field:String):String|Nil-class-method","name":"get","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":102,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":"(redis.hget(key, field)).as?(String)"}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":115,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":"(redis.hincrby(key, field, value)).as(Int64)"}},{"html_id":"increment(key:String,field:String):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":111,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"increment(key, field, by: 1)"}},{"html_id":"list_queues:Array(String)-class-method","name":"list_queues","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":123,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"key = build_key(LIST_OF_QUEUES_KEY)\nlist_queues = (redis.zrange(key, 0, -1)).as(Array)\nif list_queues.any?\nelse\n return [] of String\nend\nlist_queues.compact_map() do |__arg1|\n __arg1.as(String)\nend\n"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":132,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":"runner_prefix = \"mosquito:runners:\"\n(Redis.instance.keys(\"#{runner_prefix}*\")).map() do |__arg2|\n __arg2.as(String)\nend.map(&.sub(runner_prefix, \"\"))\n"}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-class-method","name":"lock?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/redis_backend.cr","line_number":144,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":"response = redis.set(key, value, ex: ttl.to_i, nx: true)\nresponse == \"OK\"\n"}},{"html_id":"redis-class-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":56,"url":null},"def":{"name":"redis","visibility":"Public","body":"load_scripts = @@connection.nil?\nconnection = @@connection || (@@connection = ::Redis::Client.new(URI.parse(Mosquito.configuration.redis_url.to_s)))\nif load_scripts\n Scripts.load(connection)\nend\nconnection\n"}},{"html_id":"remove_matching_key(*,keys=[]ofString,args=[]ofString,loadscripts=true)-class-method","name":"remove_matching_key","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"keys","default_value":"[] of String","external_name":"keys","restriction":""},{"name":"args","default_value":"[] of String","external_name":"args","restriction":""},{"name":"loadscripts","default_value":"true","external_name":"loadscripts","restriction":""}],"args_string":"(*, keys = [] of String, args = [] of String, loadscripts = true)","args_html":"(*, keys = [] of String, args = [] of String, loadscripts = true)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":40,"url":null},"def":{"name":"remove_matching_key","args":[{"name":"","external_name":"","restriction":""},{"name":"keys","default_value":"[] of String","external_name":"keys","restriction":""},{"name":"args","default_value":"[] of String","external_name":"args","restriction":""},{"name":"loadscripts","default_value":"true","external_name":"loadscripts","restriction":""}],"splat_index":0,"visibility":"Public","body":"begin\n script = \" if redis.call(\\\"get\\\",KEYS[1]) == ARGV[1] then\\n return redis.call(\\\"del\\\",KEYS[1])\\n else\\n return 0\\n end\"\n digest = Scripts.remove_matching_key\n redis.evalsha(digest, keys: keys, args: args)\nrescue exception : Redis::Error\n if exception.message.try(&.starts_with?(\"NOSCRIPT\"))\n else\n raise(exception)\n end\n if loadscripts\n else\n raise(exception)\n end\n (Log.for(\"remove_matching_key\")).warn do\n \"Redis Scripts have gone missing, reloading\"\n end\n Scripts.load(redis)\n remove_matching_key(keys: keys, args: args, loadscripts: false)\nend"}},{"html_id":"retrieve(key:String):Hash(String,String)-class-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":78,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"result = ((redis.hgetall(key)).as(Array)).map(&.to_s)\n(result.in_groups_of(2, \"\")).to_h\n"}},{"html_id":"set(key:String,field:String,value:String):String-class-method","name":"set","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/redis_backend.cr","line_number":106,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":"redis.hset(key, field, value)\nvalue\n"}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-class-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":74,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":"redis.hset(key, value)"}},{"html_id":"unlock(key:String,value:String):Nil-class-method","name":"unlock","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":149,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":"remove_matching_key(keys: [key], args: [value])"}}],"constructors":[{"html_id":"new(name:String|Symbol)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"args_string":"(name : String | Symbol)","args_html":"(name : String | Symbol)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":70,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String | Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":181,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"if id = redis.lmove(waiting_q, pending_q, :right, :left)\n JobRun.retrieve(id.to_s)\nend"}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":158,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":"time = Time.utc\noverdue_job_runs = (redis.zrangebyscore(scheduled_q, \"0\", time.to_unix_ms.to_s)).as(Array)\nif overdue_job_runs.any?\nelse\n return [] of JobRun\nend\noverdue_job_runs.compact_map do |job_run_id|\n redis.zrem(scheduled_q, job_run_id.to_s)\n JobRun.retrieve(job_run_id.as(String))\nend\n"}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":"key = dead_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg6|\n __arg6.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg7|\n __arg7.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for dead\")\n end\n end\nend\n"}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":"key = pending_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg4|\n __arg4.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg5|\n __arg5.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for pending\")\n end\n end\nend\n"}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":"key = scheduled_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg2|\n __arg2.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg3|\n __arg3.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for scheduled\")\n end\n end\nend\n"}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":216,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":"key = waiting_q\ntype = redis.type(key)\nif type == \"list\"\n ((redis.lrange(key, \"0\", \"-1\")).as(Array(Redis::Value))).map() do |__arg0|\n __arg0.as(String)\n end\nelse\n if type == \"zset\"\n ((redis.zrange(key, 0, -1)).as(Array(Redis::Value))).map() do |__arg1|\n __arg1.as(String)\n end\n else\n if type == \"none\"\n [] of String\n else\n raise(\"don't know how to dump a #{type} for waiting\")\n end\n end\nend\n"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/redis_backend.cr","line_number":170,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"redis.pipeline do |pipe|\n pipe.lpush(waiting_q, job_run.id)\n pipe.zadd(build_key(LIST_OF_QUEUES_KEY), Time.utc.to_unix.to_s, name)\nend\njob_run\n"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":187,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"redis.lrem(pending_q, 0, job_run.id)"}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":195,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.del(waiting_q, pending_q, scheduled_q, dead_q)"}},{"html_id":"redis-instance-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":66,"url":null},"def":{"name":"redis","visibility":"Public","body":"self.class.redis"}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/redis_backend.cr","line_number":153,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"redis.zadd(scheduled_q, scheduled_time.to_unix_ms.to_s, job_run.id)\njob_run\n"}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/redis_backend.cr","line_number":233,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":"(redis.zscore(scheduled_q, job_run.id)).as?(String)"}},{"html_id":"size(include_dead=true):Int64-instance-method","name":"size","abstract":false,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":""}],"args_string":"(include_dead = true) : Int64","args_html":"(include_dead = true) : Int64","location":{"filename":"src/mosquito/redis_backend.cr","line_number":204,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":""}],"return_type":"Int64","visibility":"Public","body":"queues = [waiting_q, pending_q]\nif include_dead\n queues << dead_q\nend\nqueue_size = queues.map do |key|\n (redis.llen(key)).as(Int64)\nend.reduce do |sum, i|\n sum + i\nend\nscheduled_size = redis.zcount(scheduled_q, \"0\", \"+inf\")\nqueue_size + (scheduled_size.as(Int64))\n"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":191,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"redis.lpush(dead_q, job_run.id)"}}]},{"html_id":"mosquito/Mosquito/Runnable","path":"Mosquito/Runnable.html","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable","abstract":false,"locations":[{"filename":"src/mosquito/runnable.cr","line_number":64,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Executor","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor"},{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"Runnable implements a general purpose spawn/loop which carries a state\nenum.\n\n## Managing a Runnable\n\nThe primary purpose of Runnable is to cleanly abstract the details of\nspawning a thread, running a loop, and shutting down when asked.\n\nA service which manages a Runnable might look like this:\n\n```crystal\nrunnable = MyRunnable.new\n\n# This will spawn and return immediately.\nrunnable.start\n\nputs runnable.state # => State::Working\n\n# Some time later...\nshould_be_stopped = runnable.stop has_stopped =\nshould_be_stopped.receive\n```\n\n\n## Implementing a Runnable\n\nA runnable implementation needs to implement only two methods: #each_run\nand #runnable_name. In addition, pre_run and post_run are available for\nsetup and teardown.\n\nRunnable state is managed automatically through startup and shutdown, but\nwithin each_run it can be manually altered with `#state=`.\n\n### Example\n\n```crystal\nclass MyRunnable\n include Mosquito::Runnable\n\n # Optional\n def pre_run\n puts \"my runnable is starting\"\n end\n\n def each_run\n puts \"my runnable is running\"\n end\n\n # Optional\n def post_run\n puts \"my runnable has stopped\"\n end\n\n def runnable_name\n \"MyRunnable\"\n end\nend\n```\n\nImplementation details about what work should be done in the spawned fiber\nare placed in #each_run.\n","summary":"

Runnable implements a general purpose spawn/loop which carries a state enum.

","instance_methods":[{"html_id":"dead?:Bool-instance-method","name":"dead?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":106,"url":null},"def":{"name":"dead?","return_type":"Bool","visibility":"Public","body":"if fiber_ = fiber\n fiber_.dead?\nelse\n false\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"Implementation of what this Runnable should do on each cycle.\n\nTake care that @state is #running? at the end of the method\nunless it is finished and should exit.","summary":"

Implementation of what this Runnable should do on each cycle.

","abstract":true,"location":{"filename":"src/mosquito/runnable.cr","line_number":168,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"fiber:Fiber|Nil-instance-method","name":"fiber","doc":"After #run has been called this holds a reference to the Fiber\nwhich is used to check that the fiber is still running.","summary":"

After #run has been called this holds a reference to the Fiber which is used to check that the fiber is still running.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":96,"url":null},"def":{"name":"fiber","return_type":"Fiber | ::Nil","visibility":"Public","body":"@fiber"}},{"html_id":"my_name:String-instance-method","name":"my_name","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":98,"url":null},"def":{"name":"my_name","return_type":"String","visibility":"Public","body":"if (value = @my_name).nil?\n @my_name = (\"#{self.class.name.underscore.gsub(\"::\", \".\")}.#{self.object_id}\")\nelse\n value\nend"}},{"html_id":"post_run:Nil-instance-method","name":"post_run","doc":"Available to hook any teardown logic after the run loop.","summary":"

Available to hook any teardown logic after the run loop.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":174,"url":null},"def":{"name":"post_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"pre_run:Nil-instance-method","name":"pre_run","doc":"Available to hook a one time setup before the run loop.","summary":"

Available to hook a one time setup before the run loop.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":171,"url":null},"def":{"name":"pre_run","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"run-instance-method","name":"run","doc":"Start the Runnable, and capture the fiber to a property.\n\nThe spawned fiber will not return as long as state.running?.\n\nState can be altered internally or externally to cause it to exit\nbut the cleanest way to do that is to call #stop.","summary":"

Start the Runnable, and capture the fiber to a property.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":120,"url":null},"def":{"name":"run","visibility":"Public","body":"@fiber = spawn(name: my_name) do\n log = Log.for(my_name)\n log.info do\n runnable_name + \" is starting\"\n end\n self.state = State::Working\n pre_run\n while state.running?\n each_run\n end\n post_run\n self.state = State::Finished\nend"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":true,"location":{"filename":"src/mosquito/runnable.cr","line_number":162,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":""}},{"html_id":"state:State-instance-method","name":"state","doc":"Tracks the state of this runnable.\n\nInitially it will be `State::Starting`. After `#run` is called it will\nbe `State::Working`.\n\nWhen `#stop` is called it will be `State::Stopping`. After `#run` finishes,\nit will be `State::Finished`.\n\nIt is not necessary to set this manually, but it's available to an implementation\nif needed. See `Mosquito::Runners::Executor#state=` (source code) for an example.","summary":"

Tracks the state of this runnable.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":92,"url":null},"def":{"name":"state","return_type":"State","visibility":"Public","body":"@state"}},{"html_id":"stop:Channel(Bool)-instance-method","name":"stop","doc":"Request that the next time the run loop cycles it should exit instead.\nThe runnable doesn't exit immediately so #stop returns a notification\nchannel.\n\n#stop spawns a fiber which monitors the state and sends a bool in two\ncircumstances. It will stop waiting for the spawn to exit at 25 seconds.\nIf the spawn has actually stopped the notification channel will broadcast\na true, otherwise false.","summary":"

Request that the next time the run loop cycles it should exit instead.

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":145,"url":null},"def":{"name":"stop","return_type":"Channel(Bool)","visibility":"Public","body":"if state.running?\n self.state = State::Stopping\nend\nnotifier = Channel(Bool).new\nspawn do\n start = Time.utc\n while state.stopping? && (Time.utc - start) < 25.seconds\n Fiber.yield\n end\n notifier.send(state.finished?)\n Log.info do\n runnable_name + \" has stopped\"\n end\nend\nnotifier\n"}}],"types":[{"html_id":"mosquito/Mosquito/Runnable/State","path":"Mosquito/Runnable/State.html","kind":"enum","full_name":"Mosquito::Runnable::State","name":"State","abstract":false,"ancestors":[{"html_id":"mosquito/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"mosquito/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runnable.cr","line_number":65,"url":null}],"repository_name":"mosquito","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Starting","name":"Starting","value":"0"},{"id":"Working","name":"Working","value":"1"},{"id":"Idle","name":"Idle","value":"2"},{"id":"Stopping","name":"Stopping","value":"3"},{"id":"Finished","name":"Finished","value":"4"}],"namespace":{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},"instance_methods":[{"html_id":"finished?-instance-method","name":"finished?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":70,"url":null},"def":{"name":"finished?","visibility":"Public","body":"self == Finished"}},{"html_id":"idle?-instance-method","name":"idle?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":68,"url":null},"def":{"name":"idle?","visibility":"Public","body":"self == Idle"}},{"html_id":"running?-instance-method","name":"running?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":72,"url":null},"def":{"name":"running?","visibility":"Public","body":"(starting? || working?) || idle?"}},{"html_id":"started?-instance-method","name":"started?","doc":"ie, not starting","summary":"

ie, not starting

","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":77,"url":null},"def":{"name":"started?","visibility":"Public","body":"working? || idle?"}},{"html_id":"starting?-instance-method","name":"starting?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":66,"url":null},"def":{"name":"starting?","visibility":"Public","body":"self == Starting"}},{"html_id":"stopping?-instance-method","name":"stopping?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":69,"url":null},"def":{"name":"stopping?","visibility":"Public","body":"self == Stopping"}},{"html_id":"working?-instance-method","name":"working?","abstract":false,"location":{"filename":"src/mosquito/runnable.cr","line_number":67,"url":null},"def":{"name":"working?","visibility":"Public","body":"self == Working"}}]}]},{"html_id":"mosquito/Mosquito/Runner","path":"Mosquito/Runner.html","kind":"class","full_name":"Mosquito::Runner","name":"Runner","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runner.cr","line_number":34,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"This singleton class serves as a shorthand for starting and managing an Overseer.\n\nA minimal usage of Mosquito::Runner is:\n\n```\nrequire \"mosquito\"\n\n# When the process receives sigint, it'll notify the overseer to shut down gracefully.\ntrap(\"INT\") do\n Mosquito::Runner.stop(wait: true)\nend\n\n# Starts the overseer, and holds the thread captive.\nMosquito::Runner.start\n```\n\nIf for some reason you want to manage an overseer or group of overseers yourself, Mosquito::Runner can be omitted entirely:\n\n```crystal\nrequire \"mosquito\"\n\nmosquito = Mosquito::Overseer.new\n\n# Spawns a mosquito managed fiber and returns immediately\nmosquito.run\n\ntrap \"INT\" do\n mosquito.stop.receive\nend\n```","summary":"

This singleton class serves as a shorthand for starting and managing an Overseer.

","class_methods":[{"html_id":"start(spin=true)-class-method","name":"start","doc":"Start the mosquito runner.\n\nIf spin = true (default) the function will not return until the runner is\nshut down. Otherwise it will return immediately.\n","summary":"

Start the mosquito runner.

","abstract":false,"args":[{"name":"spin","default_value":"true","external_name":"spin","restriction":""}],"args_string":"(spin = true)","args_html":"(spin = true)","location":{"filename":"src/mosquito/runner.cr","line_number":42,"url":null},"def":{"name":"start","args":[{"name":"spin","default_value":"true","external_name":"spin","restriction":""}],"visibility":"Public","body":"Log.notice do\n \"Mosquito is buzzing...\"\nend\ninstance.run\nwhile spin && keep_running\n sleep(1)\nend\n"}},{"html_id":"stop(wait=false)-class-method","name":"stop","doc":"Request the mosquito runner stop. The runner will not abort the current job\nbut it will not start any new jobs.\n\nSee `Mosquito::Runnable#stop`.","summary":"

Request the mosquito runner stop.

","abstract":false,"args":[{"name":"wait","default_value":"false","external_name":"wait","restriction":""}],"args_string":"(wait = false)","args_html":"(wait = false)","location":{"filename":"src/mosquito/runner.cr","line_number":60,"url":null},"def":{"name":"stop","args":[{"name":"wait","default_value":"false","external_name":"wait","restriction":""}],"visibility":"Public","body":"Log.notice do\n \"Mosquito is shutting down...\"\nend\nfinished_notifier = instance.stop\nif wait\n finished_notifier.receive\nend\n"}}]},{"html_id":"mosquito/Mosquito/Runners","path":"Mosquito/Runners.html","kind":"module","full_name":"Mosquito::Runners","name":"Runners","abstract":false,"locations":[{"filename":"src/mosquito/runners/coordinator.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/executor.cr","line_number":4,"url":null},{"filename":"src/mosquito/runners/idle_wait.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/overseer.cr","line_number":6,"url":null},{"filename":"src/mosquito/runners/queue_list.cr","line_number":5,"url":null},{"filename":"src/mosquito/runners/run_at_most.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"types":[{"html_id":"mosquito/Mosquito/Runners/Coordinator","path":"Mosquito/Runners/Coordinator.html","kind":"class","full_name":"Mosquito::Runners::Coordinator","name":"Coordinator","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/coordinator.cr","line_number":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"LockTTL","name":"LockTTL","value":"10.seconds"},{"id":"Log","name":"Log","value":"::Log.for(self)"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"primer? loader? _scheduler_","summary":"

primer? loader? scheduler

","constructors":[{"html_id":"new(queue_list:Mosquito::Runners::QueueList)-class-method","name":"new","abstract":false,"args":[{"name":"queue_list","external_name":"queue_list","restriction":"::Mosquito::Runners::QueueList"}],"args_string":"(queue_list : Mosquito::Runners::QueueList)","args_html":"(queue_list : Mosquito::Runners::QueueList)","location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"queue_list","external_name":"queue_list","restriction":"::Mosquito::Runners::QueueList"}],"visibility":"Public","body":"_ = allocate\n_.initialize(queue_list)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"enqueue_delayed_jobs-instance-method","name":"enqueue_delayed_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":67,"url":null},"def":{"name":"enqueue_delayed_jobs","visibility":"Public","body":"queue_list.each do |q|\n overdue_jobs = q.dequeue_scheduled\n if overdue_jobs.any?\n else\n next\n end\n (Log.for(\"enqueue_delayed_jobs\")).info do\n \"#{overdue_jobs.size} delayed jobs ready in #{q.name}\"\n end\n overdue_jobs.each do |job_run|\n q.enqueue(job_run)\n end\nend"}},{"html_id":"enqueue_periodic_jobs-instance-method","name":"enqueue_periodic_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":61,"url":null},"def":{"name":"enqueue_periodic_jobs","visibility":"Public","body":"Base.scheduled_job_runs.each do |scheduled_job_run|\n enqueued = scheduled_job_run.try_to_execute\nend"}},{"html_id":"instance_id:String-instance-method","name":"instance_id","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":8,"url":null},"def":{"name":"instance_id","return_type":"String","visibility":"Public","body":"@instance_id"}},{"html_id":"lock_key:String-instance-method","name":"lock_key","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":7,"url":null},"def":{"name":"lock_key","return_type":"String","visibility":"Public","body":"@lock_key"}},{"html_id":"only_if_coordinator(&):Nil-instance-method","name":"only_if_coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":29,"url":null},"def":{"name":"only_if_coordinator","yields":0,"block_arity":0,"return_type":"Nil","visibility":"Public","body":"duration = 0.seconds\nif Mosquito.configuration.run_cron_scheduler\n yield\n if @emitted_scheduling_deprecation_runtime_message\n else\n Log.warn do\n \"Scheduling coordinator / CRON Scheduler has been manually activated. This behavior is deprecated in favor of distributed locking. See https://github.com/mosquito-cr/mosquito/pull/108 \"\n end\n @emitted_scheduling_deprecation_runtime_message = true\n end\n return\nend\nif Mosquito.configuration.use_distributed_lock\nelse\n return\nend\nif Mosquito.backend.lock?(lock_key, instance_id, LockTTL)\n Log.trace do\n \"Coordinator lock acquired\"\n end\n duration = Time.measure do\n yield\n end\n Mosquito.backend.unlock(lock_key, instance_id)\n Log.trace do\n \"Coordinator lock released\"\n end\nend\nif duration > LockTTL\nelse\n return\nend\nLog.warn do\n \"Coordination activities took longer than LockTTL (#{duration} > #{LockTTL}) \"\nend\n"}},{"html_id":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":9,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":18,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"Coordinator<#{object_id}>\""}},{"html_id":"schedule:Nil-instance-method","name":"schedule","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":22,"url":null},"def":{"name":"schedule","return_type":"Nil","visibility":"Public","body":"only_if_coordinator do\n enqueue_periodic_jobs\n enqueue_delayed_jobs\nend"}}]},{"html_id":"mosquito/Mosquito/Runners/Executor","path":"Mosquito/Runners/Executor.html","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/executor.cr","line_number":23,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"The executor is the center of work in Mosquito, and it's is the demarcation\npoint between Mosquito framework and application code. Above the Executor\nis entirely Mosquito, and below it is application code.\n\nAn Executor is responsible for hydrating Job classes with deserialized\nparameters and calling `Mosquito::Job#run` on them. It measures the time it\ntakes to run a job and provides detailed log messages about the current\nstatus.\n\nAn executor is a `Mosquito::Runnable` and should be interacted with according to\nthe Runnable API.\n\nTo build an executor, provide a job input channel and an idle bell channel. These\nchannels can be shared between all available executors.\n\nThe executor will ring the idle bell when it is ready to accept work and then wait\nfor work to show up on the job pipeline. After the job is finished it will ring the\nbell again and wait for more work.","summary":"

The executor is the center of work in Mosquito, and it's is the demarcation point between Mosquito framework and application code.

","constructors":[{"html_id":"new(job_pipeline:Channel(Tuple(Mosquito::JobRun,Mosquito::Queue)),idle_bell:Channel(Bool))-class-method","name":"new","abstract":false,"args":[{"name":"job_pipeline","external_name":"job_pipeline","restriction":"::Channel(::Tuple(::Mosquito::JobRun, ::Mosquito::Queue))"},{"name":"idle_bell","external_name":"idle_bell","restriction":"::Channel(::Bool)"}],"args_string":"(job_pipeline : Channel(Tuple(Mosquito::JobRun, Mosquito::Queue)), idle_bell : Channel(Bool))","args_html":"(job_pipeline : Channel(Tuple(Mosquito::JobRun, Mosquito::Queue)), idle_bell : Channel(Bool))","location":{"filename":"src/mosquito/runners/executor.cr","line_number":51,"url":null},"def":{"name":"new","args":[{"name":"job_pipeline","external_name":"job_pipeline","restriction":"::Channel(::Tuple(::Mosquito::JobRun, ::Mosquito::Queue))"},{"name":"idle_bell","external_name":"idle_bell","restriction":"::Channel(::Bool)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(job_pipeline, idle_bell)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"execute(job_run:JobRun,from_queueq:Queue)-instance-method","name":"execute","doc":"Runs a job from a Queue.\n\nExecution time is measured and logged, and the job is either forgotten\nor, if it fails, rescheduled.","summary":"

Runs a job from a Queue.

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"q","external_name":"from_queue","restriction":"Queue"}],"args_string":"(job_run : JobRun, from_queue q : Queue)","args_html":"(job_run : JobRun, from_queue q : Queue)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":85,"url":null},"def":{"name":"execute","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"q","external_name":"from_queue","restriction":"Queue"}],"visibility":"Public","body":"log.info do\n \"#{\"Starting:\".colorize.magenta} #{job_run} from #{q.name}\"\nend\nduration = Time.measure do\n job_run.run\nend.total_seconds\nif job_run.succeeded?\n log.info do\n \"#{\"Success:\".colorize.green} #{job_run} finished and took #{time_with_units(duration)}\"\n end\n q.forget(job_run)\n job_run.delete(in: successful_job_ttl)\nelse\n message = String::Builder.new\n message << \"Failure: \".colorize.red\n message << job_run\n message << \" failed, taking \"\n message << (time_with_units(duration))\n message << \" and \"\n if job_run.rescheduleable?\n next_execution = Time.utc + job_run.reschedule_interval\n q.reschedule(job_run, next_execution)\n message << \"will run again\".colorize.cyan\n message << \" in \"\n message << job_run.reschedule_interval\n message << \" (at \"\n message << next_execution\n message << \")\"\n log.warn do\n message.to_s\n end\n else\n q.banish(job_run)\n job_run.delete(in: failed_job_ttl)\n message << \"cannot be rescheduled\".colorize.yellow\n log.error do\n message.to_s\n end\n end\nend\n"}},{"html_id":"failed_job_ttl:Int32-instance-method","name":"failed_job_ttl","doc":"How long a job config is persisted after failure","summary":"

How long a job config is persisted after failure

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":34,"url":null},"def":{"name":"failed_job_ttl","return_type":"Int32","visibility":"Public","body":"if (value = @failed_job_ttl).nil?\n @failed_job_ttl = (Mosquito.configuration.failed_job_ttl)\nelse\n value\nend"}},{"html_id":"failed_job_ttl=(failed_job_ttl:Int32)-instance-method","name":"failed_job_ttl=","doc":"How long a job config is persisted after failure","summary":"

How long a job config is persisted after failure

","abstract":false,"args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"args_string":"(failed_job_ttl : Int32)","args_html":"(failed_job_ttl : Int32)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":34,"url":null},"def":{"name":"failed_job_ttl=","args":[{"name":"failed_job_ttl","external_name":"failed_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@failed_job_ttl = failed_job_ttl"}},{"html_id":"idle_bell:Channel(Bool)-instance-method","name":"idle_bell","doc":"Used to notify the overseer that this executor is idle.","summary":"

Used to notify the overseer that this executor is idle.

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":40,"url":null},"def":{"name":"idle_bell","return_type":"Channel(Bool)","visibility":"Public","body":"@idle_bell"}},{"html_id":"job_pipeline:Channel(Tuple(JobRun,Queue))-instance-method","name":"job_pipeline","doc":"Where work is received from the overseer.","summary":"

Where work is received from the overseer.

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":37,"url":null},"def":{"name":"job_pipeline","return_type":"Channel(Tuple(JobRun, Queue))","visibility":"Public","body":"@job_pipeline"}},{"html_id":"log:::Log-instance-method","name":"log","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":28,"url":null},"def":{"name":"log","return_type":"::Log","visibility":"Public","body":"@log"}},{"html_id":"successful_job_ttl:Int32-instance-method","name":"successful_job_ttl","doc":"How long a job config is persisted after success","summary":"

How long a job config is persisted after success

","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":31,"url":null},"def":{"name":"successful_job_ttl","return_type":"Int32","visibility":"Public","body":"if (value = @successful_job_ttl).nil?\n @successful_job_ttl = (Mosquito.configuration.successful_job_ttl)\nelse\n value\nend"}},{"html_id":"successful_job_ttl=(successful_job_ttl:Int32)-instance-method","name":"successful_job_ttl=","doc":"How long a job config is persisted after success","summary":"

How long a job config is persisted after success

","abstract":false,"args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"args_string":"(successful_job_ttl : Int32)","args_html":"(successful_job_ttl : Int32)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":31,"url":null},"def":{"name":"successful_job_ttl=","args":[{"name":"successful_job_ttl","external_name":"successful_job_ttl","restriction":"Int32"}],"visibility":"Public","body":"@successful_job_ttl = successful_job_ttl"}}]},{"html_id":"mosquito/Mosquito/Runners/IdleWait","path":"Mosquito/Runners/IdleWait.html","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait","abstract":false,"locations":[{"filename":"src/mosquito/runners/idle_wait.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"instance_methods":[{"html_id":"with_idle_wait(idle_wait:Time::Span,&)-instance-method","name":"with_idle_wait","abstract":false,"args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"args_string":"(idle_wait : Time::Span, &)","args_html":"(idle_wait : Time::Span, &)","location":{"filename":"src/mosquito/runners/idle_wait.cr","line_number":3,"url":null},"def":{"name":"with_idle_wait","args":[{"name":"idle_wait","external_name":"idle_wait","restriction":"Time::Span"}],"yields":0,"block_arity":0,"visibility":"Public","body":"delta = Time.measure do\n yield\nend\nif delta < idle_wait\n sleep(idle_wait - delta)\nend\n"}}]},{"html_id":"mosquito/Mosquito/Runners/Overseer","path":"Mosquito/Runners/Overseer.html","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/overseer.cr","line_number":14,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"The Overseer is responsible for managing:\n- a `Coordinator`\n- an `Executor`\n- the `QueueList`\n- any idle state as configured\n\nAn overseer manages the loop that each thread or process runs.","summary":"

The Overseer is responsible for managing: - a Coordinator - an Executor - the QueueList - any idle state as configured

","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":39,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_executor:Executor-instance-method","name":"build_executor","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":52,"url":null},"def":{"name":"build_executor","return_type":"Executor","visibility":"Public","body":"Executor.new(work_handout, idle_notifier)"}},{"html_id":"check_for_deceased_runners:Nil-instance-method","name":"check_for_deceased_runners","doc":"If an executor dies, it's probably because a bug exists somewhere in Mosquito itself.\n\nWhen a job fails any exceptions are caught and logged. If a job causes something more\ncatastrophic we can try to recover by spawning a new executor.","summary":"

If an executor dies, it's probably because a bug exists somewhere in Mosquito itself.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":162,"url":null},"def":{"name":"check_for_deceased_runners","return_type":"Nil","visibility":"Public","body":"executors.select do |e|\n e.state.started?\nend.select(&.dead?).each do |dead_executor|\n Log.fatal do\n \" Executor #{dead_executor.runnable_name} died.\\n A new executor will be started.\"\n end\n executors.delete(dead_executor)\nend\n(executor_count - executors.size).times do\n executors << build_executor.tap(&.run)\nend\nif queue_list.dead?\n Log.fatal do\n \"QueueList has died, overseer will stop.\"\n end\n stop\nend\n"}},{"html_id":"coordinator:Mosquito::Runners::Coordinator-instance-method","name":"coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":23,"url":null},"def":{"name":"coordinator","visibility":"Public","body":"@coordinator"}},{"html_id":"dequeue_job?:Tuple(JobRun,Queue)|Nil-instance-method","name":"dequeue_job?","doc":"Weaknesses: This implementation sometimes starves queues because it doesn't\nround robin, prioritize queues, or anything else.","summary":"

Weaknesses: This implementation sometimes starves queues because it doesn't round robin, prioritize queues, or anything else.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":150,"url":null},"def":{"name":"dequeue_job?","return_type":"Tuple(JobRun, Queue) | ::Nil","visibility":"Public","body":"queue_list.each do |q|\n if job_run = q.dequeue\n return {job_run, q}\n end\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"The goal for the overseer is to:\n- Ensure that the coordinator gets run frequently to schedule delayed/periodic jobs.\n- Wait for an executor to be idle, and dequeue work if possible.\n- Monitor the executor pool for unexpected termination and respawn.","summary":"

The goal for the overseer is to: - Ensure that the coordinator gets run frequently to schedule delayed/periodic jobs.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":87,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":"coordinator.schedule\nif work_handout.closed? || idle_notifier.closed?\n Log.fatal do\n \"Executor communication channels closed, overseer will stop.\"\n end\n stop\n return\nend\nif queue_list.state.started?\nelse\n Log.debug do\n \"Waiting for the queue list to fetch possible queues\"\n end\n return\nend\nLog.trace do\n \"Waiting for an idle executor\"\nend\nall_executors_busy = true\nselect\nwhen @idle_notifier.receive\n Log.trace do\n \"Found an idle executor\"\n end\n all_executors_busy = false\nwhen timeout(idle_wait)\nend\n\ncase\nwhen all_executors_busy\n Log.trace do\n \"No idle executors\"\n end\nwhen next_job_run = dequeue_job?\n job_run, queue = next_job_run\n Log.trace do\n \"Dequeued job: #{job_run.id} #{queue.name}\"\n end\n work_handout.send(next_job_run)\nelse\n Log.trace do\n \"No job to dequeue\"\n end\n sleep\n spawn do\n @idle_notifier.send(true)\n end\nend\ncheck_for_deceased_runners\n"}},{"html_id":"executor_count:Int32-instance-method","name":"executor_count","doc":"The number of executors to start.","summary":"

The number of executors to start.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":33,"url":null},"def":{"name":"executor_count","visibility":"Public","body":"@executor_count"}},{"html_id":"executors:Array(Mosquito::Runners::Executor)-instance-method","name":"executors","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":22,"url":null},"def":{"name":"executors","visibility":"Public","body":"@executors"}},{"html_id":"idle_notifier:Channel(Bool)-instance-method","name":"idle_notifier","doc":"When an executor transitions to idle it will send a True here. The Overseer\nuses this as a signal to check the queues for more work.","summary":"

When an executor transitions to idle it will send a True here.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":30,"url":null},"def":{"name":"idle_notifier","visibility":"Public","body":"@idle_notifier"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":35,"url":null},"def":{"name":"idle_wait","return_type":"Time::Span","visibility":"Public","body":"if (value = @idle_wait).nil?\n @idle_wait = (Mosquito.configuration.idle_wait)\nelse\n value\nend"}},{"html_id":"post_run:Nil-instance-method","name":"post_run","doc":"Notify all subprocesses to stop, and wait until they do.","summary":"

Notify all subprocesses to stop, and wait until they do.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":73,"url":null},"def":{"name":"post_run","return_type":"Nil","visibility":"Public","body":"Log.info do\n \"Stopping #{@executors.size} executors.\"\nend\nstopped_notifiers = executors.map do |executor|\n executor.stop\nend\nwork_handout.close\nstopped_notifiers.each(&.receive)\nLog.info do\n \"All executors stopped.\"\nend\n"}},{"html_id":"pre_run:Nil-instance-method","name":"pre_run","doc":"Starts all the subprocesses.","summary":"

Starts all the subprocesses.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":66,"url":null},"def":{"name":"pre_run","return_type":"Nil","visibility":"Public","body":"Log.info do\n \"Starting #{@executors.size} executors.\"\nend\n@queue_list.run\n@executors.each(&.run)\n"}},{"html_id":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":56,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"Overseer<#{object_id}>\""}},{"html_id":"sleep-instance-method","name":"sleep","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":60,"url":null},"def":{"name":"sleep","visibility":"Public","body":"Log.trace do\n \"Going to sleep now for #{idle_wait}\"\nend\nsleep(idle_wait)\n"}},{"html_id":"work_handout:Channel({Mosquito::JobRun,Mosquito::Queue})-instance-method","name":"work_handout","doc":"The channel where job runs which have been dequeued are sent to executors.","summary":"

The channel where job runs which have been dequeued are sent to executors.

","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":26,"url":null},"def":{"name":"work_handout","visibility":"Public","body":"@work_handout"}}]},{"html_id":"mosquito/Mosquito/Runners/QueueList","path":"Mosquito/Runners/QueueList.html","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList","abstract":false,"superclass":{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/runners/queue_list.cr","line_number":7,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(self)"}],"included_modules":[{"html_id":"mosquito/Mosquito/Runnable","kind":"module","full_name":"Mosquito::Runnable","name":"Runnable"},{"html_id":"mosquito/Mosquito/Runners/IdleWait","kind":"module","full_name":"Mosquito::Runners::IdleWait","name":"IdleWait"},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"doc":"QueueList handles searching the redis keyspace for named queues.","summary":"

QueueList handles searching the redis keyspace for named queues.

","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":16,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"each(*args,**options)-instance-method","name":"each","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options)","args_html":"(*args, **options)","location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":24,"url":null},"def":{"name":"each","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"visibility":"Public","body":"@queues.shuffle.each(*args, **options)"}},{"html_id":"each(*args,**options,&)-instance-method","name":"each","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **options, &)","args_html":"(*args, **options, &)","location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":24,"url":null},"def":{"name":"each","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"options","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arity":1,"visibility":"Public","body":"@queues.shuffle.each(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"each_run:Nil-instance-method","name":"each_run","doc":"Implementation of what this Runnable should do on each cycle.\n\nTake care that @state is #running? at the end of the method\nunless it is finished and should exit.","summary":"

Implementation of what this Runnable should do on each cycle.

","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":26,"url":null},"def":{"name":"each_run","return_type":"Nil","visibility":"Public","body":"with_idle_wait(1.seconds) do\n @state = State::Working\n candidate_queues = Mosquito.backend.list_queues.map do |name|\n Queue.new(name)\n end\n new_queue_list = filter_queues(candidate_queues)\n Log.notice do\n queues_which_were_expected_but_not_found = @queues - new_queue_list\n queues_which_have_never_been_seen = new_queue_list - @queues\n if queues_which_have_never_been_seen.size > 0\n \"found #{queues_which_have_never_been_seen.size} new queues: #{queues_which_have_never_been_seen.map(&.name).join(\", \")}\"\n end\n end\n @queues = new_queue_list\n @state = State::Idle\nend"}},{"html_id":"queues:Array(Queue)-instance-method","name":"queues","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":14,"url":null},"def":{"name":"queues","return_type":"Array(Queue)","visibility":"Public","body":"@queues"}},{"html_id":"runnable_name:String-instance-method","name":"runnable_name","doc":"Used to print a pretty name for logging.","summary":"

Used to print a pretty name for logging.

","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":20,"url":null},"def":{"name":"runnable_name","return_type":"String","visibility":"Public","body":"\"QueueList<#{object_id}>\""}}]},{"html_id":"mosquito/Mosquito/Runners/RunAtMost","path":"Mosquito/Runners/RunAtMost.html","kind":"module","full_name":"Mosquito::Runners::RunAtMost","name":"RunAtMost","abstract":false,"locations":[{"filename":"src/mosquito/runners/run_at_most.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Runners/Executor","kind":"class","full_name":"Mosquito::Runners::Executor","name":"Executor"},{"html_id":"mosquito/Mosquito/Runners/Overseer","kind":"class","full_name":"Mosquito::Runners::Overseer","name":"Overseer"},{"html_id":"mosquito/Mosquito/Runners/QueueList","kind":"class","full_name":"Mosquito::Runners::QueueList","name":"QueueList"}],"namespace":{"html_id":"mosquito/Mosquito/Runners","kind":"module","full_name":"Mosquito::Runners","name":"Runners"},"instance_methods":[{"html_id":"execution_timestamps-instance-method","name":"execution_timestamps","abstract":false,"location":{"filename":"src/mosquito/runners/run_at_most.cr","line_number":3,"url":null},"def":{"name":"execution_timestamps","visibility":"Public","body":"@execution_timestamps"}}]}]},{"html_id":"mosquito/Mosquito/ScheduledJob","path":"Mosquito/ScheduledJob.html","kind":"class","full_name":"Mosquito::ScheduledJob","name":"ScheduledJob","abstract":true,"superclass":{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},"ancestors":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"},{"html_id":"mosquito/Mosquito/Serializers/Primitives","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/scheduled_job.cr","line_number":2,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":3,"url":null},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build_job_run-instance-method","name":"build_job_run","abstract":true,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":6,"url":null},"def":{"name":"build_job_run","visibility":"Public","body":""}},{"html_id":"rescheduleable?-instance-method","name":"rescheduleable?","doc":"abstract, override if desired.\n\nTrue if this job is rescheduleable, false if not.","summary":"

abstract, override if desired.

","abstract":false,"location":{"filename":"src/mosquito/scheduled_job.cr","line_number":20,"url":null},"def":{"name":"rescheduleable?","visibility":"Public","body":"false"}}]},{"html_id":"mosquito/Mosquito/Scripts","path":"Mosquito/Scripts.html","kind":"module","full_name":"Mosquito::Scripts","name":"Scripts","abstract":false,"locations":[{"filename":"src/mosquito/redis_backend.cr","line_number":5,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"SCRIPTS","name":"SCRIPTS","value":"{:remove_matching_key => \" if redis.call(\\\"get\\\",KEYS[1]) == ARGV[1] then\\n return redis.call(\\\"del\\\",KEYS[1])\\n else\\n return 0\\n end\"}"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"class_methods":[{"html_id":"load(connection)-class-method","name":"load","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":""}],"args_string":"(connection)","args_html":"(connection)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":18,"url":null},"def":{"name":"load","args":[{"name":"connection","external_name":"connection","restriction":""}],"visibility":"Public","body":"SCRIPTS.each do |name, script|\n sha = @@script_sha[name] = connection.script_load(script)\n Log.info do\n \"loading script : #{name} => #{sha}\"\n end\nend"}},{"html_id":"remove_matching_key-class-method","name":"remove_matching_key","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":25,"url":null},"def":{"name":"remove_matching_key","visibility":"Public","body":"@@script_sha[:remove_matching_key]"}}]},{"html_id":"mosquito/Mosquito/Serializers","path":"Mosquito/Serializers.html","kind":"module","full_name":"Mosquito::Serializers","name":"Serializers","abstract":false,"locations":[{"filename":"src/mosquito/serializers/primitives.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"types":[{"html_id":"mosquito/Mosquito/Serializers/Primitives","path":"Mosquito/Serializers/Primitives.html","kind":"module","full_name":"Mosquito::Serializers::Primitives","name":"Primitives","abstract":false,"locations":[{"filename":"src/mosquito/serializers/primitives.cr","line_number":1,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"mosquito/Mosquito/Job","kind":"class","full_name":"Mosquito::Job","name":"Job"}],"namespace":{"html_id":"mosquito/Mosquito/Serializers","kind":"module","full_name":"Mosquito::Serializers","name":"Serializers"},"instance_methods":[{"html_id":"deserialize_bool(raw:String):Bool-instance-method","name":"deserialize_bool","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Bool","args_html":"(raw : String) : Bool","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":14,"url":null},"def":{"name":"deserialize_bool","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Bool","visibility":"Public","body":"raw == \"true\""}},{"html_id":"deserialize_char(raw:String):Char-instance-method","name":"deserialize_char","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Char","args_html":"(raw : String) : Char","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":26,"url":null},"def":{"name":"deserialize_char","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Char","visibility":"Public","body":"raw[0]"}},{"html_id":"deserialize_float32(raw:String):Float32|Nil-instance-method","name":"deserialize_float32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Float32 | Nil","args_html":"(raw : String) : Float32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_float32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Float32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_f32\nend"}},{"html_id":"deserialize_float64(raw:String):Float64|Nil-instance-method","name":"deserialize_float64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Float64 | Nil","args_html":"(raw : String) : Float64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_float64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Float64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_f64\nend"}},{"html_id":"deserialize_int128(raw:String):Int128|Nil-instance-method","name":"deserialize_int128","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int128 | Nil","args_html":"(raw : String) : Int128 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int128","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int128 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i128\nend"}},{"html_id":"deserialize_int16(raw:String):Int16|Nil-instance-method","name":"deserialize_int16","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int16 | Nil","args_html":"(raw : String) : Int16 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int16","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int16 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i16\nend"}},{"html_id":"deserialize_int32(raw:String):Int32|Nil-instance-method","name":"deserialize_int32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int32 | Nil","args_html":"(raw : String) : Int32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i32\nend"}},{"html_id":"deserialize_int64(raw:String):Int64|Nil-instance-method","name":"deserialize_int64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int64 | Nil","args_html":"(raw : String) : Int64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i64\nend"}},{"html_id":"deserialize_int8(raw:String):Int8|Nil-instance-method","name":"deserialize_int8","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : Int8 | Nil","args_html":"(raw : String) : Int8 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_int8","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"Int8 | ::Nil","visibility":"Public","body":"if raw\n raw.to_i8\nend"}},{"html_id":"deserialize_string(raw:String):String-instance-method","name":"deserialize_string","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : String","args_html":"(raw : String) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":6,"url":null},"def":{"name":"deserialize_string","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"String","visibility":"Public","body":"raw"}},{"html_id":"deserialize_u_int128(raw:String):UInt128|Nil-instance-method","name":"deserialize_u_int128","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt128 | Nil","args_html":"(raw : String) : UInt128 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int128","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt128 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u128\nend"}},{"html_id":"deserialize_u_int16(raw:String):UInt16|Nil-instance-method","name":"deserialize_u_int16","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt16 | Nil","args_html":"(raw : String) : UInt16 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int16","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt16 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u16\nend"}},{"html_id":"deserialize_u_int32(raw:String):UInt32|Nil-instance-method","name":"deserialize_u_int32","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt32 | Nil","args_html":"(raw : String) : UInt32 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int32","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt32 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u32\nend"}},{"html_id":"deserialize_u_int64(raw:String):UInt64|Nil-instance-method","name":"deserialize_u_int64","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt64 | Nil","args_html":"(raw : String) : UInt64 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int64","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt64 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u64\nend"}},{"html_id":"deserialize_u_int8(raw:String):UInt8|Nil-instance-method","name":"deserialize_u_int8","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UInt8 | Nil","args_html":"(raw : String) : UInt8 | Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"deserialize_u_int8","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UInt8 | ::Nil","visibility":"Public","body":"if raw\n raw.to_u8\nend"}},{"html_id":"deserialize_uuid(raw:String):UUID-instance-method","name":"deserialize_uuid","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String) : UUID","args_html":"(raw : String) : UUID","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":34,"url":null},"def":{"name":"deserialize_uuid","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"return_type":"UUID","visibility":"Public","body":"UUID.new(raw)"}},{"html_id":"serialize_bool(value:Bool):String-instance-method","name":"serialize_bool","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Bool"}],"args_string":"(value : Bool) : String","args_html":"(value : Bool) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":10,"url":null},"def":{"name":"serialize_bool","args":[{"name":"value","external_name":"value","restriction":"Bool"}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_char(char:Char):String-instance-method","name":"serialize_char","abstract":false,"args":[{"name":"char","external_name":"char","restriction":"Char"}],"args_string":"(char : Char) : String","args_html":"(char : Char) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":22,"url":null},"def":{"name":"serialize_char","args":[{"name":"char","external_name":"char","restriction":"Char"}],"return_type":"String","visibility":"Public","body":"char.to_s"}},{"html_id":"serialize_float32(value):String-instance-method","name":"serialize_float32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_float32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_float64(value):String-instance-method","name":"serialize_float64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_float64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int128(value):String-instance-method","name":"serialize_int128","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int128","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int16(value):String-instance-method","name":"serialize_int16","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int16","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int32(value):String-instance-method","name":"serialize_int32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int64(value):String-instance-method","name":"serialize_int64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_int8(value):String-instance-method","name":"serialize_int8","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_int8","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_string(str:String):String-instance-method","name":"serialize_string","abstract":false,"args":[{"name":"str","external_name":"str","restriction":"String"}],"args_string":"(str : String) : String","args_html":"(str : String) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":2,"url":null},"def":{"name":"serialize_string","args":[{"name":"str","external_name":"str","restriction":"String"}],"return_type":"String","visibility":"Public","body":"str"}},{"html_id":"serialize_symbol(sym:Symbol):Nil-instance-method","name":"serialize_symbol","abstract":false,"args":[{"name":"sym","external_name":"sym","restriction":"Symbol"}],"args_string":"(sym : Symbol) : Nil","args_html":"(sym : Symbol) : Nil","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":18,"url":null},"def":{"name":"serialize_symbol","args":[{"name":"sym","external_name":"sym","restriction":"Symbol"}],"return_type":"Nil","visibility":"Public","body":"raise(\"Symbols cannot be deserialized. Stringify your symbol first to pass it as a mosquito job parameter.\")"}},{"html_id":"serialize_u_int128(value):String-instance-method","name":"serialize_u_int128","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int128","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int16(value):String-instance-method","name":"serialize_u_int16","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int16","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int32(value):String-instance-method","name":"serialize_u_int32","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int32","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int64(value):String-instance-method","name":"serialize_u_int64","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int64","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_u_int8(value):String-instance-method","name":"serialize_u_int8","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value) : String","args_html":"(value) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":38,"url":null},"def":{"name":"serialize_u_int8","args":[{"name":"value","external_name":"value","restriction":""}],"return_type":"String","visibility":"Public","body":"value.to_s"}},{"html_id":"serialize_uuid(uuid:UUID):String-instance-method","name":"serialize_uuid","abstract":false,"args":[{"name":"uuid","external_name":"uuid","restriction":"UUID"}],"args_string":"(uuid : UUID) : String","args_html":"(uuid : UUID) : String","location":{"filename":"src/mosquito/serializers/primitives.cr","line_number":30,"url":null},"def":{"name":"serialize_uuid","args":[{"name":"uuid","external_name":"uuid","restriction":"UUID"}],"return_type":"String","visibility":"Public","body":"uuid.to_s"}}]}]},{"html_id":"mosquito/Mosquito/TestBackend","path":"Mosquito/TestBackend.html","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend","abstract":false,"superclass":{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},"ancestors":[{"html_id":"mosquito/Mosquito/Backend","kind":"class","full_name":"Mosquito::Backend","name":"Backend"},{"html_id":"mosquito/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/test_backend.cr","line_number":38,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"mosquito/Mosquito/Backend/ClassMethods","kind":"module","full_name":"Mosquito::Backend::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"mosquito/Mosquito","kind":"module","full_name":"Mosquito","name":"Mosquito"},"doc":"An in-memory noop backend desigend to be used in application testing.\n\nThe test mode backend simply makes a copy of job_runs at enqueue time and holds them in a class getter array.\n\nJob run id, config (aka parameters), and runtime class are kept in memory, and a truncate utility function is provided.\n\nActivate test mode configure the test backend like this:\n\n```\nMosquito.configure do |settings|\n settings.backend = Mosquito::TestBackend\nend\n```\n\nThen in your tests:\n\n```\ndescribe \"testing\" do\n it \"enqueues the job\" do\n # build and enqueue a job\n job_run = EchoJob.new(text: \"hello world\").enqueue\n\n # assert that the job was enqueued\n lastest_enqueued_job = Mosquito::TestBackend.enqueued_jobs.last\n\n # check the job config\n assert_equal \"hello world\", latest_enqueued_job.config[\"text\"]\n\n # check the job_id matches\n assert_equal job_run.id, latest_enqueued_job.id\n\n # optionally, truncate the history\n Mosquito::TestBackend.flush_enqueued_jobs!\n end\nend\n```","summary":"

An in-memory noop backend desigend to be used in application testing.

","class_methods":[{"html_id":"delete(key:String,inttl:Int64=0):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"args_string":"(key : String, in ttl : Int64 = 0) : Nil","args_html":"(key : String, in ttl : Int64 = 0) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":54,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","default_value":"0","external_name":"in","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"delete(key:String,inttl:Time::Span):Nil-class-method","name":"delete","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"args_string":"(key : String, in ttl : Time::Span) : Nil","args_html":"(key : String, in ttl : Time::Span) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":57,"url":null},"def":{"name":"delete","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"ttl","external_name":"in","restriction":"Time::Span"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"enqueued_jobs-class-method","name":"enqueued_jobs","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":106,"url":null},"def":{"name":"enqueued_jobs","visibility":"Public","body":"@@enqueued_jobs"}},{"html_id":"enqueued_jobs=(enqueued_jobs:Array(Mosquito::TestBackend::EnqueuedJob))-class-method","name":"enqueued_jobs=","abstract":false,"args":[{"name":"enqueued_jobs","external_name":"enqueued_jobs","restriction":"::Array(::Mosquito::TestBackend::EnqueuedJob)"}],"args_string":"(enqueued_jobs : Array(Mosquito::TestBackend::EnqueuedJob))","args_html":"(enqueued_jobs : Array(Mosquito::TestBackend::EnqueuedJob))","location":{"filename":"src/mosquito/test_backend.cr","line_number":106,"url":null},"def":{"name":"enqueued_jobs=","args":[{"name":"enqueued_jobs","external_name":"enqueued_jobs","restriction":"::Array(::Mosquito::TestBackend::EnqueuedJob)"}],"visibility":"Public","body":"@@enqueued_jobs = enqueued_jobs"}},{"html_id":"expires_in(key:String):Int64-class-method","name":"expires_in","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Int64","args_html":"(key : String) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":60,"url":null},"def":{"name":"expires_in","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"flush:Nil-class-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":79,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"flush_enqueued_jobs!-class-method","name":"flush_enqueued_jobs!","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":108,"url":null},"def":{"name":"flush_enqueued_jobs!","visibility":"Public","body":"@@enqueued_jobs = [] of EnqueuedJob"}},{"html_id":"get(key:String,field:String):String|Nil-class-method","name":"get","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : String | Nil","args_html":"(key : String, field : String) : String | Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":64,"url":null},"def":{"name":"get","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"increment(key:String,field:String,byvalue:Int32):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"args_string":"(key : String, field : String, by value : Int32) : Int64","args_html":"(key : String, field : String, by value : Int32) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":75,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"by","restriction":"Int32"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"increment(key:String,field:String):Int64-class-method","name":"increment","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"args_string":"(key : String, field : String) : Int64","args_html":"(key : String, field : String) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":71,"url":null},"def":{"name":"increment","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"list_queues:Array(String)-class-method","name":"list_queues","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":46,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":50,"url":null},"def":{"name":"list_runners","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"lock?(key:String,value:String,ttl:Time::Span):Bool-class-method","name":"lock?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"args_string":"(key : String, value : String, ttl : Time::Span) : Bool","args_html":"(key : String, value : String, ttl : Time::Span) : Bool","location":{"filename":"src/mosquito/test_backend.cr","line_number":81,"url":null},"def":{"name":"lock?","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"},{"name":"ttl","external_name":"ttl","restriction":"Time::Span"}],"return_type":"Bool","visibility":"Public","body":"false"}},{"html_id":"retrieve(key:String):Hash(String,String)-class-method","name":"retrieve","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String) : Hash(String, String)","args_html":"(key : String) : Hash(String, String)","location":{"filename":"src/mosquito/test_backend.cr","line_number":42,"url":null},"def":{"name":"retrieve","args":[{"name":"key","external_name":"key","restriction":"String"}],"return_type":"Hash(String, String)","visibility":"Public","body":"{} of String => String"}},{"html_id":"set(key:String,field:String,value:String):String-class-method","name":"set","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, field : String, value : String) : String","args_html":"(key : String, field : String, value : String) : String","location":{"filename":"src/mosquito/test_backend.cr","line_number":67,"url":null},"def":{"name":"set","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"field","external_name":"field","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"String","visibility":"Public","body":"\"\""}},{"html_id":"store(key:String,value:Hash(String,String)):Nil-class-method","name":"store","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"args_string":"(key : String, value : Hash(String, String)) : Nil","args_html":"(key : String, value : Hash(String, String)) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":39,"url":null},"def":{"name":"store","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"Hash(String, String)"}],"return_type":"Nil","visibility":"Public","body":""}},{"html_id":"unlock(key:String,value:String):Nil-class-method","name":"unlock","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"args_string":"(key : String, value : String) : Nil","args_html":"(key : String, value : String) : Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":85,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"return_type":"Nil","visibility":"Public","body":""}}],"instance_methods":[{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":117,"url":null},"def":{"name":"dequeue","return_type":"JobRun | ::Nil","visibility":"Public","body":"raise(\"Mosquito: attempted to dequeue a job from the testing backend.\")"}},{"html_id":"deschedule:Array(JobRun)-instance-method","name":"deschedule","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":125,"url":null},"def":{"name":"deschedule","return_type":"Array(JobRun)","visibility":"Public","body":"raise(\"Mosquito: attempted to deschedule a job from the testing backend.\")"}},{"html_id":"dump_dead_q:Array(String)-instance-method","name":"dump_dead_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_dead_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_pending_q:Array(String)-instance-method","name":"dump_pending_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_pending_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_scheduled_q:Array(String)-instance-method","name":"dump_scheduled_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_scheduled_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"dump_waiting_q:Array(String)-instance-method","name":"dump_waiting_q","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":142,"url":null},"def":{"name":"dump_waiting_q","return_type":"Array(String)","visibility":"Public","body":"[] of String"}},{"html_id":"enqueue(job_run:JobRun):JobRun-instance-method","name":"enqueue","doc":"from queue.cr","summary":"

from queue.cr

","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : JobRun","args_html":"(job_run : JobRun) : JobRun","location":{"filename":"src/mosquito/test_backend.cr","line_number":112,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"@@enqueued_jobs << (EnqueuedJob.from(job_run))\njob_run\n"}},{"html_id":"finish(job_run:JobRun)-instance-method","name":"finish","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":129,"url":null},"def":{"name":"finish","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}},{"html_id":"flush:Nil-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":135,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"html_id":"schedule(job_run:JobRun,atscheduled_time:Time):JobRun-instance-method","name":"schedule","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"args_string":"(job_run : JobRun, at scheduled_time : Time) : JobRun","args_html":"(job_run : JobRun, at scheduled_time : Time) : JobRun","location":{"filename":"src/mosquito/test_backend.cr","line_number":121,"url":null},"def":{"name":"schedule","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"},{"name":"scheduled_time","external_name":"at","restriction":"Time"}],"return_type":"JobRun","visibility":"Public","body":"job_run"}},{"html_id":"scheduled_job_run_time(job_run:JobRun):String|Nil-instance-method","name":"scheduled_job_run_time","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun) : String | Nil","args_html":"(job_run : JobRun) : String | Nil","location":{"filename":"src/mosquito/test_backend.cr","line_number":148,"url":null},"def":{"name":"scheduled_job_run_time","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"String | ::Nil","visibility":"Public","body":""}},{"html_id":"size(include_dead:Bool=true):Int64-instance-method","name":"size","abstract":false,"args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"args_string":"(include_dead : Bool = true) : Int64","args_html":"(include_dead : Bool = true) : Int64","location":{"filename":"src/mosquito/test_backend.cr","line_number":138,"url":null},"def":{"name":"size","args":[{"name":"include_dead","default_value":"true","external_name":"include_dead","restriction":"Bool"}],"return_type":"Int64","visibility":"Public","body":"0_i64"}},{"html_id":"terminate(job_run:JobRun)-instance-method","name":"terminate","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":132,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}}],"types":[{"html_id":"mosquito/Mosquito/TestBackend/EnqueuedJob","path":"Mosquito/TestBackend/EnqueuedJob.html","kind":"struct","full_name":"Mosquito::TestBackend::EnqueuedJob","name":"EnqueuedJob","abstract":false,"superclass":{"html_id":"mosquito/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"mosquito/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"mosquito/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"mosquito/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/mosquito/test_backend.cr","line_number":88,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"mosquito/Mosquito/TestBackend","kind":"class","full_name":"Mosquito::TestBackend","name":"TestBackend"},"class_methods":[{"html_id":"from(job_run:JobRun)-class-method","name":"from","abstract":false,"args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"args_string":"(job_run : JobRun)","args_html":"(job_run : JobRun)","location":{"filename":"src/mosquito/test_backend.cr","line_number":93,"url":null},"def":{"name":"from","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":"job_class = Mosquito::Base.job_for_type(job_run.type)\nnew(job_run.id, job_class, job_run.config)\n"}}],"constructors":[{"html_id":"new(id:String,klass:::Mosquito::Job.class,config:Hash(String,String))-class-method","name":"new","abstract":false,"args":[{"name":"id","external_name":"id","restriction":"::String"},{"name":"klass","external_name":"klass","restriction":"::Mosquito::Job.class"},{"name":"config","external_name":"config","restriction":"::Hash(::String, ::String)"}],"args_string":"(id : String, klass : ::Mosquito::Job.class, config : Hash(String, String))","args_html":"(id : String, klass : ::Mosquito::Job.class, config : Hash(String, String))","location":{"filename":"src/mosquito/test_backend.cr","line_number":102,"url":null},"def":{"name":"new","args":[{"name":"id","external_name":"id","restriction":"::String"},{"name":"klass","external_name":"klass","restriction":"::Mosquito::Job.class"},{"name":"config","external_name":"config","restriction":"::Hash(::String, ::String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(id, klass, config)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"config:Hash(String,String)-instance-method","name":"config","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":91,"url":null},"def":{"name":"config","return_type":"Hash(String, String)","visibility":"Public","body":"@config"}},{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":89,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"klass:Mosquito::Job.class-instance-method","name":"klass","abstract":false,"location":{"filename":"src/mosquito/test_backend.cr","line_number":90,"url":null},"def":{"name":"klass","return_type":"Mosquito::Job.class","visibility":"Public","body":"@klass"}}]}]}]}]}}) \ No newline at end of file