Split of streams by time-frame (closing the books/end of year)

Hello

I’m digging into the closing the books patterns to be able to split large streams on some time-frame and the problem that I’m encountering is how to split stream and at the same time to let app knows which is the name of the new stream. For example:

(Old Stream)
Account-2022-01-01 AmountCredited,AmountDebited, AccountPeriodClosed
(New Stream)
Account-2022-02-01 AccountPeriodOpened

Maybe I’m missing an aggregate or event but at the moment I’m not sure how this could happen in consistent manner.

Similar example of CashRegister (ShiftFinished, ShiftStarted) is shown in: https://www.eventstore.com/blog/snapshots-in-event-sourcing but it doesn’t explain how to keep and update the name of the stream (e.g to let repository know stream name to use).

It would be nice if someone could share some experience on this topic.

Thanks in advance.

If I were to do it, it would be as follows

stream-id-timespan.

Your infrastructure should then deal with this, not the domain, the domain does not know about streams, or how it is persisted.

So in your infra code I would then check something like, when closing the books has fire this would then mark the stream as closed and then open a new stream with the same stream name just the time frame part would be different.

The closing event should be followed by the opening event, the reason I am saying this is they are not both there from the domain perspective, there is something wrong and not up to date.

Maybe store the old stream name and new stream name in the Metadata of the closing event, and then the same for the opening event. Your stream time series should be triggered by the closing and opening events, but should be dealt by your infra layer.

Again this is my thinking and I might be way of base here, or event introdutena code smell. Maybe wait for the guys that have more expierence?

If you then say want to get the following stream, such as account-123

Your infra layer would check for account-123-December2021,if it does not find it try and check for account-123-November2021 and so forth until you get to a point where you say okay I checked the last 12 months for instance and cannot find a stream like account-123 so that might not exist.

You would need to deal with deep searching such as an account that might be 5 years old and for some reason the books were never closed for that stream. Such as account-123-August2016 or something similar.

I also read the same article as you and I am still wondering about the approach. I think if we can get @oskar.dudycz to maybe clarify? Apologies @oskar.dudycz if I remember correctly you wrote the article. https://www.eventstore.com/blog/keep-your-streams-short-temporal-modelling-for-fast-reads-and-optimal-data-retention