pyleus.storm.component

Module containing the base class for all pyleus components and a wrapper class around Storm configurations.

class pyleus.storm.component.Component(input_stream=None, output_stream=None)[source]

Base class for all pyleus components.

OPTIONS = None

list of user-defined options for the component.

Note

Specify in subclass.

OUTPUT_FIELDS = None

list or dict of output fields for the component.

Note

Specify in subclass.

conf = None

StormConfig containing the Storm configuration for the component.

context = None

dict containing the Storm context for the component.

error(msg)[source]

Send an error message.

Parameters:msg (str) – error message
initialize()[source]

Called after component has been launched, but before processing any tuples. You can use this method to setup your component.

Note

Implement in subclass.

log(msg, level=2)[source]

Send a log message.

Parameters:
  • msg (str) – log message
  • level – log levels defined as constants in pyleus.storm. Allowed: LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR. Default: LOG_INFO
log_debug(msg)[source]

Send a log message with level LOG_DEBUG.

Parameters:msg (str) – log message
log_error(msg)[source]

Send a log message with level LOG_ERROR.

Parameters:msg (str) – log message
log_info(msg)[source]

Send a log message with level LOG_INFO.

Parameters:msg (str) – log message
log_trace(msg)[source]

Send a log message with level LOG_TRACE.

Parameters:msg (str) – log message
log_warn(msg)[source]

Send a log message with level LOG_WARN.

Parameters:msg (str) – log message
options = None

dict containing options passed to component in the yaml definition file.

run()[source]

Entry point for the component running logic.

Forgetting to call it as following will prevent the topology from running.

Example:
if __name__ == '__main__':
    MyComponent().run()
class pyleus.storm.component.StormConfig(conf)[source]

Add some convenience properites to a configuration dict from Storm. You can access Storm configuration dictionary within a component through self.conf.

tick_tuple_freq[source]

Helper property to access the value of tick tuple frequency stored in Storm configuration.

Returns:tick tuple frequency for the component
Return type:float or None

Note

Bolts not specifying tick tuple frequency default to None, while spouts are not supposed to use tick tuples at all.