class
Mosquito::Runners::Executor
- Mosquito::Runners::Executor
- Reference
- Object
Overview
The executor is the center of work in Mosquito, and it's is the demarcation point between Mosquito framework and application code. Above the Executor is entirely Mosquito, and below it is application code.
An Executor is responsible for hydrating Job classes with deserialized
parameters and calling Mosquito::Job#run on them. It measures the time it
takes to run a job and provides detailed log messages about the current
status.
An executor is a Mosquito::Runnable and should be interacted with according to
the Runnable API.
To build an executor, provide a job input channel and an idle bell channel. These channels can be shared between all available executors.
The executor will ring the idle bell when it is ready to accept work and then wait for work to show up on the job pipeline. After the job is finished it will ring the bell again and wait for more work.
Included Modules
Defined in:
mosquito/runners/executor.crConstructors
Instance Method Summary
-
#decommission!
Marks this executor for graceful shutdown.
- #decommissioned? : Bool
-
#execute
Runs a job from a Queue.
-
#failed_job_ttl : Int32
How long a job config is persisted after failure
-
#failed_job_ttl=(failed_job_ttl : Int32)
How long a job config is persisted after failure
-
#finished_bell : Channel(WorkUnit | Nil)
Used to notify the overseer when this executor is idle.
-
#job_pipeline : Channel(WorkUnit)
Where work is received from the overseer.
- #observer : Observability::Executor
- #overseer : Overseer
-
#stop(wait_group : WaitGroup = WaitGroup.new(1)) : WaitGroup
Request that the next time the run loop cycles it should exit instead.
-
#successful_job_ttl : Int32
How long a job config is persisted after success
-
#successful_job_ttl=(successful_job_ttl : Int32)
How long a job config is persisted after success
- #work_unit : WorkUnit
- #work_unit? : WorkUnit | Nil
Instance methods inherited from module Mosquito::Runnable
dead? : Bool
dead?,
each_run : Nil
each_run,
fiber : Fiber | Nil
fiber,
my_name : String
my_name,
post_run : Nil
post_run,
pre_run : Nil
pre_run,
run(*, spawn spawn_fiber = true)
run,
runnable_name : String
runnable_name,
state : State
state,
stop(wait_group : WaitGroup = WaitGroup.new(1)) : WaitGroup
stop
Instance methods inherited from module Mosquito::Runners::RunAtMost
execution_timestamps
execution_timestamps
Constructor Detail
Instance Method Detail
Marks this executor for graceful shutdown. It will stop after completing its current job (if any).
Runs a job from a Queue.
Execution time is measured and logged, and the job is either forgotten or, if it fails, rescheduled.
Used to notify the overseer when this executor is idle. Sends the {JobRun, Queue} tuple that was just finished, or nil when the executor first starts up.
Request that the next time the run loop cycles it should exit instead. The runnable doesn't exit immediately so #stop spawns a fiber to monitor the state transition.
Returns the WaitGroup, which will be decremented when the
runnable has finished. This enables runnable.stop.wait.
If a WaitGroup is provided, it will be decremented when the
runnable has finished. This is useful when stopping multiple
runnables and waiting for all of them to finish.
Calling stop on a runnable that has already finished or crashed is a no-op (the wait_group is signaled immediately).
How long a job config is persisted after success