55-export ([start_link /3 ,
66 is_ready /1 ,
77 pick /2 ,
8+ pick /3 ,
89 stop /1 ,
910 stop /2 ]).
1011-export ([init /1 ,
@@ -58,11 +59,19 @@ is_ready(Name) ->
5859 gen_statem :call (? CHANNEL (Name ), is_ready ).
5960
6061% % @doc Picks a subchannel from a pool using the configured strategy.
61- -spec pick (name (), unary | stream ) -> {ok , {pid (), grpcbox_client :interceptor () | undefined }} |
62- {error , undefined_channel | no_endpoints }.
62+ -spec pick (name (), unary | stream ) ->
63+ {ok , {pid (), grpcbox_client :interceptor () | undefined }} |
64+ {error , undefined_channel | no_endpoints }.
6365pick (Name , CallType ) ->
66+ pick (Name , CallType , undefined ).
67+
68+ % % @doc Picks a subchannel from a pool using the configured strategy.
69+ -spec pick (name (), unary | stream , term () | undefined ) ->
70+ {ok , {pid (), grpcbox_client :interceptor () | undefined }} |
71+ {error , undefined_channel | no_endpoints }.
72+ pick (Name , CallType , Key ) ->
6473 try
65- case gproc_pool : pick_worker (Name ) of
74+ case pick_worker (Name , Key ) of
6675 false -> {error , no_endpoints };
6776 Pid when is_pid (Pid ) ->
6877 {ok , {Pid , interceptor (Name , CallType )}}
@@ -72,6 +81,11 @@ pick(Name, CallType) ->
7281 {error , undefined_channel }
7382 end .
7483
84+ pick_worker (Name , undefined ) ->
85+ gproc_pool :pick_worker (Name );
86+ pick_worker (Name , Key ) ->
87+ gproc_pool :pick_worker (Name , Key ).
88+
7589-spec interceptor (name (), unary | stream ) -> grpcbox_client :interceptor () | undefined .
7690interceptor (Name , CallType ) ->
7791 case ets :lookup (? CHANNELS_TAB , {Name , CallType }) of
@@ -177,4 +191,3 @@ start_workers(Pool, StatsHandler, Encoding, Endpoints) ->
177191 Encoding , StatsHandler ),
178192 Pid
179193 end || Endpoint = {Transport , Host , Port , EndpointOptions } <- Endpoints ].
180-
0 commit comments