derekkraan / horde

Horde is a distributed Supervisor and Registry backed by DeltaCrdt
MIT License
1.3k stars 102 forks source link

DynamicSupervisor and Registry init spec is wrong. #181

Closed deadtrickster closed 4 years ago

deadtrickster commented 4 years ago

Example:

<...>/horde/supervisor.ex:10:callback_type_mismatch
Type mismatch for @callback init/1 in Horde.DynamicSupervisor behaviour.

Expected type:

  {:ok,
   [
     {:delta_crdt_options
      | :distribution_strategy
      | :extra_arguments
      | :max_restarts
      | :max_seconds
      | :members
      | :name
      | :shutdown
      | :strategy, atom() | [any()] | integer()}
   ]}

Actual type:

  :ignore
  | {:ok,
     {%{:intensity => _, :period => _, :strategy => _}, [any()]}
     | %{
         :delta_crdt_options => %{:max_sync_size => _, :shutdown => _, :sync_interval => _},
         :distribution_strategy => _,
         :extra_arguments => _,
         :intensity => _,
         :max_children => _,
         :members => _,
         :period => _,
         :strategy => _
       }}
  | {:stop, {:bad_return, {atom(), :init, _}}}
  def init(options) do
    [strategy: :one_for_one, members: get_members()]
    |> Keyword.merge(options)
    |> Horde.DynamicSupervisor.init()
  end
anthonator commented 4 years ago

Has this been resolved by #189 or are there still typespec issues?

derekkraan commented 4 years ago

I think this one has been resolved @anthonator

gbrlcustodio commented 4 years ago

Actually, #189 fixes DynamicSupervisor's wrong specs. It still complains about Registry one.

Expected:

{:ok, Keyword.t()}

Got:

:ignore
| {:ok,
    {%{intensity: any, period: any, strategy: any}, [any]}
    | %{
        delta_crdt_options: %{
          max_sync_size: any,
          shutdown: any,
          sync_interval: any
        },
        distribution_strategy: any,
        keys: any,
        listeners: any,
        members: any,
        meta: any
      }}
| {:stop, {:bad_return, {atom, :init, any}}}
anthonator commented 4 years ago

Anybody know how to suppress this warning until 381279c has been released?

gbrlcustodio commented 4 years ago

Hey @anthonator

I'm using @dialyzer {:nowarn_function, init: 1} to disable it inside my module.

anthonator commented 4 years ago

Ah, nice! I was making this more complicated than it needed to be. Thank you!