diff --git a/CHANGELOG.md b/CHANGELOG.md index b6ebdb6..cef4928 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,19 @@ raised `@imqueue/core` floor is how most fixes in the transport reach a service. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- **A service served in process.** `local: true` on a service registers it, + once started, with every client in its own process, and those clients call + it directly — the same checks, hooks and method, with no trip through the + queue. The request and the answer are each copied through JSON, as the queue + copies them, so values arrive exactly as they would have. The queue is still + served, so other processes, delayed calls and `publish()` are unaffected. A + client's `local: false` keeps it on the queue. `localService()`, + `localServiceNames()` and `wireCopy()` are exported for a host. + ## [3.10.0] - 2026-11-12 ### Added diff --git a/README.md b/README.md index 29da33c..22275a4 100644 --- a/README.md +++ b/README.md @@ -330,6 +330,58 @@ Delivery remains **at-least-once** either way. A drain narrows the window in which in-flight work is lost; `SIGKILL`, an OOM kill or a lost node still take it, so handlers must stay idempotent. +## Serving a service in process + +A service may also run inside the process of its caller. Start it with +`local: true` and every client in that process calls it directly, through the +same `@expose()`d methods and the same generated client, with no trip through +the queue: + +~~~typescript +const service = new UserService({ local: true }); + +await service.start(); + +const client = new userService.UserClient(); + +await client.start(); +await client.get('42'); // answered in this process +~~~ + +Which services share a process is a deployment choice: nothing in the service +or the client changes, and the same service runs standalone where `local` is +off. + +What stays the same: + +- **The queue is still served.** A client in another process, a call made with + an `IMQDelay` (the queue holds it until it is due) and `publish()` work as + before. +- **Values travel as the queue carries them.** The request and the answer are + each copied through JSON, so a `Date` arrives as its ISO string, a class + instance as a plain object, `undefined` properties are dropped and + `undefined` array items become `null`, and neither side can change an object + the other holds. +- **Errors are the same plain `{ code, message, … }` objects**, hooks run as + they do (`beforeCall`, `wrapCall` and `afterCall` on both sides), `callTimeout` + applies, and `callTiming()` splits the call, its `transit` now being the two + copies and the wait for the event loop. + +What differs: + +- An answer that cannot be written as JSON (a `BigInt`, a cycle) rejects at once + with `IMQ_RPC_CALL_ERROR`, where through the queue the service failed to send + it and the call timed out. +- A service served in process belongs to its host: it installs no signal + handlers, does not drain, starts no metrics server and cannot fork workers + (`multiProcess`). Destroy it from the host's own shutdown. +- A client with `local: false` sends every call through the queue regardless. + +The service and the client need not share one copy of this package — a host +that loads a service from its own directory loads that service's own +`@imqueue/rpc` beside its own — so long as both are 3.11 or later. +`localServiceNames()` lists what a process serves itself. + ## Notes For image containers builds assign machine UUID in `/etc/machine-id` and diff --git a/src/IMQClient.ts b/src/IMQClient.ts index 7a9f5b0..220d7f1 100644 --- a/src/IMQClient.ts +++ b/src/IMQClient.ts @@ -54,6 +54,7 @@ import { removeTrackedSignalHandler, isProcessDrainEnabled, } from './helpers/index.js'; +import { type IMQLocalService, localService, wireCopy } from './IMQLocal.js'; import { EventEmitter } from 'node:events'; import { Script } from 'node:vm'; import { spawnSync } from 'node:child_process'; @@ -368,6 +369,14 @@ export abstract class IMQClient extends EventEmitter { } const callTimeout = this.options.callTimeout; + const local = + !delayed && this.options.local !== false + ? localService(to) + : undefined; + + if (local) { + return this.localCall(local, request, callTimeout); + } return new Promise((resolve, reject) => { let timer: NodeJS.Timeout | null = null; @@ -431,6 +440,127 @@ export abstract class IMQClient extends EventEmitter { }) as Promise; } + /** + * Calls a service this process serves itself, as {@link remoteCall} would + * through the queue. + * + * @param local - the service's in-process endpoint + * @param request - the request, after `beforeCall` ran + * @param callTimeout - as {@link IMQClientOptions.callTimeout} + * + * @remarks + * The request and the answer are each copied through JSON, as the queue + * copies them, so neither side holds an object of the other's and the + * values arrive as they would have. Where the queue would have failed + * silently and left the call to time out — an answer that cannot be + * written as JSON — this rejects at once with `IMQ_RPC_CALL_ERROR`. + */ + private localCall( + local: IMQLocalService, + request: IMQRPCRequest, + callTimeout?: number, + ): Promise { + const { method, args } = request; + const to = this.serviceName; + + return new Promise((resolve, reject) => { + let timer: NodeJS.Timeout | null = null; + let settled = false; + const settle = + (done: (value: V) => void) => + (value: V): void => { + settled = true; + + if (timer) { + clearTimeout(timer); + timer = null; + } + + done(value); + }; + const doResolve = settle(resolve); + const doReject = settle(reject); + + if (callTimeout && callTimeout > 0) { + timer = setTimeout(() => { + doReject( + IMQError( + 'IMQ_RPC_CALL_TIMEOUT', + `Call to ${to}.${method}() timed out after ${ + callTimeout + } ms.`, + new Error().stack, + method, + args, + ), + ); + }, callTimeout); + timer.unref?.(); + } + + void (async () => { + try { + request.sentAt = Date.now(); + + const answered = await local.call(wireCopy(request)); + let response: IMQRPCResponse; + + try { + response = { + ...answered, + ...wireCopy({ + data: answered.data, + error: answered.error, + }), + }; + } catch (err: any) { + response = { + ...answered, + data: null, + error: IMQError( + 'IMQ_RPC_CALL_ERROR', + `${to}.${method}() answered with a value ` + + `that cannot be sent: ${err?.message}`, + err?.stack, + method, + args, + ), + }; + } + + if (settled) { + logSafe( + this.logger, + 'warn', + `${to}: in-process answer to ${method}() came ` + + 'after the call had timed out', + ); + + return; + } + + if (response.error) { + return imqCallRejector( + doReject, + request, + this, + )(response.error, response); + } + + imqCallResolver( + doResolve, + request, + this, + )(response.data, response); + } catch (err) { + if (!settled) { + imqCallRejector(doReject, request, this)(err); + } + } + })(); + }); + } + /** * Subscribes to the service's event channel, named after * {@link IMQClient.serviceName} — the same channel a service's `publish()` diff --git a/src/IMQLocal.ts b/src/IMQLocal.ts new file mode 100644 index 0000000..448504d --- /dev/null +++ b/src/IMQLocal.ts @@ -0,0 +1,121 @@ +/*! + * IMQLocal implementation + * + * I'm Queue Software Project + * Copyright (C) 2025 imqueue.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * If you want to use this code in a closed source (commercial) project, you can + * purchase a proprietary commercial license. Please contact us at + * to get commercial licensing options. + */ +import type { IMQRPCRequest } from './IMQRPCRequest.js'; +import type { IMQRPCResponse } from './IMQRPCResponse.js'; + +/** + * A service this process serves itself, as a client in the same process + * reaches it. + * + * @remarks + * Registered by a service started with {@link IMQServiceOptions.local}, and + * found by name by every client in the process. The contract is this object + * and nothing else, because the service and its client need not share one + * copy of this package: a host that loads a service from its own directory + * loads that service's own `@imqueue/rpc` beside the host's, and both see one + * registry. + */ +export interface IMQLocalService { + /** + * The service name, which is also its queue name. + */ + readonly name: string; + /** + * Answers one request as the service would through its queue. + * + * @param request - the request as it would arrive off the queue: already + * a copy the caller no longer holds + * @returns the response the service would have sent, before it is copied + * back to the caller + */ + call(request: IMQRPCRequest): Promise; +} + +const registry = (() => { + const anchor = globalThis as unknown as Record< + symbol, + Map | undefined + >; + const symbol = Symbol.for('@imqueue/rpc:IMQ_LOCAL_SERVICES'); + + return (anchor[symbol] ??= new Map()); +})(); + +/** + * Makes a service reachable in process under its name. + * + * @param service - the service's local endpoint + * + * @remarks + * A second service under the same name replaces the first, so that a service + * started again after it was destroyed is the one called. + */ +export function registerLocalService(service: IMQLocalService): void { + registry.set(service.name, service); +} + +/** + * Stops reaching a service in process. Its clients go back to the queue. + * + * @param service - the endpoint that was registered; another one registered + * since under the same name is left in place + */ +export function unregisterLocalService(service: IMQLocalService): void { + if (registry.get(service.name) === service) { + registry.delete(service.name); + } +} + +/** + * The service this process serves under the given name, if it serves one. + * + * @param name - the service (queue) name + */ +export function localService(name: string): IMQLocalService | undefined { + return registry.get(name); +} + +/** + * The name of every service this process serves itself, sorted. + */ +export function localServiceNames(): string[] { + return [...registry.keys()].sort(); +} + +/** + * Copies a value the way the queue does: through JSON and back. + * + * @param value - an object to copy + * @returns the copy, which shares nothing with the value + * + * @remarks + * This is what keeps an in-process call's semantics those of a queued one: a + * `Date` arrives as its ISO string, a class instance as a plain object, + * `undefined` properties are gone and `undefined` array items are `null`, and + * neither side can change an object the other still holds. It throws where + * the queue would fail to send, on a `BigInt` or a cycle. + */ +export function wireCopy(value: T): T { + return JSON.parse(JSON.stringify(value)); +} diff --git a/src/IMQRPCOptions.ts b/src/IMQRPCOptions.ts index 19c025a..0157032 100644 --- a/src/IMQRPCOptions.ts +++ b/src/IMQRPCOptions.ts @@ -240,6 +240,26 @@ export interface IMQServiceOptions extends IMQOptions { * abandoned, logged, and the process exits `0` regardless. */ drainTimeout?: number; + /** + * Serve this service in process as well: a client in the same process + * calls it directly, with no trip through the queue. + * + * @defaultValue false + * + * @remarks + * The queue is still served, so a client in another process, a delayed + * call and `publish()` work as before, and turning this off again changes + * nothing a caller sees. An in-process call copies its request and its + * answer through JSON exactly as the queue does, so dates, class instances + * and `undefined` arrive as they would have; see {@link wireCopy}. + * + * A service served in process belongs to the process that hosts it: it + * installs no signal handlers and does not drain (the host's shutdown + * decides when it is destroyed), its queue installs none either, and it + * starts no metrics server. It cannot be combined with + * {@link IMQServiceOptions.multiProcess}. + */ + local?: boolean; } /** @@ -333,6 +353,20 @@ export interface IMQClientOptions extends IMQOptions { * Use it to bound Redis connections when a process instantiates many clients. */ singleQueue?: boolean; + /** + * Call a service this process serves itself directly, rather than through + * the queue. + * + * @defaultValue true + * + * @remarks + * It matters only where a service in the same process was started with + * {@link IMQServiceOptions.local}; otherwise every call goes through the + * queue regardless. `false` sends every call through the queue. A call + * made with an {@link IMQDelay} always goes through the queue, which is + * what holds it until it is due. + */ + local?: boolean; } /** diff --git a/src/IMQService.ts b/src/IMQService.ts index 4e3a2dc..71cc0d6 100644 --- a/src/IMQService.ts +++ b/src/IMQService.ts @@ -64,7 +64,13 @@ import { type IMQWrapCall, } from './IMQRPCOptions.js'; import { runWithRequest } from './IMQRequestContext.js'; +import { + type IMQLocalService, + registerLocalService, + unregisterLocalService, +} from './IMQLocal.js'; import { createServer, type Server } from 'node:http'; +import { randomUUID } from 'node:crypto'; /** * The self-description a service serves to its clients, and the input to client @@ -233,6 +239,11 @@ export abstract class IMQService { * the first and force an immediate exit. */ private draining = false; + /** + * How a client in this process reaches this service, present only with + * {@link IMQServiceOptions.local} on, and registered while it serves. + */ + private readonly localEndpoint?: IMQLocalService; /** * This service's name, which is also its queue name and the key its description @@ -297,6 +308,25 @@ export abstract class IMQService { }, }; this.logger = this.options.logger || /* istanbul ignore next */ console; + + if (this.options.local) { + if (this.options.multiProcess) { + throw new TypeError( + `${this.name}: a service served in process cannot ` + + 'also fork workers (local with multiProcess)', + ); + } + + // the host owns this process's shutdown, so neither this service + // nor its queue may exit it from a signal of their own + this.options.handleSignals = false; + this.options.drain = false; + this.localEndpoint = { + name: this.name, + call: request => this.answerLocally(request), + }; + } + this.drainEnabled = this.options.drain ?? drainEnabledFromEnv(); this.drainTimeout = this.options.drainTimeout ?? drainTimeoutFromEnv(); @@ -315,7 +345,7 @@ export abstract class IMQService { this.handleRequest = this.handleRequest.bind(this); - SIGNALS.forEach((signal: string) => { + (this.localEndpoint ? [] : SIGNALS).forEach((signal: string) => { if (this.drainEnabled && DRAIN_SIGNALS.includes(signal)) { const handler = (): void => { // a drain that throws must not leave the process hanging @@ -533,6 +563,36 @@ export abstract class IMQService { id: string, received: number, ): Promise { + const response = await this.respond(request, id, received); + + return await send(request, response, this); + } + + /** + * Answers a request a client in this process made, with no trip through + * the queue: the same checks, hooks and method as a queued request, and + * the response handed back rather than sent. + * + * @param request - the request, already copied the way the queue copies it + */ + private async answerLocally( + request: IMQRPCRequest, + ): Promise { + const received = Date.now(); + const response = await runWithRequest(request, () => + this.respond(request, randomUUID(), received), + ); + + await afterCall(request, response, this); + + return response; + } + + private async respond( + request: IMQRPCRequest, + id: string, + received: number, + ): Promise { const logger = this.options.logger || console; const method = request.method; const description = await this.describe(); @@ -605,7 +665,7 @@ export abstract class IMQService { response.timing = { received, started: now, finished: now }; - return await send(request, response, this); + return response; } const started = Date.now(); @@ -642,7 +702,7 @@ export abstract class IMQService { response.timing = { received, started, finished: Date.now() }; - return await send(request, response, this); + return response; } /** @@ -674,7 +734,19 @@ export abstract class IMQService { this.describe(); - return this.startWithMetricsServer(); + if (!this.localEndpoint) { + return this.startWithMetricsServer(); + } + + // in process the metrics port is the host's, and a second listener + // on it would fail; the queue still starts first, so a method can + // publish from the first in-process call + const started = await this.imq.start(); + + registerLocalService(this.localEndpoint); + this.logger.info('%s: serving in process too', this.name); + + return started; } if (cluster.isMaster) { @@ -761,6 +833,10 @@ export abstract class IMQService { */ @profile() public async destroy(): Promise { + if (this.localEndpoint) { + unregisterLocalService(this.localEndpoint); + } + // unregister this instance's process signal handlers so destroyed // services do not leak process-level listeners for (const [signal, handler] of this.signalHandlers) { @@ -865,20 +941,38 @@ export async function send( response: IMQRPCResponse, service: IMQService, ): Promise { - const logger = service.options.logger || console; const id = await (service as any).imq.send(request.from, response); - if (typeof service.options.afterCall === 'function') { - const afterCall: IMQAfterCall = ( - service.options.afterCall as IMQAfterCall - ).bind(service); + await afterCall(request, response, service); - try { - await afterCall(request, response); - } catch (err: any) { - logger.warn(AFTER_HOOK_ERROR, err); - } + return id; +} + +/** + * Runs the service's optional after-call hook on an answered request, logging + * rather than propagating its failure. + * + * @param request - the request answered + * @param response - the response it was answered with + * @param service - imq service to bind + */ +async function afterCall( + request: IMQRPCRequest, + response: IMQRPCResponse, + service: IMQService, +): Promise { + if (typeof service.options.afterCall !== 'function') { + return; } - return id; + const logger = service.options.logger || console; + const hook: IMQAfterCall = ( + service.options.afterCall as IMQAfterCall + ).bind(service); + + try { + await hook(request, response); + } catch (err: any) { + logger.warn(AFTER_HOOK_ERROR, err); + } } diff --git a/src/index.ts b/src/index.ts index a0afd65..92b344a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,6 +29,7 @@ export * from './IMQRPCError.js'; export * from './IMQRPCRequest.js'; export * from './IMQRPCResponse.js'; export * from './IMQCallTiming.js'; +export * from './IMQLocal.js'; export * from './IMQLock.js'; export * from './IMQService.js'; export * from './IMQClient.js'; diff --git a/test/IMQLocal.spec.ts b/test/IMQLocal.spec.ts new file mode 100644 index 0000000..c0c441f --- /dev/null +++ b/test/IMQLocal.spec.ts @@ -0,0 +1,325 @@ +/*! + * IMQLocal Unit Tests + * + * I'm Queue Software Project + * Copyright (C) 2025 imqueue.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * If you want to use this code in a closed source (commercial) project, you can + * purchase a proprietary commercial license. Please contact us at + * to get commercial licensing options. + */ +import { describe, it, before, after, mock } from 'node:test'; +import assert from 'node:assert/strict'; +import { logger } from './mocks/index.js'; +import { + IMQClient, + IMQService, + IMQDelay, + IMQMetadata, + callTiming, + currentMetadata, + expose, + remote, + localService, + localServiceNames, + wireCopy, +} from '../index.js'; + +class Shelf { + constructor(public readonly label: string) {} +} + +const kept = { items: ['a'] }; +let hang: Promise = Promise.resolve(); + +class LocalShop extends IMQService { + @expose() + public echo(value: any) { + return value; + } + + @expose() + public stamp() { + return { + at: new Date('2026-11-12T10:00:00.000Z'), + shelf: new Shelf('front'), + gone: undefined, + list: [1, undefined, 3], + }; + } + + @expose() + public grab(arg: { touched?: boolean }) { + arg.touched = true; + + return kept; + } + + @expose() + public refuse() { + const error: any = new Error('Not today'); + + error.code = 'SHOP_CLOSED'; + throw error; + } + + @expose() + public whoAsks() { + return currentMetadata()?.['who'] ?? null; + } + + @expose() + public async wait() { + await hang; + + return 'late'; + } + + @expose() + public big() { + return { n: 1n }; + } +} + +class LocalShopClient extends IMQClient { + @remote() + public async echo(value: any, metadata?: IMQMetadata, delay?: IMQDelay) { + return await this.remoteCall(...arguments); + } + + @remote() + public async stamp() { + return await this.remoteCall(...arguments); + } + + @remote() + public async grab(arg: { touched?: boolean }) { + return await this.remoteCall(...arguments); + } + + @remote() + public async refuse() { + return await this.remoteCall(...arguments); + } + + @remote() + public async whoAsks(metadata?: IMQMetadata) { + return await this.remoteCall(...arguments); + } + + @remote() + public async wait() { + return await this.remoteCall(...arguments); + } + + @remote() + public async big() { + return await this.remoteCall(...arguments); + } + + @remote() + public async missing() { + return await this.remoteCall(...arguments); + } +} + +describe('IMQService served in process (local)', () => { + let service: any; + let client: any; + let serviceSend: any; + let clientSend: any; + let signalsAdded = -1; + const answered: any[] = []; + + before(async () => { + const signalsBefore = process.listenerCount('SIGTERM'); + + service = new LocalShop({ logger, local: true }, 'LocalShop'); + signalsAdded = process.listenerCount('SIGTERM') - signalsBefore; + await service.start(); + client = new LocalShopClient( + { + logger, + afterCall: async (request: any, response: any) => { + answered.push(callTiming(request, response)); + }, + }, + 'LocalShop', + ); + await client.start(); + serviceSend = mock.method(service.imq, 'send'); + clientSend = mock.method(client.imq, 'send'); + }); + + after(async () => { + await client.destroy(); + await service.destroy(); + }); + + it('is registered under its name once started', () => { + assert.ok(localService('LocalShop')); + assert.ok(localServiceNames().includes('LocalShop')); + }); + + it('installs no signal handlers of its own', () => { + assert.equal(signalsAdded, 0); + assert.equal(service.options.handleSignals, false); + }); + + it('answers a client in the same process without the queue', async () => { + clientSend.mock.resetCalls(); + serviceSend.mock.resetCalls(); + + assert.equal(await client.echo('hello'), 'hello'); + assert.equal(clientSend.mock.callCount(), 0); + assert.equal(serviceSend.mock.callCount(), 0); + }); + + it('copies values as the queue does', async () => { + const answer = await client.stamp(); + + assert.deepEqual(answer, { + at: '2026-11-12T10:00:00.000Z', + shelf: { label: 'front' }, + list: [1, null, 3], + }); + assert.equal('gone' in answer, false); + }); + + it('shares no object between the two sides', async () => { + const arg: { touched?: boolean } = {}; + const answer = await client.grab(arg); + + assert.equal(arg.touched, undefined); + answer.items.push('b'); + assert.deepEqual(kept.items, ['a']); + }); + + it('rejects with the plain error object the queue delivers', async () => { + await assert.rejects(client.refuse(), (err: any) => { + assert.equal(err instanceof Error, false); + assert.equal(err.code, 'SHOP_CLOSED'); + assert.equal(err.message, 'Not today'); + + return true; + }); + }); + + it('refuses a method the service does not have', async () => { + await assert.rejects(client.missing(), (err: any) => { + assert.equal(err.code, 'IMQ_RPC_NO_METHOD'); + + return true; + }); + }); + + it('carries the metadata to the method', async () => { + assert.equal( + await client.whoAsks(new IMQMetadata({ who: 'Ann' })), + 'Ann', + ); + }); + + it('stamps a timing the caller can split', async () => { + answered.length = 0; + await client.echo(1); + + assert.equal(answered.length, 1); + assert.equal(typeof answered[0].transit, 'number'); + }); + + it('rejects at once an answer that cannot be sent', async () => { + await assert.rejects(client.big(), (err: any) => { + assert.equal(err.code, 'IMQ_RPC_CALL_ERROR'); + + return true; + }); + }); + + it('sends a delayed call through the queue', async () => { + clientSend.mock.resetCalls(); + void client.echo('later', undefined, new IMQDelay(10)); + await new Promise(resolve => setTimeout(resolve, 20)); + + assert.equal(clientSend.mock.callCount(), 1); + }); + + it('goes through the queue for a client that says local: false', async () => { + const queued: any = new LocalShopClient( + { logger, local: false }, + 'LocalShop', + ); + + await queued.start(); + const send = mock.method(queued.imq, 'send'); + + void queued.echo('queued'); + await new Promise(resolve => setTimeout(resolve, 20)); + assert.equal(send.mock.callCount(), 1); + await queued.destroy(); + }); + + it('times out a call that is never answered', async () => { + let release: () => void = () => undefined; + + hang = new Promise(resolve => (release = resolve)); + + const waiting: any = new LocalShopClient( + { logger, callTimeout: 20 }, + 'LocalShop', + ); + + await assert.rejects(waiting.wait(), (err: any) => { + assert.equal(err.code, 'IMQ_RPC_CALL_TIMEOUT'); + + return true; + }); + release(); + await waiting.destroy(); + }); +}); + +describe('IMQService local options', () => { + it('cannot be combined with multiProcess', () => { + assert.throws( + () => new LocalShop({ logger, local: true, multiProcess: true }), + TypeError, + ); + }); + + it('is no longer reached once destroyed', async () => { + const service = new LocalShop({ logger, local: true }, 'Destroyed'); + + await service.start(); + assert.ok(localService('Destroyed')); + await service.destroy(); + assert.equal(localService('Destroyed'), undefined); + }); + + it('is not served in process unless asked', async () => { + const service = new LocalShop({ logger }, 'QueueOnly'); + + await service.start(); + assert.equal(localService('QueueOnly'), undefined); + await service.destroy(); + }); +}); + +describe('wireCopy()', () => { + it('throws where the queue cannot send', () => { + assert.throws(() => wireCopy({ n: 1n })); + }); +});