2

I have an interesting and problem I'm facing. I'm trying to maintain a set of metrics independently based off of a time frequency.

Note: This is a simplification of the problem I've omitted pieces of the code the remain brief I have a simple architecture which looks like so:

public interface INode<TIn, TOut> : IBaseNode
{
    event EventHandler<TOut> Output; 
    void Subscribe(IBaseNode node);
    void OnInput(object sender, TIn input)
}

I have a bunch of nodes which independently subscribe to pieces of data they want to track which can be depicted as so:

enter image description here

All of the events are fired from a parent node in a Breadth First Manner. So the nodes that are further away from the original event will fire after, which means that the Nodes that are further away from the originating node will take longer to fire since they are dependent on the nodes before them provide output. Additionally, since new nodes are coming in, some nodes may fire multiple times before reach other nodes in the chain of events.

I'm looking for a strategy to keep these relatively in sync. Based off their frequency. e.g If the frequency is 3 requests per 1000ms I would like to be sure that All of the PriceMA and the Volume MA values are processed for that specific time frame before doing additional calculations

My intuition say that this should be solved relatively easy by added a Synchronization Node at the end which waits for all subscribed nodes to be complete based off of some requestId e.g:

enter image description here

However seeing as I've never done this before, I'm not sure that's the best strategy, since I want all events which occur within a specific time frame to be processed prior to chains in other time frames.

What is a relatively reliable strategy for handling breadth first synchronization of events?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.