-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
Re-evaluate the multi-stream event slicing/grouping APIs #3443
Comments
Hey Jeremy, I completely agree with your assessment of the multi-stream event slicing/grouping API. As it stands, there’s a lot of implicit behavior that makes it difficult to reason about what’s actually happening. This often leads to complex and redundant code, especially when implementing custom slicers or groupers. One specific pain point is the need to implement both For example, here's a part of my own code where I had to implement a custom slicer, and you can see how much duplication occurs between the two methods: public class CustomSlicer: IEventSlicer<AantalConsultatiesPerStatus, string>
{
public async ValueTask<IReadOnlyList<EventSlice<AantalConsultatiesPerStatus, string>>> SliceInlineActions(
IQuerySession querySession, IEnumerable<StreamAction> streams)
{
var allEvents = streams.SelectMany(x => x.Events).ToList();
var group = await TenantSliceGroup(querySession, allEvents);
return group.Slices.ToList();
}
public async ValueTask<IReadOnlyList<TenantSliceGroup<AantalConsultatiesPerStatus, string>>> SliceAsyncEvents(
IQuerySession querySession, List<IEvent> events)
{
var group = await TenantSliceGroup(querySession, events);
return new List<TenantSliceGroup<AantalConsultatiesPerStatus, string>> { group };
}
private static async Task<TenantSliceGroup<AantalConsultatiesPerStatus, string>> TenantSliceGroup(IQuerySession querySession, List<IEvent> events)
{
// Event processing logic here...
}
} Both methods end up doing almost the exact same thing—managing a group of events, yet I'm forced to handle them separately for synchronous and asynchronous operations. In this case, it feels like I’m writing the same logic twice, just in different contexts. This goes against the idea of reducing boilerplate and improving maintainability. Having a unified API for event slicing that abstracts away the difference between sync and async operations would significantly reduce this kind of duplication. Another issue is the ambiguity in Furthermore, if it stays a complex thing, then we just need to add a lot more examples, maybe even an example page. Lastly, I think the term "slicing" is a bit too vague. It doesn’t immediately convey its purpose, and something more descriptive like In summary, streamlining the API to make it more explicit and reducing the redundant logic between sync and async handling would go a long way toward improving the developer experience. I’d be happy to help with further discussions or contribute to these changes. |
I’ve been thinking about the current slicing/grouping API as well, and I wanted to offer some concrete suggestions that might help reduce the complexity and make things more explicit. 1. Unify
|
It's horrible. Worst API in Marten imho. My thinking right now is to push it toward making the users write more explicit code. This is more of a placeholder for conversation than anything immediately actionable.
The text was updated successfully, but these errors were encountered: