diff --git a/Mosquito/Job.html b/Mosquito/Job.html index ae8f9514..df452cf6 100644 --- a/Mosquito/Job.html +++ b/Mosquito/Job.html @@ -454,7 +454,7 @@

  • - #fail(reason = "") + #fail(reason = "", *, retry : Bool = true)

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

    @@ -528,6 +528,20 @@

  • +
  • + #should_retry : Bool + +

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

    + +
  • + +
  • + #should_retry=(should_retry : Bool) + +

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

    + +
  • +
  • #state : Mosquito::Job::State @@ -978,18 +992,18 @@

    -
    +
    - def fail(reason = "") + def fail(reason = "", *, retry : Bool = true) - # + #

    To be called from inside a #perform -Marks this job as a failure. If the job is a candidate for +Marks this job as a failure. By default, if the job is a candidate for re-scheduling, it will be run again at a later time.

    @@ -1191,6 +1205,46 @@

    +
    +
    + + def should_retry : Bool + + # +
    + +
    + +

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

    +
    + +
    +
    + +
    +
    + +
    +
    + + def should_retry=(should_retry : Bool) + + # +
    + +
    + +

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

    +
    + +
    +
    + +
    +
    +
    diff --git a/Mosquito/PeriodicJob.html b/Mosquito/PeriodicJob.html index 6d9a6ca9..5854e570 100644 --- a/Mosquito/PeriodicJob.html +++ b/Mosquito/PeriodicJob.html @@ -379,8 +379,8 @@

    Instance methods inherited from class M executed?, - - fail(reason = "") + + fail(reason = "", *, retry : Bool = true) fail, @@ -434,6 +434,16 @@

    Instance methods inherited from class M run, + + should_retry : Bool + should_retry, + + + + should_retry=(should_retry : Bool) + should_retry=, + + state : Mosquito::Job::State state, diff --git a/Mosquito/QueuedJob.html b/Mosquito/QueuedJob.html index f8ed495a..5e4c2aef 100644 --- a/Mosquito/QueuedJob.html +++ b/Mosquito/QueuedJob.html @@ -365,8 +365,8 @@

    Instance methods inherited from class M executed?, - - fail(reason = "") + + fail(reason = "", *, retry : Bool = true) fail, @@ -420,6 +420,16 @@

    Instance methods inherited from class M run, + + should_retry : Bool + should_retry, + + + + should_retry=(should_retry : Bool) + should_retry=, + + state : Mosquito::Job::State state, diff --git a/Mosquito/ScheduledJob.html b/Mosquito/ScheduledJob.html index 83a41b01..7f094c56 100644 --- a/Mosquito/ScheduledJob.html +++ b/Mosquito/ScheduledJob.html @@ -379,8 +379,8 @@

    Instance methods inherited from class M executed?, - - fail(reason = "") + + fail(reason = "", *, retry : Bool = true) fail, @@ -434,6 +434,16 @@

    Instance methods inherited from class M run, + + should_retry : Bool + should_retry, + + + + should_retry=(should_retry : Bool) + should_retry=, + + state : Mosquito::Job::State state, diff --git a/index.json b/index.json index 38ea2b10..e6d97984 100644 --- a/index.json +++ b/index.json @@ -1 +1 @@ -{"repository_name":"mosquito","body":"\"mosquito\"\n\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mosquito-cr/mosquito/ci.yml?branch=master&style=for-the-badge)\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.\n\nMosquito currently provides these features:\n- Delayed execution\n- Scheduled / Periodic execution\n- Job Storage in Redis\n- Automatic rescheduling of failed jobs\n- Progressively increasing delay of 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/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/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\"}"}],"subclasses":[{"html_id":"mosquito/Mosquito/RedisBackend","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend"}],"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":9,"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":5,"url":null},"def":{"name":"named","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"new(name)"}}],"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":19,"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":13,"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":"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":55,"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":65,"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":67,"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":73,"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":73,"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":73,"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":73,"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":64,"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":59,"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":68,"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":70,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"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":51,"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":66,"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":77,"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":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":71,"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":47,"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":69,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}}],"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":23,"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":29,"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":30,"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":31,"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":38,"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":33,"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":36,"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":35,"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":26,"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":27,"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":40,"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":25,"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":34,"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":24,"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":"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":176,"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":180,"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":56,"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":44,"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":99,"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":95,"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=\"\")-instance-method","name":"fail","doc":"To be called from inside a #perform\nMarks this job as a failure. 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":""}],"args_string":"(reason = \"\")","args_html":"(reason = "")","location":{"filename":"src/mosquito/job.cr","line_number":140,"url":null},"def":{"name":"fail","args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""}],"visibility":"Public","body":"raise(JobFailed.new(reason))"}},{"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":170,"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":132,"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":162,"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":154,"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":147,"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":103,"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":70,"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":"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":119,"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":107,"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":49,"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":6,"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.","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":10,"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":"[]=","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":25,"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":"[]?","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":21,"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","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":40,"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:Nil-instance-method","name":"delete","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":13,"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","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":35,"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","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":30,"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":45,"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":45,"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":8,"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":7,"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":7,"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","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":17,"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":45,"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":45,"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":7,"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","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":23,"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:Time-instance-method","name":"last_executed_at","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":5,"url":null},"def":{"name":"last_executed_at","return_type":"Time","visibility":"Public","body":"@last_executed_at"}},{"html_id":"last_executed_at=(last_executed_at:Time)-instance-method","name":"last_executed_at=","abstract":false,"args":[{"name":"last_executed_at","external_name":"last_executed_at","restriction":"Time"}],"args_string":"(last_executed_at : Time)","args_html":"(last_executed_at : Time)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":5,"url":null},"def":{"name":"last_executed_at=","args":[{"name":"last_executed_at","external_name":"last_executed_at","restriction":"Time"}],"visibility":"Public","body":"@last_executed_at = last_executed_at"}},{"html_id":"try_to_execute:Bool-instance-method","name":"try_to_execute","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":11,"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 @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,"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":82,"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":138,"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":124,"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":100,"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":116,"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":92,"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":96,"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":"backend.schedule(job_run, execute_time)"}},{"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":88,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"backend.enqueue(job_run)"}},{"html_id":"flush-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":142,"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":120,"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":134,"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":111,"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":129,"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":137,"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":144,"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":130,"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":"QUEUES","name":"QUEUES","value":"[\"waiting\", \"scheduled\", \"pending\", \"dead\"] of ::String"}],"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":90,"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":94,"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":102,"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":123,"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":149,"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":106,"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":119,"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":115,"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":127,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"search_queue_prefixes = QUEUES.first(2)\nsearch_queue_prefixes.map do |search_queue|\n key = build_key(search_queue, \"*\")\n long_names = redis.keys(key)\n queue_prefix = (build_key(search_queue)) + \":\"\n long_names.map(&.to_s).map do |long_name|\n long_name.sub(queue_prefix, \"\")\n end\nend.flatten.uniq\n"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":141,"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":153,"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":54,"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":38,"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":82,"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":110,"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":78,"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)-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)","args_html":"(key : String, value : String)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":158,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"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":68,"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":"dead_q-instance-method","name":"dead_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"dead_q","visibility":"Public","body":"build_key(\"dead\", name)"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":184,"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":167,"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":219,"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":219,"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":219,"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":219,"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":179,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"redis.lpush(waiting_q, job_run.id)\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":190,"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":198,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.del(waiting_q, pending_q, scheduled_q, dead_q)"}},{"html_id":"pending_q-instance-method","name":"pending_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"pending_q","visibility":"Public","body":"build_key(\"pending\", name)"}},{"html_id":"redis-instance-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":64,"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":162,"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":236,"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":"scheduled_q-instance-method","name":"scheduled_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"scheduled_q","visibility":"Public","body":"build_key(\"scheduled\", name)"}},{"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":207,"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":194,"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":"waiting_q-instance-method","name":"waiting_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"waiting_q","visibility":"Public","body":"build_key(\"waiting\", name)"}}]},{"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":4,"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"},"class_methods":[{"html_id":"keep_running:Bool-class-method","name":"keep_running","doc":"Should mosquito continue working?","summary":"

    Should mosquito continue working?

    ","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":8,"url":null},"def":{"name":"keep_running","return_type":"Bool","visibility":"Public","body":"@@keep_running"}},{"html_id":"keep_running=(keep_running:Bool)-class-method","name":"keep_running=","doc":"Should mosquito continue working?","summary":"

    Should mosquito continue working?

    ","abstract":false,"args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"args_string":"(keep_running : Bool)","args_html":"(keep_running : Bool)","location":{"filename":"src/mosquito/runner.cr","line_number":8,"url":null},"def":{"name":"keep_running=","args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"visibility":"Public","body":"@@keep_running = keep_running"}},{"html_id":"start(spin=true)-class-method","name":"start","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":10,"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-class-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":19,"url":null},"def":{"name":"stop","visibility":"Public","body":"Log.notice do\n \"Mosquito is shutting down...\"\nend\nself.keep_running = false\ninstance.stop\n"}}],"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":29,"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":"run-instance-method","name":"run","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":34,"url":null},"def":{"name":"run","visibility":"Public","body":"spawn do\n @overseer.run\nend"}},{"html_id":"stop-instance-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":40,"url":null},"def":{"name":"stop","visibility":"Public","body":"@overseer.stop"}}]},{"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":1,"url":null},{"filename":"src/mosquito/runners/overseer.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/queue_list.cr","line_number":1,"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/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/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)"}],"included_modules":[{"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":"primer? loader?","summary":"

    primer? loader?

    ","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":13,"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":"bloop-instance-method","name":"bloop","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":20,"url":null},"def":{"name":"bloop","visibility":"Public","body":"only_if_coordinator do\n enqueue_periodic_jobs\n enqueue_delayed_jobs\nend"}},{"html_id":"enqueue_delayed_jobs-instance-method","name":"enqueue_delayed_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":69,"url":null},"def":{"name":"enqueue_delayed_jobs","visibility":"Public","body":"run_at_most(every: 1.second, label: :enqueue_delayed_job_runs) do |t|\n 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\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":57,"url":null},"def":{"name":"enqueue_periodic_jobs","visibility":"Public","body":"run_at_most(every: 1.second, label: :enqueue_periodic_job_runs) do |now|\n Base.scheduled_job_runs.each do |scheduled_job_run|\n enqueued = scheduled_job_run.try_to_execute\n (Log.for(\"enqueue_periodic_jobs\")).debug do\n if enqueued\n \"enqueued #{scheduled_job_run.class}\"\n end\n end\n end\nend"}},{"html_id":"instance_id:String-instance-method","name":"instance_id","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":10,"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":9,"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":27,"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 duration = Time.measure do\n yield\n end\n Mosquito.backend.unlock(lock_key, instance_id)\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":11,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}}]},{"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/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":8,"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/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":"An Executor is responsible for building Job classes with deserialized\nparameters and calling #run on them. It measures the time it takes to\nrun a job and provides detailed log messages about the current status.\n\nExecutor#deqeue_and_run_jobs is the entrypoint and shoud be treated as\nif it will return only after a relative eternity.","summary":"

    An Executor is responsible for building Job classes with deserialized parameters and calling #run on them.

    ","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/executor.cr","line_number":21,"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":"dequeue_and_run_jobs-instance-method","name":"dequeue_and_run_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":24,"url":null},"def":{"name":"dequeue_and_run_jobs","visibility":"Public","body":"queue_list.each do |q|\n run_next_job(q)\nend"}},{"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":17,"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":17,"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":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":19,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"run_next_job(q:Queue)-instance-method","name":"run_next_job","abstract":false,"args":[{"name":"q","external_name":"q","restriction":"Queue"}],"args_string":"(q : Queue)","args_html":"(q : Queue)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":30,"url":null},"def":{"name":"run_next_job","args":[{"name":"q","external_name":"q","restriction":"Queue"}],"visibility":"Public","body":"job_run = q.dequeue\nif job_run\nelse\n return\nend\nLog.notice 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.notice 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 else\n q.banish(job_run)\n job_run.delete(in: failed_job_ttl)\n message << \"cannot be rescheduled\".colorize.yellow\n end\n Log.warn do\n message.to_s\n end\nend\n"}},{"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":14,"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":14,"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":"time_with_units(seconds:Float64)-instance-method","name":"time_with_units","abstract":false,"args":[{"name":"seconds","external_name":"seconds","restriction":"Float64"}],"args_string":"(seconds : Float64)","args_html":"(seconds : Float64)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":74,"url":null},"def":{"name":"time_with_units","args":[{"name":"seconds","external_name":"seconds","restriction":"Float64"}],"visibility":"Public","body":"if seconds > 0.1\n \"#{((seconds) * 100).trunc / 100}s\".colorize.red\nelse\n if seconds > 0.001\n \"#{(seconds * 1000).trunc}ms\".colorize.yellow\n else\n if seconds > 0.000001\n \"#{(seconds * 100000).trunc}µs\".colorize.green\n else\n if seconds > 0.000000001\n \"#{(seconds * 1000000000).trunc}ns\".colorize.green\n else\n \"no discernible time at all\".colorize.green\n end\n end\n end\nend"}}]},{"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/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/overseer.cr","line_number":9,"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/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":23,"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":"coordinator:Mosquito::Runners::Coordinator-instance-method","name":"coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"coordinator","visibility":"Public","body":"@coordinator"}},{"html_id":"executor:Mosquito::Runners::Executor-instance-method","name":"executor","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"executor","visibility":"Public","body":"@executor"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","doc":"Minimum time in seconds to wait between checking for jobs.","summary":"

    Minimum time in seconds to wait between checking for jobs.

    ","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":15,"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":"idle_wait=(idle_wait:Time::Span)-instance-method","name":"idle_wait=","doc":"Minimum time in seconds to wait between checking for jobs.","summary":"

    Minimum time in seconds to wait between checking for jobs.

    ","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/overseer.cr","line_number":15,"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":"keep_running:Bool-instance-method","name":"keep_running","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":19,"url":null},"def":{"name":"keep_running","return_type":"Bool","visibility":"Public","body":"@keep_running"}},{"html_id":"keep_running=(keep_running:Bool)-instance-method","name":"keep_running=","abstract":false,"args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"args_string":"(keep_running : Bool)","args_html":"(keep_running : Bool)","location":{"filename":"src/mosquito/runners/overseer.cr","line_number":19,"url":null},"def":{"name":"keep_running=","args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"visibility":"Public","body":"@keep_running = keep_running"}},{"html_id":"queue_list:Mosquito::Runners::QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"queue_list","visibility":"Public","body":"@queue_list"}},{"html_id":"run-instance-method","name":"run","doc":"Runs the overseer workflow.\nInfinite loop.","summary":"

    Runs the overseer workflow.

    ","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":42,"url":null},"def":{"name":"run","visibility":"Public","body":"Log.info do\n worker_id + \" clocking in.\"\nend\nwhile keep_running\n tick\nend\nLog.info do\n worker_id + \" finished for now.\"\nend\n"}},{"html_id":"stop-instance-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":35,"url":null},"def":{"name":"stop","visibility":"Public","body":"Log.info do\n worker_id + \" is done after this job.\"\nend\n@keep_running = false\n"}},{"html_id":"tick-instance-method","name":"tick","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":52,"url":null},"def":{"name":"tick","visibility":"Public","body":"delta = Time.measure do\n queue_list.fetch\n coordinator.bloop\n executor.dequeue_and_run_jobs\nend\nif delta < idle_wait\n sleep(idle_wait - delta)\nend\n"}},{"html_id":"worker_id-instance-method","name":"worker_id","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":31,"url":null},"def":{"name":"worker_id","visibility":"Public","body":"\"Worker [#{coordinator.instance_id}]\""}}]},{"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/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":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"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":6,"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":10,"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.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":10,"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.each(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"fetch-instance-method","name":"fetch","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":12,"url":null},"def":{"name":"fetch","visibility":"Public","body":"run_at_most(every: 0.25.seconds, label: :fetch_queues) do |t|\n candidate_queues = Mosquito.backend.list_queues.map do |name|\n Queue.new(name)\n end\n @queues = filter_queues(candidate_queues)\n (Log.for(\"fetch_queues\")).debug do\n if @queues.size > 0\n \"found #{@queues.size} queues: #{@queues.map(&.name).join(\", \")}\"\n end\n end\nend"}}]},{"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/Coordinator","kind":"class","full_name":"Mosquito::Runners::Coordinator","name":"Coordinator"},{"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"}}]}]}]}]}} \ No newline at end of file +{"repository_name":"mosquito","body":"\"mosquito\"\n\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mosquito-cr/mosquito/ci.yml?branch=master&style=for-the-badge)\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.\n\nMosquito currently provides these features:\n- Delayed execution\n- Scheduled / Periodic execution\n- Job Storage in Redis\n- Automatic rescheduling of failed jobs\n- Progressively increasing delay of 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/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/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\"}"}],"subclasses":[{"html_id":"mosquito/Mosquito/RedisBackend","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend"}],"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":9,"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":5,"url":null},"def":{"name":"named","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"new(name)"}}],"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":19,"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":13,"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":"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":55,"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":65,"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":67,"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":73,"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":73,"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":73,"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":73,"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":64,"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":59,"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":68,"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":70,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"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":51,"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":66,"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":77,"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":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":71,"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":47,"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":69,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}}],"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":23,"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":29,"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":30,"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":31,"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":38,"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":33,"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":36,"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":35,"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":26,"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":27,"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":40,"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":25,"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":34,"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":24,"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":"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":6,"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.","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":10,"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":"[]=","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":25,"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":"[]?","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":21,"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","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":40,"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:Nil-instance-method","name":"delete","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":13,"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","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":35,"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","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":30,"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":45,"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":45,"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":8,"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":7,"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":7,"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","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":17,"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":45,"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":45,"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":7,"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","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":23,"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:Time-instance-method","name":"last_executed_at","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":5,"url":null},"def":{"name":"last_executed_at","return_type":"Time","visibility":"Public","body":"@last_executed_at"}},{"html_id":"last_executed_at=(last_executed_at:Time)-instance-method","name":"last_executed_at=","abstract":false,"args":[{"name":"last_executed_at","external_name":"last_executed_at","restriction":"Time"}],"args_string":"(last_executed_at : Time)","args_html":"(last_executed_at : Time)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":5,"url":null},"def":{"name":"last_executed_at=","args":[{"name":"last_executed_at","external_name":"last_executed_at","restriction":"Time"}],"visibility":"Public","body":"@last_executed_at = last_executed_at"}},{"html_id":"try_to_execute:Bool-instance-method","name":"try_to_execute","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":11,"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 @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,"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":82,"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":138,"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":124,"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":100,"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":116,"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":92,"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":96,"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":"backend.schedule(job_run, execute_time)"}},{"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":88,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"backend.enqueue(job_run)"}},{"html_id":"flush-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":142,"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":120,"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":134,"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":111,"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":129,"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":137,"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":144,"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":130,"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":"QUEUES","name":"QUEUES","value":"[\"waiting\", \"scheduled\", \"pending\", \"dead\"] of ::String"}],"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":90,"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":94,"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":102,"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":123,"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":149,"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":106,"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":119,"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":115,"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":127,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"search_queue_prefixes = QUEUES.first(2)\nsearch_queue_prefixes.map do |search_queue|\n key = build_key(search_queue, \"*\")\n long_names = redis.keys(key)\n queue_prefix = (build_key(search_queue)) + \":\"\n long_names.map(&.to_s).map do |long_name|\n long_name.sub(queue_prefix, \"\")\n end\nend.flatten.uniq\n"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":141,"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":153,"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":54,"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":38,"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":82,"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":110,"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":78,"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)-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)","args_html":"(key : String, value : String)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":158,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"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":68,"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":"dead_q-instance-method","name":"dead_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"dead_q","visibility":"Public","body":"build_key(\"dead\", name)"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":184,"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":167,"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":219,"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":219,"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":219,"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":219,"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":179,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"redis.lpush(waiting_q, job_run.id)\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":190,"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":198,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.del(waiting_q, pending_q, scheduled_q, dead_q)"}},{"html_id":"pending_q-instance-method","name":"pending_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"pending_q","visibility":"Public","body":"build_key(\"pending\", name)"}},{"html_id":"redis-instance-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":64,"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":162,"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":236,"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":"scheduled_q-instance-method","name":"scheduled_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"scheduled_q","visibility":"Public","body":"build_key(\"scheduled\", name)"}},{"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":207,"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":194,"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":"waiting_q-instance-method","name":"waiting_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"waiting_q","visibility":"Public","body":"build_key(\"waiting\", name)"}}]},{"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":4,"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"},"class_methods":[{"html_id":"keep_running:Bool-class-method","name":"keep_running","doc":"Should mosquito continue working?","summary":"

    Should mosquito continue working?

    ","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":8,"url":null},"def":{"name":"keep_running","return_type":"Bool","visibility":"Public","body":"@@keep_running"}},{"html_id":"keep_running=(keep_running:Bool)-class-method","name":"keep_running=","doc":"Should mosquito continue working?","summary":"

    Should mosquito continue working?

    ","abstract":false,"args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"args_string":"(keep_running : Bool)","args_html":"(keep_running : Bool)","location":{"filename":"src/mosquito/runner.cr","line_number":8,"url":null},"def":{"name":"keep_running=","args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"visibility":"Public","body":"@@keep_running = keep_running"}},{"html_id":"start(spin=true)-class-method","name":"start","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":10,"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-class-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":19,"url":null},"def":{"name":"stop","visibility":"Public","body":"Log.notice do\n \"Mosquito is shutting down...\"\nend\nself.keep_running = false\ninstance.stop\n"}}],"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":29,"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":"run-instance-method","name":"run","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":34,"url":null},"def":{"name":"run","visibility":"Public","body":"spawn do\n @overseer.run\nend"}},{"html_id":"stop-instance-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":40,"url":null},"def":{"name":"stop","visibility":"Public","body":"@overseer.stop"}}]},{"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":1,"url":null},{"filename":"src/mosquito/runners/overseer.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/queue_list.cr","line_number":1,"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/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/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)"}],"included_modules":[{"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":"primer? loader?","summary":"

    primer? loader?

    ","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":13,"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":"bloop-instance-method","name":"bloop","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":20,"url":null},"def":{"name":"bloop","visibility":"Public","body":"only_if_coordinator do\n enqueue_periodic_jobs\n enqueue_delayed_jobs\nend"}},{"html_id":"enqueue_delayed_jobs-instance-method","name":"enqueue_delayed_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":69,"url":null},"def":{"name":"enqueue_delayed_jobs","visibility":"Public","body":"run_at_most(every: 1.second, label: :enqueue_delayed_job_runs) do |t|\n 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\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":57,"url":null},"def":{"name":"enqueue_periodic_jobs","visibility":"Public","body":"run_at_most(every: 1.second, label: :enqueue_periodic_job_runs) do |now|\n Base.scheduled_job_runs.each do |scheduled_job_run|\n enqueued = scheduled_job_run.try_to_execute\n (Log.for(\"enqueue_periodic_jobs\")).debug do\n if enqueued\n \"enqueued #{scheduled_job_run.class}\"\n end\n end\n end\nend"}},{"html_id":"instance_id:String-instance-method","name":"instance_id","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":10,"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":9,"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":27,"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 duration = Time.measure do\n yield\n end\n Mosquito.backend.unlock(lock_key, instance_id)\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":11,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}}]},{"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/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":8,"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/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":"An Executor is responsible for building Job classes with deserialized\nparameters and calling #run on them. It measures the time it takes to\nrun a job and provides detailed log messages about the current status.\n\nExecutor#deqeue_and_run_jobs is the entrypoint and shoud be treated as\nif it will return only after a relative eternity.","summary":"

    An Executor is responsible for building Job classes with deserialized parameters and calling #run on them.

    ","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/executor.cr","line_number":21,"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":"dequeue_and_run_jobs-instance-method","name":"dequeue_and_run_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":24,"url":null},"def":{"name":"dequeue_and_run_jobs","visibility":"Public","body":"queue_list.each do |q|\n run_next_job(q)\nend"}},{"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":17,"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":17,"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":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":19,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"run_next_job(q:Queue)-instance-method","name":"run_next_job","abstract":false,"args":[{"name":"q","external_name":"q","restriction":"Queue"}],"args_string":"(q : Queue)","args_html":"(q : Queue)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":30,"url":null},"def":{"name":"run_next_job","args":[{"name":"q","external_name":"q","restriction":"Queue"}],"visibility":"Public","body":"job_run = q.dequeue\nif job_run\nelse\n return\nend\nLog.notice 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.notice 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 else\n q.banish(job_run)\n job_run.delete(in: failed_job_ttl)\n message << \"cannot be rescheduled\".colorize.yellow\n end\n Log.warn do\n message.to_s\n end\nend\n"}},{"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":14,"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":14,"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":"time_with_units(seconds:Float64)-instance-method","name":"time_with_units","abstract":false,"args":[{"name":"seconds","external_name":"seconds","restriction":"Float64"}],"args_string":"(seconds : Float64)","args_html":"(seconds : Float64)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":74,"url":null},"def":{"name":"time_with_units","args":[{"name":"seconds","external_name":"seconds","restriction":"Float64"}],"visibility":"Public","body":"if seconds > 0.1\n \"#{((seconds) * 100).trunc / 100}s\".colorize.red\nelse\n if seconds > 0.001\n \"#{(seconds * 1000).trunc}ms\".colorize.yellow\n else\n if seconds > 0.000001\n \"#{(seconds * 100000).trunc}µs\".colorize.green\n else\n if seconds > 0.000000001\n \"#{(seconds * 1000000000).trunc}ns\".colorize.green\n else\n \"no discernible time at all\".colorize.green\n end\n end\n end\nend"}}]},{"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/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/overseer.cr","line_number":9,"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/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":23,"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":"coordinator:Mosquito::Runners::Coordinator-instance-method","name":"coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"coordinator","visibility":"Public","body":"@coordinator"}},{"html_id":"executor:Mosquito::Runners::Executor-instance-method","name":"executor","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"executor","visibility":"Public","body":"@executor"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","doc":"Minimum time in seconds to wait between checking for jobs.","summary":"

    Minimum time in seconds to wait between checking for jobs.

    ","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":15,"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":"idle_wait=(idle_wait:Time::Span)-instance-method","name":"idle_wait=","doc":"Minimum time in seconds to wait between checking for jobs.","summary":"

    Minimum time in seconds to wait between checking for jobs.

    ","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/overseer.cr","line_number":15,"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":"keep_running:Bool-instance-method","name":"keep_running","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":19,"url":null},"def":{"name":"keep_running","return_type":"Bool","visibility":"Public","body":"@keep_running"}},{"html_id":"keep_running=(keep_running:Bool)-instance-method","name":"keep_running=","abstract":false,"args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"args_string":"(keep_running : Bool)","args_html":"(keep_running : Bool)","location":{"filename":"src/mosquito/runners/overseer.cr","line_number":19,"url":null},"def":{"name":"keep_running=","args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"visibility":"Public","body":"@keep_running = keep_running"}},{"html_id":"queue_list:Mosquito::Runners::QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"queue_list","visibility":"Public","body":"@queue_list"}},{"html_id":"run-instance-method","name":"run","doc":"Runs the overseer workflow.\nInfinite loop.","summary":"

    Runs the overseer workflow.

    ","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":42,"url":null},"def":{"name":"run","visibility":"Public","body":"Log.info do\n worker_id + \" clocking in.\"\nend\nwhile keep_running\n tick\nend\nLog.info do\n worker_id + \" finished for now.\"\nend\n"}},{"html_id":"stop-instance-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":35,"url":null},"def":{"name":"stop","visibility":"Public","body":"Log.info do\n worker_id + \" is done after this job.\"\nend\n@keep_running = false\n"}},{"html_id":"tick-instance-method","name":"tick","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":52,"url":null},"def":{"name":"tick","visibility":"Public","body":"delta = Time.measure do\n queue_list.fetch\n coordinator.bloop\n executor.dequeue_and_run_jobs\nend\nif delta < idle_wait\n sleep(idle_wait - delta)\nend\n"}},{"html_id":"worker_id-instance-method","name":"worker_id","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":31,"url":null},"def":{"name":"worker_id","visibility":"Public","body":"\"Worker [#{coordinator.instance_id}]\""}}]},{"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/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":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"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":6,"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":10,"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.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":10,"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.each(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"fetch-instance-method","name":"fetch","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":12,"url":null},"def":{"name":"fetch","visibility":"Public","body":"run_at_most(every: 0.25.seconds, label: :fetch_queues) do |t|\n candidate_queues = Mosquito.backend.list_queues.map do |name|\n Queue.new(name)\n end\n @queues = filter_queues(candidate_queues)\n (Log.for(\"fetch_queues\")).debug do\n if @queues.size > 0\n \"found #{@queues.size} queues: #{@queues.map(&.name).join(\", \")}\"\n end\n end\nend"}}]},{"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/Coordinator","kind":"class","full_name":"Mosquito::Runners::Coordinator","name":"Coordinator"},{"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"}}]}]}]}]}} \ No newline at end of file diff --git a/search-index.js b/search-index.js index 07381bf7..9b622691 100644 --- a/search-index.js +++ b/search-index.js @@ -1 +1 @@ -crystal_doc_search_index_callback({"repository_name":"mosquito","body":"\"mosquito\"\n\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mosquito-cr/mosquito/ci.yml?branch=master&style=for-the-badge)\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.\n\nMosquito currently provides these features:\n- Delayed execution\n- Scheduled / Periodic execution\n- Job Storage in Redis\n- Automatic rescheduling of failed jobs\n- Progressively increasing delay of 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/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/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\"}"}],"subclasses":[{"html_id":"mosquito/Mosquito/RedisBackend","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend"}],"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":9,"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":5,"url":null},"def":{"name":"named","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"new(name)"}}],"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":19,"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":13,"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":"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":55,"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":65,"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":67,"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":73,"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":73,"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":73,"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":73,"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":64,"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":59,"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":68,"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":70,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"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":51,"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":66,"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":77,"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":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":71,"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":47,"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":69,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}}],"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":23,"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":29,"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":30,"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":31,"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":38,"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":33,"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":36,"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":35,"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":26,"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":27,"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":40,"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":25,"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":34,"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":24,"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":"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":176,"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":180,"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":56,"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":44,"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":99,"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":95,"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=\"\")-instance-method","name":"fail","doc":"To be called from inside a #perform\nMarks this job as a failure. 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":""}],"args_string":"(reason = \"\")","args_html":"(reason = "")","location":{"filename":"src/mosquito/job.cr","line_number":140,"url":null},"def":{"name":"fail","args":[{"name":"reason","default_value":"\"\"","external_name":"reason","restriction":""}],"visibility":"Public","body":"raise(JobFailed.new(reason))"}},{"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":170,"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":132,"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":162,"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":154,"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":147,"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":103,"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":70,"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":"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":119,"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":107,"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":49,"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":6,"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.","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":10,"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":"[]=","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":25,"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":"[]?","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":21,"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","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":40,"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:Nil-instance-method","name":"delete","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":13,"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","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":35,"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","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":30,"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":45,"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":45,"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":8,"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":7,"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":7,"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","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":17,"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":45,"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":45,"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":7,"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","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":23,"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:Time-instance-method","name":"last_executed_at","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":5,"url":null},"def":{"name":"last_executed_at","return_type":"Time","visibility":"Public","body":"@last_executed_at"}},{"html_id":"last_executed_at=(last_executed_at:Time)-instance-method","name":"last_executed_at=","abstract":false,"args":[{"name":"last_executed_at","external_name":"last_executed_at","restriction":"Time"}],"args_string":"(last_executed_at : Time)","args_html":"(last_executed_at : Time)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":5,"url":null},"def":{"name":"last_executed_at=","args":[{"name":"last_executed_at","external_name":"last_executed_at","restriction":"Time"}],"visibility":"Public","body":"@last_executed_at = last_executed_at"}},{"html_id":"try_to_execute:Bool-instance-method","name":"try_to_execute","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":11,"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 @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,"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":82,"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":138,"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":124,"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":100,"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":116,"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":92,"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":96,"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":"backend.schedule(job_run, execute_time)"}},{"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":88,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"backend.enqueue(job_run)"}},{"html_id":"flush-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":142,"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":120,"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":134,"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":111,"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":129,"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":137,"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":144,"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":130,"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":"QUEUES","name":"QUEUES","value":"[\"waiting\", \"scheduled\", \"pending\", \"dead\"] of ::String"}],"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":90,"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":94,"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":102,"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":123,"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":149,"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":106,"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":119,"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":115,"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":127,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"search_queue_prefixes = QUEUES.first(2)\nsearch_queue_prefixes.map do |search_queue|\n key = build_key(search_queue, \"*\")\n long_names = redis.keys(key)\n queue_prefix = (build_key(search_queue)) + \":\"\n long_names.map(&.to_s).map do |long_name|\n long_name.sub(queue_prefix, \"\")\n end\nend.flatten.uniq\n"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":141,"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":153,"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":54,"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":38,"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":82,"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":110,"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":78,"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)-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)","args_html":"(key : String, value : String)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":158,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"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":68,"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":"dead_q-instance-method","name":"dead_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"dead_q","visibility":"Public","body":"build_key(\"dead\", name)"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":184,"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":167,"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":219,"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":219,"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":219,"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":219,"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":179,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"redis.lpush(waiting_q, job_run.id)\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":190,"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":198,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.del(waiting_q, pending_q, scheduled_q, dead_q)"}},{"html_id":"pending_q-instance-method","name":"pending_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"pending_q","visibility":"Public","body":"build_key(\"pending\", name)"}},{"html_id":"redis-instance-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":64,"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":162,"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":236,"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":"scheduled_q-instance-method","name":"scheduled_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"scheduled_q","visibility":"Public","body":"build_key(\"scheduled\", name)"}},{"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":207,"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":194,"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":"waiting_q-instance-method","name":"waiting_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"waiting_q","visibility":"Public","body":"build_key(\"waiting\", name)"}}]},{"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":4,"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"},"class_methods":[{"html_id":"keep_running:Bool-class-method","name":"keep_running","doc":"Should mosquito continue working?","summary":"

    Should mosquito continue working?

    ","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":8,"url":null},"def":{"name":"keep_running","return_type":"Bool","visibility":"Public","body":"@@keep_running"}},{"html_id":"keep_running=(keep_running:Bool)-class-method","name":"keep_running=","doc":"Should mosquito continue working?","summary":"

    Should mosquito continue working?

    ","abstract":false,"args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"args_string":"(keep_running : Bool)","args_html":"(keep_running : Bool)","location":{"filename":"src/mosquito/runner.cr","line_number":8,"url":null},"def":{"name":"keep_running=","args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"visibility":"Public","body":"@@keep_running = keep_running"}},{"html_id":"start(spin=true)-class-method","name":"start","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":10,"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-class-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":19,"url":null},"def":{"name":"stop","visibility":"Public","body":"Log.notice do\n \"Mosquito is shutting down...\"\nend\nself.keep_running = false\ninstance.stop\n"}}],"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":29,"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":"run-instance-method","name":"run","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":34,"url":null},"def":{"name":"run","visibility":"Public","body":"spawn do\n @overseer.run\nend"}},{"html_id":"stop-instance-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":40,"url":null},"def":{"name":"stop","visibility":"Public","body":"@overseer.stop"}}]},{"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":1,"url":null},{"filename":"src/mosquito/runners/overseer.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/queue_list.cr","line_number":1,"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/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/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)"}],"included_modules":[{"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":"primer? loader?","summary":"

    primer? loader?

    ","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":13,"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":"bloop-instance-method","name":"bloop","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":20,"url":null},"def":{"name":"bloop","visibility":"Public","body":"only_if_coordinator do\n enqueue_periodic_jobs\n enqueue_delayed_jobs\nend"}},{"html_id":"enqueue_delayed_jobs-instance-method","name":"enqueue_delayed_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":69,"url":null},"def":{"name":"enqueue_delayed_jobs","visibility":"Public","body":"run_at_most(every: 1.second, label: :enqueue_delayed_job_runs) do |t|\n 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\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":57,"url":null},"def":{"name":"enqueue_periodic_jobs","visibility":"Public","body":"run_at_most(every: 1.second, label: :enqueue_periodic_job_runs) do |now|\n Base.scheduled_job_runs.each do |scheduled_job_run|\n enqueued = scheduled_job_run.try_to_execute\n (Log.for(\"enqueue_periodic_jobs\")).debug do\n if enqueued\n \"enqueued #{scheduled_job_run.class}\"\n end\n end\n end\nend"}},{"html_id":"instance_id:String-instance-method","name":"instance_id","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":10,"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":9,"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":27,"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 duration = Time.measure do\n yield\n end\n Mosquito.backend.unlock(lock_key, instance_id)\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":11,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}}]},{"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/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":8,"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/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":"An Executor is responsible for building Job classes with deserialized\nparameters and calling #run on them. It measures the time it takes to\nrun a job and provides detailed log messages about the current status.\n\nExecutor#deqeue_and_run_jobs is the entrypoint and shoud be treated as\nif it will return only after a relative eternity.","summary":"

    An Executor is responsible for building Job classes with deserialized parameters and calling #run on them.

    ","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/executor.cr","line_number":21,"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":"dequeue_and_run_jobs-instance-method","name":"dequeue_and_run_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":24,"url":null},"def":{"name":"dequeue_and_run_jobs","visibility":"Public","body":"queue_list.each do |q|\n run_next_job(q)\nend"}},{"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":17,"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":17,"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":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":19,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"run_next_job(q:Queue)-instance-method","name":"run_next_job","abstract":false,"args":[{"name":"q","external_name":"q","restriction":"Queue"}],"args_string":"(q : Queue)","args_html":"(q : Queue)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":30,"url":null},"def":{"name":"run_next_job","args":[{"name":"q","external_name":"q","restriction":"Queue"}],"visibility":"Public","body":"job_run = q.dequeue\nif job_run\nelse\n return\nend\nLog.notice 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.notice 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 else\n q.banish(job_run)\n job_run.delete(in: failed_job_ttl)\n message << \"cannot be rescheduled\".colorize.yellow\n end\n Log.warn do\n message.to_s\n end\nend\n"}},{"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":14,"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":14,"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":"time_with_units(seconds:Float64)-instance-method","name":"time_with_units","abstract":false,"args":[{"name":"seconds","external_name":"seconds","restriction":"Float64"}],"args_string":"(seconds : Float64)","args_html":"(seconds : Float64)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":74,"url":null},"def":{"name":"time_with_units","args":[{"name":"seconds","external_name":"seconds","restriction":"Float64"}],"visibility":"Public","body":"if seconds > 0.1\n \"#{((seconds) * 100).trunc / 100}s\".colorize.red\nelse\n if seconds > 0.001\n \"#{(seconds * 1000).trunc}ms\".colorize.yellow\n else\n if seconds > 0.000001\n \"#{(seconds * 100000).trunc}µs\".colorize.green\n else\n if seconds > 0.000000001\n \"#{(seconds * 1000000000).trunc}ns\".colorize.green\n else\n \"no discernible time at all\".colorize.green\n end\n end\n end\nend"}}]},{"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/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/overseer.cr","line_number":9,"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/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":23,"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":"coordinator:Mosquito::Runners::Coordinator-instance-method","name":"coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"coordinator","visibility":"Public","body":"@coordinator"}},{"html_id":"executor:Mosquito::Runners::Executor-instance-method","name":"executor","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"executor","visibility":"Public","body":"@executor"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","doc":"Minimum time in seconds to wait between checking for jobs.","summary":"

    Minimum time in seconds to wait between checking for jobs.

    ","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":15,"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":"idle_wait=(idle_wait:Time::Span)-instance-method","name":"idle_wait=","doc":"Minimum time in seconds to wait between checking for jobs.","summary":"

    Minimum time in seconds to wait between checking for jobs.

    ","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/overseer.cr","line_number":15,"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":"keep_running:Bool-instance-method","name":"keep_running","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":19,"url":null},"def":{"name":"keep_running","return_type":"Bool","visibility":"Public","body":"@keep_running"}},{"html_id":"keep_running=(keep_running:Bool)-instance-method","name":"keep_running=","abstract":false,"args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"args_string":"(keep_running : Bool)","args_html":"(keep_running : Bool)","location":{"filename":"src/mosquito/runners/overseer.cr","line_number":19,"url":null},"def":{"name":"keep_running=","args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"visibility":"Public","body":"@keep_running = keep_running"}},{"html_id":"queue_list:Mosquito::Runners::QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"queue_list","visibility":"Public","body":"@queue_list"}},{"html_id":"run-instance-method","name":"run","doc":"Runs the overseer workflow.\nInfinite loop.","summary":"

    Runs the overseer workflow.

    ","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":42,"url":null},"def":{"name":"run","visibility":"Public","body":"Log.info do\n worker_id + \" clocking in.\"\nend\nwhile keep_running\n tick\nend\nLog.info do\n worker_id + \" finished for now.\"\nend\n"}},{"html_id":"stop-instance-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":35,"url":null},"def":{"name":"stop","visibility":"Public","body":"Log.info do\n worker_id + \" is done after this job.\"\nend\n@keep_running = false\n"}},{"html_id":"tick-instance-method","name":"tick","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":52,"url":null},"def":{"name":"tick","visibility":"Public","body":"delta = Time.measure do\n queue_list.fetch\n coordinator.bloop\n executor.dequeue_and_run_jobs\nend\nif delta < idle_wait\n sleep(idle_wait - delta)\nend\n"}},{"html_id":"worker_id-instance-method","name":"worker_id","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":31,"url":null},"def":{"name":"worker_id","visibility":"Public","body":"\"Worker [#{coordinator.instance_id}]\""}}]},{"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/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":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"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":6,"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":10,"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.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":10,"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.each(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"fetch-instance-method","name":"fetch","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":12,"url":null},"def":{"name":"fetch","visibility":"Public","body":"run_at_most(every: 0.25.seconds, label: :fetch_queues) do |t|\n candidate_queues = Mosquito.backend.list_queues.map do |name|\n Queue.new(name)\n end\n @queues = filter_queues(candidate_queues)\n (Log.for(\"fetch_queues\")).debug do\n if @queues.size > 0\n \"found #{@queues.size} queues: #{@queues.map(&.name).join(\", \")}\"\n end\n end\nend"}}]},{"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/Coordinator","kind":"class","full_name":"Mosquito::Runners::Coordinator","name":"Coordinator"},{"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"}}]}]}]}]}}) \ No newline at end of file +crystal_doc_search_index_callback({"repository_name":"mosquito","body":"\"mosquito\"\n\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mosquito-cr/mosquito/ci.yml?branch=master&style=for-the-badge)\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.\n\nMosquito currently provides these features:\n- Delayed execution\n- Scheduled / Periodic execution\n- Job Storage in Redis\n- Automatic rescheduling of failed jobs\n- Progressively increasing delay of 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/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/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\"}"}],"subclasses":[{"html_id":"mosquito/Mosquito/RedisBackend","kind":"class","full_name":"Mosquito::RedisBackend","name":"RedisBackend"}],"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":9,"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":5,"url":null},"def":{"name":"named","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"new(name)"}}],"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":19,"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":13,"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":"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":55,"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":65,"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":67,"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":73,"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":73,"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":73,"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":73,"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":64,"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":59,"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":68,"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":70,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":""}},{"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":51,"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":66,"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":77,"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":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":71,"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":47,"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":69,"url":null},"def":{"name":"terminate","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"visibility":"Public","body":""}}],"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":23,"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":29,"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":30,"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":31,"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":38,"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":33,"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":36,"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":35,"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":26,"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":27,"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":40,"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":25,"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":34,"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":24,"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":"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":6,"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.","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":10,"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":"[]=","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":25,"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":"[]?","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":21,"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","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":40,"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:Nil-instance-method","name":"delete","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":13,"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","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":35,"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","abstract":false,"args":[{"name":"key","external_name":"key","restriction":""}],"args_string":"(key)","args_html":"(key)","location":{"filename":"src/mosquito/metadata.cr","line_number":30,"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":45,"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":45,"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":8,"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":7,"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":7,"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","abstract":false,"location":{"filename":"src/mosquito/metadata.cr","line_number":17,"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":45,"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":45,"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":7,"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","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":23,"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:Time-instance-method","name":"last_executed_at","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":5,"url":null},"def":{"name":"last_executed_at","return_type":"Time","visibility":"Public","body":"@last_executed_at"}},{"html_id":"last_executed_at=(last_executed_at:Time)-instance-method","name":"last_executed_at=","abstract":false,"args":[{"name":"last_executed_at","external_name":"last_executed_at","restriction":"Time"}],"args_string":"(last_executed_at : Time)","args_html":"(last_executed_at : Time)","location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":5,"url":null},"def":{"name":"last_executed_at=","args":[{"name":"last_executed_at","external_name":"last_executed_at","restriction":"Time"}],"visibility":"Public","body":"@last_executed_at = last_executed_at"}},{"html_id":"try_to_execute:Bool-instance-method","name":"try_to_execute","abstract":false,"location":{"filename":"src/mosquito/periodic_job_run.cr","line_number":11,"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 @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,"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":82,"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":138,"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":124,"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":100,"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":116,"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":92,"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":96,"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":"backend.schedule(job_run, execute_time)"}},{"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":88,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"backend.enqueue(job_run)"}},{"html_id":"flush-instance-method","name":"flush","abstract":false,"location":{"filename":"src/mosquito/queue.cr","line_number":142,"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":120,"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":134,"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":111,"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":129,"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":137,"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":144,"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":130,"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":"QUEUES","name":"QUEUES","value":"[\"waiting\", \"scheduled\", \"pending\", \"dead\"] of ::String"}],"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":90,"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":94,"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":102,"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":123,"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":149,"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":106,"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":119,"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":115,"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":127,"url":null},"def":{"name":"list_queues","return_type":"Array(String)","visibility":"Public","body":"search_queue_prefixes = QUEUES.first(2)\nsearch_queue_prefixes.map do |search_queue|\n key = build_key(search_queue, \"*\")\n long_names = redis.keys(key)\n queue_prefix = (build_key(search_queue)) + \":\"\n long_names.map(&.to_s).map do |long_name|\n long_name.sub(queue_prefix, \"\")\n end\nend.flatten.uniq\n"}},{"html_id":"list_runners:Array(String)-class-method","name":"list_runners","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":141,"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":153,"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":54,"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":38,"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":82,"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":110,"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":78,"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)-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)","args_html":"(key : String, value : String)","location":{"filename":"src/mosquito/redis_backend.cr","line_number":158,"url":null},"def":{"name":"unlock","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"String"}],"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":68,"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":"dead_q-instance-method","name":"dead_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"dead_q","visibility":"Public","body":"build_key(\"dead\", name)"}},{"html_id":"dequeue:JobRun|Nil-instance-method","name":"dequeue","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":184,"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":167,"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":219,"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":219,"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":219,"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":219,"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":179,"url":null},"def":{"name":"enqueue","args":[{"name":"job_run","external_name":"job_run","restriction":"JobRun"}],"return_type":"JobRun","visibility":"Public","body":"redis.lpush(waiting_q, job_run.id)\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":190,"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":198,"url":null},"def":{"name":"flush","return_type":"Nil","visibility":"Public","body":"redis.del(waiting_q, pending_q, scheduled_q, dead_q)"}},{"html_id":"pending_q-instance-method","name":"pending_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"pending_q","visibility":"Public","body":"build_key(\"pending\", name)"}},{"html_id":"redis-instance-method","name":"redis","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":64,"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":162,"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":236,"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":"scheduled_q-instance-method","name":"scheduled_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"scheduled_q","visibility":"Public","body":"build_key(\"scheduled\", name)"}},{"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":207,"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":194,"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":"waiting_q-instance-method","name":"waiting_q","abstract":false,"location":{"filename":"src/mosquito/redis_backend.cr","line_number":72,"url":null},"def":{"name":"waiting_q","visibility":"Public","body":"build_key(\"waiting\", name)"}}]},{"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":4,"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"},"class_methods":[{"html_id":"keep_running:Bool-class-method","name":"keep_running","doc":"Should mosquito continue working?","summary":"

    Should mosquito continue working?

    ","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":8,"url":null},"def":{"name":"keep_running","return_type":"Bool","visibility":"Public","body":"@@keep_running"}},{"html_id":"keep_running=(keep_running:Bool)-class-method","name":"keep_running=","doc":"Should mosquito continue working?","summary":"

    Should mosquito continue working?

    ","abstract":false,"args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"args_string":"(keep_running : Bool)","args_html":"(keep_running : Bool)","location":{"filename":"src/mosquito/runner.cr","line_number":8,"url":null},"def":{"name":"keep_running=","args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"visibility":"Public","body":"@@keep_running = keep_running"}},{"html_id":"start(spin=true)-class-method","name":"start","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":10,"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-class-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":19,"url":null},"def":{"name":"stop","visibility":"Public","body":"Log.notice do\n \"Mosquito is shutting down...\"\nend\nself.keep_running = false\ninstance.stop\n"}}],"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":29,"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":"run-instance-method","name":"run","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":34,"url":null},"def":{"name":"run","visibility":"Public","body":"spawn do\n @overseer.run\nend"}},{"html_id":"stop-instance-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runner.cr","line_number":40,"url":null},"def":{"name":"stop","visibility":"Public","body":"@overseer.stop"}}]},{"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":1,"url":null},{"filename":"src/mosquito/runners/overseer.cr","line_number":1,"url":null},{"filename":"src/mosquito/runners/queue_list.cr","line_number":1,"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/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/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)"}],"included_modules":[{"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":"primer? loader?","summary":"

    primer? loader?

    ","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":13,"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":"bloop-instance-method","name":"bloop","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":20,"url":null},"def":{"name":"bloop","visibility":"Public","body":"only_if_coordinator do\n enqueue_periodic_jobs\n enqueue_delayed_jobs\nend"}},{"html_id":"enqueue_delayed_jobs-instance-method","name":"enqueue_delayed_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":69,"url":null},"def":{"name":"enqueue_delayed_jobs","visibility":"Public","body":"run_at_most(every: 1.second, label: :enqueue_delayed_job_runs) do |t|\n 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\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":57,"url":null},"def":{"name":"enqueue_periodic_jobs","visibility":"Public","body":"run_at_most(every: 1.second, label: :enqueue_periodic_job_runs) do |now|\n Base.scheduled_job_runs.each do |scheduled_job_run|\n enqueued = scheduled_job_run.try_to_execute\n (Log.for(\"enqueue_periodic_jobs\")).debug do\n if enqueued\n \"enqueued #{scheduled_job_run.class}\"\n end\n end\n end\nend"}},{"html_id":"instance_id:String-instance-method","name":"instance_id","abstract":false,"location":{"filename":"src/mosquito/runners/coordinator.cr","line_number":10,"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":9,"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":27,"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 duration = Time.measure do\n yield\n end\n Mosquito.backend.unlock(lock_key, instance_id)\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":11,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}}]},{"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/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":8,"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/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":"An Executor is responsible for building Job classes with deserialized\nparameters and calling #run on them. It measures the time it takes to\nrun a job and provides detailed log messages about the current status.\n\nExecutor#deqeue_and_run_jobs is the entrypoint and shoud be treated as\nif it will return only after a relative eternity.","summary":"

    An Executor is responsible for building Job classes with deserialized parameters and calling #run on them.

    ","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/executor.cr","line_number":21,"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":"dequeue_and_run_jobs-instance-method","name":"dequeue_and_run_jobs","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":24,"url":null},"def":{"name":"dequeue_and_run_jobs","visibility":"Public","body":"queue_list.each do |q|\n run_next_job(q)\nend"}},{"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":17,"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":17,"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":"queue_list:QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/executor.cr","line_number":19,"url":null},"def":{"name":"queue_list","return_type":"QueueList","visibility":"Public","body":"@queue_list"}},{"html_id":"run_next_job(q:Queue)-instance-method","name":"run_next_job","abstract":false,"args":[{"name":"q","external_name":"q","restriction":"Queue"}],"args_string":"(q : Queue)","args_html":"(q : Queue)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":30,"url":null},"def":{"name":"run_next_job","args":[{"name":"q","external_name":"q","restriction":"Queue"}],"visibility":"Public","body":"job_run = q.dequeue\nif job_run\nelse\n return\nend\nLog.notice 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.notice 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 else\n q.banish(job_run)\n job_run.delete(in: failed_job_ttl)\n message << \"cannot be rescheduled\".colorize.yellow\n end\n Log.warn do\n message.to_s\n end\nend\n"}},{"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":14,"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":14,"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":"time_with_units(seconds:Float64)-instance-method","name":"time_with_units","abstract":false,"args":[{"name":"seconds","external_name":"seconds","restriction":"Float64"}],"args_string":"(seconds : Float64)","args_html":"(seconds : Float64)","location":{"filename":"src/mosquito/runners/executor.cr","line_number":74,"url":null},"def":{"name":"time_with_units","args":[{"name":"seconds","external_name":"seconds","restriction":"Float64"}],"visibility":"Public","body":"if seconds > 0.1\n \"#{((seconds) * 100).trunc / 100}s\".colorize.red\nelse\n if seconds > 0.001\n \"#{(seconds * 1000).trunc}ms\".colorize.yellow\n else\n if seconds > 0.000001\n \"#{(seconds * 100000).trunc}µs\".colorize.green\n else\n if seconds > 0.000000001\n \"#{(seconds * 1000000000).trunc}ns\".colorize.green\n else\n \"no discernible time at all\".colorize.green\n end\n end\n end\nend"}}]},{"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/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/overseer.cr","line_number":9,"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/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":23,"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":"coordinator:Mosquito::Runners::Coordinator-instance-method","name":"coordinator","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"coordinator","visibility":"Public","body":"@coordinator"}},{"html_id":"executor:Mosquito::Runners::Executor-instance-method","name":"executor","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"executor","visibility":"Public","body":"@executor"}},{"html_id":"idle_wait:Time::Span-instance-method","name":"idle_wait","doc":"Minimum time in seconds to wait between checking for jobs.","summary":"

    Minimum time in seconds to wait between checking for jobs.

    ","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":15,"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":"idle_wait=(idle_wait:Time::Span)-instance-method","name":"idle_wait=","doc":"Minimum time in seconds to wait between checking for jobs.","summary":"

    Minimum time in seconds to wait between checking for jobs.

    ","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/overseer.cr","line_number":15,"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":"keep_running:Bool-instance-method","name":"keep_running","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":19,"url":null},"def":{"name":"keep_running","return_type":"Bool","visibility":"Public","body":"@keep_running"}},{"html_id":"keep_running=(keep_running:Bool)-instance-method","name":"keep_running=","abstract":false,"args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"args_string":"(keep_running : Bool)","args_html":"(keep_running : Bool)","location":{"filename":"src/mosquito/runners/overseer.cr","line_number":19,"url":null},"def":{"name":"keep_running=","args":[{"name":"keep_running","external_name":"keep_running","restriction":"Bool"}],"visibility":"Public","body":"@keep_running = keep_running"}},{"html_id":"queue_list:Mosquito::Runners::QueueList-instance-method","name":"queue_list","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":21,"url":null},"def":{"name":"queue_list","visibility":"Public","body":"@queue_list"}},{"html_id":"run-instance-method","name":"run","doc":"Runs the overseer workflow.\nInfinite loop.","summary":"

    Runs the overseer workflow.

    ","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":42,"url":null},"def":{"name":"run","visibility":"Public","body":"Log.info do\n worker_id + \" clocking in.\"\nend\nwhile keep_running\n tick\nend\nLog.info do\n worker_id + \" finished for now.\"\nend\n"}},{"html_id":"stop-instance-method","name":"stop","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":35,"url":null},"def":{"name":"stop","visibility":"Public","body":"Log.info do\n worker_id + \" is done after this job.\"\nend\n@keep_running = false\n"}},{"html_id":"tick-instance-method","name":"tick","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":52,"url":null},"def":{"name":"tick","visibility":"Public","body":"delta = Time.measure do\n queue_list.fetch\n coordinator.bloop\n executor.dequeue_and_run_jobs\nend\nif delta < idle_wait\n sleep(idle_wait - delta)\nend\n"}},{"html_id":"worker_id-instance-method","name":"worker_id","abstract":false,"location":{"filename":"src/mosquito/runners/overseer.cr","line_number":31,"url":null},"def":{"name":"worker_id","visibility":"Public","body":"\"Worker [#{coordinator.instance_id}]\""}}]},{"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/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":3,"url":null}],"repository_name":"mosquito","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"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":6,"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":10,"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.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":10,"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.each(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"html_id":"fetch-instance-method","name":"fetch","abstract":false,"location":{"filename":"src/mosquito/runners/queue_list.cr","line_number":12,"url":null},"def":{"name":"fetch","visibility":"Public","body":"run_at_most(every: 0.25.seconds, label: :fetch_queues) do |t|\n candidate_queues = Mosquito.backend.list_queues.map do |name|\n Queue.new(name)\n end\n @queues = filter_queues(candidate_queues)\n (Log.for(\"fetch_queues\")).debug do\n if @queues.size > 0\n \"found #{@queues.size} queues: #{@queues.map(&.name).join(\", \")}\"\n end\n end\nend"}}]},{"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/Coordinator","kind":"class","full_name":"Mosquito::Runners::Coordinator","name":"Coordinator"},{"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"}}]}]}]}]}}) \ No newline at end of file