Skip to content

Commit

Permalink
Implement code_change/3 for our GenServers
Browse files Browse the repository at this point in the history
  • Loading branch information
jchristgit committed Jun 9, 2023
1 parent d99e2e9 commit 2603b0b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/nostrum/shard/connector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ defmodule Nostrum.Shard.Connector do
Process.sleep(@wait_time - time)
{:reply, :ok, %{state | last_connect: Util.now()}}
end

def code_change(_version, state, _extra) do
{:ok, state}
end
end
5 changes: 5 additions & 0 deletions lib/nostrum/voice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ defmodule Nostrum.Voice do
{:noreply, Map.delete(state, guild_id)}
end

@doc false
def code_change(_version, state, data, _extra) do
{:ok, state, data}
end

@doc false
def start_if_ready(%VoiceState{} = voice) do
if VoiceState.ready_for_ws?(voice) do
Expand Down
4 changes: 4 additions & 0 deletions lib/nostrum/voice/ports.ex
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,8 @@ defmodule Nostrum.Voice.Ports do
def handle_info(_, state) do
{:noreply, state}
end

def code_change(_version, state, data, _extra) do
{:ok, state, data}
end
end
4 changes: 4 additions & 0 deletions lib/nostrum/voice/session.ex
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ defmodule Nostrum.Voice.Session do
:gun.close(state.conn)
end

def code_change(_old_vsn, state, _extra) do
{:ok, state}
end

def restart_session_async(state) do
spawn(fn ->
Process.monitor(state.conn_pid)
Expand Down

0 comments on commit 2603b0b

Please sign in to comment.