Adds support for handle_continue/2 to gen_stage
- {:continue, _term} instructions can now be returned as one would expect from gen_server.
- :hibernate is now supported on init similar to gen_server.
Attempts to revive #227
The :continue tests will only work OTP 21+, not sure what the best strategy is for limiting these tests to those versions...
EDIT: Added a compile time conditional that checks the OTP major version, if there's a better way let me know! 😃
The failing test seems to be inherently flakey - I can reproduce on master. Not sure what's causing it but running mix test on a loop it occasionally shows up, can investigate separately:
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
$ for i in 1 2 3 4 5; mix test; end
Compiling 3 files (.ex)
................................................................................................................................................................................................
Finished in 6.0 seconds
192 tests, 0 failures
Randomized with seed 355674
................................................................................................................................................................................................
Finished in 6.0 seconds
192 tests, 0 failures
Randomized with seed 77758
.....................................................................................................
1) test producer_consumer callbacks producer handle_cancel/3 on consumer down (GenStageTest)
test/gen_stage_test.exs:1553
Assertion failed, no matching message after 500ms
The following variables were pinned:
ref = #Reference<0.3941081809.3725066241.213827>
consumer = #PID<0.589.0>
Showing 2 of 2 messages in the mailbox
code: assert_receive {:producer_consumer_cancelled, {^consumer, ^ref}, {:down, :killed}}
mailbox:
pattern: {:producer_consumer_cancelled, {^consumer, ^ref}, {:down, :killed}}
value: {:consumer_subscribed, {#PID<0.588.0>, #Reference<0.3941081809.3725066241.213827>}}
pattern: {:producer_consumer_cancelled, {^consumer, ^ref}, {:down, :killed}}
value: {:producer_consumer_cancelled, {#PID<0.589.0>, #Reference<0.3941081809.3725066241.213827>}, {:down, :noproc}}
stacktrace:
test/gen_stage_test.exs:1560: (test)
..........................................................................................
Finished in 6.7 seconds
192 tests, 1 failure
Randomized with seed 791161
................................................................................................................................................................................................
Finished in 6.0 seconds
192 tests, 0 failures
Randomized with seed 199756
................................................................................................................................................................................................
Finished in 6.0 seconds
192 tests, 0 failures
Randomized with seed 937796
Rebased for #265
@josevalim is there something I need to do to move this forward?
Hi @hazardfn, apparently this fell under the cracks, sorry about that. I will try to save some time to review it this week but it may take a while because there are quite some factors to consider here. In any case, thanks for the PR and the ping!
Would love this feature. Anything I can do to help test/QA/review?
Just checking in to say I won't have as much time as I thought tonight, will post here when I'm able to actually take a bite out of this.
This would be incredible to have access to.
Closed in favour of https://github.com/elixir-lang/gen_stage/pull/300.