pyleus.storm.spout

Module containing the implementation of the Spout component.

class pyleus.storm.spout.Spout(input_stream=None, output_stream=None)[source]

Spout component class. Inherit from Component.

ack(tup_id)[source]

Ack a tuple to the source.

Parameters:tup_id (str or long) – tuple identifier

Note

Implement in subclass. Default behaviour is pass.

emit(values, stream=None, tup_id=None, direct_task=None, need_task_ids=True)[source]

Build and send an output tuple command dict and return the ids of the tasks to which the tuple was sent by Storm.

Parameters:
  • values (tuple or list) – pyleus tuple values to be emitted
  • stream (str) – output stream the message is going to belong to, default DEFAULT
  • tup_id (str or long) – identifier that will be used by Storm for tracking the tuple for reliability purpose. It will be passed as argument to both ack() and fail() when the tuple terminates its lifecycle. Default None
  • direct_task (int) – task message will be sent to, default None
  • need_task_ids (bool) – whether emit should return the ids of the task the message has been sent to, default True

Note

tup_id should be JSON-serializable.

Note

Omitting tup_id will disable reliability tracking for that tuple. If you provide a value for tup_id, then you also need to run at least one Storm acker (see Guaranteeing message processing), otherwise your topology will hang.

Tip

Setting need_task_ids to False really helps in achieving better performances. You should always do that if your application does not leverage task ids.

Danger

direct_task is not yet supported.

fail(tup_id)[source]

Fail a tuple to the source.

Parameters:tup_id (str or long) – tuple identifier

Note

Implement in subclass. Default behaviour is pass.

next_tuple()[source]

Emit the next tuple into the topology.

Note

Implement in subclass.