@hotmeshio/hotmesh 0.0.4 → 0.0.6
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 +2 -2
- package/build/{package.json → cjs/package.json} +12 -5
- package/build/{services → cjs/services}/activities/trigger.js +2 -2
- package/build/{services → cjs/services}/connector/index.js +3 -3
- package/build/{services → cjs/services}/durable/client.js +2 -2
- package/build/{services → cjs/services}/durable/connection.js +2 -2
- package/build/{services → cjs/services}/durable/worker.d.ts +1 -0
- package/build/{services → cjs/services}/durable/worker.js +13 -3
- package/build/{services → cjs/services}/hotmesh/index.js +2 -2
- package/build/{services → cjs/services}/mapper/index.d.ts +3 -3
- package/build/{services → cjs/services}/store/index.js +1 -1
- package/build/esm/index.d.ts +4 -0
- package/build/esm/index.js +3 -0
- package/build/esm/modules/errors.d.ts +28 -0
- package/build/esm/modules/errors.js +41 -0
- package/build/esm/modules/key.d.ts +75 -0
- package/build/esm/modules/key.js +111 -0
- package/build/esm/modules/utils.d.ts +34 -0
- package/build/esm/modules/utils.js +154 -0
- package/build/esm/package.json +80 -0
- package/build/esm/services/activities/activity.d.ts +61 -0
- package/build/esm/services/activities/activity.js +411 -0
- package/build/esm/services/activities/await.d.ts +16 -0
- package/build/esm/services/activities/await.js +140 -0
- package/build/esm/services/activities/emit.d.ts +9 -0
- package/build/esm/services/activities/emit.js +10 -0
- package/build/esm/services/activities/index.d.ts +15 -0
- package/build/esm/services/activities/index.js +14 -0
- package/build/esm/services/activities/iterate.d.ts +9 -0
- package/build/esm/services/activities/iterate.js +10 -0
- package/build/esm/services/activities/trigger.d.ts +22 -0
- package/build/esm/services/activities/trigger.js +158 -0
- package/build/esm/services/activities/worker.d.ts +17 -0
- package/build/esm/services/activities/worker.js +162 -0
- package/build/esm/services/collator/index.d.ts +56 -0
- package/build/esm/services/collator/index.js +191 -0
- package/build/esm/services/compiler/deployer.d.ts +36 -0
- package/build/esm/services/compiler/deployer.js +423 -0
- package/build/esm/services/compiler/index.d.ts +30 -0
- package/build/esm/services/compiler/index.js +82 -0
- package/build/esm/services/compiler/validator.d.ts +32 -0
- package/build/esm/services/compiler/validator.js +131 -0
- package/build/esm/services/connector/clients/ioredis.d.ts +13 -0
- package/build/esm/services/connector/clients/ioredis.js +47 -0
- package/build/esm/services/connector/clients/redis.d.ts +13 -0
- package/build/esm/services/connector/clients/redis.js +59 -0
- package/build/esm/services/connector/index.d.ts +5 -0
- package/build/esm/services/connector/index.js +27 -0
- package/build/esm/services/dimension/index.d.ts +29 -0
- package/build/esm/services/dimension/index.js +32 -0
- package/build/esm/services/durable/asyncLocalStorage.d.ts +3 -0
- package/build/esm/services/durable/asyncLocalStorage.js +2 -0
- package/build/esm/services/durable/client.d.ts +15 -0
- package/build/esm/services/durable/client.js +114 -0
- package/build/esm/services/durable/connection.d.ts +4 -0
- package/build/esm/services/durable/connection.js +47 -0
- package/build/esm/services/durable/factory.d.ts +3 -0
- package/build/esm/services/durable/factory.js +119 -0
- package/build/esm/services/durable/handle.d.ts +8 -0
- package/build/esm/services/durable/handle.js +34 -0
- package/build/esm/services/durable/index.d.ts +57 -0
- package/build/esm/services/durable/index.js +55 -0
- package/build/esm/services/durable/native.d.ts +4 -0
- package/build/esm/services/durable/native.js +43 -0
- package/build/esm/services/durable/worker.d.ts +37 -0
- package/build/esm/services/durable/worker.js +268 -0
- package/build/esm/services/durable/workflow.d.ts +6 -0
- package/build/esm/services/durable/workflow.js +128 -0
- package/build/esm/services/engine/index.d.ts +82 -0
- package/build/esm/services/engine/index.js +522 -0
- package/build/esm/services/hotmesh/index.d.ts +45 -0
- package/build/esm/services/hotmesh/index.js +131 -0
- package/build/esm/services/logger/index.d.ts +17 -0
- package/build/esm/services/logger/index.js +70 -0
- package/build/esm/services/mapper/index.d.ts +24 -0
- package/build/esm/services/mapper/index.js +69 -0
- package/build/esm/services/pipe/functions/array.d.ts +24 -0
- package/build/esm/services/pipe/functions/array.js +66 -0
- package/build/esm/services/pipe/functions/bitwise.d.ts +9 -0
- package/build/esm/services/pipe/functions/bitwise.js +21 -0
- package/build/esm/services/pipe/functions/conditional.d.ts +10 -0
- package/build/esm/services/pipe/functions/conditional.js +24 -0
- package/build/esm/services/pipe/functions/date.d.ts +57 -0
- package/build/esm/services/pipe/functions/date.js +164 -0
- package/build/esm/services/pipe/functions/index.d.ts +25 -0
- package/build/esm/services/pipe/functions/index.js +24 -0
- package/build/esm/services/pipe/functions/json.d.ts +5 -0
- package/build/esm/services/pipe/functions/json.js +9 -0
- package/build/esm/services/pipe/functions/math.d.ts +38 -0
- package/build/esm/services/pipe/functions/math.js +108 -0
- package/build/esm/services/pipe/functions/number.d.ts +25 -0
- package/build/esm/services/pipe/functions/number.js +130 -0
- package/build/esm/services/pipe/functions/object.d.ts +22 -0
- package/build/esm/services/pipe/functions/object.js +60 -0
- package/build/esm/services/pipe/functions/string.d.ts +23 -0
- package/build/esm/services/pipe/functions/string.js +66 -0
- package/build/esm/services/pipe/functions/symbol.d.ts +12 -0
- package/build/esm/services/pipe/functions/symbol.js +30 -0
- package/build/esm/services/pipe/functions/unary.d.ts +7 -0
- package/build/esm/services/pipe/functions/unary.js +15 -0
- package/build/esm/services/pipe/index.d.ts +30 -0
- package/build/esm/services/pipe/index.js +122 -0
- package/build/esm/services/quorum/index.d.ts +34 -0
- package/build/esm/services/quorum/index.js +144 -0
- package/build/esm/services/reporter/index.d.ts +47 -0
- package/build/esm/services/reporter/index.js +327 -0
- package/build/esm/services/serializer/index.d.ts +41 -0
- package/build/esm/services/serializer/index.js +251 -0
- package/build/esm/services/signaler/store.d.ts +15 -0
- package/build/esm/services/signaler/store.js +50 -0
- package/build/esm/services/signaler/stream.d.ts +43 -0
- package/build/esm/services/signaler/stream.js +315 -0
- package/build/esm/services/store/cache.d.ts +66 -0
- package/build/esm/services/store/cache.js +124 -0
- package/build/esm/services/store/clients/ioredis.d.ts +27 -0
- package/build/esm/services/store/clients/ioredis.js +93 -0
- package/build/esm/services/store/clients/redis.d.ts +29 -0
- package/build/esm/services/store/clients/redis.js +140 -0
- package/build/esm/services/store/index.d.ts +88 -0
- package/build/esm/services/store/index.js +623 -0
- package/build/esm/services/stream/clients/ioredis.d.ts +23 -0
- package/build/esm/services/stream/clients/ioredis.js +112 -0
- package/build/esm/services/stream/clients/redis.d.ts +23 -0
- package/build/esm/services/stream/clients/redis.js +116 -0
- package/build/esm/services/stream/index.d.ts +21 -0
- package/build/esm/services/stream/index.js +6 -0
- package/build/esm/services/sub/clients/ioredis.d.ts +20 -0
- package/build/esm/services/sub/clients/ioredis.js +69 -0
- package/build/esm/services/sub/clients/redis.d.ts +20 -0
- package/build/esm/services/sub/clients/redis.js +60 -0
- package/build/esm/services/sub/index.d.ts +18 -0
- package/build/esm/services/sub/index.js +6 -0
- package/build/esm/services/task/index.d.ts +18 -0
- package/build/esm/services/task/index.js +70 -0
- package/build/esm/services/telemetry/index.d.ts +49 -0
- package/build/esm/services/telemetry/index.js +217 -0
- package/build/esm/services/worker/index.d.ts +30 -0
- package/build/esm/services/worker/index.js +102 -0
- package/build/esm/types/activity.d.ts +87 -0
- package/build/esm/types/activity.js +1 -0
- package/build/esm/types/app.d.ts +16 -0
- package/build/esm/types/app.js +1 -0
- package/build/esm/types/async.d.ts +5 -0
- package/build/esm/types/async.js +1 -0
- package/build/esm/types/cache.d.ts +1 -0
- package/build/esm/types/cache.js +1 -0
- package/build/esm/types/collator.d.ts +8 -0
- package/build/esm/types/collator.js +8 -0
- package/build/esm/types/durable.d.ts +59 -0
- package/build/esm/types/durable.js +1 -0
- package/build/esm/types/hook.d.ts +31 -0
- package/build/esm/types/hook.js +6 -0
- package/build/esm/types/hotmesh.d.ts +82 -0
- package/build/esm/types/hotmesh.js +1 -0
- package/build/esm/types/index.d.ts +20 -0
- package/build/esm/types/index.js +5 -0
- package/build/esm/types/ioredisclient.d.ts +5 -0
- package/build/esm/types/ioredisclient.js +2 -0
- package/build/esm/types/job.d.ts +50 -0
- package/build/esm/types/job.js +1 -0
- package/build/esm/types/logger.d.ts +6 -0
- package/build/esm/types/logger.js +1 -0
- package/build/esm/types/map.d.ts +4 -0
- package/build/esm/types/map.js +1 -0
- package/build/esm/types/pipe.d.ts +4 -0
- package/build/esm/types/pipe.js +1 -0
- package/build/esm/types/quorum.d.ts +46 -0
- package/build/esm/types/quorum.js +1 -0
- package/build/esm/types/redis.d.ts +8 -0
- package/build/esm/types/redis.js +1 -0
- package/build/esm/types/redisclient.d.ts +25 -0
- package/build/esm/types/redisclient.js +1 -0
- package/build/esm/types/serializer.d.ts +33 -0
- package/build/esm/types/serializer.js +1 -0
- package/build/esm/types/stats.d.ts +83 -0
- package/build/esm/types/stats.js +1 -0
- package/build/esm/types/stream.d.ts +67 -0
- package/build/esm/types/stream.js +22 -0
- package/build/esm/types/telemetry.d.ts +1 -0
- package/build/esm/types/telemetry.js +1 -0
- package/build/esm/types/transition.d.ts +17 -0
- package/build/esm/types/transition.js +1 -0
- package/package.json +12 -5
- package/services/activities/activity.ts +1 -1
- package/services/activities/trigger.ts +2 -2
- package/services/connector/index.ts +3 -3
- package/services/durable/client.ts +2 -2
- package/services/durable/connection.ts +2 -2
- package/services/durable/worker.ts +13 -3
- package/services/hotmesh/index.ts +2 -2
- package/services/mapper/index.ts +6 -7
- package/services/store/index.ts +3 -3
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.esm.json +9 -0
- package/build/{index.d.ts → cjs/index.d.ts} +0 -0
- package/build/{index.js → cjs/index.js} +0 -0
- package/build/{modules → cjs/modules}/errors.d.ts +0 -0
- package/build/{modules → cjs/modules}/errors.js +0 -0
- package/build/{modules → cjs/modules}/key.d.ts +0 -0
- package/build/{modules → cjs/modules}/key.js +0 -0
- package/build/{modules → cjs/modules}/utils.d.ts +0 -0
- package/build/{modules → cjs/modules}/utils.js +0 -0
- package/build/{services → cjs/services}/activities/activity.d.ts +0 -0
- package/build/{services → cjs/services}/activities/activity.js +1 -1
- /package/build/{services → cjs/services}/activities/await.d.ts +0 -0
- /package/build/{services → cjs/services}/activities/await.js +0 -0
- /package/build/{services → cjs/services}/activities/emit.d.ts +0 -0
- /package/build/{services → cjs/services}/activities/emit.js +0 -0
- /package/build/{services → cjs/services}/activities/index.d.ts +0 -0
- /package/build/{services → cjs/services}/activities/index.js +0 -0
- /package/build/{services → cjs/services}/activities/iterate.d.ts +0 -0
- /package/build/{services → cjs/services}/activities/iterate.js +0 -0
- /package/build/{services → cjs/services}/activities/trigger.d.ts +0 -0
- /package/build/{services → cjs/services}/activities/worker.d.ts +0 -0
- /package/build/{services → cjs/services}/activities/worker.js +0 -0
- /package/build/{services → cjs/services}/collator/index.d.ts +0 -0
- /package/build/{services → cjs/services}/collator/index.js +0 -0
- /package/build/{services → cjs/services}/compiler/deployer.d.ts +0 -0
- /package/build/{services → cjs/services}/compiler/deployer.js +0 -0
- /package/build/{services → cjs/services}/compiler/index.d.ts +0 -0
- /package/build/{services → cjs/services}/compiler/index.js +0 -0
- /package/build/{services → cjs/services}/compiler/validator.d.ts +0 -0
- /package/build/{services → cjs/services}/compiler/validator.js +0 -0
- /package/build/{services → cjs/services}/connector/clients/ioredis.d.ts +0 -0
- /package/build/{services → cjs/services}/connector/clients/ioredis.js +0 -0
- /package/build/{services → cjs/services}/connector/clients/redis.d.ts +0 -0
- /package/build/{services → cjs/services}/connector/clients/redis.js +0 -0
- /package/build/{services → cjs/services}/connector/index.d.ts +0 -0
- /package/build/{services → cjs/services}/dimension/index.d.ts +0 -0
- /package/build/{services → cjs/services}/dimension/index.js +0 -0
- /package/build/{services → cjs/services}/durable/asyncLocalStorage.d.ts +0 -0
- /package/build/{services → cjs/services}/durable/asyncLocalStorage.js +0 -0
- /package/build/{services → cjs/services}/durable/client.d.ts +0 -0
- /package/build/{services → cjs/services}/durable/connection.d.ts +0 -0
- /package/build/{services → cjs/services}/durable/factory.d.ts +0 -0
- /package/build/{services → cjs/services}/durable/factory.js +0 -0
- /package/build/{services → cjs/services}/durable/handle.d.ts +0 -0
- /package/build/{services → cjs/services}/durable/handle.js +0 -0
- /package/build/{services → cjs/services}/durable/index.d.ts +0 -0
- /package/build/{services → cjs/services}/durable/index.js +0 -0
- /package/build/{services → cjs/services}/durable/native.d.ts +0 -0
- /package/build/{services → cjs/services}/durable/native.js +0 -0
- /package/build/{services → cjs/services}/durable/workflow.d.ts +0 -0
- /package/build/{services → cjs/services}/durable/workflow.js +0 -0
- /package/build/{services → cjs/services}/engine/index.d.ts +0 -0
- /package/build/{services → cjs/services}/engine/index.js +0 -0
- /package/build/{services → cjs/services}/hotmesh/index.d.ts +0 -0
- /package/build/{services → cjs/services}/logger/index.d.ts +0 -0
- /package/build/{services → cjs/services}/logger/index.js +0 -0
- /package/build/{services → cjs/services}/mapper/index.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/array.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/array.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/bitwise.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/bitwise.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/conditional.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/conditional.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/date.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/date.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/index.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/index.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/json.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/json.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/math.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/math.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/number.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/number.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/object.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/object.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/string.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/string.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/symbol.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/symbol.js +0 -0
- /package/build/{services → cjs/services}/pipe/functions/unary.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/functions/unary.js +0 -0
- /package/build/{services → cjs/services}/pipe/index.d.ts +0 -0
- /package/build/{services → cjs/services}/pipe/index.js +0 -0
- /package/build/{services → cjs/services}/quorum/index.d.ts +0 -0
- /package/build/{services → cjs/services}/quorum/index.js +0 -0
- /package/build/{services → cjs/services}/reporter/index.d.ts +0 -0
- /package/build/{services → cjs/services}/reporter/index.js +0 -0
- /package/build/{services → cjs/services}/serializer/index.d.ts +0 -0
- /package/build/{services → cjs/services}/serializer/index.js +0 -0
- /package/build/{services → cjs/services}/signaler/store.d.ts +0 -0
- /package/build/{services → cjs/services}/signaler/store.js +0 -0
- /package/build/{services → cjs/services}/signaler/stream.d.ts +0 -0
- /package/build/{services → cjs/services}/signaler/stream.js +0 -0
- /package/build/{services → cjs/services}/store/cache.d.ts +0 -0
- /package/build/{services → cjs/services}/store/cache.js +0 -0
- /package/build/{services → cjs/services}/store/clients/ioredis.d.ts +0 -0
- /package/build/{services → cjs/services}/store/clients/ioredis.js +0 -0
- /package/build/{services → cjs/services}/store/clients/redis.d.ts +0 -0
- /package/build/{services → cjs/services}/store/clients/redis.js +0 -0
- /package/build/{services → cjs/services}/store/index.d.ts +0 -0
- /package/build/{services → cjs/services}/stream/clients/ioredis.d.ts +0 -0
- /package/build/{services → cjs/services}/stream/clients/ioredis.js +0 -0
- /package/build/{services → cjs/services}/stream/clients/redis.d.ts +0 -0
- /package/build/{services → cjs/services}/stream/clients/redis.js +0 -0
- /package/build/{services → cjs/services}/stream/index.d.ts +0 -0
- /package/build/{services → cjs/services}/stream/index.js +0 -0
- /package/build/{services → cjs/services}/sub/clients/ioredis.d.ts +0 -0
- /package/build/{services → cjs/services}/sub/clients/ioredis.js +0 -0
- /package/build/{services → cjs/services}/sub/clients/redis.d.ts +0 -0
- /package/build/{services → cjs/services}/sub/clients/redis.js +0 -0
- /package/build/{services → cjs/services}/sub/index.d.ts +0 -0
- /package/build/{services → cjs/services}/sub/index.js +0 -0
- /package/build/{services → cjs/services}/task/index.d.ts +0 -0
- /package/build/{services → cjs/services}/task/index.js +0 -0
- /package/build/{services → cjs/services}/telemetry/index.d.ts +0 -0
- /package/build/{services → cjs/services}/telemetry/index.js +0 -0
- /package/build/{services → cjs/services}/worker/index.d.ts +0 -0
- /package/build/{services → cjs/services}/worker/index.js +0 -0
- /package/build/{types → cjs/types}/activity.d.ts +0 -0
- /package/build/{types → cjs/types}/activity.js +0 -0
- /package/build/{types → cjs/types}/app.d.ts +0 -0
- /package/build/{types → cjs/types}/app.js +0 -0
- /package/build/{types → cjs/types}/async.d.ts +0 -0
- /package/build/{types → cjs/types}/async.js +0 -0
- /package/build/{types → cjs/types}/cache.d.ts +0 -0
- /package/build/{types → cjs/types}/cache.js +0 -0
- /package/build/{types → cjs/types}/collator.d.ts +0 -0
- /package/build/{types → cjs/types}/collator.js +0 -0
- /package/build/{types → cjs/types}/durable.d.ts +0 -0
- /package/build/{types → cjs/types}/durable.js +0 -0
- /package/build/{types → cjs/types}/hook.d.ts +0 -0
- /package/build/{types → cjs/types}/hook.js +0 -0
- /package/build/{types → cjs/types}/hotmesh.d.ts +0 -0
- /package/build/{types → cjs/types}/hotmesh.js +0 -0
- /package/build/{types → cjs/types}/index.d.ts +0 -0
- /package/build/{types → cjs/types}/index.js +0 -0
- /package/build/{types → cjs/types}/ioredisclient.d.ts +0 -0
- /package/build/{types → cjs/types}/ioredisclient.js +0 -0
- /package/build/{types → cjs/types}/job.d.ts +0 -0
- /package/build/{types → cjs/types}/job.js +0 -0
- /package/build/{types → cjs/types}/logger.d.ts +0 -0
- /package/build/{types → cjs/types}/logger.js +0 -0
- /package/build/{types → cjs/types}/map.d.ts +0 -0
- /package/build/{types → cjs/types}/map.js +0 -0
- /package/build/{types → cjs/types}/pipe.d.ts +0 -0
- /package/build/{types → cjs/types}/pipe.js +0 -0
- /package/build/{types → cjs/types}/quorum.d.ts +0 -0
- /package/build/{types → cjs/types}/quorum.js +0 -0
- /package/build/{types → cjs/types}/redis.d.ts +0 -0
- /package/build/{types → cjs/types}/redis.js +0 -0
- /package/build/{types → cjs/types}/redisclient.d.ts +0 -0
- /package/build/{types → cjs/types}/redisclient.js +0 -0
- /package/build/{types → cjs/types}/serializer.d.ts +0 -0
- /package/build/{types → cjs/types}/serializer.js +0 -0
- /package/build/{types → cjs/types}/stats.d.ts +0 -0
- /package/build/{types → cjs/types}/stats.js +0 -0
- /package/build/{types → cjs/types}/stream.d.ts +0 -0
- /package/build/{types → cjs/types}/stream.js +0 -0
- /package/build/{types → cjs/types}/telemetry.d.ts +0 -0
- /package/build/{types → cjs/types}/telemetry.js +0 -0
- /package/build/{types → cjs/types}/transition.d.ts +0 -0
- /package/build/{types → cjs/types}/transition.js +0 -0
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ run().catch((err) => {
|
|
|
66
66
|
```javascript
|
|
67
67
|
import { Durable } from '@hotmeshio/hotmesh';
|
|
68
68
|
import Redis from 'ioredis';
|
|
69
|
-
import {
|
|
69
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
70
70
|
|
|
71
71
|
async function run() {
|
|
72
72
|
const connection = await Durable.Connection.connect({
|
|
@@ -85,7 +85,7 @@ async function run() {
|
|
|
85
85
|
args: ['HotMesh'],
|
|
86
86
|
taskQueue: 'hello-world',
|
|
87
87
|
workflowName: 'example',
|
|
88
|
-
workflowId: 'workflow-' +
|
|
88
|
+
workflowId: 'workflow-' + uuidv4(),
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
console.log(`Started workflow ${handle.workflowId}`);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hotmeshio/hotmesh",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Durable Workflows",
|
|
5
|
-
"main": "build/index.js",
|
|
6
|
-
"
|
|
5
|
+
"main": "build/cjs/index.js",
|
|
6
|
+
"module": "build/esm/index.js",
|
|
7
|
+
"types": "build/cjs/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": "./build/esm/index.js",
|
|
10
|
+
"require": "./build/cjs/index.js"
|
|
11
|
+
},
|
|
7
12
|
"repository": {
|
|
8
13
|
"type": "git",
|
|
9
14
|
"url": "https://github.com/hotmeshio/sdk-typescript.git"
|
|
@@ -14,7 +19,9 @@
|
|
|
14
19
|
},
|
|
15
20
|
"scripts": {
|
|
16
21
|
"clean": "rimraf ./build",
|
|
17
|
-
"build": "tsc --build tsconfig.json",
|
|
22
|
+
"build:cjs": "tsc --build tsconfig.cjs.json",
|
|
23
|
+
"build:esm": "tsc --build tsconfig.esm.json",
|
|
24
|
+
"build": "npm run build:cjs && npm run build:esm",
|
|
18
25
|
"clean-build": "npm run clean && npm run build",
|
|
19
26
|
"lint": "eslint . --ext .ts",
|
|
20
27
|
"lint:fix": "eslint . --fix --ext .ts",
|
|
@@ -52,7 +59,7 @@
|
|
|
52
59
|
"@opentelemetry/api": "^1.4.1",
|
|
53
60
|
"js-yaml": "^4.1.0",
|
|
54
61
|
"ms": "^2.1.3",
|
|
55
|
-
"
|
|
62
|
+
"uuid": "^9.0.1",
|
|
56
63
|
"winston": "^3.8.2"
|
|
57
64
|
},
|
|
58
65
|
"devDependencies": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Trigger = void 0;
|
|
4
|
-
const
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
5
|
const errors_1 = require("../../modules/errors");
|
|
6
6
|
const utils_1 = require("../../modules/utils");
|
|
7
7
|
const activity_1 = require("./activity");
|
|
@@ -137,7 +137,7 @@ class Trigger extends activity_1.Activity {
|
|
|
137
137
|
}
|
|
138
138
|
resolveJobId(context) {
|
|
139
139
|
const jobId = this.config.stats?.id;
|
|
140
|
-
return jobId ? pipe_1.Pipe.resolve(jobId, context) : (0,
|
|
140
|
+
return jobId ? pipe_1.Pipe.resolve(jobId, context) : (0, uuid_1.v4)();
|
|
141
141
|
}
|
|
142
142
|
resolveJobKey(context) {
|
|
143
143
|
const jobKey = this.config.stats?.key;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectorService = void 0;
|
|
4
|
-
const
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
5
|
const utils_1 = require("../../modules/utils");
|
|
6
6
|
const ioredis_1 = require("../connector/clients/ioredis");
|
|
7
7
|
const redis_1 = require("../connector/clients/redis");
|
|
@@ -13,12 +13,12 @@ class ConnectorService {
|
|
|
13
13
|
const instances = [];
|
|
14
14
|
if ((0, utils_1.identifyRedisTypeFromClass)(Redis) === 'redis') {
|
|
15
15
|
for (let i = 1; i <= 3; i++) {
|
|
16
|
-
instances.push(redis_1.RedisConnection.connect((0,
|
|
16
|
+
instances.push(redis_1.RedisConnection.connect((0, uuid_1.v4)(), Redis, options));
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
for (let i = 1; i <= 3; i++) {
|
|
21
|
-
instances.push(ioredis_1.RedisConnection.connect((0,
|
|
21
|
+
instances.push(ioredis_1.RedisConnection.connect((0, uuid_1.v4)(), Redis, options));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
const [store, stream, sub] = await Promise.all(instances);
|
|
@@ -12,7 +12,7 @@ Here is an example of how the methods in this file are used:
|
|
|
12
12
|
import { Durable } from '@hotmeshio/hotmesh';
|
|
13
13
|
import Redis from 'ioredis';
|
|
14
14
|
import { example } from './workflows';
|
|
15
|
-
import {
|
|
15
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
16
16
|
|
|
17
17
|
async function run() {
|
|
18
18
|
const connection = await Durable.Connection.connect({
|
|
@@ -31,7 +31,7 @@ async function run() {
|
|
|
31
31
|
args: ['HotMesh'],
|
|
32
32
|
taskQueue: 'hello-world',
|
|
33
33
|
workflowName: 'example',
|
|
34
|
-
workflowId: 'workflow-' +
|
|
34
|
+
workflowId: 'workflow-' + uuidv4(),
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
console.log(`Started workflow ${handle.workflowId}`);
|
|
@@ -8,7 +8,7 @@ Here is an example of how the methods in this file are used:
|
|
|
8
8
|
|
|
9
9
|
import { Durable } from '@hotmeshio/hotmesh';
|
|
10
10
|
import Redis from 'ioredis';
|
|
11
|
-
import {
|
|
11
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
12
12
|
|
|
13
13
|
async function run() {
|
|
14
14
|
const connection = await Durable.Connection.connect({
|
|
@@ -27,7 +27,7 @@ async function run() {
|
|
|
27
27
|
taskQueue: 'hello-world',
|
|
28
28
|
args: ['HotMesh'],
|
|
29
29
|
workflowName: 'example',
|
|
30
|
-
workflowId:
|
|
30
|
+
workflowId: uuidv4(),
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
console.log(`Started workflow ${handle.workflowId}`);
|
|
@@ -20,6 +20,7 @@ export declare class WorkerService {
|
|
|
20
20
|
*/
|
|
21
21
|
static registerActivities<ACT>(activities: ACT): Registry;
|
|
22
22
|
static create(config: WorkerConfig): Promise<WorkerService>;
|
|
23
|
+
static resolveWorkflowTarget(workflow: object | Function): [string, Function];
|
|
23
24
|
run(): Promise<void>;
|
|
24
25
|
initActivityWorkflow(config: WorkerConfig, activityTopic: string): Promise<HotMesh>;
|
|
25
26
|
wrapActivityFunctions(): Function;
|
|
@@ -110,9 +110,7 @@ class WorkerService {
|
|
|
110
110
|
WorkerService.registerActivities(config.activities);
|
|
111
111
|
//import the user's workflow file (triggers activity functions to be wrapped)
|
|
112
112
|
const workflow = await Promise.resolve(`${config.workflowsPath}`).then(s => __importStar(require(s)));
|
|
113
|
-
const
|
|
114
|
-
const workflowFunctionName = workflowFunctionNames[workflowFunctionNames.length - 1];
|
|
115
|
-
const workflowFunction = workflow[workflowFunctionName];
|
|
113
|
+
const [workflowFunctionName, workflowFunction] = WorkerService.resolveWorkflowTarget(workflow);
|
|
116
114
|
const baseTopic = `${config.taskQueue}-${workflowFunctionName}`;
|
|
117
115
|
const activityTopic = `${baseTopic}-activity`;
|
|
118
116
|
const workflowTopic = `${baseTopic}`;
|
|
@@ -124,6 +122,18 @@ class WorkerService {
|
|
|
124
122
|
await WorkerService.activateWorkflow(worker.workflowRunner, workflowTopic, factory_1.getWorkflowYAML);
|
|
125
123
|
return worker;
|
|
126
124
|
}
|
|
125
|
+
static resolveWorkflowTarget(workflow) {
|
|
126
|
+
let workflowFunction;
|
|
127
|
+
if (typeof workflow === 'function') {
|
|
128
|
+
workflowFunction = workflow;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
const workflowFunctionNames = Object.keys(workflow);
|
|
132
|
+
workflowFunction = workflow[workflowFunctionNames[workflowFunctionNames.length - 1]];
|
|
133
|
+
return WorkerService.resolveWorkflowTarget(workflowFunction);
|
|
134
|
+
}
|
|
135
|
+
return [workflowFunction.name, workflowFunction];
|
|
136
|
+
}
|
|
127
137
|
async run() {
|
|
128
138
|
if (this.workflowRunner) {
|
|
129
139
|
this.workflowRunner.engine.logger.info('WorkerService is running');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HotMeshService = void 0;
|
|
4
|
-
const
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
5
|
const key_1 = require("../../modules/key");
|
|
6
6
|
const engine_1 = require("../engine");
|
|
7
7
|
const logger_1 = require("../logger");
|
|
@@ -39,7 +39,7 @@ class HotMeshService {
|
|
|
39
39
|
}
|
|
40
40
|
static async init(config) {
|
|
41
41
|
const instance = new HotMeshService();
|
|
42
|
-
instance.guid = (0,
|
|
42
|
+
instance.guid = (0, uuid_1.v4)();
|
|
43
43
|
instance.verifyAndSetNamespace(config.namespace);
|
|
44
44
|
instance.verifyAndSetAppId(config.appId);
|
|
45
45
|
instance.logger = new logger_1.LoggerService(config.appId, instance.guid, config.name || '', config.logLevel);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { JobState } from
|
|
2
|
-
import { TransitionRule } from
|
|
3
|
-
import { StreamCode } from
|
|
1
|
+
import { JobState } from '../../types/job';
|
|
2
|
+
import { TransitionRule } from '../../types/transition';
|
|
3
|
+
import { StreamCode } from '../../types';
|
|
4
4
|
declare class MapperService {
|
|
5
5
|
private rules;
|
|
6
6
|
private data;
|
|
@@ -110,7 +110,7 @@ class StoreService {
|
|
|
110
110
|
else {
|
|
111
111
|
if (bCreate) {
|
|
112
112
|
const packageJson = await Promise.resolve().then(() => __importStar(require('../../package.json')));
|
|
113
|
-
const version = packageJson.
|
|
113
|
+
const version = packageJson['version'] || '0.0.0';
|
|
114
114
|
settings = { namespace: key_1.PSNS, version };
|
|
115
115
|
await this.setSettings(settings);
|
|
116
116
|
return settings;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ActivityDuplex } from "../types/activity";
|
|
2
|
+
import { CollationFaultType, CollationStage } from "../types/collator";
|
|
3
|
+
declare class GetStateError extends Error {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
declare class SetStateError extends Error {
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
declare class MapDataError extends Error {
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
declare class RegisterTimeoutError extends Error {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
declare class DuplicateJobError extends Error {
|
|
16
|
+
constructor(jobId: string);
|
|
17
|
+
}
|
|
18
|
+
declare class ExecActivityError extends Error {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
declare class CollationError extends Error {
|
|
22
|
+
status: number;
|
|
23
|
+
leg: ActivityDuplex;
|
|
24
|
+
stage: CollationStage;
|
|
25
|
+
fault: CollationFaultType;
|
|
26
|
+
constructor(status: number, leg: ActivityDuplex, stage: CollationStage, fault?: CollationFaultType);
|
|
27
|
+
}
|
|
28
|
+
export { CollationError, DuplicateJobError, GetStateError, SetStateError, MapDataError, RegisterTimeoutError, ExecActivityError };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
class GetStateError extends Error {
|
|
2
|
+
constructor() {
|
|
3
|
+
super("Error occurred while getting job state");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
class SetStateError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("Error occurred while setting job state");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
class MapDataError extends Error {
|
|
12
|
+
constructor() {
|
|
13
|
+
super("Error occurred while mapping data");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class RegisterTimeoutError extends Error {
|
|
17
|
+
constructor() {
|
|
18
|
+
super("Error occurred while registering activity timeout");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class DuplicateJobError extends Error {
|
|
22
|
+
constructor(jobId) {
|
|
23
|
+
super("Duplicate job");
|
|
24
|
+
this.message = `Duplicate job: ${jobId}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
class ExecActivityError extends Error {
|
|
28
|
+
constructor() {
|
|
29
|
+
super("Error occurred while executing activity");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class CollationError extends Error {
|
|
33
|
+
constructor(status, leg, stage, fault) {
|
|
34
|
+
super("collation-error");
|
|
35
|
+
this.leg = leg;
|
|
36
|
+
this.status = status;
|
|
37
|
+
this.stage = stage;
|
|
38
|
+
this.fault = fault;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export { CollationError, DuplicateJobError, GetStateError, SetStateError, MapDataError, RegisterTimeoutError, ExecActivityError };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys
|
|
3
|
+
*
|
|
4
|
+
* hmsh -> {hash} hotmesh config {version: "0.0.1", namespace: "hmsh"}
|
|
5
|
+
* hmsh:a:<appid> -> {hash} app profile { "id": "appid", "version": "2", "versions/1": "GMT", "versions/2": "GMT"}
|
|
6
|
+
* hmsh:<appid>:e:<engineId> -> {string} setnx to ensure only one engine of given id
|
|
7
|
+
* hmsh:<appid>:w: -> {zset} work items/tasks an engine must do like garbage collect or hook a set of matching records (hookAll)
|
|
8
|
+
* hmsh:<appid>:t: -> {zset} an ordered set of list (work lists) ids
|
|
9
|
+
* hmsh:<appid>:t:<timeValue?> -> {list} a worklist of `jobId+activityId` items that should be awakened
|
|
10
|
+
* hmsh:<appid>:q: -> {hash} quorum-wide messages
|
|
11
|
+
* hmsh:<appid>:q:<ngnid> -> {hash} engine-targeted messages (targeted quorum-oriented message)
|
|
12
|
+
* hmsh:<appid>:j:<jobid> -> {hash} job data
|
|
13
|
+
* hmsh:<appid>:j:<jobid>:<activityid> -> {hash} job activity data (a1)
|
|
14
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime> -> {hash} job stats (general)
|
|
15
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime>:mdn:<field/path>:<fieldvalue> -> {zset} job stats (median)
|
|
16
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime>:index:<field/path>:<fieldvalue> -> {list} job stats (index of jobid[])
|
|
17
|
+
* hmsh:<appid>:v:<version>:activities -> {hash} schemas [cache]
|
|
18
|
+
* hmsh:<appid>:v:<version>:transitions -> {hash} transitions [cache]
|
|
19
|
+
* hmsh:<appid>:v:<version>:subscriptions -> {hash} subscriptions [cache]
|
|
20
|
+
* hmsh:<appid>:x: -> {xstream} when an engine is sent or reads a buffered task (engines read from their custom topic)
|
|
21
|
+
* hmsh:<appid>:x:<topic> -> {xstream} when a worker is sent or reads a buffered task (workers read from their custom topic)
|
|
22
|
+
* hmsh:<appid>:hooks -> {hash} hook patterns/rules; set at compile time
|
|
23
|
+
* hmsh:<appid>:signals -> {hash} dynamic hook signals (hget/hdel) when resolving (always self-clean); added/removed at runtime
|
|
24
|
+
* hmsh:<appid>:sym:keys: -> {hash} list of symbol ranges and :cursor assigned at version deploy time for job keys
|
|
25
|
+
* hmsh:<appid>:sym:keys:<activityid|$subscribes> -> {hash} list of symbols based upon schema enums (initially) and adaptively optimized (later) during runtime; if '$subscribes' is used as the activityid, it is a top-level `job` symbol set (for job keys)
|
|
26
|
+
* hmsh:<appid>:sym:vals: -> {hash} list of symbols for job values across all app versions
|
|
27
|
+
*/
|
|
28
|
+
declare const PSNS = "hmsh";
|
|
29
|
+
declare enum KeyType {
|
|
30
|
+
APP = 0,
|
|
31
|
+
ENGINE_ID = 1,
|
|
32
|
+
HOOKS = 2,
|
|
33
|
+
JOB_STATE = 3,
|
|
34
|
+
JOB_STATS_GENERAL = 4,
|
|
35
|
+
JOB_STATS_MEDIAN = 5,
|
|
36
|
+
JOB_STATS_INDEX = 6,
|
|
37
|
+
HOTMESH = 7,
|
|
38
|
+
QUORUM = 8,
|
|
39
|
+
SCHEMAS = 9,
|
|
40
|
+
SIGNALS = 10,
|
|
41
|
+
STREAMS = 11,
|
|
42
|
+
SUBSCRIPTIONS = 12,
|
|
43
|
+
SUBSCRIPTION_PATTERNS = 13,
|
|
44
|
+
SYMKEYS = 14,
|
|
45
|
+
SYMVALS = 15,
|
|
46
|
+
TIME_RANGE = 16,
|
|
47
|
+
WORK_ITEMS = 17
|
|
48
|
+
}
|
|
49
|
+
type KeyStoreParams = {
|
|
50
|
+
appId?: string;
|
|
51
|
+
engineId?: string;
|
|
52
|
+
appVersion?: string;
|
|
53
|
+
jobId?: string;
|
|
54
|
+
activityId?: string;
|
|
55
|
+
jobKey?: string;
|
|
56
|
+
dateTime?: string;
|
|
57
|
+
facet?: string;
|
|
58
|
+
topic?: string;
|
|
59
|
+
timeValue?: number;
|
|
60
|
+
};
|
|
61
|
+
declare class KeyService {
|
|
62
|
+
/**
|
|
63
|
+
* returns a key that can be used to access a value in the key/value store
|
|
64
|
+
* appropriate for the given key type; the keys have an implicit hierarchy
|
|
65
|
+
* and are used to organize data in the store in a tree-like structure
|
|
66
|
+
* via the use of colons as separators. The top-level entity is the hmsh manifest.
|
|
67
|
+
* This file will reveal the full scope of what is on the server (apps, versions, etc)
|
|
68
|
+
* @param namespace
|
|
69
|
+
* @param keyType
|
|
70
|
+
* @param params
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
static mintKey(namespace: string, keyType: KeyType, params: KeyStoreParams): string;
|
|
74
|
+
}
|
|
75
|
+
export { KeyService, KeyType, KeyStoreParams, PSNS };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys
|
|
3
|
+
*
|
|
4
|
+
* hmsh -> {hash} hotmesh config {version: "0.0.1", namespace: "hmsh"}
|
|
5
|
+
* hmsh:a:<appid> -> {hash} app profile { "id": "appid", "version": "2", "versions/1": "GMT", "versions/2": "GMT"}
|
|
6
|
+
* hmsh:<appid>:e:<engineId> -> {string} setnx to ensure only one engine of given id
|
|
7
|
+
* hmsh:<appid>:w: -> {zset} work items/tasks an engine must do like garbage collect or hook a set of matching records (hookAll)
|
|
8
|
+
* hmsh:<appid>:t: -> {zset} an ordered set of list (work lists) ids
|
|
9
|
+
* hmsh:<appid>:t:<timeValue?> -> {list} a worklist of `jobId+activityId` items that should be awakened
|
|
10
|
+
* hmsh:<appid>:q: -> {hash} quorum-wide messages
|
|
11
|
+
* hmsh:<appid>:q:<ngnid> -> {hash} engine-targeted messages (targeted quorum-oriented message)
|
|
12
|
+
* hmsh:<appid>:j:<jobid> -> {hash} job data
|
|
13
|
+
* hmsh:<appid>:j:<jobid>:<activityid> -> {hash} job activity data (a1)
|
|
14
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime> -> {hash} job stats (general)
|
|
15
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime>:mdn:<field/path>:<fieldvalue> -> {zset} job stats (median)
|
|
16
|
+
* hmsh:<appid>:s:<jobkey>:<dateTime>:index:<field/path>:<fieldvalue> -> {list} job stats (index of jobid[])
|
|
17
|
+
* hmsh:<appid>:v:<version>:activities -> {hash} schemas [cache]
|
|
18
|
+
* hmsh:<appid>:v:<version>:transitions -> {hash} transitions [cache]
|
|
19
|
+
* hmsh:<appid>:v:<version>:subscriptions -> {hash} subscriptions [cache]
|
|
20
|
+
* hmsh:<appid>:x: -> {xstream} when an engine is sent or reads a buffered task (engines read from their custom topic)
|
|
21
|
+
* hmsh:<appid>:x:<topic> -> {xstream} when a worker is sent or reads a buffered task (workers read from their custom topic)
|
|
22
|
+
* hmsh:<appid>:hooks -> {hash} hook patterns/rules; set at compile time
|
|
23
|
+
* hmsh:<appid>:signals -> {hash} dynamic hook signals (hget/hdel) when resolving (always self-clean); added/removed at runtime
|
|
24
|
+
* hmsh:<appid>:sym:keys: -> {hash} list of symbol ranges and :cursor assigned at version deploy time for job keys
|
|
25
|
+
* hmsh:<appid>:sym:keys:<activityid|$subscribes> -> {hash} list of symbols based upon schema enums (initially) and adaptively optimized (later) during runtime; if '$subscribes' is used as the activityid, it is a top-level `job` symbol set (for job keys)
|
|
26
|
+
* hmsh:<appid>:sym:vals: -> {hash} list of symbols for job values across all app versions
|
|
27
|
+
*/
|
|
28
|
+
//default namespace for hotmesh
|
|
29
|
+
const PSNS = "hmsh";
|
|
30
|
+
//these are the entity types that are stored in the key/value store
|
|
31
|
+
var KeyType;
|
|
32
|
+
(function (KeyType) {
|
|
33
|
+
KeyType[KeyType["APP"] = 0] = "APP";
|
|
34
|
+
KeyType[KeyType["ENGINE_ID"] = 1] = "ENGINE_ID";
|
|
35
|
+
KeyType[KeyType["HOOKS"] = 2] = "HOOKS";
|
|
36
|
+
KeyType[KeyType["JOB_STATE"] = 3] = "JOB_STATE";
|
|
37
|
+
KeyType[KeyType["JOB_STATS_GENERAL"] = 4] = "JOB_STATS_GENERAL";
|
|
38
|
+
KeyType[KeyType["JOB_STATS_MEDIAN"] = 5] = "JOB_STATS_MEDIAN";
|
|
39
|
+
KeyType[KeyType["JOB_STATS_INDEX"] = 6] = "JOB_STATS_INDEX";
|
|
40
|
+
KeyType[KeyType["HOTMESH"] = 7] = "HOTMESH";
|
|
41
|
+
KeyType[KeyType["QUORUM"] = 8] = "QUORUM";
|
|
42
|
+
KeyType[KeyType["SCHEMAS"] = 9] = "SCHEMAS";
|
|
43
|
+
KeyType[KeyType["SIGNALS"] = 10] = "SIGNALS";
|
|
44
|
+
KeyType[KeyType["STREAMS"] = 11] = "STREAMS";
|
|
45
|
+
KeyType[KeyType["SUBSCRIPTIONS"] = 12] = "SUBSCRIPTIONS";
|
|
46
|
+
KeyType[KeyType["SUBSCRIPTION_PATTERNS"] = 13] = "SUBSCRIPTION_PATTERNS";
|
|
47
|
+
KeyType[KeyType["SYMKEYS"] = 14] = "SYMKEYS";
|
|
48
|
+
KeyType[KeyType["SYMVALS"] = 15] = "SYMVALS";
|
|
49
|
+
KeyType[KeyType["TIME_RANGE"] = 16] = "TIME_RANGE";
|
|
50
|
+
KeyType[KeyType["WORK_ITEMS"] = 17] = "WORK_ITEMS";
|
|
51
|
+
})(KeyType || (KeyType = {}));
|
|
52
|
+
class KeyService {
|
|
53
|
+
/**
|
|
54
|
+
* returns a key that can be used to access a value in the key/value store
|
|
55
|
+
* appropriate for the given key type; the keys have an implicit hierarchy
|
|
56
|
+
* and are used to organize data in the store in a tree-like structure
|
|
57
|
+
* via the use of colons as separators. The top-level entity is the hmsh manifest.
|
|
58
|
+
* This file will reveal the full scope of what is on the server (apps, versions, etc)
|
|
59
|
+
* @param namespace
|
|
60
|
+
* @param keyType
|
|
61
|
+
* @param params
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
static mintKey(namespace, keyType, params) {
|
|
65
|
+
switch (keyType) {
|
|
66
|
+
case KeyType.HOTMESH:
|
|
67
|
+
return namespace;
|
|
68
|
+
case KeyType.ENGINE_ID:
|
|
69
|
+
return `${namespace}:${params.appId}:e:${params.engineId}`;
|
|
70
|
+
case KeyType.WORK_ITEMS:
|
|
71
|
+
return `${namespace}:${params.appId}:w:`;
|
|
72
|
+
case KeyType.TIME_RANGE:
|
|
73
|
+
return `${namespace}:${params.appId}:t:${params.timeValue || ''}`;
|
|
74
|
+
case KeyType.APP:
|
|
75
|
+
return `${namespace}:a:${params.appId || ''}`;
|
|
76
|
+
case KeyType.QUORUM:
|
|
77
|
+
return `${namespace}:${params.appId}:q:${params.engineId || ''}`;
|
|
78
|
+
case KeyType.JOB_STATE:
|
|
79
|
+
return `${namespace}:${params.appId}:j:${params.jobId}`;
|
|
80
|
+
case KeyType.JOB_STATS_GENERAL:
|
|
81
|
+
return `${namespace}:${params.appId}:s:${params.jobKey}:${params.dateTime}`;
|
|
82
|
+
case KeyType.JOB_STATS_MEDIAN:
|
|
83
|
+
return `${namespace}:${params.appId}:s:${params.jobKey}:${params.dateTime}:${params.facet}`;
|
|
84
|
+
case KeyType.JOB_STATS_INDEX:
|
|
85
|
+
return `${namespace}:${params.appId}:s:${params.jobKey}:${params.dateTime}:${params.facet}`;
|
|
86
|
+
case KeyType.SCHEMAS:
|
|
87
|
+
return `${namespace}:${params.appId}:v:${params.appVersion}:schemas`;
|
|
88
|
+
case KeyType.SUBSCRIPTIONS:
|
|
89
|
+
return `${namespace}:${params.appId}:v:${params.appVersion}:subscriptions`;
|
|
90
|
+
case KeyType.SUBSCRIPTION_PATTERNS:
|
|
91
|
+
return `${namespace}:${params.appId}:v:${params.appVersion}:transitions`;
|
|
92
|
+
case KeyType.HOOKS:
|
|
93
|
+
//`hooks` provide the pattern to resolve a value
|
|
94
|
+
return `${namespace}:${params.appId}:hooks`;
|
|
95
|
+
case KeyType.SIGNALS:
|
|
96
|
+
//`signals` provide the registry of resolved values that link back to paused jobs
|
|
97
|
+
return `${namespace}:${params.appId}:signals`;
|
|
98
|
+
case KeyType.SYMKEYS:
|
|
99
|
+
//`symbol keys` provide the registry of replacement values for job keys
|
|
100
|
+
return `${namespace}:${params.appId}:sym:keys:${params.activityId || ''}`;
|
|
101
|
+
case KeyType.SYMVALS:
|
|
102
|
+
//`symbol vals` provide the registry of replacement values for job vals
|
|
103
|
+
return `${namespace}:${params.appId}:sym:vals:`;
|
|
104
|
+
case KeyType.STREAMS:
|
|
105
|
+
return `${namespace}:${params.appId || ''}:x:${params.topic || ''}`;
|
|
106
|
+
default:
|
|
107
|
+
throw new Error("Invalid key type.");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export { KeyService, KeyType, PSNS };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { StoreService } from "../services/store";
|
|
3
|
+
import { AppSubscriptions, AppTransitions, AppVID } from "../types/app";
|
|
4
|
+
import { RedisClient, RedisMulti } from "../types/redis";
|
|
5
|
+
import { StringAnyType } from "../types/serializer";
|
|
6
|
+
import { StreamCode, StreamStatus } from "../types/stream";
|
|
7
|
+
export declare function sleepFor(ms: number): Promise<unknown>;
|
|
8
|
+
export declare function identifyRedisType(redisInstance: any): 'redis' | 'ioredis' | null;
|
|
9
|
+
export declare function identifyRedisTypeFromClass(redisClass: any): 'redis' | 'ioredis' | null;
|
|
10
|
+
export declare function matchesStatusCode(code: StreamCode, pattern: string | RegExp): boolean;
|
|
11
|
+
export declare function matchesStatus(status: StreamStatus, targetStatus: StreamStatus): boolean;
|
|
12
|
+
export declare function XSleepFor(ms: number): {
|
|
13
|
+
promise: Promise<unknown>;
|
|
14
|
+
timerId: NodeJS.Timeout;
|
|
15
|
+
};
|
|
16
|
+
export declare function findTopKey(obj: AppTransitions, input: string): string | null;
|
|
17
|
+
export declare function findSubscriptionForTrigger(obj: AppSubscriptions, value: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Get the subscription topic for the flow to which @activityId belongs.
|
|
20
|
+
* TODO: resolve this value in the compiler...do not call this at runtime
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSubscriptionTopic(activityId: string, store: StoreService<RedisClient, RedisMulti>, appVID: AppVID): Promise<string | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* returns the 12-digit format of the iso timestamp (e.g, 202101010000)
|
|
25
|
+
*/
|
|
26
|
+
export declare function getTimeSeries(granularity: string): string;
|
|
27
|
+
export declare function formatISODate(input: Date | string): string;
|
|
28
|
+
export declare function getSymKey(number: number): string;
|
|
29
|
+
export declare function getSymVal(number: number): string;
|
|
30
|
+
export declare function getIndexedHash<T>(hash: T, target: string): [number, T];
|
|
31
|
+
export declare function getValueByPath(obj: {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}, path: string): any;
|
|
34
|
+
export declare function restoreHierarchy(obj: StringAnyType): StringAnyType;
|