hexastack-grpc
High-performance gRPC presentation adapter, interceptors, and CQRS service integration for Hexastack.
1. Overview & Capabilities
hexastack-grpc provides a binary RPC presentation adapter for Hexastack applications:
- Declarative Service Registration (
@grpc_service): Mounts generated protobuf RPC servicers onto thegrpc.Serverwith automatic DI resolution. - Cross-Cutting Interceptor Pipeline:
CorrelationServerInterceptor: Propagatesx-correlation-idfrom incoming metadata intoContextVar.LoggingServerInterceptor: Structured telemetry for RPC method invocations.TimingServerInterceptor: Measures RPC execution latency in milliseconds.
- Single-Pass Reflection: Automatically discovers and registers decorated servicers in Phase 3 module scanning via
create_grpc_visitor. - gRPC Server Reflection: Automatically enables gRPC Server Reflection Protocol when
grpcio-reflectionis installed.
2. Package Anatomy & Key Components
hexastack_grpc/
├── domain/ # GrpcError, ServiceRegistrationError, RpcExecutionError
└── infra/
├── bootstrap.py # GrpcBootstrapper (order=40)
├── config.py # HexastackGrpcConfig
├── decorators.py# @grpc_service
├── autodiscovery.py # create_grpc_visitor, autodiscover_grpc_services
├── interceptors/# correlation, logging, timing interceptors
└── registries/ # service.py (GrpcServiceRegistry)
3. Monorepo & Sibling Relationships
graph TD
subgraph Clients ["gRPC Clients (Microservices, Mobile, Gateway)"]
CLIENT["gRPC Protobuf Client"]
end
subgraph GrpcAdapter ["hexastack-grpc"]
SERVER["grpc.Server"]
INTERCEPTORS["Interceptors (Correlation, Logging, Timing)"]
REG["GrpcServiceRegistry"]
SERVICER["CQRS Protobuf Servicer"]
end
subgraph CQRSExecution ["hexastack-cqrs"]
CBUS["CommandBusPort"]
QBUS["QueryBusPort"]
end
CLIENT --> SERVER
SERVER --> INTERCEPTORS
INTERCEPTORS --> SERVICER
SERVICER -->|dispatches commands| CBUS
SERVICER -->|dispatches queries| QBUS
Explicit Dependencies (Direct)
hexastack-core: DI container (rodi), configuration registry, context variables.hexastack-cqrs:CommandBusPortandQueryBusPort.grpcio>=1.68.0,protobuf>=5.29.0.
Optional Integrations (Extras)
[reflection]: Installsgrpcio-reflection>=1.68.0for runtime service reflection tools (grpcurl, Postman).
4. Installation
# Standalone installation
pip install hexastack-grpc
# With Server Reflection support
pip install "hexastack-grpc[reflection]"
# Via umbrella package
pip install "hexastack[grpc]"
5. Configuration Reference
[hexastack.grpc]
host = "0.0.0.0"
port = 50051
max_workers = 10
enable_reflection = true
auto_start = false
6. Quickstart Example
from hexastack_core.infra.bootstrap import bootstrap
from hexastack_grpc.infra.decorators import grpc_service
# 1. Define Servicer implementing generated protobuf class
class GreeterServicer:
def SayHello(self, request, context):
return HelloReply(message=f"Hello, {request.name}!")
# 2. Register Servicer with generated add hook
@grpc_service(add_GreeterServicer_to_server)
class GreeterService(GreeterServicer):
pass
# 3. Bootstrap Runtime and Start Server
runtime = bootstrap(packages_to_scan=[__name__])
grpc_server = runtime.get("grpc_server")
grpc_server.start()
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hexastack_grpc-0.2.0.tar.gz
(12.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hexastack_grpc-0.2.0.tar.gz.
File metadata
- Download URL: hexastack_grpc-0.2.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43a99cbe59d79258193ece627530bf22832f250a445df7ce252eeca52ac2cb73
|
|
| MD5 |
38f628974cbfa57c9a80f52bc33027a6
|
|
| BLAKE2b-256 |
18be66643891756806ec247144afbb042537d2b0a8150f78cd20988a215374c6
|
File details
Details for the file hexastack_grpc-0.2.0-py3-none-any.whl.
File metadata
- Download URL: hexastack_grpc-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e42c53381c169e7352d086f207427d0c1f25dc22a6b7b56ac8b71ab2393a2540
|
|
| MD5 |
3a70ca11141d88f943e5aa23b27076df
|
|
| BLAKE2b-256 |
3b0442abde9e044b682a3cd7ae58527ddbb836c5f6b7a91a8855828fcec67023
|