Fill state in new consumers

I’m thinking about using GenStage to process timeseries data and do some aggregations on that. To do this, the consumers need to keep track of state. However, when a consumer is restarted, the state is empty, and to fill this it needs historic events (for example, all events of the current day so far).

Is there a native approach in GenStage to get previous events (I doubt it)? Or is there a best practice for this? My initial idea is to query the database on startup to fill the state, but it smells wrong. Preferably this can be solved with just event handling. For example, with Kafka, you can just put back the data pointer on startup.

Any people with good idea? :slight_smile:

Oh, of course an obvious solution is to make state persistent, but I’m trying to think of ways to not have to do this.