@hotmeshio/hotmesh 0.1.12 → 0.1.13

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -48,6 +48,12 @@ declare class EngineService {
48
48
  initSubChannel(sub: RedisClient): Promise<void>;
49
49
  initStreamChannel(stream: RedisClient): Promise<void>;
50
50
  initRouter(config: HotMeshConfig): Promise<Router>;
51
+ /**
52
+ * resolves the distributed executable version using a delay
53
+ * to allow deployment race conditions to resolve
54
+ * @private
55
+ */
56
+ fetchAndVerifyVID(vid: AppVID, count?: number): Promise<AppVID>;
51
57
  getVID(vid?: AppVID): Promise<AppVID>;
52
58
  setCacheMode(cacheMode: CacheMode, untilVersion: string): void;
53
59
  routeToSubscribers(topic: string, message: JobOutput): Promise<void>;
@@ -94,6 +94,30 @@ class EngineService {
94
94
  throttle,
95
95
  }, this.stream, this.store, this.logger);
96
96
  }
97
+ /**
98
+ * resolves the distributed executable version using a delay
99
+ * to allow deployment race conditions to resolve
100
+ * @private
101
+ */
102
+ async fetchAndVerifyVID(vid, count = 0) {
103
+ if (isNaN(Number(vid.version))) {
104
+ const app = await this.store.getApp(vid.id, true);
105
+ if (!isNaN(Number(app.version))) {
106
+ if (!this.apps)
107
+ this.apps = {};
108
+ this.apps[vid.id] = app;
109
+ return { id: vid.id, version: app.version };
110
+ }
111
+ else if (count < 10) {
112
+ await (0, utils_1.sleepFor)(enums_1.HMSH_QUORUM_DELAY_MS * 2);
113
+ return await this.fetchAndVerifyVID(vid, count + 1);
114
+ }
115
+ else {
116
+ this.logger.error('engine-vid-resolution-error', { id: vid.id, guid: this.guid });
117
+ }
118
+ }
119
+ return vid;
120
+ }
97
121
  async getVID(vid) {
98
122
  if (this.cacheMode === 'nocache') {
99
123
  const app = await this.store.getApp(this.appId, true);
@@ -112,7 +136,10 @@ class EngineService {
112
136
  return vid;
113
137
  }
114
138
  else {
115
- return { id: this.appId, version: this.apps?.[this.appId].version };
139
+ return await this.fetchAndVerifyVID({
140
+ id: this.appId,
141
+ version: this.apps?.[this.appId].version
142
+ });
116
143
  }
117
144
  }
118
145
  setCacheMode(cacheMode, untilVersion) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",