-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for querying by a set of tags #651
Comments
I guess you want to consume events from different kinds of entities with a single projection in order to build an aggregated view. Is that correct? I can also imagine that you want a But back to the idea of having Ultimately, that could be added to the API and we could decide that not all plugin implementations are required to implement it. Actually, that's the case already. We have the APIs and plugins implement them according to the capacity of the underlying database. I'm not sure about your specific use case, but if I inferred it correctly, you have different kind of entities all producing events with different tags and you want a projection capable of consuming all of them. If that's the case, they all belong to the same application and I don't think it will be a bad design if they share the same tag. At the end of the day, tags are here to allow us to build read-side views. If I would need to build a
You could consume events from each fruit independently, but also consume all the |
The Then there's the "need to know" factor. My fruits do not need to know they are part of an imagined basket. |
I understand your concern about entities not needing to know about each other. On the other hand, if they need to be consumed preserving the ordering, then it sounds to me that the transactional boundary is not in the right place. Looks like if you were using CRUD, you will have some joins and the different tables would have been updated on the same transaction. But because of event sourcing and the transaction boundary split, they are happening in different transactions now, but we need to reconstruct the ordering back. Or maybe the ordering is not that important and the requirement could be relaxed? Back to your idea of introducing search-by-tags, I think this will be non-trivial and maybe it will introduce a feature that's more of an edge case. If you want to have such a query, I think the first option would be to try to get something alongside the Akka APIs that query your journal in the way you need. Like an alternative Query plugin. Then of course, once you have a working solution, we could discuss if this is something to be integrated back into Akka or not. WDYT? |
Thanks for the clarification. Our actions going forwards will be:
I think this will work if we just analyse the transactions in more detail and find out what ACTUALLY happens. That usually does the trick :-)
IMHO this issue can be closed. |
@PerWiklander I'm just curious, what database do you use? |
For the projections? Postgres at the moment, but will probably use Neo4j for most future views. Also some pure in memory views where the number of events per entity is low there is no need to see the data more than a few minutes after it happened. |
I you use Postgres for the write side also I would recommend that you take a look at https://doc.akka.io/docs/akka-persistence-r2dbc/current/index.html There we take a different approach to how to read events for Projections. Instead of tags we use something we call slices. You can read more about that in the documentation. It doesn't solve the feature request you asked for here, but the design might become more like a firehose with a stream of all events and then in memory filtering and routing when consuming those to build different views. |
Oh! So more like getting an event stream and filtering in the client (the code I write) than to have n number of projections poll the database for "has anything happened on tag x since last time I checked?". That sounds... much better :-) |
But it looks like I misunderstood. Our use case is so small that we don't see a need for sharding at the moment. On the other hand we have many types of entities so we run many projections that mostly sit idle and poll for "has anything happened on this tag yet?". |
One more question, now that we are on the topic of akka-persistence-r2dbc:
Does this imply that I risk missing events, or that the polling (that still happens but less often) would catch missed published events? |
You would typically have one
The latter. It will not miss events. Duplicates are automatically filtered out before they are delivered. |
Short description
It would be nice to be able to query on more than one tag at a time.
Let's say I'm creating a projection that is interested in events tagged with "apple", "banana" and "orange".
I want to see them together in the order they were persisted.
Details
The proposed API is
and
Alternatively, please inform me on how I am totally wrong and how a projection would never need to handle events from multiple sources :-)
The text was updated successfully, but these errors were encountered: