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 ,
@@ -55,11 +56,19 @@ is_ready(Name) ->
5556 gen_statem :call (? CHANNEL (Name ), is_ready ).
5657
5758% % @doc Picks a subchannel from a pool using the configured strategy.
58- -spec pick (name (), unary | stream ) -> {ok , {pid (), grpcbox_client :interceptor () | undefined }} |
59- {error , undefined_channel | no_endpoints }.
59+ -spec pick (name (), unary | stream ) ->
60+ {ok , {pid (), grpcbox_client :interceptor () | undefined }} |
61+ {error , undefined_channel | no_endpoints }.
6062pick (Name , CallType ) ->
63+ pick (Name , CallType , undefined ).
64+
65+ % % @doc Picks a subchannel from a pool using the configured strategy.
66+ -spec pick (name (), unary | stream , term () | undefined ) ->
67+ {ok , {pid (), grpcbox_client :interceptor () | undefined }} |
68+ {error , undefined_channel | no_endpoints }.
69+ pick (Name , CallType , Key ) ->
6170 try
62- case gproc_pool : pick_worker (Name ) of
71+ case pick_worker (Name , Key ) of
6372 false -> {error , no_endpoints };
6473 Pid when is_pid (Pid ) ->
6574 {ok , {Pid , interceptor (Name , CallType )}}
@@ -69,6 +78,11 @@ pick(Name, CallType) ->
6978 {error , undefined_channel }
7079 end .
7180
81+ pick_worker (Name , undefined ) ->
82+ gproc_pool :pick_worker (Name );
83+ pick_worker (Name , Key ) ->
84+ gproc_pool :pick_worker (Name , Key ).
85+
7286-spec interceptor (name (), unary | stream ) -> grpcbox_client :interceptor () | undefined .
7387interceptor (Name , CallType ) ->
7488 case ets :lookup (? CHANNELS_TAB , {Name , CallType }) of
@@ -175,4 +189,3 @@ start_workers(Pool, StatsHandler, Encoding, Endpoints) ->
175189 Encoding , StatsHandler ),
176190 Pid
177191 end || Endpoint = {Transport , Host , Port , SSLOptions } <- Endpoints ].
178-
0 commit comments