routes module

class micro_framework.routes.CallbackRoute(*args, callback_target, callback_worker_class=None, **kwargs)

Bases: micro_framework.routes.Route

callback_worker_class

alias of micro_framework.workers.CallbackWorker

async get_callback_worker_instance(original_worker)
async handle_finished_worker(entry_id, worker)

Override this method to do some validations after a worker has finished.

This method should return either the worker instance or None.

Parameters
  • entry_id

  • worker

Returns

async start_callback_route(entry_id, worker)
class micro_framework.routes.Route(target, entrypoint, translators=None, worker_class=None, backoff=None, method_name=None, metric_label=None)

Bases: micro_framework.extensions.Extension

Base Extension Destined to link an endpoint to an entry function.

Protocol-Specific routes should implement this class and extend its features.

property backoff
property entrypoint
async get_worker_instance(*fn_args, _meta=None, **fn_kwargs)
async handle_finished_worker(entry_id, worker)

Override this method to do some validations after a worker has finished.

This method should return either the worker instance or None.

Parameters
  • entry_id

  • worker

Returns

property metric_label
async run_backoff(entry_id, worker)

Run a backoff class.

This method will return the worker from the retry. If None is returned, then it indicates that the backoff is running asynchronously and we let the entrypoint decide what to do.

Parameters

entry_id – Some object/identifier to be used to send a response

for the correct caller.

Parameters

worker (Worker) – Worker Instance with result/exception attrs

Return Optional[Worker]

Worker Instance with result/exception

attrs or a None type, indicating an asynchronous backoff was made.

async run_worker(entry_id, worker)
async start_route(entry_id, *fn_args, _meta=None, **fn_kwargs)
async stop()

Commands the extension to do a graceful stop

property translators
worker_class

alias of micro_framework.workers.Worker