gcf-common-lib 0.25.39 → 0.25.40

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gcf-common-lib",
3
3
  "description": "",
4
- "version": "0.25.39",
4
+ "version": "0.25.40",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "branches": [
@@ -21,7 +21,7 @@
21
21
  "url": "https://github.com/TopTechnologies/gcf-common.git"
22
22
  },
23
23
  "dependencies": {
24
- "@google-cloud/pubsub": "^4.0.0",
24
+ "@google-cloud/pubsub": "^4.0.1",
25
25
  "@google-cloud/secret-manager": "^5.0.0",
26
26
  "@google-cloud/storage": "^7.0.1",
27
27
  "amqplib": "^0.10.3",
package/src/index.js CHANGED
@@ -68,7 +68,7 @@ class GcfCommon {
68
68
  return __awaiter(this, void 0, void 0, function* () {
69
69
  return Promise.race([(0, utils_1.timeoutAfter)(timeout), (handler !== null && handler !== void 0 ? handler : (() => Promise.resolve(undefined)))(event, context)])
70
70
  .then((res) => __awaiter(this, void 0, void 0, function* () {
71
- console.log('res:', res);
71
+ // console.log('res:', res);
72
72
  yield this.publish(event, context, res);
73
73
  }))
74
74
  .catch((err) => __awaiter(this, void 0, void 0, function* () {
@@ -89,11 +89,14 @@ class GcfCommon {
89
89
  }
90
90
  static publish(event, context, json, attributes) {
91
91
  return __awaiter(this, void 0, void 0, function* () {
92
+ console.time('safeGetAttributes');
92
93
  const { topic, exchange, queue, appId, env, requestId } = yield this.safeGetAttributes(event, context, [
93
94
  'topic',
94
95
  'exchange',
95
96
  'queue',
96
97
  ]);
98
+ console.timeEnd('safeGetAttributes');
99
+ console.time('publish');
97
100
  if (topic && !(0, isEmpty_1.default)(topic)) {
98
101
  console.log('publish:', topic, appId, env, json, attributes);
99
102
  return exports.pubSub.topic(topic).publishMessage({
@@ -117,6 +120,7 @@ class GcfCommon {
117
120
  yield (0, utils_1.publishAmqp)(ch, exchange, queue !== null && queue !== void 0 ? queue : '', json !== null && json !== void 0 ? json : {}, this.amqpOptions.publishOptions);
118
121
  }), this.amqpOptions.url);
119
122
  }
123
+ console.timeEnd('publish');
120
124
  });
121
125
  }
122
126
  static safeGetAttributes(event, context, props) {
package/src/index.ts CHANGED
@@ -48,7 +48,7 @@ export class GcfCommon {
48
48
  ) {
49
49
  return Promise.race([timeoutAfter(timeout), (handler ?? (() => Promise.resolve(undefined)))(event, context)])
50
50
  .then(async (res: T | undefined) => {
51
- console.log('res:', res);
51
+ // console.log('res:', res);
52
52
  await this.publish(event, context, res);
53
53
  })
54
54
  .catch(async (err: Error) => {
@@ -68,11 +68,15 @@ export class GcfCommon {
68
68
  }
69
69
 
70
70
  static async publish(event: TEvent, context: TContext, json?: TResponse, attributes?: Dict<any>) {
71
+ console.time('safeGetAttributes');
71
72
  const { topic, exchange, queue, appId, env, requestId } = await this.safeGetAttributes(event, context, [
72
73
  'topic',
73
74
  'exchange',
74
75
  'queue',
75
76
  ]);
77
+ console.timeEnd('safeGetAttributes');
78
+
79
+ console.time('publish');
76
80
 
77
81
  if (topic && !isEmpty(topic)) {
78
82
  console.log('publish:', topic, appId, env, json, attributes);
@@ -105,6 +109,8 @@ export class GcfCommon {
105
109
  await publishAmqp(ch, exchange, queue ?? '', json ?? {}, this.amqpOptions.publishOptions);
106
110
  }, this.amqpOptions.url as string);
107
111
  }
112
+
113
+ console.timeEnd('publish');
108
114
  }
109
115
 
110
116
  static async safeGetAttributes(event: TEvent, context: TContext, props: string[]) {