Skip to content

Commit

Permalink
Fix dialyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
lucazulian committed Dec 5, 2023
1 parent c86614c commit 1547973
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
45 changes: 19 additions & 26 deletions lib/bgp/server/rde.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ defmodule BGP.Server.RDE do
```
"""

# TODO
# implement handle info for monitor
# {Ref, join, Group, [JoinPid1, JoinPid2]}

@behaviour :gen_statem

alias BGP.{Message.UPDATE, Server}
Expand Down Expand Up @@ -48,24 +44,18 @@ defmodule BGP.Server.RDE do
@impl :gen_statem
def init([server]) do
Group.monitor(server)

data = %{}
actions = [{:next_event, :internal, :accept_updates}]

{:ok, :idle, data, actions}
{:ok, :idle, %{}, [{:state_timeout, 1_000, nil}]}
end

@impl :gen_statem
def handle_event(:enter, old_state, new_state, data) do
Logger.debug("RDE #{data}: #{old_state} -> #{new_state}")
def handle_event(:enter, old_state, new_state, _data) do
Logger.debug("RDE: #{old_state} -> #{new_state}")
:keep_state_and_data
end

def handle_event(:internal, :accept_updates, :idle, _data) do
{
:keep_state_and_data,
[{:state_timeout, 1_000}]
}
# TODO update in table
:keep_state_and_data
end

def handle_event(:state_timeout, _, :idle, data) do
Expand All @@ -84,6 +74,7 @@ defmodule BGP.Server.RDE do
:idle,
data,
[
{:state_timeout, 1_000, nil},
{:next_event, :internal, :route_dissemination}
]
}
Expand All @@ -94,17 +85,19 @@ defmodule BGP.Server.RDE do
:keep_state_and_data
end

# @spec start_link(Keyword.t()) :: GenServer.on_start()
# def start_link(args),
# do: GenServer.start_link(__MODULE__, args, name: Server.rde_for(args[:server]))
def handle_event(:info, {_ref, :join, _group, _pids}, _state, _data) do
:keep_state_and_data
end

def handle_event(:info, {_ref, :leave, _group, _pids}, _state, _data) do
:keep_state_and_data
end

# @impl GenServer
# def init(_args) do
# {:ok, %{rib: MapSet.new(), rib_in: MapSet.new(), rib_out: MapSet.new()}}
# end
def handle_event({:call, from}, {:process_update, _update}, :idle, _data) do
{:keep_state_and_data, {:reply, from, :ok}}
end

# @impl GenServer
# def handle_call({:process_update, %UPDATE{}}, _from, state) do
# {:reply, :ok, state}
# end
def handle_event({:call, from}, {:process_update, _update}, _, _data) do
{:postpone, {:reply, from, :ok}}
end
end
2 changes: 1 addition & 1 deletion lib/bgp/server/session/group.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defmodule BGP.Server.Session.Group do
def leave(server, group),
do: :pg.leave(Server.session_group_for(server), group, self())

@spec monitor(Server.t()) :: {reference(), [pid()]}
@spec monitor(Server.t()) :: {reference(), %{optional(group()) => [pid()]}}
def monitor(server) do
:pg.monitor_scope(Server.session_group_for(server))
end
Expand Down

0 comments on commit 1547973

Please sign in to comment.