@@ -105,6 +105,32 @@ defmodule GRPC.Stub do
105105 end
106106 end
107107
108+ @ spec connect (
109+ String . t ( ) | { :local , String . t ( ) } ,
110+ binary ( ) | non_neg_integer ( ) ,
111+ keyword ( )
112+ ) :: { :ok , Channel . t ( ) } | { :error , any ( ) }
113+ def connect ( host , port , opts ) when is_binary ( port ) do
114+ connect ( host , String . to_integer ( port ) , opts )
115+ end
116+
117+ def connect ( host , port , opts ) when is_integer ( port ) do
118+ if Application . get_env ( :grpc , :http2_client_adapter ) do
119+ raise "the :http2_client_adapter config key has been deprecated.\
120+ The currently supported way is to configure it\
121+ through the :adapter option for GRPC.Stub.connect/3"
122+ end
123+
124+ ip_type =
125+ case :inet . parse_address ( to_charlist ( host ) ) do
126+ { :ok , { _ , _ , _ , _ } } -> "ipv4"
127+ { :ok , { _ , _ , _ , _ , _ , _ , _ , _ } } -> "ipv6"
128+ { :error , _ } -> "ipv4"
129+ end
130+
131+ connect ( "#{ ip_type } :#{ host } :#{ port } " , opts )
132+ end
133+
108134 @ doc """
109135 Establish a connection with gRPC server and return `GRPC.Channel` needed for
110136 sending requests.
@@ -140,6 +166,8 @@ defmodule GRPC.Stub do
140166 Conn . connect ( addr , opts )
141167 end
142168
169+
170+
143171 def retry_timeout ( curr ) when curr < 11 do
144172 timeout =
145173 if curr < 11 do
0 commit comments