Class GrpcContextKeys
java.lang.Object
org.a2aproject.sdk.transport.grpc.context.GrpcContextKeys
Shared gRPC context keys for A2A protocol data.
These keys provide access to gRPC context information stored in
Context, enabling rich context access in service method
implementations similar to Python's grpc.aio.ServicerContext.
Usage Example
public void processRequest(ServerCallContext context) {
// Access gRPC context information
Context grpcContext = Context.current();
String method = GrpcContextKeys.GRPC_METHOD_NAME_KEY.get(grpcContext);
Metadata metadata = GrpcContextKeys.METADATA_KEY.get(grpcContext);
String peerInfo = GrpcContextKeys.PEER_INFO_KEY.get(grpcContext);
// Access A2A protocol headers
String version = GrpcContextKeys.VERSION_HEADER_KEY.get(grpcContext);
String extensions = GrpcContextKeys.EXTENSIONS_HEADER_KEY.get(grpcContext);
}
Context Population
These context keys are populated by server interceptors (typically
A2AExtensionsInterceptor) that capture request metadata and store
it in the gRPC context before service methods are called.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.grpc.Context.Key<String> Context key for storing the a2a-extensions header value.static final io.grpc.Context.Key<String> Context key for storing the method name being called.static final io.grpc.Context.Key<io.grpc.Metadata> Context key for storing the complete gRPC Metadata object.Mapping from gRPC method names to A2A protocol method names.static final io.grpc.Context.Key<String> Context key for storing the method name being called.static final io.grpc.Context.Key<String> Context key for storing the peer information.static final io.grpc.Context.Key<String> Context key for storing the a2a-version header value. -
Method Summary
-
Field Details
-
VERSION_HEADER_KEY
Context key for storing the a2a-version header value. Set by server interceptors and accessed by service handlers. -
EXTENSIONS_HEADER_KEY
Context key for storing the a2a-extensions header value. Set by server interceptors and accessed by service handlers. -
METADATA_KEY
public static final io.grpc.Context.Key<io.grpc.Metadata> METADATA_KEYContext key for storing the complete gRPC Metadata object. Provides access to all request headers and metadata. -
GRPC_METHOD_NAME_KEY
Context key for storing the method name being called. Equivalent to Python's context.method() functionality. -
METHOD_NAME_KEY
Context key for storing the method name being called. Equivalent to Python's context.method() functionality. -
PEER_INFO_KEY
Context key for storing the peer information. Provides access to client connection details. -
METHOD_MAPPING
Mapping from gRPC method names to A2A protocol method names.This mapping translates gRPC protobuf method names to their corresponding A2A protocol method name constants for consistent method identification across all transports.
Method Mappings:
- SendMessage → SendMessage
- SendStreamingMessage → SendStreamingMessage
- GetTask → GetTask
- ListTask → ListTasks
- CancelTask → CancelTask
- SubscribeToTask → SubscribeToTask
- CreateTaskPushNotification → CreateTaskPushNotificationConfig
- GetTaskPushNotification → GetTaskPushNotificationConfig
- ListTaskPushNotification → ListTaskPushNotificationConfigs
- DeleteTaskPushNotification → DeleteTaskPushNotificationConfig
- See Also:
-