@orion-js/echoes 3.5.3 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  import { EchoesOptions } from '../types';
2
- export default function (options: EchoesOptions): void;
2
+ export default function startService(options: EchoesOptions): Promise<void>;
@@ -8,7 +8,7 @@ const config_1 = __importDefault(require("../config"));
8
8
  const requestsHandler_1 = __importDefault(require("../requestsHandler"));
9
9
  const types_1 = __importDefault(require("../echo/types"));
10
10
  const http_1 = require("@orion-js/http");
11
- function default_1(options) {
11
+ async function startService(options) {
12
12
  config_1.default.echoes = options.echoes;
13
13
  if (options.requests) {
14
14
  config_1.default.requests = options.requests;
@@ -18,13 +18,16 @@ function default_1(options) {
18
18
  const kafka = new kafkajs_1.Kafka(options.client);
19
19
  config_1.default.producer = kafka.producer(options.producer);
20
20
  config_1.default.consumer = kafka.consumer(options.consumer);
21
- config_1.default.producer.connect();
22
- config_1.default.consumer.connect();
21
+ await config_1.default.producer.connect();
22
+ await config_1.default.consumer.connect();
23
23
  for (const topic in options.echoes) {
24
24
  const echo = options.echoes[topic];
25
25
  if (echo.type !== types_1.default.event)
26
26
  continue;
27
- config_1.default.consumer.subscribe({ topic });
27
+ await config_1.default.consumer.subscribe({
28
+ topic,
29
+ fromBeginning: options.readTopicsFromBeginning === false ? false : true
30
+ });
28
31
  }
29
32
  config_1.default.consumer.run({
30
33
  eachMessage: async (payload) => {
@@ -38,4 +41,4 @@ function default_1(options) {
38
41
  });
39
42
  }
40
43
  }
41
- exports.default = default_1;
44
+ exports.default = startService;
package/lib/types.d.ts CHANGED
@@ -68,6 +68,10 @@ export interface EchoesOptions {
68
68
  consumer?: ConsumerConfig;
69
69
  requests?: RequestsConfig;
70
70
  echoes: EchoesMap;
71
+ /**
72
+ * Defaults to true. When true, allows a reconnecting service to read missed messages.
73
+ */
74
+ readTopicsFromBeginning?: boolean;
71
75
  }
72
76
  export interface EchoesConfigHandler {
73
77
  producer?: Producer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/echoes",
3
- "version": "3.5.3",
3
+ "version": "3.6.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@orion-js/env": "^3.5.0",
21
21
  "@orion-js/helpers": "^3.5.3",
22
- "@orion-js/http": "^3.5.3",
22
+ "@orion-js/http": "^3.6.1",
23
23
  "@orion-js/services": "^3.5.3",
24
24
  "axios": "^0.24.0",
25
25
  "jssha": "^3.2.0",
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "34430096bb765afdc07b6f3c079915d424491b9c"
43
+ "gitHead": "ce643e657e199d1893c8c0f1d067d96e542f1796"
44
44
  }