Skip to content

Add support for handle_continue/2 callback#300

Open
maartenvanvliet wants to merge 6 commits into
elixir-lang:mainfrom
maartenvanvliet:handle-continue-support
Open

Add support for handle_continue/2 callback#300
maartenvanvliet wants to merge 6 commits into
elixir-lang:mainfrom
maartenvanvliet:handle-continue-support

Conversation

@maartenvanvliet

@maartenvanvliet maartenvanvliet commented May 11, 2023

Copy link
Copy Markdown

I took the liberty to address the feedback for this PR #264 as it was open for more than a year. @hazardfn hope you are okay with this?

GenServers also support a timeout in the return value {:ok, state, timeout | :hibernate | {:continue, term}}which is currently not supported by GenStage. I've added this too.

Howard Beard-Marlowe and others added 4 commits May 12, 2023 11:44
  * {:continue, _term} instructions can now be returned as one
    would expect from gen_server.

  * :hibernate is now supported on init similar to gen_server.
Comment thread lib/gen_stage.ex Outdated
init_producer(mod, opts, state)
init_producer(mod, opts, state, nil)

{:producer, state, opts, continue_or_hibernate} when is_list(opts) ->

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the naming of continue_or_hibernate as it can also contain the timeout. Including that as well seems verbose, is there a shorter term for it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call it additional_info.

Comment thread lib/gen_stage.ex
defp handle_gen_server_init_args(:hibernate, stage), do: {:ok, stage, :hibernate}

defp handle_gen_server_init_args(timeout, stage)
when (is_integer(timeout) and timeout >= 0) or timeout == :infinity,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing the timeout value here. Should this guard be placed elsewhere as well?

@maartenvanvliet

Copy link
Copy Markdown
Author

@josevalim could you have a look?

@acco

acco commented Mar 15, 2024

Copy link
Copy Markdown
Contributor

@whatyouhide I know you reviewed the last revision - any chance you can take a look at this one? 🙏

@whatyouhide whatyouhide left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m totally down for this, @josevalim?

Comment thread lib/gen_stage.ex Outdated
init_producer(mod, opts, state)
init_producer(mod, opts, state, nil)

{:producer, state, opts, continue_or_hibernate} when is_list(opts) ->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call it additional_info.

Comment thread lib/gen_stage.ex Outdated
@whatyouhide whatyouhide requested a review from josevalim March 18, 2024 08:43
@whatyouhide whatyouhide changed the title handle continue support Add support for handle_continue/2 callback Mar 18, 2024
@VasiliyS

VasiliyS commented Sep 19, 2024

Copy link
Copy Markdown

@josevalim @whatyouhide - Hi there! I was just looking for this feature to enable timer base scheduling in my GenStage producer. Is there a chance this could be approved soon?

@josevalim

Copy link
Copy Markdown
Member

I need to sit down and review it. The issue is that we need to consider all possible execution scenarios for producers, consumers, and producer_consumer, and those are not trivial. So I need to be in the proper headspace and other tasks take priority at the moment. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants