import type { Service as NATSService, ServiceClient, ServiceConfig, ServiceInfo, ServiceStats } from '@nats-io/services'; import type { NatsConnection } from '@nats-io/transport-node'; import type { RPCClient } from './client.js'; /** * Service metadata: each instance also takes requests on its own subject, * see directSubject(). * * Internal: utils.ts uses it. */ export declare const DIRECT_SUBJECT_METADATA = "cui.chunk.direct"; /** * The subject of one service instance for an endpoint. The header and chunks * of a chunked request go there: a queue group would hand them to different * instances. * * Internal: utils.ts uses it. */ export declare function directSubject(instanceId: string, path: string): string; /** * The endpoint subject only this service has, next to the bare one that two * services with the same method name share. * * Internal: utils.ts uses it. */ export declare function serviceSubject(serviceName: string, path: string): string; /** * RPC Service wrapper with automatic encoding/decoding and streaming support */ export declare class RPCService { private client; private svc?; private services; private nc?; constructor(client: RPCClient); /** * Initialize the service manager. Re-initializes when the underlying * connection changed (suspend()+connect() creates a fresh NatsConnection) — * a Svcm bound to the old, closed connection would break monitor() and * service discovery after every reconnect cycle. */ init(nc: NatsConnection): void; /** * Add a service with automatic RPC endpoint wrapping * Supports objects, classes, nested structures, streaming, callbacks, * pull iterators and chunking. * * Every method is served on its bare endpoint subject, on * svc.., which no other service shares, and for * chunked requests on a subject of this instance alone (announced in the * service metadata). A request is answered on .reply.. */ registerHandler(config: ServiceConfig, handlers: object, options?: { isolatedConnection?: boolean; }): Promise; /** * Get service monitoring client */ monitor(): ServiceClient; /** * Stop all services and cleanup isolated connections */ stopAll(): Promise; /** * Stop a specific service by name */ stop(serviceName: string): Promise; /** * Get all services info */ getAllInfo(): ServiceInfo[]; /** * Get info for a specific service */ getInfo(serviceName: string): ServiceInfo | undefined; /** * Get all services stats */ getAllStats(): Promise; /** * Get stats for a specific service */ getStats(serviceName: string): Promise; } export declare class Service { private natsService; get isStopped(): boolean; constructor(natsService: NATSService); info(): ServiceInfo; stats(): Promise; stop(err?: Error): Promise; }