class
GRPC::Channel
- GRPC::Channel
- Reference
- Object
Overview
Channel represents a client-side gRPC endpoint. It manages HTTP/2 connections and is the entry point for RPC calls.
Plain TCP examples: channel = GRPC::Channel.new("localhost:50051") channel = GRPC::Channel.new("http://api.example.com:8080")
TLS examples: channel = GRPC::Channel.new("https://api.example.com:443") ctx = OpenSSL::SSL::Context::Client.new ctx.verify_mode = OpenSSL::SSL::VerifyMode::NONE # skip cert check (testing only) channel = GRPC::Channel.new("https://localhost:50051", tls_context: ctx)
Defined in:
grpc/channel.crConstructors
-
.new(address : String, interceptors : Array(ClientInterceptor) = [] of ClientInterceptor, tls_context : OpenSSL::SSL::Context::Client | Nil = nil, endpoint_config : EndpointConfig = EndpointConfig.new, transport_factory : ClientTransportFactory | Nil = nil)
Create a channel to address.
-
.new(endpoint : Endpoint, interceptors : Array(ClientInterceptor) = [] of ClientInterceptor, tls_context : OpenSSL::SSL::Context::Client | Nil = nil, endpoint_config : EndpointConfig = EndpointConfig.new, transport_factory : ClientTransportFactory | Nil = nil)
Create a channel to endpoint.
Instance Method Summary
- #close : Nil
- #endpoint : Endpoint
- #endpoint_config : EndpointConfig
-
#open_bidi_stream_live(service : String, method : String, ctx : ClientContext = ClientContext.new, send_queue_size : Int32 = 0) : RawBidiCall
open_bidi_stream_live opens a true full-duplex bidi-streaming RPC.
-
#open_client_stream_live(service : String, method : String, ctx : ClientContext = ClientContext.new, send_queue_size : Int32 = 0) : RawClientCall
open_client_stream_live opens a live client-streaming RPC.
-
#open_server_stream(service : String, method : String, request_bytes : Bytes, ctx : ClientContext = ClientContext.new) : RawServerStream
open_server_stream initiates a server-streaming gRPC call.
-
#unary_call(service : String, method : String, request_bytes : Bytes, ctx : ClientContext = ClientContext.new) : ResponseEnvelope
unary_call performs a single gRPC unary RPC.
-
#unary_call(service : String, method : String, request_bytes : Bytes, metadata : Metadata) : ResponseEnvelope
unary_call with a plain Metadata object — convenience overload for generated code.
Constructor Detail
Create a channel to address.
Address formats: "host:port", "http://host:port", "https://host:port". HTTPS triggers TLS; use tls_context to supply a custom OpenSSL context (e.g. to disable certificate verification for testing).
Create a channel to endpoint.
Instance Method Detail
open_bidi_stream_live opens a true full-duplex bidi-streaming RPC. Returns a RawBidiCall whose send_raw / close_send / each methods let the caller interleave request messages and response messages freely. send_queue_size limits how many outgoing frames may be buffered before send_raw blocks the calling fiber (0 = unbounded).
open_client_stream_live opens a live client-streaming RPC. Returns a RawClientCall whose send_raw / close_and_recv methods let the caller send messages incrementally then receive the server's single response. send_queue_size limits how many outgoing frames may be buffered before send_raw blocks the calling fiber (0 = unbounded).
open_server_stream initiates a server-streaming gRPC call. Returns a RawServerStream that can be iterated to receive response messages. This is the internal API used by generated client stubs.
unary_call performs a single gRPC unary RPC. This is the internal API used by generated client stubs. Returns the raw unary response envelope with metadata and status. If client interceptors are registered they wrap this call outermost-first.
unary_call with a plain Metadata object — convenience overload for generated code. Interceptors are NOT applied on this low-level overload.