Implementing a sink operator using the Python Operator API

A sink operator transmits information or events to an external system, such as a dashboard, web-server, mail-server, or a database.

For this example, we’ll simply convert the tuple to json and print it to the standard output.

import streams
import json

class Operator(streams.Operator):
    def __init__(self, ctx, params):
        super().__init__(ctx)


    def allPortsReady(self):
        pass

    def processTuple(self, tuple, port):
        print("Received", port, json.dumps(tuple, indent=4))

    def processPunctuation(self, punctuation, port):
        pass