Skip to main content

hexastack-grpc

hexastack-grpc

High-performance gRPC presentation adapter, interceptors, and CQRS service integration for Hexastack.

PyPI: hexastack-grpc Python 3.13+ Coverage Part of Hexastack Governed by Hexaqual License: Apache 2.0

Part of the Hexastack Framework · Governed by Hexaqual.


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 the grpc.Server with automatic DI resolution.
  • gRPC Health Checking Protocol: Standard grpc.health.v1.Health servicer (GrpcHealthServicer) supporting Kubernetes liveness, readiness, and stream health probes.
  • Bidirectional & Server-Streaming RPC Dispatch: dispatch_rpc_stream_query and dispatch_rpc_bidirectional_stream streaming CQRS command and query pipelines over HTTP/2.
  • Cross-Cutting Interceptor Pipeline:
    • CorrelationServerInterceptor: Propagates x-correlation-id from incoming metadata into ContextVar.
    • LoggingServerInterceptor: Structured telemetry for RPC method invocations.
    • TimingServerInterceptor: Measures RPC execution latency in milliseconds.
    • MetricsServerInterceptor: Records RPC request rates, statuses, and handling durations to MetricsPort.
  • 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-reflection is installed.

2. Package Anatomy & Key Components

hexastack_grpc/
├── domain/          # GrpcError, ServiceRegistrationError, RpcExecutionError
├── adapters/        # create_async_grpc_server, run_grpc_server, GrpcHealthServicer
└── infra/
    ├── bootstrap.py # GrpcBootstrapper (order=40)
    ├── config.py    # HexastackGrpcConfig
    ├── decorators.py# @grpc_service
    ├── dispatch.py  # dispatch_rpc_command, dispatch_rpc_query, dispatch_rpc_stream_query, dispatch_rpc_bidirectional_stream
    ├── 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: CommandBusPort and QueryBusPort.
  • grpcio>=1.68.0, protobuf>=5.29.0.

Optional Integrations (Extras)

  • [reflection]: Installs grpcio-reflection>=1.68.0 for 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()

Metadata

Release files for hexastack-grpc 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hexastack-grpc 0.11.0
File Size Uploaded Provenance Actions
hexastack_grpc-0.11.0.tar.gz 16.5 kB Without provenance Details for hexastack_grpc-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hexastack-grpc 0.11.0
File Interpreter ABI Platform Actions
hexastack_grpc-0.11.0-py3-none-any.whl Python 3 none any Details for hexastack_grpc-0.11.0-py3-none-any.whl

Total release size: 41.1 kB

Release files / hexastack_grpc-0.11.0.tar.gz

Download URL hexastack_grpc-0.11.0.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
041dd6d51ed2839abc7a18de773605ac77ab9b1161c11c0370483156b884d8fa
BLAKE2b-256 checksum
How to use checksums
e8a41a741e70e8d1e496678146cbf997aa0f8133c9150304c5e1c71a66b1912a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / hexastack_grpc-0.11.0-py3-none-any.whl

Download URL hexastack_grpc-0.11.0-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc8007e83ce4d8971df6260abcabe0cf6a00190bcedbee3b69c8500d04f7037a
BLAKE2b-256 checksum
How to use checksums
2c94e750c9ed79ea276136a46b8f68685c9b1cc00c2740e31e67e79204a8f504
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for hexastack-grpc 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page