Skip to content

Add a new field, transportSpecific to ServerContext #2228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Sources/GRPCCore/Call/Server/ServerContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

/// Additional information about an RPC handled by a server.
public struct ServerContext: Sendable {

/// Protocol used to help identify transport specific context fields
public protocol TransportSpecific: Sendable {}

/// A description of the method being called.
public var descriptor: MethodDescriptor

Expand Down Expand Up @@ -45,6 +49,15 @@ public struct ServerContext: Sendable {
/// - "in-process:27182".
public var localPeer: String

/// An optional field for transports to store specific data
///
/// Refer to the transport documentation to understand what type of
/// value this field will contain, if any.
///
/// An example of what this field can be used for, would be to store
/// things like a peer certificate from a mTLS connection
public var transportSpecific: (any TransportSpecific)?

/// A handle for checking the cancellation status of an RPC.
public var cancellation: RPCCancellationHandle

Expand Down