Skip to content

Commit

Permalink
Fix dialyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
lucazulian committed Nov 7, 2023
1 parent a545b41 commit 3727226
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
50 changes: 22 additions & 28 deletions lib/bgp/server/rde.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +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 All @@ -38,7 +33,9 @@ defmodule BGP.Server.RDE do

@spec start_link(term()) :: :gen_statem.start_ret()
def start_link(server) do
:gen_statem.start_link({:local, Server.rde_for(server)}, __MODULE__, [server], debug: [:trace])
:gen_statem.start_link({:local, Server.rde_for(server)}, __MODULE__, [server],
debug: [:trace]
)
end

@impl :gen_statem
Expand All @@ -47,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 @@ -83,6 +74,7 @@ defmodule BGP.Server.RDE do
:idle,
data,
[
{:state_timeout, 1_000, nil},
{:next_event, :internal, :route_dissemination}
]
}
Expand All @@ -93,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

# @impl GenServer
# def init(_args) do
# {:ok, %{rib: MapSet.new(), rib_in: MapSet.new(), rib_out: MapSet.new()}}
# end
def handle_event(:info, {_ref, :leave, _group, _pids}, _state, _data) do
:keep_state_and_data
end

# @impl GenServer
# def handle_call({:process_update, %UPDATE{}}, _from, state) do
# {:reply, :ok, state}
# end
def handle_event({:call, from}, {:process_update, _update}, :idle, _data) do
{:keep_state_and_data, {:reply, from, :ok}}
end

def handle_event({:call, from}, {:process_update, _update}, _, _data) do
{:postpone, {:reply, from, :ok}}
end
end
4 changes: 2 additions & 2 deletions lib/bgp/server/session/group.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ 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))
:pg.monitor_scope(Server.session_group_for(server))

Check warning on line 35 in lib/bgp/server/session/group.ex

View workflow job for this annotation

GitHub Actions / Test (OTP 24 / Elixir 1.15)

:pg.monitor_scope/1 is undefined or private

Check warning on line 35 in lib/bgp/server/session/group.ex

View workflow job for this annotation

GitHub Actions / Test (OTP 24 / Elixir 1.14)

:pg.monitor_scope/1 is undefined or private

Check warning on line 35 in lib/bgp/server/session/group.ex

View workflow job for this annotation

GitHub Actions / Test (OTP 23 / Elixir 1.14)

:pg.monitor_scope/1 is undefined or private

Check warning on line 35 in lib/bgp/server/session/group.ex

View workflow job for this annotation

GitHub Actions / Test (OTP 24 / Elixir 1.13)

:pg.monitor_scope/1 is undefined or private

Check warning on line 35 in lib/bgp/server/session/group.ex

View workflow job for this annotation

GitHub Actions / Test (OTP 23 / Elixir 1.13)

:pg.monitor_scope/1 is undefined or private

Check warning on line 35 in lib/bgp/server/session/group.ex

View workflow job for this annotation

GitHub Actions / Test (OTP 24 / Elixir 1.12)

:pg.monitor_scope/1 is undefined or private

Check warning on line 35 in lib/bgp/server/session/group.ex

View workflow job for this annotation

GitHub Actions / Test (OTP 23 / Elixir 1.12)

:pg.monitor_scope/1 is undefined or private
end
end
5 changes: 2 additions & 3 deletions lib/bgp/server/session/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ defmodule BGP.Server.Session.Supervisor do
def init(server) do
children =
Server.get_config(server)
|> Keyword.fetch!(:peers)
|> Enum.map(&{BGP.Server.Session, &1})

|> Keyword.fetch!(:peers)
|> Enum.map(&{BGP.Server.Session, &1})

Supervisor.init(children, strategy: :one_for_one)
end
Expand Down

0 comments on commit 3727226

Please sign in to comment.