network-services
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,5 +0,5 @@ | ||
export interface IIdentifierGenerator { | ||
export interface IdentifierGenerator { | ||
getIdentifier(): string; | ||
} | ||
export declare class NumericIdentifierGenerator implements IIdentifierGenerator { | ||
export declare class NumericIdentifierGenerator implements IdentifierGenerator { | ||
id: number; | ||
@@ -6,0 +6,0 @@ constructor(); |
@@ -7,2 +7,3 @@ import { createService, Service } from "./service"; | ||
import { CallMessage, ResultMessage } from "./messages"; | ||
export { createService, Service, ServiceApp, ServiceAPI, Async, CallMessage, ResultMessage, CallTimeoutError, InstantiationError, QueueSizeLimitError, NotImplementedError, PropertyPathError, StreamClosedError, }; | ||
import { IdentifierGenerator, NumericIdentifierGenerator } from "./identifier_generator"; | ||
export { createService, Service, ServiceApp, ServiceAPI, Async, IdentifierGenerator, NumericIdentifierGenerator, CallMessage, ResultMessage, CallTimeoutError, InstantiationError, QueueSizeLimitError, NotImplementedError, PropertyPathError, StreamClosedError, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StreamClosedError = exports.PropertyPathError = exports.NotImplementedError = exports.QueueSizeLimitError = exports.InstantiationError = exports.CallTimeoutError = exports.ResultMessage = exports.CallMessage = exports.ServiceAPI = exports.ServiceApp = exports.Service = exports.createService = void 0; | ||
exports.StreamClosedError = exports.PropertyPathError = exports.NotImplementedError = exports.QueueSizeLimitError = exports.InstantiationError = exports.CallTimeoutError = exports.ResultMessage = exports.CallMessage = exports.NumericIdentifierGenerator = exports.ServiceAPI = exports.ServiceApp = exports.Service = exports.createService = void 0; | ||
const service_1 = require("./service"); | ||
@@ -21,1 +21,3 @@ Object.defineProperty(exports, "createService", { enumerable: true, get: function () { return service_1.createService; } }); | ||
Object.defineProperty(exports, "ResultMessage", { enumerable: true, get: function () { return messages_1.ResultMessage; } }); | ||
const identifier_generator_1 = require("./identifier_generator"); | ||
Object.defineProperty(exports, "NumericIdentifierGenerator", { enumerable: true, get: function () { return identifier_generator_1.NumericIdentifierGenerator; } }); |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import { ObjectMux } from "./object_mux"; | ||
import { IIdentifierGenerator } from "./identifier_generator"; | ||
import { IdentifierGenerator } from "./identifier_generator"; | ||
export interface CallOptions { | ||
@@ -22,3 +22,3 @@ id: string; | ||
timeout?: number; | ||
identifierGenerator: IIdentifierGenerator; | ||
identifierGenerator: IdentifierGenerator; | ||
} | ||
@@ -28,3 +28,3 @@ export declare class ServiceAPI { | ||
mux: BufferMux | ObjectMux; | ||
identifierGenerator: IIdentifierGenerator; | ||
identifierGenerator: IdentifierGenerator; | ||
timeout?: number; | ||
@@ -31,0 +31,0 @@ egressBufferLimit?: number; |
@@ -10,3 +10,3 @@ /// <reference types="node" /> | ||
import { ObjectMux } from './object_mux'; | ||
import { IIdentifierGenerator } from './identifier_generator'; | ||
import { IdentifierGenerator } from './identifier_generator'; | ||
export interface ServiceOptions { | ||
@@ -17,3 +17,3 @@ ingressQueueSizeLimit?: number; | ||
deserializeMessage?: (data: Buffer) => ResultMessage | CallMessage; | ||
identifierGenerator?: IIdentifierGenerator; | ||
identifierGenerator?: IdentifierGenerator; | ||
} | ||
@@ -20,0 +20,0 @@ export declare class Service { |
{ | ||
"name": "network-services", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -9,3 +9,3 @@ # Network⬄Services | ||
 | ||
 | ||
### Features | ||
@@ -117,4 +117,5 @@ - A type-safe API facility: *code completion*, *parameter types*, and *return types*. | ||
- `egressQueueSizeLimit` `<number>` An optional egress buffer size limit in bytes. This argument specifies the limit on buffered data that may accumulate from calls *to* the remote Service App and return values *to* the remote Service API. If the size of the egress buffer exceeds this value, a `QueueSizeLimitError` will be thrown and the stream will close. **Default:** `undefined` (i.e., no limit). | ||
- `serializeMessage` `<(message: ResultMessage | CallMessage) => Buffer>` An optional handler for serializing messages. If undefined, Network-Services will use its minimalist default JSON message protocol. **Default:** `undefined` | ||
- `deserializeMessage` `<(data: Buffer) => ResultMessage | CallMessage>` An optional handler for deserializing messages. If undefined, Network-Services will use its minimalist default JSON message protocol. **Default:** `undefined` | ||
- `serializeMessageHandler` `<(message: ResultMessage | CallMessage) => Buffer>` An optional handler for serializing messages. If undefined, Network-Services will use its minimalist default JSON message protocol. A Serialization handler is relevant only when the `net.Duplex` stream is not in object mode. **Default:** `undefined` | ||
- `deserializeMessageHandler` `<(data: Buffer) => ResultMessage | CallMessage>` An optional handler for deserializing messages. If undefined, Network-Services will use its minimalist default JSON message protocol. A Deserialization handler is relevant only when the `net.Duplex` stream is not in object mode. **Default:** `undefined` | ||
- `identifierGenerator` `<IdentifierGenerator>` An optional class instance that implements the `IdentifierGenerator` interface. This class instance will be used for generating unique identifiers. The default `NumericIdentifierGenerator` will work for the common case; however, a more robust solution may be required for one-to-many custom `net.Duplex` implementations. **Default:** `network-services.NumericIdentifierGenerator` | ||
- Returns: `<Service>` | ||
@@ -169,3 +170,3 @@ | ||
## Message Protocol | ||
Network-Services provides a default *minimalist* JSON message protocol. However, you can marshal your messages however you choose by implementing the`serializeMessage` and `deserializeMessage` handlers and passing them in the `ServiceOptions` when you create your Service. As an example, you can find the default implementations in the [Service](https://github.com/faranalytics/network-services/blob/main/src/service.ts) class. | ||
Network-Services provides a default *minimalist* JSON message protocol. However, you can marshal your messages however you choose by implementing the`serializeMessageHandler` and `deserializeMessageHandler` handlers and passing them in the `ServiceOptions` when you create your Service. As an example, you can find the default implementations in the [Service](https://github.com/faranalytics/network-services/blob/main/src/service.ts) class. | ||
@@ -172,0 +173,0 @@ ### Default JSON Message Protocol |
54532
775
243