Skip to content

Add optional callback of format_status/1 to GenServer #12241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/elixir/lib/gen_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,14 @@ defmodule GenServer do
@callback format_status(reason, pdict_and_state :: list) :: term
when reason: :normal | :terminate

@callback format_status(status) :: status

@optional_callbacks code_change: 3,
terminate: 2,
handle_info: 2,
handle_cast: 2,
handle_call: 3,
format_status: 1,
format_status: 2,
handle_continue: 2

Expand Down Expand Up @@ -747,6 +750,13 @@ defmodule GenServer do
"""
@type from :: {pid, tag :: term}

@type status :: %{
required(:state) => term(),
required(:log) => list(:sys.system_event()),
optional(:message) => list(),
optional(:reason) => term()
}

@doc false
defmacro __using__(opts) do
quote location: :keep, bind_quoted: [opts: opts] do
Expand Down