@azu12138/center-registry
v0.2.0
Published
Center Registry gRPC lifecycle SDK
Readme
@azu12138/center-registry
Publicly downloadable, UNLICENSED Node.js and Bun SDK for registering a service with Wanxiang Xiaoer Center over the existing xiaoming.center.v1.CenterRegistry gRPC contract.
Install
Install the exact public npm version without a registry credential:
npm install @azu12138/[email protected]Center registration credentials are runtime service values and are never npm package credentials.
Register a service
import { createCenterRegistration } from "@azu12138/center-registry";
const registration = createCenterRegistration({
connection: {
target: process.env.CENTER_REGISTRY_ADDRESS!,
serviceToken: process.env.CENTER_REGISTRY_SERVICE_TOKEN!,
signingSecret: process.env.CENTER_REGISTRY_SIGNING_SECRET!,
requestTimeoutMs: 5_000,
},
service: {
serviceId: "runtime:runtime-001",
serviceCode: "xiaoming-runtime",
serviceType: "runtime",
environment: "production",
instanceId: "runtime-001",
runtimeId: "runtime-001",
host: "xiaoming-runtime",
version: "1.0.0",
endpoints: [
{
name: "voice-websocket",
protocol: "ws",
host: "xiaoming-runtime",
port: 18_003,
path: "/internal/voice/ws",
},
],
capabilities: ["chat", "voice"],
metadata: {},
ttlMs: 60_000,
maxConnections: 100,
},
lifecycle: {
heartbeatIntervalMs: 30_000,
retryIntervalMs: 5_000,
getActiveConnections: () => voiceEngine.activeConnectionCount,
},
onStateChange: (snapshot) => runtimeHealth.updateCenter(snapshot),
});
await registration.start();
// During ordered shutdown, stop new work before deregistering.
await registration.stop();start() and stop() are idempotent. A missing or expired instance triggers a complete re-registration. Authentication, signature, configuration, and protocol failures are not retried; transient transport failures are retried while state remains degraded.
Subpath exports
@azu12138/center-registry: lifecycle API and sanitized error types.@azu12138/center-registry/grpc: raw gRPC transport and packaged protobuf loader.@azu12138/center-registry/signature: Center-owned signature constants and helpers.@azu12138/center-registry/contract: runtime DTOs and protocol constants.
The package supports ESM and CommonJS on Node.js 20 or newer and Bun 1.3.14 or newer.
