spakky-grpc¶
gRPC 서비스 컨트롤러 통합 — code-first, 타입 안전 프로토콜 생성
스테레오타입¶
gRPC controller stereotype for service grouping.
Provides the @GrpcController stereotype for marking classes as gRPC service controllers with automatic service registration and protobuf package configuration.
GrpcController(package, service_name=None, *, name='', scope=Scope.SINGLETON)
dataclass
¶
Bases: Controller
Stereotype for gRPC service controllers.
Marks a class as a gRPC service controller with automatic service registration. Methods decorated with @rpc will be registered as gRPC service methods.
Attributes:
| Name | Type | Description |
|---|---|---|
package |
str
|
Protobuf package name for the service. |
service_name |
str | None
|
gRPC service name. Defaults to the class name if not provided. |
package
instance-attribute
¶
Protobuf package name for the service.
service_name = None
class-attribute
instance-attribute
¶
gRPC service name. Defaults to the class name.
__call__(obj)
¶
Apply the gRPC controller stereotype to a class.
Automatically generates the service name from the class name if not provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
AnyT
|
The class to decorate. |
required |
Returns:
| Type | Description |
|---|---|
AnyT
|
The decorated class registered as a Pod. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/stereotypes/grpc_controller.py
데코레이터¶
RPC method decorator for gRPC service methods.
Provides the @rpc decorator for marking controller methods as gRPC service methods with support for all four gRPC streaming patterns.
RpcMethodType
¶
Bases: StrEnum
gRPC method streaming patterns.
Attributes:
| Name | Type | Description |
|---|---|---|
UNARY |
Single request, single response. |
|
SERVER_STREAMING |
Single request, stream of responses. |
|
CLIENT_STREAMING |
Stream of requests, single response. |
|
BIDI_STREAMING |
Stream of requests, stream of responses. |
Rpc(method_type=RpcMethodType.UNARY, request_type=None, response_type=None)
dataclass
¶
Bases: FunctionAnnotation
Function annotation for marking methods as gRPC RPC endpoints.
Stores RPC configuration including the streaming pattern and request/response type metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
method_type |
RpcMethodType
|
gRPC streaming pattern for this method. |
request_type |
type | None
|
Request message type. Auto-extracted from type hints if not provided. |
response_type |
type | None
|
Response message type. Auto-extracted from type hints if not provided. |
__call__(obj)
¶
Annotate a method as an RPC endpoint.
Extracts request and response types from type hints if not explicitly provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Callable[..., AnyT]
|
The method to annotate. |
required |
Returns:
| Type | Description |
|---|---|
Callable[..., AnyT]
|
The annotated method. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/decorators/rpc.py
rpc(method_type=RpcMethodType.UNARY, request_type=None, response_type=None)
¶
Decorator to mark a controller method as a gRPC RPC endpoint.
Attaches RPC configuration to the method including streaming pattern and message type metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method_type
|
RpcMethodType
|
gRPC streaming pattern for this method. |
UNARY
|
request_type
|
type | None
|
Request message type. Auto-extracted from type hints if not provided. |
None
|
response_type
|
type | None
|
Response message type. Auto-extracted from type hints if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[Callable[..., AnyT]], Callable[..., AnyT]]
|
A decorator function that attaches the RPC configuration. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/decorators/rpc.py
어노테이션¶
Protobuf field annotation for pydantic-based message definitions.
Provides the ProtoField annotation for specifying protobuf field numbers
on pydantic BaseModel fields using the Annotated type hint pattern.
Example::
from pydantic import BaseModel
from typing import Annotated
class HelloRequest(BaseModel):
name: Annotated[str, ProtoField(number=1)]
greeting_count: Annotated[int, ProtoField(number=2)]
ProtoField(number)
dataclass
¶
Protobuf field number annotation for pydantic model fields.
Used with typing.Annotated to specify the protobuf field number
for a pydantic BaseModel field, enabling code-first protobuf
message definition. The annotation is read at runtime from the
model's model_fields[name].metadata tuple.
Attributes:
| Name | Type | Description |
|---|---|---|
number |
int
|
The protobuf field number. Must be a positive integer. |
number
instance-attribute
¶
The protobuf field number.
Handler¶
Generic RPC handler for code-first gRPC service dispatch.
Routes incoming gRPC calls to @GrpcController methods by matching
the fully-qualified method name, performing protobuf ↔ pydantic
BaseModel conversion via the google.protobuf.json_format
bridge.
GrpcServiceHandler(*, controller_type, package, service_name, container, application_context, registry)
¶
Bases: GenericRpcHandler
Generic handler dispatching gRPC calls to @GrpcController methods.
For each @rpc-decorated method, builds a grpc.RpcMethodHandler
with serialiser/deserialiser that convert between protobuf wire
format and pydantic BaseModel instances.
Attributes:
| Name | Type | Description |
|---|---|---|
_full_service_name |
str
|
Fully-qualified |
_controller_type |
type
|
The |
_container |
IContainer
|
IoC container for obtaining fresh controller instances. |
_application_context |
IApplicationContext
|
Application context for request-scoped isolation. |
_registry |
DescriptorRegistry
|
Descriptor registry for message class lookup. |
_handlers |
dict[str, RpcMethodHandler]
|
Pre-built map of |
Initialise the handler and pre-build per-method dispatchers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_type
|
type
|
The |
required |
package
|
str
|
Protobuf package name. |
required |
service_name
|
str
|
gRPC service name. |
required |
container
|
IContainer
|
IoC container for obtaining controller instances. |
required |
application_context
|
IApplicationContext
|
Application context for request isolation. |
required |
registry
|
DescriptorRegistry
|
Descriptor registry for message class lookup. |
required |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/handler.py
service(handler_call_details)
¶
Resolve an RPC method handler for the incoming call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler_call_details
|
HandlerCallDetails
|
Describes the incoming RPC. |
required |
Returns:
| Type | Description |
|---|---|
RpcMethodHandler | None
|
The matched handler, or |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/handler.py
서버 명세¶
Deferred gRPC server configuration.
grpc.aio.server() binds to the current event loop at creation time, so
the real server must be instantiated on the event loop that eventually
runs it. :class:GrpcServerSpec collects everything needed to build the
server (interceptors, generic handlers, bind addresses) during
post-processing, and :class:GrpcServerService materialises it at
start_async time on the correct loop.
GrpcServerSpec()
¶
Configuration collected during post-processing for deferred server creation.
Attributes:
| Name | Type | Description |
|---|---|---|
handlers |
list[GenericRpcHandler]
|
Generic RPC handlers to register on the server. |
interceptors |
list[ServerInterceptor]
|
Server interceptors to apply at creation time. |
bind_addresses |
list[str]
|
|
bound_ports |
list[int]
|
Ports returned by |
Initialise an empty spec.
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/server_spec.py
add_handler(handler)
¶
Register a generic RPC handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler
|
GenericRpcHandler
|
The handler to add to the server. |
required |
add_interceptor(interceptor)
¶
Register a server interceptor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interceptor
|
ServerInterceptor
|
The interceptor to install on the server. |
required |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/server_spec.py
add_insecure_port(address)
¶
Register an insecure bind address.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address
|
str
|
Address in |
required |
build()
¶
Instantiate the underlying grpc.aio.Server on the current loop.
Must be called from the event loop that will run the server; see the module docstring for the rationale.
Returns:
| Type | Description |
|---|---|
Server
|
The fully-configured server ready for |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/server_spec.py
스키마¶
Registry¶
Descriptor pool registry for compiled protobuf descriptors.
Manages FileDescriptorProto registration in a descriptor_pool, provides caching, and returns compiled message classes and service descriptors.
DescriptorRegistry(pool=None)
¶
Registry for protobuf descriptors backed by a DescriptorPool.
Registers FileDescriptorProto instances, prevents duplicates, and provides access to compiled message classes and service descriptors.
Attributes:
| Name | Type | Description |
|---|---|---|
pool |
DescriptorPool
|
The underlying DescriptorPool. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/registry.py
register(file_proto)
¶
Register a FileDescriptorProto in the pool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_proto
|
FileDescriptorProto
|
The file descriptor proto to register. |
required |
Returns:
| Type | Description |
|---|---|
FileDescriptor
|
The compiled FileDescriptor. |
Raises:
| Type | Description |
|---|---|
DescriptorAlreadyRegisteredError
|
If the file is already registered. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/registry.py
is_registered(file_name)
¶
Check if a file is already registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
str
|
The proto file name. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the file has been registered. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/registry.py
find_message_descriptor(full_name)
¶
Find a message descriptor by its fully-qualified name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_name
|
str
|
The fully-qualified protobuf message name
(e.g. |
required |
Returns:
| Type | Description |
|---|---|
Descriptor
|
The message Descriptor. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/registry.py
get_message_class(full_name)
¶
Get a runtime message class for the given type name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_name
|
str
|
The fully-qualified protobuf message name. |
required |
Returns:
| Type | Description |
|---|---|
type[Message]
|
A Message subclass that can be instantiated. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/registry.py
find_service_descriptor(full_name)
¶
Find a service descriptor by its fully-qualified name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_name
|
str
|
The fully-qualified protobuf service name
(e.g. |
required |
Returns:
| Type | Description |
|---|---|
ServiceDescriptor
|
The ServiceDescriptor. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/registry.py
Descriptor Builder¶
Pydantic BaseModel to protobuf FileDescriptorProto builder.
Converts pydantic BaseModel subclasses with ProtoField metadata
and @rpc-decorated controller methods into protobuf
FileDescriptorProto instances.
build_message_descriptor(model_type, collected=None)
¶
Build a DescriptorProto from a pydantic BaseModel subclass.
Recursively processes nested BaseModel fields into nested message
descriptors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_type
|
type[BaseModel]
|
The |
required |
collected
|
dict[str, DescriptorProto] | None
|
Accumulator for all message descriptors encountered during recursive processing. Used internally. |
None
|
Returns:
| Type | Description |
|---|---|
DescriptorProto
|
A tuple of (root |
dict[str, DescriptorProto]
|
descriptors). |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/descriptor_builder.py
build_service_descriptor(controller_type, package, service_name, collected)
¶
Build a ServiceDescriptorProto from an @GrpcController class.
Inspects all @rpc-decorated methods on the controller and generates
method descriptors with fully-qualified type names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_type
|
type
|
The controller class to inspect. |
required |
package
|
str
|
The protobuf package name. |
required |
service_name
|
str
|
The gRPC service name. |
required |
collected
|
dict[str, DescriptorProto]
|
Accumulator for message descriptors found in method signatures. |
required |
Returns:
| Type | Description |
|---|---|
ServiceDescriptorProto
|
A |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/descriptor_builder.py
build_file_descriptor(controller_type)
¶
Build a complete FileDescriptorProto from an @GrpcController class.
Generates all message descriptors referenced by @rpc methods and
the service descriptor, packaged into a single FileDescriptorProto.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_type
|
type
|
The |
required |
Returns:
| Type | Description |
|---|---|
FileDescriptorProto
|
A |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/descriptor_builder.py
타입 맵¶
Python type to protobuf type mapping.
Maps Python built-in types and composite types (list, Optional,
nested BaseModel) to their protobuf FieldDescriptorProto
equivalents. Field-number metadata is extracted from pydantic
BaseModel.model_fields[name].metadata entries carrying a
:class:ProtoField instance.
PYTHON_TO_PROTO_TYPE = {str: FieldDescriptorProto.TYPE_STRING, int: FieldDescriptorProto.TYPE_INT64, float: FieldDescriptorProto.TYPE_DOUBLE, bool: FieldDescriptorProto.TYPE_BOOL, bytes: FieldDescriptorProto.TYPE_BYTES}
module-attribute
¶
Mapping of Python primitive types to protobuf field type constants.
ResolvedFieldType(proto_type, *, is_repeated=False, is_optional=False, is_message=False, message_type=None)
¶
Result of resolving a Python type annotation to protobuf metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
proto_type |
Protobuf field type constant from |
|
is_repeated |
Whether the field is a repeated (list) field. |
|
is_optional |
Whether the field is optional. |
|
is_message |
Whether the field references a nested message type. |
|
message_type |
The nested |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/type_map.py
resolve_type(annotation)
¶
Resolve a Python type annotation to protobuf field metadata.
Handles:
- Primitive types (str, int, float, bool, bytes)
- list[T] → repeated field
- Optional[T] (T | None) → optional field
- Nested BaseModel → message type
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
annotation
|
object
|
The Python type annotation to resolve. |
required |
Returns:
| Type | Description |
|---|---|
ResolvedFieldType
|
A ResolvedFieldType with protobuf mapping information. |
Raises:
| Type | Description |
|---|---|
UnsupportedFieldTypeError
|
If the type cannot be mapped. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/type_map.py
extract_proto_field(model_type, field_name)
¶
Extract the ProtoField metadata from a pydantic model field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_type
|
type[BaseModel]
|
The |
required |
field_name
|
str
|
The name of the field. |
required |
Returns:
| Type | Description |
|---|---|
ProtoField
|
The |
Raises:
| Type | Description |
|---|---|
MissingProtoFieldAnnotationError
|
If the field is absent or
carries no |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/schema/type_map.py
인터셉터¶
Tracing interceptor for W3C Trace Context propagation over gRPC.
Extracts trace context from incoming gRPC metadata, activates a child span for the RPC lifetime, and injects trace context into trailing metadata.
TracingInterceptor(*, propagator)
¶
Bases: ServerInterceptor
Interceptor that propagates W3C Trace Context across gRPC boundaries.
Extracts traceparent / tracestate from incoming request
metadata, activates a child span for the RPC lifetime, and injects
the current trace context into trailing metadata.
Initialize the tracing interceptor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
propagator
|
ITracePropagator
|
Trace context propagator for extract/inject. |
required |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/interceptors/tracing.py
intercept_service(continuation, handler_call_details)
async
¶
Intercept an RPC and set up W3C Trace Context.
Extracts trace context from incoming metadata, creates a child span (or a new root when no parent exists), and wraps the handler to inject trace context into trailing metadata and clear it after completion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
continuation
|
Callable[[HandlerCallDetails], Awaitable[RpcMethodHandler]]
|
Calls the next interceptor or resolves the handler. |
required |
handler_call_details
|
HandlerCallDetails
|
Describes the incoming RPC. |
required |
Returns:
| Type | Description |
|---|---|
RpcMethodHandler
|
A handler with trace-context lifecycle wrappers. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/interceptors/tracing.py
Error handling interceptor for gRPC servers.
Catches domain exceptions and maps them to appropriate gRPC status codes.
Unexpected exceptions are logged and returned as INTERNAL status.
ErrorHandlingInterceptor(*, debug=False)
¶
Bases: ServerInterceptor
Interceptor that converts exceptions to gRPC status codes.
AbstractGrpcStatusError subclasses are mapped to their declared
status_code. All other exceptions become INTERNAL.
Attributes:
| Name | Type | Description |
|---|---|---|
__debug |
bool
|
When True, include tracebacks in error details. |
Initialize the error handling interceptor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
debug
|
bool
|
Whether to include full tracebacks in error details. |
False
|
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/interceptors/error_handling.py
intercept_service(continuation, handler_call_details)
async
¶
Intercept an RPC and wrap the handler with error handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
continuation
|
Callable[[HandlerCallDetails], Awaitable[RpcMethodHandler]]
|
Calls the next interceptor or resolves the handler. |
required |
handler_call_details
|
HandlerCallDetails
|
Describes the incoming RPC. |
required |
Returns:
| Type | Description |
|---|---|
RpcMethodHandler
|
A handler with error-catching wrappers on its behavior methods. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/interceptors/error_handling.py
후처리기s¶
Post-processor for registering gRPC services from controllers.
Scans @GrpcController-decorated Pods, builds protobuf descriptors
at runtime, and appends generic RPC handlers to the shared
:class:GrpcServerSpec.
RegisterServicesPostProcessor
¶
Bases: IPostProcessor, IContainerAware, IApplicationContextAware
Post-processor that registers gRPC services from controllers.
When a @GrpcController Pod is created, this processor:
- Builds a
FileDescriptorProtofrom the controller's@rpcmethods and dataclass message types. - Registers the descriptor in the shared
DescriptorRegistry. - Creates a
GrpcServiceHandler(generic handler) and appends it to the shared :class:GrpcServerSpec.
Runs at @Order(0) — first in the gRPC post-processor chain.
set_container(container)
¶
Inject the IoC container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
IContainer
|
The IoC container. |
required |
set_application_context(application_context)
¶
Inject the application context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
application_context
|
IApplicationContext
|
The application context. |
required |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/register_services.py
post_process(pod)
¶
Register a gRPC service if pod is a @GrpcController.
Non-controller Pods are returned unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
object
|
The Pod instance to process. |
required |
Returns:
| Type | Description |
|---|---|
object
|
The unmodified Pod. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/register_services.py
Post-processor for recording interceptors on the gRPC server spec.
Adds ErrorHandlingInterceptor and (when the tracing plugin is loaded)
TracingInterceptor to the shared :class:GrpcServerSpec. The actual
grpc.aio.Server is instantiated later, on the event loop that will
run it (see :mod:spakky.plugins.grpc.server_spec).
AddInterceptorsPostProcessor
¶
Bases: IPostProcessor, IContainerAware, IApplicationContextAware
Post-processor that records interceptors on the shared server spec.
Interceptors added (in order):
ErrorHandlingInterceptor— always.TracingInterceptor— only when anITracePropagatoris available in the application context.
Runs at @Order(1) — after service registration.
set_container(container)
¶
Inject the IoC container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
IContainer
|
The IoC container. |
required |
set_application_context(application_context)
¶
Inject the application context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
application_context
|
IApplicationContext
|
The application context. |
required |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/add_interceptors.py
post_process(pod)
¶
Record interceptors on the server spec once per spec instance.
The spec is resolved lazily so that interceptor registration runs
exactly once: the first time a GrpcServerSpec Pod is seen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
object
|
The Pod instance to process. |
required |
Returns:
| Type | Description |
|---|---|
object
|
The pod unchanged. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/add_interceptors.py
Post-processor for binding gRPC server lifecycle.
Wires a :class:GrpcServerSpec Pod into the ApplicationContext so
that the underlying grpc.aio.Server is materialised on the context's
event loop and started/stopped alongside the application.
GRACEFUL_SHUTDOWN_SECONDS = 5.0
module-attribute
¶
Default grace period (seconds) for server shutdown.
GrpcServerService(spec)
¶
Bases: IAsyncService
Async service wrapper that instantiates the gRPC server on the right loop.
grpc.aio.server() binds to whatever event loop is running when it
is called, so the real server is created inside :meth:start_async
from the captured :class:GrpcServerSpec.
Attributes:
| Name | Type | Description |
|---|---|---|
_spec |
GrpcServerSpec
|
Configuration collected during post-processing. |
_server |
Server | None
|
The materialised server, set once :meth: |
_stop_event |
Event
|
Async event passed by the application context; unused
internally because shutdown is driven by :meth: |
Initialise the service with a server spec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
GrpcServerSpec
|
Collected server configuration. |
required |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/bind_server.py
set_stop_event(stop_event)
¶
Store the async stop event from the application context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stop_event
|
Event
|
Async event forwarded by the application context. |
required |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/bind_server.py
start_async()
async
¶
Build the gRPC server on the current loop and start it.
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/bind_server.py
stop_async()
async
¶
Gracefully stop the gRPC server if it was started.
Clears _server after a successful stop so that repeated
stop_async calls are safe no-ops.
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/bind_server.py
BindServerPostProcessor
¶
Bases: IPostProcessor, IContainerAware, IApplicationContextAware
Post-processor that binds a :class:GrpcServerSpec to the ApplicationContext.
Wraps the spec in a :class:GrpcServerService and registers it with
the ApplicationContext for automatic start/stop management.
Runs at @Order(2) — last in the gRPC post-processor chain.
set_container(container)
¶
Inject the IoC container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
IContainer
|
The IoC container. |
required |
set_application_context(application_context)
¶
Inject the application context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
application_context
|
IApplicationContext
|
The application context. |
required |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/bind_server.py
post_process(pod)
¶
Bind server lifecycle if pod is a GrpcServerSpec.
Non-spec Pods are returned unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
object
|
The Pod instance to process. |
required |
Returns:
| Type | Description |
|---|---|
object
|
The unmodified spec Pod. |
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/post_processors/bind_server.py
에러¶
gRPC plugin error hierarchy.
Provides base error classes, gRPC status-mapped errors, and schema errors.
AbstractSpakkyGrpcError
¶
Bases: AbstractSpakkyFrameworkError, ABC
Base exception for all Spakky gRPC errors.
AbstractGrpcStatusError
¶
Bases: AbstractSpakkyGrpcError, ABC
Base for gRPC errors that map to a specific status code.
Subclasses must define status_code to specify which gRPC status
code the error maps to.
InvalidArgument
¶
NotFound
¶
AlreadyExists
¶
PermissionDenied
¶
Unauthenticated
¶
FailedPrecondition
¶
Unavailable
¶
InternalError
¶
UnsupportedFieldTypeError(field_type)
¶
Bases: AbstractSpakkyGrpcError
Raised when a Python type cannot be mapped to a protobuf type.
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/error.py
MissingProtoFieldAnnotationError(model_type, field_name)
¶
Bases: AbstractSpakkyGrpcError
Raised when a BaseModel field lacks a ProtoField annotation.
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/error.py
UnsupportedResponseTypeError(value_type)
¶
Bases: AbstractSpakkyGrpcError
Raised when a serializer receives an object it cannot encode.
The gRPC response serializer accepts either a protobuf Message
(passed through verbatim) or a pydantic BaseModel (encoded via
the json_format bridge). Any other type signals a controller
returned an unsupported value.
Source code in plugins/spakky-grpc/src/spakky/plugins/grpc/error.py
DescriptorAlreadyRegisteredError(file_name)
¶
Bases: AbstractSpakkyGrpcError
Raised when a FileDescriptorProto is registered more than once.