Skip to content

Commit

Permalink
linting fixes (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjheilmann authored Dec 21, 2023
1 parent e8daac9 commit c0c6d0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/grpc_reflection/dynamic_supervisor.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule GrpcReflection.DynamicSupervisor do
@moduledoc false

use DynamicSupervisor

def start_link(init_arg) do
Expand Down
16 changes: 9 additions & 7 deletions lib/grpc_reflection/service/agent.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ defmodule GrpcReflection.Service.Agent do
defstruct services: [], files: %{}, symbols: %{}

@type descriptor_t :: GrpcReflection.descriptor_t()
@type t :: %{
required(:services) => list(module()),
required(:files) => %{optional(binary()) => descriptor_t()},
required(:symbols) => %{optional(binary()) => descriptor_t()}
@type cfg_t :: {atom(), list(atom)}
@type t :: %__MODULE__{
services: list(module()),
files: %{optional(binary()) => descriptor_t()},
symbols: %{optional(binary()) => descriptor_t()}
}

def start_link(_, opts) do
Expand All @@ -31,24 +32,25 @@ defmodule GrpcReflection.Service.Agent do
end
end

@spec list_services(atom()) :: list(binary)
@spec list_services(cfg_t()) :: list(binary)
def list_services(cfg) do
name = start_agent_on_first_call(cfg)
Agent.get(name, &Lookup.lookup_services/1)
end

@spec get_by_symbol(atom(), binary()) :: {:ok, descriptor_t()} | {:error, binary}
@spec get_by_symbol(cfg_t(), binary()) :: {:ok, descriptor_t()} | {:error, binary}
def get_by_symbol(cfg, symbol) do
name = start_agent_on_first_call(cfg)
Agent.get(name, &Lookup.lookup_symbol(symbol, &1))
end

@spec get_by_filename(atom(), binary()) :: {:ok, descriptor_t()} | {:error, binary}
@spec get_by_filename(cfg_t(), binary()) :: {:ok, descriptor_t()} | {:error, binary}
def get_by_filename(cfg, filename) do
name = start_agent_on_first_call(cfg)
Agent.get(name, &Lookup.lookup_filename(filename, &1))
end

@spec put_state(cfg_t(), t()) :: :ok
def put_state(cfg, %__MODULE__{} = state) do
name = start_agent_on_first_call(cfg)
Agent.update(name, fn _old_state -> state end)
Expand Down

0 comments on commit c0c6d0e

Please sign in to comment.