This question is regarding rxpy.
I am trying to build a reactive system that handles messages from a source observable. In addition to that, I am trying to integrate it with a leader election system based on zookeeper.
This combination will allow only one leader in a farm of processes to handle the message stream. Below is the gist of the code I am trying to construct.
# event_source is an observable of messages
# manager.leaders is an observable of leader election events
# manager.followers is an observable of leader relinquish events
event_source\
.skip_until(manager.leaders)\
.take_until(manager.followers)\
.subscribe(observer)
It works fine and all, but I need to inject between skip_until
and take_until
a piece to handle backfill. This is designed to handle potential gap between a leader process failure and another process assuming leadership. Every processed message will leave a record so that a new leader can catch up on missing messages, if any, before proceeding with the stream.
I tried start_with
operator without success. Am I not approaching it in a manner it is not meant to be used for?
Ultimately, the solution I am looking for is to inject a specific number of items in the stream triggered by an event from another stream.