Base classes

class DANE.base_classes.base_worker(queue, binding_key, config, depends_on=[], auto_connect=True, no_api=False)

Abstract base class for a worker.

This class contains most of the logic of dealing with DANE-server, classes (workers) inheriting from this class only need to specific the callback method.

Parameters:
  • queue (str) – Name of the queue for this worker
  • binding_key (str or list) – A string following the format as explained here: https://www.rabbitmq.com/tutorials/tutorial-five-python.html or a list of such strings
  • config (dict) – Config settings of the worker
  • depends_on (list, optional) – List of task_keys that need to have been performed on the document before this task can be run
  • auto_connect (bool, optional) – Connect to AMQ on init, set to false to debug worker as a standalone class.
  • no_api (bool, optional) – Disable ESHandler, mainly for debugging.
callback(task, document)

Function containing the core functionality that is specific to a worker.

Parameters:
Returns:

Task response with the message, state, and optional additional response information

Return type:

dict

connect()

Connect the worker to the AMQ. Called by init if autoconnecting.

getDirs(document)

This function returns the TEMP and OUT directories for this job creating them if they do not yet exist output should be stored in response[‘SHARED’]

Parameters:job (DANE.Job) – The job
Returns:Dict with keys TEMP_FOLDER and OUT_FOLDER
Return type:dict
run()

Start listening for tasks to be executed.

stop()

Stop listening for tasks to be executed.