cyme.branch.supervisor

cyme.branch.supervisor

class cyme.branch.supervisor.Supervisor(interval=None, queue=None, set_as_current=True)

The supervisor wakes up at intervals to monitor changes in the model. It can also be requested to perform specific operations, and these operations can be either async or sync.

Parameters:
  • interval – This is the interval (in seconds as an int/float), between verifying all the registered instances.
  • queue – Custom Queue instance used to send and receive commands.

It is responsible for:

  • Stopping removed instances.
  • Starting new instances.
  • Restarting unresponsive/killed instances.
  • Making sure the instances consumes from the queues specified in the model, sending add_consumer/- cancel_consumer broadcast commands to the instances as it finds inconsistencies.
  • Making sure the max/min concurrency setting is as specified in the model, sending autoscale broadcast commands to the noes as it finds inconsistencies.

The supervisor is resilient to intermittent connection failures, and will auto-retry any operation that is dependent on a broker.

Since workers cannot respond to broadcast commands while the broker is off-line, the supervisor will not restart affected instances until the instance has had a chance to reconnect (decided by the wait_after_broker_revived attribute).

before()
interval = 60.0

Default interval (time in seconds as a float to reschedule).

pause()

Pause all timers.

paused = False

Connection errors pauses the supervisor, so events does not accumulate.

restart(instances)

Restart one or more instances.

Parameters:instances – List of instances to restart.

This operation is asynchronous, and returns a Greenlet instance that can be used to wait for the operation to complete.

restart_max_rate = '1/m'

Limit instance restarts to 1/m, so out of control instances will be disabled

resume()

Resume all timers.

run()
shutdown(instances)

Shutdown one or more instances.

Parameters:instances – List of instances to stop.

This operation is asynchronous, and returns a Greenlet instance that can be used to wait for the operation to complete.

Warning

Note that the supervisor will automatically restart any stopped instances unless the corresponding Instance model has been marked as disabled.

verify(instances, ratelimit=False)

Verify the consistency of one or more instances.

Parameters:instances – List of instances to verify.

This operation is asynchronous, and returns a Greenlet instance that can be used to wait for the operation to complete.

wait_after_broker_revived = 35.0

Default interval_max for ensure_connection is 30 secs.

cyme.branch.supervisor.get_current()
cyme.branch.supervisor.set_current(sup)

Previous topic

cyme.branch.managers

Next topic

cyme.branch.httpd

This Page