API reference

Nodes

class fluteline.Node

A common interface for all fluteline nodes to start and stop them gracefully.

Call start and stop to interact with the node. Override enter to setup resources and exit to clean after yourself.

enter()

Override to prepare resources.

exit()

Override to cleanup after yourself.

start()

Start the node.

stop()

Stop the node gracefully.

class fluteline.Producer

Inherit this class to create producers.

produce()

Override to produce new messages.

class fluteline.Consumer

Inherit this class to create consumers or consumer-producers.

Variables:input (Queue) – An input queue to accept messages.
consume(msg)

Override to consume messages.

put(msg)

Send a message to this consumer.

class fluteline.SynchronousConsumer

Same API as Consumer but… synchronous!

  • Execution happen the in thread that calls the put method.
  • enter and exit are called when calling start and stop.
  • There’s no input queue.
  • It’s lighter on resources and usually faster.

Utilities

fluteline.connect(nodes)

Connect a list of nodes.

Connected nodes have an output member which is the following node in the line. The last node’s output is a Queue for easy plumbing.

fluteline.start(nodes)

Start multiple nodes.

fluteline.stop(nodes)

Stop multiple nodes.

Queues

class fluteline.Queue

Thread-safe queue for nodes communication.

empty()

Return True if the queue is empty, False otherwise (not reliable!).

get()

Remove and return an item from the queue.

put(item)

Put an item into the queue.