Monkey#

class mobu.services.monkey.Monkey(*, name, flock=None, business_config, user, http_client, events, repo_manager, logger)#

Bases: object

Runs one business and manages its log and configuration.

Parameters:
  • name (str) – Name of this monkey.

  • flock (str | None, default: None) – Name of the flock this monkey belongs to, or None if it is running as a solitary.

  • business_config (BusinessConfig) – Configuration for the business it should run.

  • user (AuthenticatedUser) – User the monkey should run as.

  • http_client (AsyncClient) – Shared HTTP client.

  • events (Events) – Event publishers.

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

  • logger (BoundLogger) – Global logger.

Methods Summary

alert(exc)

Send an exception to Sentry.

dump()

Return information about a running monkey.

logfile()

Get the log file for a monkey's log.

run_once()

Run the monkey business once.

signal_refresh()

Tell the business to refresh.

start(scheduler)

Start the monkey.

stop()

Stop the monkey.

Methods Documentation

async alert(exc)#

Send an exception to Sentry.

Parameters:

exc (Exception) – Exception prompting the alert.

Return type:

None

dump()#

Return information about a running monkey.

Return type:

MonkeyData

logfile()#

Get the log file for a monkey’s log.

Return type:

str

async run_once()#

Run the monkey business once.

Returns:

Error message on failure, or None if the business succeeded.

Return type:

str or None

signal_refresh()#

Tell the business to refresh.

Return type:

None

async start(scheduler)#

Start the monkey.

Parameters:

scheduler (Scheduler)

Return type:

None

async stop()#

Stop the monkey.

Return type:

None