FlockManager#

class mobu.services.manager.FlockManager(*, gafaelfawr_storage, http_client, events, repo_manager, logger)#

Bases: object

Manages all of the running flocks.

This should be a process singleton. It is responsible for managing all of the flocks running in the background, including shutting them down and starting new ones.

Parameters:
  • gafaelfawr_storage (GafaelfawrStorage) – Gafaelfawr storage client.

  • http_client (AsyncClient) – Shared HTTP client.

  • events (Events) – Event publishers.

  • repo_manager (RepoManager) – For efficiently cloning git repos.

  • logger (BoundLogger) – Global logger to use for process-wide (not monkey) logging.

Methods Summary

aclose()

Stop all flocks and free all resources.

autostart()

Automatically start configured flocks.

get_flock(name)

Retrieve a flock by name.

list_flocks()

List all flocks.

list_flocks_for_repo(repo_url, repo_ref)

refresh_flock(name)

Tell a flock to refresh.

start_flock(flock_config)

Create and start a new flock of monkeys.

stop_flock(name)

Stop a flock.

summarize_flocks()

Summarize the status of all flocks.

Methods Documentation

async aclose()#

Stop all flocks and free all resources.

Return type:

None

async autostart()#

Automatically start configured flocks.

This function should be called from the startup hook of the FastAPI application.

Return type:

None

get_flock(name)#

Retrieve a flock by name.

Parameters:

name (str) – Name of the flock.

Returns:

Flock with that name.

Return type:

Flock

Raises:

FlockNotFoundError – Raised if no flock was found with that name.

list_flocks()#

List all flocks.

Returns:

Names of all flocks in sorted order.

Return type:

list of str

list_flocks_for_repo(repo_url, repo_ref)#
Parameters:
  • repo_url (str)

  • repo_ref (str)

Return type:

list[str]

refresh_flock(name)#

Tell a flock to refresh.

Parameters:

name (str) – Name of flock to refresh.

Raises:

FlockNotFoundError – Raised if no flock was found with that name.

Return type:

None

async start_flock(flock_config)#

Create and start a new flock of monkeys.

Parameters:

flock_config (FlockConfig) – Configuration for that flock.

Returns:

Newly-created flock.

Return type:

Flock

async stop_flock(name)#

Stop a flock.

Parameters:

name (str) – Name of flock to stop.

Raises:

FlockNotFoundError – Raised if no flock was found with that name.

Return type:

None

summarize_flocks()#

Summarize the status of all flocks.

Returns:

Flock summary data sorted by flock name.

Return type:

list of mobu.models.flock.FlockSummary