Adding progress callbacks to `Ecto.Multi`

Hi there,

In our application we’re building up pretty large %Ecto.Multi{} structs which are then executed. While our clients are waiting for transactions like these to finish, we’d like to show them a progress bar.

To facilitate this I created an add_progress_calls/2 helper function which intertwines each step in the Multi with a callback to a function which gets the current percentage as input argument. (To get this to work I had to inspect how the Multi struct is built up internally, unfortunately, I could not find an API to tear a multi apart and build it up again without inspecting its contents).

Is this something that could be contributed to Ecto? It seems like a feature which could be useful for more people.
I whipped up a quick gist here; If there’s interest I’ll pollish this and make it into an official PR… :slight_smile:


It is okay to mention @josevalim or other intense Ecto contributors like @michalmuskala or @ericmj to draw their attention here, I think. So I just did it for you :D.


Thanks :slight_smile:

1 Like