antikythera v0.4.0 AntikytheraCore.ExecutorPool.AsyncJobBroker View Source

A broker that finds a pair of "a runnable job in job queue" and "an available AsyncJobRunner process in worker pool".

This GenServer becomes :active when both antikythera and the job queue for the same executor pool are ready. When entering :active phase it notifies AntikytheraCore.TerminationManager of the pid so that it will be notified afterward. Before host termination it becomes :inactive on receipt of a message from AntikytheraCore.TerminationManager; from then on it won't start new jobs.

During :active phase it checks out a process from the async job worker pool of the same executor pool, fetches a job from the job queue, and tells the process to run the job.

Communications between broker and job queue are basically event-driven, i.e., no polling mechanism is needed for them to work, most of the time. However, in rare occasions, messages between them may be lost due to e.g. failure of majority members in the job queue's consensus group. Therefore we also use periodic polling to recover from this kind of troubles.

Link to this section Summary

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

deactivate(pid()) :: :ok
Link to this function

notify_job_registered(pid)

View Source

Specs

notify_job_registered(pid()) :: :ok
Link to this function

notify_pool_capacity_may_have_changed(name)

View Source

Specs

notify_pool_capacity_may_have_changed(atom()) :: :ok