Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
titleExample Greeter Processor
linenumberstrue
from streampipes.core import StandaloneSubmitter, EventProcessor
from streampipes.manager import Declarer


class Greeter(EventProcessor):
    greeting = None

    def on_invocation(self):
        # extract greeting text from static property
        self.greeting = self.static_properties.get('greeting')

    def on_event(self, event):
        event['greeting'] = self.greeting
        return event

    def on_detach(self):
        pass


def main():
    # dict with processor id and processor class
    processors = {
        'org.apache.streampipes.examples.python.processor': Greeter,
    }

    Declarer.add(processors=processors)
    StandaloneSubmitter.init()


if __name__ == '__main__':
    main()