Skip to content

Commit

Permalink
fix types, appease dialyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleclair committed Feb 8, 2024
1 parent aa25730 commit 83c21a2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ jobs:
- name: Run Tests
run: mix test --warnings-as-errors
if: ${{ matrix.lint }}

- name: Run Dialyzer
run: mix dialyzer
if: ${{ matrix.lint }}
8 changes: 4 additions & 4 deletions lib/finch/http1/pool_metrics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defmodule Finch.HTTP1.PoolMetrics do

def maybe_add(nil, _metrics_list), do: :ok

def maybe_add(ref, metrics_list) when is_reference(ref) do
def maybe_add(ref, metrics_list) do
Enum.each(metrics_list, fn {metric_name, val} ->
:atomics.add(ref, @atomic_idx[metric_name], val)
end)
Expand All @@ -57,7 +57,9 @@ defmodule Finch.HTTP1.PoolMetrics do
|> get_pool_status()
end

def get_pool_status(ref) when is_reference(ref) do
def get_pool_status(nil), do: {:error, :not_found}

def get_pool_status(ref) do
%{
pool_idx: pool_idx,
pool_size: pool_size,
Expand All @@ -76,6 +78,4 @@ defmodule Finch.HTTP1.PoolMetrics do

{:ok, result}
end

def get_pool_status(nil), do: {:error, :not_found}
end
8 changes: 4 additions & 4 deletions lib/finch/http2/pool_metrics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Finch.HTTP2.PoolMetrics do

def maybe_add(nil, _metrics_list), do: :ok

def maybe_add(ref, metrics_list) when is_reference(ref) do
def maybe_add(ref, metrics_list) do
Enum.each(metrics_list, fn {metric_name, val} ->
:atomics.add(ref, @atomic_idx[metric_name], val)
end)
Expand All @@ -47,7 +47,9 @@ defmodule Finch.HTTP2.PoolMetrics do
|> get_pool_status()
end

def get_pool_status(ref) when is_reference(ref) do
def get_pool_status(nil), do: {:error, :not_found}

def get_pool_status(ref) do
%{
pool_idx: pool_idx,
in_flight_requests: in_flight_requests
Expand All @@ -63,6 +65,4 @@ defmodule Finch.HTTP2.PoolMetrics do

{:ok, result}
end

def get_pool_status(nil), do: {:error, :not_found}
end

0 comments on commit 83c21a2

Please sign in to comment.