Lets say there are two services. One generates event A
and the other event B
.
We need to build a new service that implements the function C = func(A, B)
, which produces the result C
.
But as A
and B
are asynchronous events, they may reach (and invoke) the new service separately.
Depending on what is required, it may be apt for the new service to:
- either wait for both events,
- or implement different variations of the function:
C = func(A,C')
orC = func(B,C')
whereC'
is the previous state ofC
(assuming that it is even possible to build that function) - or query back to retrieve the complimentary event, e.g. if
A
invoked the service, then query forB
.
Question:
Lets say the requirement is that we update the state of C
ASAP, and A
and B
have a significant time gap in occurrence - that rules out option #1.
Additionally assume it is hard/impossible to build different variations of the function (#2).
That leaves us with option #3, which probably has drawbacks because it may be breaking the event driven paradigm (or maybe not, I am not sure).
How should we solve this problem? I expected this to be a common problem with a recommended pattern, but I could not find it. Any suggestions or pointers on where I could find the answer, or if the question is wrong, how should I look at it?