Skip to content

Conversation

@declanclark
Copy link

The documentation in the "process anti patterns" section shows an example of a Counter which uses a GenServer in its implementation.
The bump handler replies with the current state before any bump operation has been applied to it however the iex snippet shows the new value being returned.

I chose to fix the iex snippets rather than editing the bump handler because in the docs for the Supervisor, we have a very similar example which does return the "old" value of the counter and I thought it best to keep the docs consistent.

@josevalim
Copy link
Member

Thank you for the PR. I am thinking in this case it may make more sense to change the example. Because the goal here is not really to show how the GenServer works, but the supervisor, and this makes non-supervisor part of the example more verbose. Perhaps we should only have the :bump callback even?

Alternatively we implement it using an Agent, which should considerably cut down the lines of code?

A third option, which perhaps is the one I prefer the most, is to rewrite this example altogether. I don't think the goal here is to show supervisor APIs, but rather to say that tools like Observer and Phoenix LiveDashboard gives us better instrospection if we supervise them.

@josevalim
Copy link
Member

I took a stab at 3 here: #14764 - Can you please let me know what you think?

@declanclark
Copy link
Author

Thanks José! LGTM

github-actions bot pushed a commit that referenced this pull request Sep 10, 2025
josevalim added a commit that referenced this pull request Sep 10, 2025
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.

2 participants