class

GRPC::Transport::Http2ClientConnection

Inherits GRPC::Transport::ClientTransport < GRPC::Transport::Http2Connection < Reference < Object

Http2ClientConnection manages one HTTP/2 connection from a gRPC client.

Constants

DATA_READ_CB = LibNghttp2::DataSourceReadCallback.new do |_session, _stream_id, buf, length, data_flags, source, _user_data| sb = Box(SendBuffer).unbox(source.value.ptr) to_copy = (Math.min(length.to_i, sb.remaining)).to_i if to_copy == 0 data_flags.value = data_flags.value | LibNghttp2::DATA_FLAG_EOF next 0_i64 end buf.copy_from(sb.data.to_unsafe + sb.offset, to_copy) sb.offset = sb.offset + to_copy if sb.remaining == 0 data_flags.value = data_flags.value | LibNghttp2::DATA_FLAG_EOF end to_copy.to_i64 end
DATA_READ_CB_LIVE = LibNghttp2::DataSourceReadCallback.new do |_session, stream_id, buf, length, data_flags, _source, user_data| conn = Box(Http2ClientConnection).unbox(user_data) conn.read_live_send_data(stream_id, buf, length, data_flags) end

Constructors

new(host : String, port : Int32, use_tls : Bool = false, tls_context : OpenSSL::SSL::Context::Client | Nil = nil, endpoint_config : EndpointConfig = EndpointConfig.new)
Source

Instance methods

on_begin_headers_cb(frame : Pointer(Void)) : Nil
Source
on_data_chunk_cb(stream_id : Int32, data : Pointer(UInt8), len : LibC::SizeT) : Nil
Source
on_frame_recv_cb(frame : Pointer(Void)) : Nil
Source
on_header_cb(frame : Pointer(Void), name : Pointer(UInt8), nlen : LibC::SizeT, value : Pointer(UInt8), vlen : LibC::SizeT) : Nil
Source
on_stream_close_cb(stream_id : Int32, error_code : UInt32) : Nil
Source
open_bidi_stream_live(service : String, method : String, metadata : Metadata = Metadata.new, send_queue_size : Int32 = 0) : RawBidiCall

open_bidi_stream_live opens a true full-duplex bidi stream. Returns a RawBidiCall whose send_raw / close_send / each methods let the caller interleave sends and receives freely. send_queue_size limits how many outgoing frames may be buffered before send_raw blocks the calling fiber (0 = unbounded).

Source
open_client_stream_live(service : String, method : String, metadata : Metadata = Metadata.new, send_queue_size : Int32 = 0) : RawClientCall

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; the server's single response arrives after close_and_recv returns. send_queue_size limits how many outgoing frames may be buffered before send_raw blocks the calling fiber (0 = unbounded).

Source
open_server_stream(service : String, method : String, request_bytes : Bytes, metadata : Metadata = Metadata.new) : RawServerStream

open_server_stream sends one gRPC request and returns a RawServerStream that delivers server-pushed messages as they arrive.

Source
unary_call(service : String, method : String, request_body : Bytes, metadata : Metadata = Metadata.new) : ResponseEnvelope

unary_call sends one gRPC request and blocks until the response arrives.

Source