Components

class wishbone.queue.Queue(max_size=1)[source]

Bases: object

A queue used to organize communication messaging between Wishbone Actors.

Parameters:max_size (-) – The max number of elements in the queue. Default: 1

When a queue is created, it will drop all messages. This is by design. When <disableFallThrough()> is called, the queue will keep submitted messages. The motivation for this is that when is queue is not connected to any consumer it would just sit there filled and possibly blocking the chain.

The <stats()> function will reveal whether any events have disappeared via this queue.

clean()[source]

Deletes the content of the queue.

dump()[source]

Dumps the queue as a generator and cleans it when done.

empty()[source]

Returns True when queue and unacknowledged is empty otherwise False.

get(block=True)[source]

Gets an element from the queue.

size()[source]

Returns the length of the queue.

stats()[source]

Returns statistics of the queue.

class wishbone.queue.QueuePool(size)[source]

Bases: object

createQueue(name)[source]

Creates a Queue.

createSystemQueue(name)[source]

Creates a queue starting with _ which is forbidden by users as special system queues are prefixed with ‘_’.

This method should normally never be used directly because of user input. It’s the Wishbone framework itself which should make system related queues.

Parameters:name – The name of the queue (should start with _)
getQueue(name)[source]

Convenience funtion which returns the queue instance.

hasQueue(name)[source]

Returns <True> when queue with <name> exists.

join()[source]

Blocks until all queues in the pool are empty.

listQueues(names=False, default=True)[source]

returns the list of queue names from the queuepool.

class wishbone.logging.Logging(name, q, identification=None)[source]

Bases: object

Generates Wishbone formatted log messages following the Syslog priority definition.

alert(message, *args, **kwargs)[source]

Generates a log message with priority alert(1).

crit(message, *args, **kwargs)

Generates a log message with priority critical(2).

critical(message, *args, **kwargs)[source]

Generates a log message with priority critical(2).

debug(message, *args, **kwargs)[source]

Generates a log message with priority debug(7).

emerg(message, *args, **kwargs)

Generates a log message with priority emergency(0).

emergency(message, *args, **kwargs)[source]

Generates a log message with priority emergency(0).

err(message, *args, **kwargs)

Generates a log message with priority error(3).

error(message, *args, **kwargs)[source]

Generates a log message with priority error(3).

exception(message, *args, **kwargs)

Generates a log message with priority emergency(0).

info(message, *args, **kwargs)

Generates a log message with priority informational(6).

informational(message, *args, **kwargs)[source]

Generates a log message with priority informational(6).

notice(message, *args, **kwargs)[source]

Generates a log message with priority notice(5).

warn(message, *args, **kwargs)

Generates a log message with priority warning(4).

warning(message, *args, **kwargs)[source]

Generates a log message with priority warning(4).

class wishbone.config.ConfigFile(filename, logstyle, loglevel=6, identification='wishbone', colorize_stdout=True)[source]

Generates a wishbone.router configuration object used to initialize a wishbone router object.

This config generator has some tailered functionality which makes it suitable when bootstrapping from CLI.

It does following automatic configurations:

  • Initializes a wishbone.module.flow.funnel module called _logs which is connected to the _logs queue of all modules except if this module has already been connected in the bootstrap file.

  • Initializes a wishbone.module.flow.funnel module called _metrics which is connected to the _metrics queue of all modules except if this module has already been connected in the bootstrap file. The _metrics modules is by default not connected to any other modules. The effect of this is that all metrics are dropped unless the user connects a module for furhter processing the metrics.

  • Adds a wishbone.module.flow.queueselect module called _logs_filter responsible for dropping logs which log level do not correspond to the define --log-level

  • Adds either a wishbone.module.output.stdout called _logs_stdout module or wishbone.module.output.syslog module called _logs_syslog and connects this instance to _logs.outbox.

  • Initializes the following template functions and makes them available to each initialized module:

    - strftime()
    - env()
    - epoch()
    - version()
    
Parameters:
  • filename – The filename of the configuration to load.
  • logstyle – How logging should be setup. Possible options are: stdout and syslog.
  • loglevel – The loglevel for the router to use to use.
  • identification – A string which identifies the router instance
  • colorize_stdout – When True, colors each stdout printed logline using proper coloring.
addConnection(source_module, source_queue, destination_module, destination_queue)[source]

Adds connections between module queues.

Parameters:
  • source_module – The source module instance name
  • source_queue – The source module instance queue name
  • destination_module – The destination instance name
  • destination_queue – The destination instance queue name
addModule(name, module, arguments={}, description='', functions={}, protocol=None, event=False)[source]

Adds a module to the configuration.

Parameters:
  • name – The module instance name
  • module – The module name
  • arguments – The module variables
  • description – A description of the module instance
  • functions – The module functions
  • protocol – The protocol to apply to the module
  • event – Whether incoming or outgoing events need to be treated as full events.
addModuleFunction(name, function, arguments={})[source]

Adds a module function to the configuration.

Parameters:
  • name – The name of the function instance
  • function – The entry point name of the function
  • arguments – The arguments to initiate the function class.
addProtocol(name, protocol, arguments={})[source]

Adds a protocol to the configuration

Parameters:
  • name – The name of the protocol instance
  • protcol – The entry point name of the protocol
  • arguments – The arguments to initiate the protocol class.
addTemplateFunction(name, function, arguments={})[source]

Adds a template funtion to the configuration.

Parameters:
  • name – The name of the function instance
  • function – The entry point name of the function
  • arguments – The arguments to initiate the function class.
dump()[source]

Dumps the configuration as an EasyDict instance.

load(filename)[source]

Loads a YAML bootstrap file.

Parameters:filename – The filename to load.
class wishbone.queue.QueuePool(size)[source]
createQueue(name)[source]

Creates a Queue.

createSystemQueue(name)[source]

Creates a queue starting with _ which is forbidden by users as special system queues are prefixed with ‘_’.

This method should normally never be used directly because of user input. It’s the Wishbone framework itself which should make system related queues.

Parameters:name – The name of the queue (should start with _)
getQueue(name)[source]

Convenience funtion which returns the queue instance.

hasQueue(name)[source]

Returns <True> when queue with <name> exists.

join()[source]

Blocks until all queues in the pool are empty.

listQueues(names=False, default=True)[source]

returns the list of queue names from the queuepool.