@hotmeshio/hotmesh 0.1.7 → 0.1.8

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/README.md CHANGED
@@ -295,31 +295,31 @@ const hotMesh = await HotMesh.init({
295
295
  ```
296
296
 
297
297
  ### Observability
298
- Workflows and activities are run according to the rules you define, offering [Graph-Oriented](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/system_lifecycle.md#telemetry) telemetry insights into your legacy function executions.
298
+ Workflows and activities are run according to the rules you define, offering [Graph-Oriented](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/system_lifecycle.md#telemetry) telemetry insights into your legacy function executions.
299
299
 
300
300
  ## FAQ
301
- Refer to the [FAQ](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/faq.md) for terminology, definitions, and an exploration of how HotMesh facilitates orchestration use cases.
301
+ Refer to the [FAQ](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/faq.md) for terminology, definitions, and an exploration of how HotMesh facilitates orchestration use cases.
302
302
 
303
303
  ## Quick Start
304
- Refer to the [Quick Start](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/quickstart.md) for sample YAML workflows you can copy, paste, and modify to get started.
304
+ Refer to the [Quick Start](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/quickstart.md) for sample YAML workflows you can copy, paste, and modify to get started.
305
305
 
306
306
  ## Developer Guide
307
- For more details on the complete development process, including information about schemas, APIs, and deployment, consult the [Developer Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/developer_guide.md).
307
+ For more details on the complete development process, including information about schemas, APIs, and deployment, consult the [Developer Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/developer_guide.md).
308
308
 
309
309
  ## Model Driven Development
310
- [Model Driven Development](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/model_driven_development.md) is an established strategy for managing process-oriented tasks. Check out this guide to understand its foundational principles.
310
+ [Model Driven Development](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/model_driven_development.md) is an established strategy for managing process-oriented tasks. Check out this guide to understand its foundational principles.
311
311
 
312
312
  ## Data Mapping
313
- Exchanging data between activities is central to HotMesh. For detailed information on supported functions and the functional mapping syntax (@pipes), see the [Data Mapping Overview](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/data_mapping.md).
313
+ Exchanging data between activities is central to HotMesh. For detailed information on supported functions and the functional mapping syntax (@pipes), see the [Data Mapping Overview](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/data_mapping.md).
314
314
 
315
315
  ## Composition
316
- While the simplest graphs are linear, detailing a consistent sequence of non-cyclical activities, graphs can be layered to represent intricate business scenarios. Some can even be designed to accommodate long-lasting workflows that span months. For more details, check out the [Composable Workflow Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/composable_workflow.md).
316
+ While the simplest graphs are linear, detailing a consistent sequence of non-cyclical activities, graphs can be layered to represent intricate business scenarios. Some can even be designed to accommodate long-lasting workflows that span months. For more details, check out the [Composable Workflow Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/composable_workflow.md).
317
317
 
318
318
  ## System Lifecycle
319
- Gain insight into HotMesh's monitoring, exception handling, and alarm configurations via the [System Lifecycle Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/system_lifecycle.md).
319
+ Gain insight into HotMesh's monitoring, exception handling, and alarm configurations via the [System Lifecycle Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/system_lifecycle.md).
320
320
 
321
321
  ## Distributed Orchestration | System Overview
322
- HotMesh is a distributed orchestration engine. Refer to the [Distributed Orchestration Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/distributed_orchestration.md) for a high-level overview of the approach.
322
+ HotMesh is a distributed orchestration engine. Refer to the [Distributed Orchestration Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/distributed_orchestration.md) for a high-level overview of the approach.
323
323
 
324
324
  ## Distributed Orchestration | System Design
325
325
  HotMesh is more than Redis and TypeScript. The theory that underlies the architecture is applicable to any number of data storage and streaming backends: [A Message-Oriented Approach to Decentralized Process Orchestration](https://zenodo.org/records/12168558).
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -19,10 +19,11 @@ class ClientService {
19
19
  this.getHotMeshClient = async (workflowTopic, namespace) => {
20
20
  const targetNS = namespace ?? factory_1.APP_ID;
21
21
  if (ClientService.instances.has(targetNS)) {
22
+ const targetTopic = `${namespace ?? factory_1.APP_ID}.${workflowTopic}`;
22
23
  const hotMeshClient = await ClientService.instances.get(targetNS);
23
24
  await this.verifyWorkflowActive(hotMeshClient, targetNS);
24
- if (!ClientService.topics.includes(workflowTopic)) {
25
- ClientService.topics.push(workflowTopic);
25
+ if (!ClientService.topics.includes(targetTopic)) {
26
+ ClientService.topics.push(targetTopic);
26
27
  await ClientService.createStream(hotMeshClient, workflowTopic, namespace);
27
28
  }
28
29
  return hotMeshClient;
@@ -205,11 +206,12 @@ ClientService.createStream = async (hotMeshClient, workflowTopic, namespace) =>
205
206
  * exists and if not, create it.
206
207
  */
207
208
  ClientService.verifyStream = async (workflowTopic, namespace) => {
209
+ const targetTopic = `${namespace ?? factory_1.APP_ID}.${workflowTopic}`;
208
210
  const targetNS = namespace ?? factory_1.APP_ID;
209
211
  if (ClientService.instances.has(targetNS)) {
210
212
  const hotMeshClient = await ClientService.instances.get(targetNS);
211
- if (!ClientService.topics.includes(workflowTopic)) {
212
- ClientService.topics.push(workflowTopic);
213
+ if (!ClientService.topics.includes(targetTopic)) {
214
+ ClientService.topics.push(targetTopic);
213
215
  await ClientService.createStream(hotMeshClient, workflowTopic, namespace);
214
216
  }
215
217
  return hotMeshClient;
@@ -2,11 +2,12 @@ import { HotMeshService as HotMesh } from '../hotmesh';
2
2
  import { Connection, Registry, WorkerConfig, WorkerOptions } from '../../types/durable';
3
3
  export declare class WorkerService {
4
4
  static activityRegistry: Registry;
5
- static connection: Connection;
5
+ static connections: Map<string, import("../../types/durable").ConnectionConfig>;
6
6
  static instances: Map<string, HotMesh | Promise<HotMesh>>;
7
7
  workflowRunner: HotMesh;
8
8
  activityRunner: HotMesh;
9
9
  static getHotMesh: (workflowTopic: string, config?: Partial<WorkerConfig>, options?: WorkerOptions) => Promise<HotMesh>;
10
+ static findConnectionByNamespace: (namespace: string) => Connection;
10
11
  static activateWorkflow(hotMesh: HotMesh): Promise<void>;
11
12
  static registerActivities<ACT>(activities: ACT): Registry;
12
13
  static create(config: WorkerConfig): Promise<WorkerService>;
@@ -58,7 +58,8 @@ class WorkerService {
58
58
  return WorkerService.activityRegistry;
59
59
  }
60
60
  static async create(config) {
61
- WorkerService.connection = config.connection;
61
+ const targetNamespace = config.namespace ?? factory_1.APP_ID;
62
+ WorkerService.connections.set(targetNamespace, config.connection);
62
63
  const workflow = config.workflow;
63
64
  const [workflowFunctionName, workflowFunction] = WorkerService.resolveWorkflowTarget(workflow);
64
65
  const baseTopic = `${config.taskQueue}-${workflowFunctionName}`;
@@ -371,20 +372,37 @@ class WorkerService {
371
372
  }
372
373
  _a = WorkerService;
373
374
  WorkerService.activityRegistry = {}; //user's activities
375
+ WorkerService.connections = new Map();
374
376
  WorkerService.instances = new Map();
375
377
  WorkerService.getHotMesh = async (workflowTopic, config, options) => {
376
- if (WorkerService.instances.has(workflowTopic)) {
377
- return await WorkerService.instances.get(workflowTopic);
378
+ const targetNamespace = config?.namespace ?? factory_1.APP_ID;
379
+ const targetTopic = `${targetNamespace}.${workflowTopic}`;
380
+ if (WorkerService.instances.has(targetTopic)) {
381
+ return await WorkerService.instances.get(targetTopic);
378
382
  }
379
383
  const hotMeshClient = hotmesh_1.HotMeshService.init({
380
384
  logLevel: options?.logLevel ?? enums_1.HMSH_LOGLEVEL,
381
- appId: config.namespace ?? factory_1.APP_ID,
382
- engine: { redis: { ...WorkerService.connection } },
385
+ appId: targetNamespace,
386
+ engine: {
387
+ redis: { ...WorkerService.findConnectionByNamespace(targetNamespace) },
388
+ },
383
389
  });
384
- WorkerService.instances.set(workflowTopic, hotMeshClient);
390
+ WorkerService.instances.set(targetTopic, hotMeshClient);
385
391
  await WorkerService.activateWorkflow(await hotMeshClient);
386
392
  return hotMeshClient;
387
393
  };
394
+ WorkerService.findConnectionByNamespace = (namespace) => {
395
+ let defaultConnection;
396
+ for (const [ns, value] of WorkerService.connections) {
397
+ if (ns === namespace) {
398
+ return value;
399
+ }
400
+ else if (!defaultConnection) {
401
+ defaultConnection = value;
402
+ }
403
+ }
404
+ return defaultConnection;
405
+ };
388
406
  WorkerService.Context = {
389
407
  info: () => {
390
408
  return {
@@ -7,7 +7,7 @@ export { ActivityConfig, ActivityWorkflowDataType, ChildResponseType, ClientConf
7
7
  export { DurableChildErrorType, DurableProxyErrorType, DurableSleepErrorType, DurableWaitForAllErrorType, DurableWaitForErrorType, } from './error';
8
8
  export { ActivityAction, DependencyExport, DurableJobExport, ExportCycles, ExportItem, ExportOptions, ExportTransitions, JobAction, JobExport, JobActionExport, JobTimeline, } from './exporter';
9
9
  export { HookCondition, HookConditions, HookGate, HookInterface, HookRule, HookRules, HookSignal, } from './hook';
10
- export { ILogger } from './logger';
10
+ export { ILogger, LogLevel, } from './logger';
11
11
  export { ExtensionType, JobCompletionOptions, JobData, JobsData, JobInterruptOptions, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState, } from './job';
12
12
  export { MappingStatements } from './map';
13
13
  export { Pipe, PipeContext, PipeItem, PipeItems, PipeObject, ReduceObject, } from './pipe';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
package/types/index.ts CHANGED
@@ -77,7 +77,10 @@ export {
77
77
  HookRules,
78
78
  HookSignal,
79
79
  } from './hook';
80
- export { ILogger } from './logger';
80
+ export {
81
+ ILogger,
82
+ LogLevel,
83
+ } from './logger';
81
84
  export {
82
85
  ExtensionType,
83
86
  JobCompletionOptions,