Processing in batches from async events

I think this may be a case of learning to walk before you start running. When working with GenStage it helps to have a solid understanding of how and why GenServer works.

Furthermore GenStage is used when you need to regulate backpressure - i.e. slow the producing end down so that the later stages in the pipeline don’t get overwhelmed by the data that needs to be processed - but it doesn’t really sound like you have that kind of a problem.

It sounds more like you just need a GenServer that collects events over some period of time and then starts a new, separate process (Task) to deal with those collected events.

This contrived example and brief explanation may be a potential starting point.

1 Like