Skip to content

Commit

Permalink
Act on review result: ease typespec'ing my bumping CI to min. 25
Browse files Browse the repository at this point in the history
rebar.config tells a different story, as per the README, but that's
intentional
  • Loading branch information
paulo-ferraz-oliveira committed Aug 7, 2023
1 parent b1980cc commit 327b58a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
otp: ['24', '25', '26']
otp: ['25', '26']
rebar: ['3.22']

steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ Worker Pool is available on [Hex.pm](https://hex.pm/packages/worker_pool).

## Requirements

**Required OTP version 24** or higher. We only provide guarantees that the system runs on `OTP24+` since that's what we're testing it in, but the `minimum_otp_vsn` is `"21"` because some systems where **worker_pool** is integrated do require it.
**Required OTP version 25** or higher. We only provide guarantees that the system runs on `OTP25+` since that's what we're testing it in, but the `minimum_otp_vsn` is `"21"` because some systems where **worker_pool** is integrated do require it.
18 changes: 3 additions & 15 deletions src/wpool.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@
-export([stats/0, stats/1, get_workers/1]).
-export([default_strategy/0]).

-if(?OTP_RELEASE >= 25).

-type gen_server_request_id() :: gen_server:request_id().

-else.

-type gen_server_request_id() :: reference().

-endif.

-elvis([{elvis_style, export_used_types, disable}]).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ADMIN API
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -206,20 +194,20 @@ cast(Sup, Cast, Strategy) ->
wpool_pool:Strategy(Sup), Cast).

%% @equiv send_request(Sup, Call, default_strategy(), 5000)
-spec send_request(name(), term()) -> noproc | timeout | gen_server_request_id().
-spec send_request(name(), term()) -> noproc | timeout | gen_server:request_id().
send_request(Sup, Call) ->
send_request(Sup, Call, default_strategy()).

%% @equiv send_request(Sup, Call, Strategy, 5000)
-spec send_request(name(), term(), strategy()) ->
noproc | timeout | gen_server_request_id().
noproc | timeout | gen_server:request_id().
send_request(Sup, Call, Strategy) ->
send_request(Sup, Call, Strategy, 5000).

%% @doc Picks a server and issues the call to it.
%% Timeout applies only for the time used choosing a worker in the available_worker strategy
-spec send_request(name(), term(), strategy(), timeout()) ->
noproc | timeout | gen_server_request_id().
noproc | timeout | gen_server:request_id().
send_request(Sup, Call, available_worker, Timeout) ->
wpool_pool:send_request_available_worker(Sup, Call, Timeout);
send_request(Sup, Call, {hash_worker, HashKey}, _Timeout) ->
Expand Down
14 changes: 1 addition & 13 deletions src/wpool_pool.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@

-export_type([wpool/0]).

-if(?OTP_RELEASE >= 25).

-type gen_server_request_id() :: gen_server:request_id().

-else.

-type gen_server_request_id() :: reference().

-endif.

-elvis([{elvis_style, export_used_types, disable}]).

%% ===================================================================
%% API functions
%% ===================================================================
Expand Down Expand Up @@ -136,7 +124,7 @@ call_available_worker(Name, Call, Timeout) ->
%% @doc Picks the first available worker and sends the request to it.
%% The timeout provided considers only the time it takes to get a worker
-spec send_request_available_worker(wpool:name(), any(), timeout()) ->
noproc | timeout | gen_server_request_id().
noproc | timeout | gen_server:request_id().
send_request_available_worker(Name, Call, Timeout) ->
wpool_queue_manager:send_request_available_worker(queue_manager_name(Name),
Call,
Expand Down
18 changes: 2 additions & 16 deletions src/wpool_queue_manager.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

-export_type([state/0]).

-type from() :: {pid(), gen_server_reply_tag()}.
-type from() :: {pid(), gen_server:reply_tag()}.

-export_type([from/0]).

Expand All @@ -60,20 +60,6 @@
-export_type([call_request/0]).
-export_type([queue_mgr/0, queue_type/0]).

-if(?OTP_RELEASE >= 25).

-type gen_server_request_id() :: gen_server:request_id().
-type gen_server_reply_tag() :: gen_server:reply_tag().

-else.

-type gen_server_request_id() :: reference().
-type gen_server_reply_tag() :: reference().

-endif.

-elvis([{elvis_style, export_used_types, disable}]).

%%%===================================================================
%%% API
%%%===================================================================
Expand Down Expand Up @@ -110,7 +96,7 @@ cast_to_available_worker(QueueManager, Cast) ->

%% @doc returns the first available worker in the pool
-spec send_request_available_worker(queue_mgr(), any(), timeout()) ->
noproc | timeout | gen_server_request_id().
noproc | timeout | gen_server:request_id().
send_request_available_worker(QueueManager, Call, Timeout) ->
case get_available_worker(QueueManager, Call, Timeout) of
{ok, _TimeLeft, Worker} ->
Expand Down

0 comments on commit 327b58a

Please sign in to comment.