@nestjs-plugins/nestjs-nats-jetstream-transport
Advanced tools
Comparing version 1.1.5 to 1.1.6
import { ClientProxy, ReadPacket, WritePacket } from "@nestjs/microservices"; | ||
import { NatsConnection, NatsError } from "nats"; | ||
import { NatsConnection } from "nats"; | ||
import { NatsJetStreamClientOptions } from "./interfaces/nats-jetstream-client-options.interface"; | ||
@@ -11,5 +11,4 @@ export declare class NatsJetStreamClientProxy extends ClientProxy { | ||
close(): Promise<void>; | ||
serializeError(err: NatsError): NatsError; | ||
protected publish(packet: ReadPacket, callback: (packet: WritePacket) => void): () => void; | ||
protected dispatchEvent(packet: ReadPacket): Promise<any>; | ||
} |
@@ -37,8 +37,2 @@ "use strict"; | ||
} | ||
serializeError(err) { | ||
if (err.code === nats_1.ErrorCode.NoResponders) { | ||
err.message = "NO_RESPONDERS"; | ||
} | ||
return err; | ||
} | ||
publish(packet, callback) { | ||
@@ -45,0 +39,0 @@ const payload = this.codec.encode(packet.data); |
export * from "./server"; | ||
export * from "./client"; | ||
export * from "./nats-jetstream-transport.module"; | ||
export * from "./interfaces/nats-connection-options.interface"; | ||
export * from "./interfaces/nats-jetstream-client-options.interface"; | ||
@@ -5,0 +6,0 @@ export * from "./interfaces/nats-jetstream-server-options.interface"; |
@@ -16,2 +16,3 @@ "use strict"; | ||
__exportStar(require("./nats-jetstream-transport.module"), exports); | ||
__exportStar(require("./interfaces/nats-connection-options.interface"), exports); | ||
__exportStar(require("./interfaces/nats-jetstream-client-options.interface"), exports); | ||
@@ -18,0 +19,0 @@ __exportStar(require("./interfaces/nats-jetstream-server-options.interface"), exports); |
import { ModuleMetadata } from "@nestjs/common"; | ||
import { ConnectionOptions, JetStreamOptions, JetStreamPublishOptions } from "nats"; | ||
import { NatsConnectionOptions } from "./nats-connection-options.interface"; | ||
export interface NatsJetStreamClientOptions { | ||
connectionOptions: ConnectionOptions & Pick<ConnectionOptions, 'name'>; | ||
connectionOptions: Partial<NatsConnectionOptions> & Pick<ConnectionOptions, "name">; | ||
jetStreamOption?: JetStreamOptions; | ||
@@ -6,0 +7,0 @@ jetStreamPublishOptions?: JetStreamPublishOptions; |
@@ -1,8 +0,10 @@ | ||
import { ConnectionOptions, JetStreamOptions, StreamConfig } from "nats"; | ||
import { JetStreamOptions } from "nats"; | ||
import { ServerConsumerOptions } from "./server-consumer-options.interface"; | ||
import { NatsConnectionOptions } from "./nats-connection-options.interface"; | ||
import { NatsStreamConfig } from "./nats-stream-config.interface"; | ||
export interface NatsJetStreamServerOptions { | ||
connectionOptions: ConnectionOptions & Pick<ConnectionOptions, "name">; | ||
connectionOptions: Partial<NatsConnectionOptions> & Pick<NatsConnectionOptions, "name">; | ||
consumerOptions: Partial<ServerConsumerOptions>; | ||
jetStreamOptions?: JetStreamOptions; | ||
streamConfig?: Partial<StreamConfig> & Pick<StreamConfig, "name" | "subjects">; | ||
streamConfig?: NatsStreamConfig; | ||
} |
@@ -78,3 +78,3 @@ "use strict"; | ||
const messageHandlers = [...this.messageHandlers.entries()].filter(([, handler]) => !handler.isEventHandler); | ||
messageHandlers.forEach(async ([subject, messageHandler]) => { | ||
for (const [subject, messageHandler] of messageHandlers) { | ||
const subscriptionOptions = { | ||
@@ -94,3 +94,3 @@ queue: this.options.consumerOptions.deliverTo, | ||
this.logger.log(`Subscribed to ${subject} messages`); | ||
}); | ||
} | ||
} | ||
@@ -104,3 +104,2 @@ async setupStream() { | ||
this.logger.log(`Stream ${streamInfo.config.name} updated`); | ||
console.log(streamInfo.config); | ||
} | ||
@@ -107,0 +106,0 @@ else { |
{ | ||
"name": "@nestjs-plugins/nestjs-nats-jetstream-transport", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Nats JetStream Transport for NestJS", | ||
@@ -44,3 +44,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "b12508d7a71f66c9dcecd3f29f97a3787d3b4a0f" | ||
"gitHead": "e575637db472c7511c88b33c0bc461a51cb9fe4e" | ||
} |
@@ -54,2 +54,4 @@ # ๐ Nats JetStream Transport Module for NestJS | ||
## ๐ Description - configuration objects | ||
@@ -59,5 +61,6 @@ | ||
- **connectionOptions**: ConnectionOptions | ||
- **connectionOptions**: NatsConnectionOptions | ||
- **serverConsumerOptions**: ServerConsumerOptions | ||
- **jetStreamOptions**: JetStreamOption | ||
- **streamConfig**: NatsStreamConfig - Stream configuration. If defined, create stream if not exist. | ||
@@ -97,3 +100,3 @@ ### NatsJetStreamClientOptions | ||
### ConnectionOptions | ||
### NatsConnectionOptions | ||
@@ -140,2 +143,40 @@ - **servers**: string | string[] (default: 'localhost:4222') - String or Array of hostport for servers. | ||
### **NatsStreamConfig** | ||
- **name**: string - Stream name | ||
- **subjects**: string[] - Array of subjects | ||
- **storage?**: StorageType (default: StorageType.File) - The type of storage backend, `File` and `Memory` | ||
- **retention?**: RetentionPolicy.limits (default: RetentionPolicy.Limits) - How message retention is considered, `Limits`, `Interest` or `WorkQueue` | ||
- **discard?**: DiscardPolicy (default: DiscardPolicy.Old) | ||
- **max_msgs?**: number (default: -1) - How large the Stream may become in total messages before the configured discard policy kicks in. | ||
- **max_msgs_per_subject?**: number (default: -1) | ||
- **max_msg_size?**: number (default: -1) - The largest message that will be accepted by the Stream. | ||
- **max_age?**: number (default: 0) - Maximum age of any message in the stream, expressed in microseconds. | ||
- **duplicate_window?**: number (default: 120000000000) - The window within which to track duplicate messages. | ||
- **num_replicas?**: number (default:1) - How many replicas to keep for each message in a clustered JetStream, maximum 5 | ||
- **max_consumers?**: number (default: -1) - not exposed | ||
- **sealed?**: boolean (default: false) - not exposed | ||
- **deny_delete?**: boolean (default: false) - not exposed | ||
- **deny_purge?**: boolean (default: false) - not exposed | ||
- **allow_rollup_hdrs?**: boolean (default: false) - not exposed | ||
## Code example | ||
@@ -326,6 +367,10 @@ | ||
deliverGroup: 'myservice-group', | ||
durable: 'myservice', | ||
deliverTo: 'myservice', | ||
durable: 'myservice-durable', | ||
deliverTo: 'myservice-messages', | ||
manualAck: true, | ||
}, | ||
streamConfig: { | ||
name: 'mystream', | ||
subjects: ['order.*'] | ||
} | ||
}), | ||
@@ -332,0 +377,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
143218
40
423
382