Protocol::GRPCSourceProtocolGRPCCall

class Call

Represents context for a single RPC call.

Definitions

def initialize(request, response = nil, deadline: nil)

Initialize a new RPC call context.

Signature

parameter request Protocol::HTTP::Request

The HTTP request

parameter response Protocol::HTTP::Response | Nil

The HTTP response (for setting metadata and trailers)

parameter deadline Async::Deadline | Nil

Deadline for the call

Implementation

def initialize(request, response = nil, deadline: nil)
	@request = request
	@response = response
	@deadline = deadline
	@cancelled = false
end

attr_reader :request

Signature

attribute Protocol::HTTP::Request

The underlying HTTP request.

attr_reader :response

Signature

attribute Protocol::HTTP::Response | Nil

The HTTP response.

attr_reader :deadline

Signature

attribute Async::Deadline | Nil

The deadline for this call.

def metadata

Extract metadata from request headers.

Signature

returns Hash

Custom metadata key-value pairs

Implementation

def metadata
	@metadata ||= Methods.extract_metadata(@request.headers)
end

def deadline_exceeded?

Check if the deadline has expired.

Signature

returns Boolean

true if the deadline has expired, false otherwise

Implementation

def deadline_exceeded?
	@deadline&.expired? || false
end

def time_remaining

Get the time remaining until the deadline.

Signature

returns Numeric | Nil

Seconds remaining, or Nil if no deadline is set

Implementation

def time_remaining
	@deadline&.remaining
end

def cancel!

Mark this call as cancelled.

Implementation

def cancel!
	@cancelled = true
end

def cancelled?

Check if the call was cancelled.

Signature

returns Boolean

true if the call was cancelled, false otherwise

Implementation

def cancelled?
	@cancelled
end

def peer

Get peer information (client address).

Signature

returns String | Nil

The peer address as a string, or Nil if not available

Implementation

def peer
	@request.peer&.to_s
end