- Bug fixes
- Make sure flows are garbage collected when consumed as a stream which is halted
- Enhancements
- Add
Flow.stream/2andFlow.run/2which acceptlink: false
- Add
- Bug fix
- Fix
Flow.merge/2followed by consumer
- Fix
- Enhancements
- Allow stages to be ignored
- Add
Flow.child_spec/1
-
Bug fixes
- Fix bugs where shuffling would ignore partitions before/after
- Ensure flow options effectively override producer dispatcher
-
Deprecations
- Deprecate
Flow.map/2and friends afterreduceto avoid confusion regarding bookkeeping of state
- Deprecate
-
Enhancements
- Add
Flow.map_batch/2
- Add
-
Bug fixes
- Do not leak flows while enumerating
- Enhancements
- Require GenStage v1.0.0
-
Enhancements
- Add on_init callback to MapReducer
- Deprecate Flow.each to avoid pitfalls
- Remove previously deprecated code
-
Bug fixes
- Set demand to accumulate before producer_consumer subscribe
- Bug fixes
- Don't fuse mappers into enumerables (#62)
- Trap exits to ensure event completion on shutdown
- Fix
flat_mapfollowed byemit_and_reduce(#68)
- Bug fixes
- Make sure consumers added via
into_specs/3restart the flow in case of failures
- Make sure consumers added via
-
Deprecations
Flow.filter_map/3is deprecated in favor of filter+mapFlow.from_stage/2is deprecated in favor ofFlow.from_stages/2Flow.merge/2is deprecated in favor ofFlow.partition/2orFlow.shuffle/2
-
Enhancements
- Add
Flow.shuffle/2to shuffle the stages into new ones - Add
Flow.through_stages/3for hookingproducer_consumers into the flow - Add
Flow.from_specs/2,Flow.through_specs/3andFlow.into_specs/3to start stages in the same supervision tree as the flow
- Add
This release includes a redesign of how triggers and the reducing accumulator works.
Prior to this version, the Flow module was responsible for traversing events in the mapper stage and to accumulate the state in reducing stages. When working with unbound data, the Flow.Window was used to control exactly when to emit data from the reducing stages and when to reset the partition state.
This approach meant that understanding which data is emitted and when the state was reset was hard because the logic was spread in multiple places. To make matters worse, if you wanted to have your own rules for emitting events, such as user session or sliding windows, it was only possible to achieve it via custom window implementations.
This design limitation caused many users to drop Flow and use GenStage, as GenStage provides the necessary abstractions for tackling those problems. However, since Flow is built on top of GenStage, why not expose it directly through Flow? That's what v0.14.0 does.
v0.14.0 introduces two new functions: emit_and_reduce/3 and on_trigger/2 which gives developers explicit control of when to emit data. The on_trigger/2 function also allows developers to fully control the state that is kept in the reducing stage after the trigger.
Unfortunately this change is incompatible (or rather, fully replaces) the following functionalities:
-
each_state/2andmap_state/2- those two functions were only invoked when there was a trigger and they have now been replaced by a more explicitly namedon_trigger/2function -
The
:keepand:resetargument to windows and triggers have been removed as you control the behaviour onon_trigger/2
For example, if you used map_state/2 (or each_state/2) and a :reset trigger, like this:
|> Flow.map_state(fn acc -> do_something(acc) end)
You can now replace this code by:
|> Flow.on_trigger(fn acc -> {do_something(acc), []} end)
Where the first element of the tuple returned by on_trigger is the data to emit and the second element is the new accumulator of the reducer stage. Similarly, if you were using map_state/2 (or each_state/2) and a :keep trigger, like this:
|> Flow.map_state(fn acc -> do_something(acc) end)
You can now replace this code by:
|> Flow.on_trigger(fn acc -> {do_something(acc), acc} end)
Note that on_trigger/2 can only be called once per partition. In case you were calling map_state/2 and each_state/2 multiple times, you can simply inline all calls inside the same on_trigger/2.
We believe emit_and_reduce/3 and on_trigger/2 provide a conceptually simpler module to reason about flows while being more powerful.
This release also deprecates Flow.Window.session/3 as developers can trivially roll their own with more customization power and flexibility using emit_and_reduce/3 and on_trigger/2.
-
Enhancements
use Flownow defines achild_spec/1to be used under supervision- Added
emit_and_reduce/3andon_trigger/2 - Use
DemandDispatcherwhen there is one stage in partition
-
Deprecations
- Session windows are deprecated in favor of
Flow.emit_and_reduce/3andFlow.on_trigger/2
- Session windows are deprecated in favor of
-
Backwards incompatible changes
Flow.map_state/2was removed in favor ofFlow.on_trigger/2Flow.each_state/2was removed in favor ofFlow.on_trigger/2- Passing
:keepor:resetto triggers was removed in favor of explicit control viaFlow.on_trigger/2. If you are passing or matching on those atoms, those entries can be removed
-
Enhancements
- Expose a timeout parameter for start_link and into_stages
- Allow shutdown time for stages to be configured
-
Bug fixes
- Ensure proper shutdown propagation on start_link, into_stages and friends (#40)
- Ensure proper shutdown order in Flow (#35)
-
Enhancements
- Allow late subscriptions to Flow returned by
Flow.into_stages
- Allow late subscriptions to Flow returned by
-
Bug fixes
- Cancel timer when termination is triggered on periodic window. This avoid invoking termination callbacks twice.
-
Enhancements
- Add the ability to emit only certain events in a trigger
-
Bug fixes
- Add
:gen_stageto the applications list - Ensure we handle supervisor exits on flow coordinator
- Ensure we do not unnecessary partition when fusing producer+streams
- Add
Extracted from GenStage.