Skip to content

Instantly share code, notes, and snippets.

@swarbhanu
Created July 19, 2012 19:36
Show Gist options
  • Save swarbhanu/3146265 to your computer and use it in GitHub Desktop.
Save swarbhanu/3146265 to your computer and use it in GitHub Desktop.
An example script that launches the publisher that stores data in redis and streams it and the redis coordination transform that listens to those streams and removes the data from the same redis database.
class TransformEventListener(TransformEventProcess):
def on_start(self, event_type = None, event_origin = None, event_origin_type = None, event_subtype = None, algorithm = None):
self.listener = EventSubscriber( origin=event_origin,
origin_type = event_origin_type,
event_type=event_type,
sub_type=event_subtype,
callback=self.process_event )
self.listener.start()
self.algorithm = algorithm
def process_event(self, msg, headers):
# do something with the event and the algorithm which is a TransformAlgorithm object
raise NotImplementedError('Method process_event not implemented')
def on_quit(self):
self.listener.stop()
class TransformEventPublisher(TransformEventProcess):
def on_start(self, event_type):
self.publisher = EventPublisher(event_type=event_type)
def publish_event(self, *args, **kwargs):
self.publisher.publish_event(**kwargs)
def on_quit(self):
self.publisher.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment