Skip to content
AdvancedDocs 1.3.x

Creating Custom Protocol Plugins ​

Most applications need only the built-in Health Check and Reflection modules. A custom protocol is an extension point for infrastructure RPCs or plain HTTP endpoints that do not belong in a business service.

Custom protocol initialization and routing A per-server factory separates snapshot-based setup from repeatable router registration, while unmatched HTTP requests pass through explicit handlers to protocol-aware fallback errors. NEW ROUTER FALSE One factory instanceper servername; synchronous setup / registerAdd before start or the first local clientKeep server state in a fresh closure ProtocolContext snapshotservices: mounted service descriptorsregistry: their files + importsApplication + preceding protocols setup(context)Read snapshot; prepare shared stateOnce after successful materializationInitial failure can rerun setup register(router)Only add RPC routesRepeats per HTTP / local routerNo observable side effects HTTP requestRPC routes checked firstThen HTTP fallbacks Unmatched HTTPhttpHandler: /metricstrue handles; false passes Matched RPC routeServerInfo endpointHTTP + local routers Default fallbackUnknown Connect / gRPC / gRPC-Web: unimplementedOther requests: 404 Not Found
Keep setup idempotent because failed initial materialization can retry it. Create a fresh protocol instance per server. Supported RPC content types receive protocol-aware unimplemented errors; other unmatched requests retain 404.

Keep registration repeatable ​

Do not put observable side effects in register(). Create a fresh protocol instance for each server, and add it before startup or the first in-process client materializes routes. If initial materialization fails, setup can run again on the next attempt.

Go deeper ​

Find a section from the full guide

The detailed material is preserved on a separate page. Earlier section links still work here.