Skip to content

Commit

Permalink
Merge pull request #261 from andyleclair/main
Browse files Browse the repository at this point in the history
fix types, appease dialyzer
  • Loading branch information
sneako authored Feb 9, 2024
2 parents aa25730 + c78d2d5 commit 97c70e6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,25 @@ jobs:
otp-version: ${{matrix.pair.otp}}
elixir-version: ${{matrix.pair.elixir}}

# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
# Cache key based on Elixir & Erlang version (also useful when running in matrix)
- name: Cache Dialyzer's PLT
uses: actions/cache@v3
if: ${{ matrix.lint }}
id: cache-plt
with:
path: _build/test
key: |
${{ runner.os }}-plt-otp${{ matrix.erlang }}-elixir${{ matrix.elixir }}
- name: Install Dependencies
run: mix deps.get

# Create PLTs if no cache was found
- name: Create PLTs
if: ${{ matrix.lint && steps.cache-plt.outputs.cache-hit != 'true' }}
run: mix dialyzer --plt

- run: mix format --check-formatted
if: ${{ matrix.lint }}

Expand All @@ -62,3 +78,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 97c70e6

Please sign in to comment.