borgcube.daemon package

borgcube.daemon.client module

exception borgcube.daemon.client.APIError[source]

Bases: RuntimeError

class borgcube.daemon.client.APIClient(address=None, context=None)[source]

Bases: object

Client to talk to the backend daemon (borgcubed)

All of these can raise zmq.ZMQError, zmq.Again etc. and these should be handled gracefully (ie not with a 500).

do_request(request_dict)[source]

Send request_dict to the borgcube daemon and return the response dictionary.

cancel_job(job)[source]
stats()[source]

borgcube.daemon.hookspec module

borgcube.daemon.hookspec.borgcubed_startup(apiserver)[source]

Called after borgcubed has fully started up.

apiserver is the daemon.APIServer instance handling this. Interesting APIs are:

def error(self, message, *parameters):
Log error message formatted (%) with parameters. Return response dictionary.
def queue_job(self, job):
Enqueue job instance for execution.
borgcube.daemon.hookspec.borgcubed_handle_request(apiserver, request)[source]

Handle request and return a response dictionary.

request[‘command’] is the command string. If this is not for you, return None.

borgcube.daemon.hookspec.borgcubed_idle(apiserver)[source]

Called on every ‘idle’ iteration in the daemon. This typically occurs roughly every second.

borgcube.daemon.hookspec.borgcubed_job_exit(apiserver, job, exit_code, signo)[source]

Called when a job child process is reaped.

job is the job, while exit_code is the exit code of the process. signo is the POSIX signal number. If the process did not exit due to a signal, signo is zero.

borgcube.daemon.hookspec.borgcubed_client_call(apiclient, call)[source]

Called if an unknown APIClient method call (str) is invoked.

Return a client function that should handle the call.

Return None if you don’t care about it.

You are likely interested in this apiclient API:

def do_request(self, request_dict):
Send request_dict to the borgcube daemon and return the response dictionary.

Don’t forget to raise the appropiate APIError if the daemon returns an error.