I have an event source that generates events that belong to certain groups. I would like to buffer these groups and send the groups (in batches) to storage. So far I have this:
eventSource
.GroupBy(event => event.GroupingKey)
.Select(group => new { group.Key, Events = group })
.Subscribe(group => group.Events
.Buffer(TimeSpan.FromSeconds(60), 100)
.Subscribe(list => SendToStorage(list)));
So there's a nested subscribe to the events in a group. Somehow I think there's a better way but I haven't been able to figure it out yet.