def listening_to_log(): dedicated_logging_op = FrontendDedicatedLoggingOp() dedicated_logging_container = FrontendDedicatedLoggingContainer() dedicated_logging_container.add_operator_edge( from_operator=dedicated_logging_op, to_operator=DummyUtil.dummy_streaming_operator() ) dedicated_logging_container.initialize() dedicated_logging_container.execute()
op2 = HelloWorldOp(operator_name='hello_world_op2') op3 = HelloWorldOp(operator_name='hello_world_op3') op4 = HelloWorldOp(operator_name='hello_world_op4') container1 = HelloWorldContainer() container1.bind_backend(server_url="localhost:11443") container1.add_operator_edge(from_operator=op1, to_operator=op3) container1.add_operator_edge(from_operator=op1, to_operator=op4) container1.add_operator_edge(from_operator=op2, to_operator=op3) container1.add_operator_edge(from_operator=op2, to_operator=op4) container1.initialize() container1.execute() op1.unset_dependency() op1.unset_status() op2.unset_dependency() op2.unset_status() op3.unset_dependency() op3.unset_status() op4.unset_dependency() op4.unset_status() container2 = HelloWorldContainer(container_name='hello_world_container_2') container2.bind_backend(server_url="localhost:11443") dummy_op = DummyUtil.dummy_streaming_operator(operator_name='dummy') container2.add_operator_edge(from_operator=op1, to_operator=dummy_op) container2.add_operator_edge(from_operator=op2, to_operator=dummy_op) container2.add_operator_edge(from_operator=op3, to_operator=dummy_op) container2.add_operator_edge(from_operator=op4, to_operator=dummy_op) container2.initialize() container2.execute()
subscriber = Subscriber( connection_str='amqp://*****:*****@localhost:5672' ) subscriber.bind_to_op(self) subscriber.subscribe( exchange_name='test_exchange_1', topic_name='test1', message_type=HealthCheckerRequest ) subscriber.subscribe( exchange_name='test_exchange_2', topic_name='test2', message_type=HealthCheckerRequest ) subscriber.start() class SubscriberExampleContainer(DefaultStreamingContainer): def __init__(self): super().__init__(container_name='subscriber_example_container', ttl=7) if __name__ == "__main__": op = SubscriberExampleOp() container = SubscriberExampleContainer() container.add_operator_edge(from_operator=op, to_operator=DummyUtil.dummy_streaming_operator()) container.initialize() container.execute()
from pslx.streaming.operator import StreamingOperator from pslx.streaming.container import DefaultStreamingContainer from pslx.util.dummy_util import DummyUtil class HelloWorldOp(StreamingOperator): def __init__(self): super().__init__(operator_name='hello_world_op') def execute_impl(self): print('hello world') class HelloWorldContainer(DefaultStreamingContainer): def __init__(self): super().__init__(container_name='hello_world_container') if __name__ == "__main__": op = HelloWorldOp() container = HelloWorldContainer() container.add_operator_edge( from_operator=op, to_operator=DummyUtil.dummy_streaming_operator()) container.add_operator_edge(from_operator=op, to_operator=DummyUtil.dummy_streaming_operator( operator_name='dummy_streaming_operator2')) container.initialize() container.execute()
def pubsub_msg_parser(exchange_name, topic_name, message): print(exchange_name, topic_name, message) def execute_impl(self): subscriber = Subscriber( connection_str='amqp://*****:*****@localhost:5672') subscriber.bind_to_op(self) subscriber.subscribe(exchange_name='test_exchange_1', topic_name='test1', message_type=HealthCheckerRequest) subscriber.subscribe(exchange_name='test_exchange_2', topic_name='test2', message_type=HealthCheckerRequest) subscriber.start() class SubscriberExampleContainer(DefaultStreamingContainer): def __init__(self): super().__init__(container_name='subscriber_example_container') if __name__ == "__main__": op = SubscriberExampleOp() container = SubscriberExampleContainer() container.add_operator_edge( from_operator=op, to_operator=DummyUtil.dummy_streaming_operator()) container.initialize() container.execute()