I am using akka to process event data and generate the nodes and edges of a graph in memory (which I later push to a graphdb, once the complete subgraph is generated). The events sometime come in out-of-order, so that is posing some challenge. Let me try explaining the situation.
Let's say, there are 4 types of events that come in: A, B, C and D. They results in the following:
A: Node M B: Node N, Edge (M-N) C: Node P, Edge (N-P) D: Edge (M-P)
If the events are coming in order, all are fine. But let's say B comes before A. In that case, I have to also create node M, with partial information, and then put in the edge M-N. Similarly, if D comes before any of the events, I will have to create M and P nodes with partial information, and create M-P edge. I fill in the rest of the information for the M and P nodes later when I receive the respective events.
I have written akka processors for each event type. However, in this pattern, I am having to repeat the code for 'partial node creation of each type' in each of the event processor code. e.g., processor actors for events B, C and D all repeat the code for creating nodes M (with partial information) and so on. That smells a bit of some problem.
Is there any other pattern I can follow for my use case? Thanks for any pointers.
Aucun commentaire:
Enregistrer un commentaire