@hotmeshio/hotmesh 0.0.4 → 0.0.5
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}/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 +36 -0
- package/build/esm/services/durable/worker.js +258 -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/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/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 +0 -0
- /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/worker.d.ts +0 -0
- /package/build/{services → cjs/services}/durable/worker.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
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import ms from 'ms';
|
|
2
|
+
import { asyncLocalStorage } from './asyncLocalStorage';
|
|
3
|
+
import { WorkerService } from './worker';
|
|
4
|
+
import { ClientService as Client } from './client';
|
|
5
|
+
import { ConnectionService as Connection } from './connection';
|
|
6
|
+
/*
|
|
7
|
+
`proxyActivities` returns a wrapped instance of the
|
|
8
|
+
target activity, so that when the workflow calls a
|
|
9
|
+
proxied activity, it is actually calling the proxy
|
|
10
|
+
function, which in turn calls the activity function.
|
|
11
|
+
|
|
12
|
+
`proxyActivities` must be called AFTER the activities
|
|
13
|
+
have been registered in order to work properly.
|
|
14
|
+
If the activities are not already registered,
|
|
15
|
+
`proxyActivities` will throw an error. This is OK.
|
|
16
|
+
|
|
17
|
+
The `client` (client.ts) is equivalent to the
|
|
18
|
+
HotMesh `engine`. The jobs it creates will be
|
|
19
|
+
put in the taskQueue. When the `worker` (worker.ts)
|
|
20
|
+
is eventually initialized (if it happens to be inited later),
|
|
21
|
+
it will see the items in the queue and process them. If it happens
|
|
22
|
+
to already be inited, the jobs will immediately be dequeued and
|
|
23
|
+
processed. In either case, the jobs will be processed.
|
|
24
|
+
|
|
25
|
+
Here is an example of how the methods in this file are used:
|
|
26
|
+
|
|
27
|
+
./workflows.ts
|
|
28
|
+
|
|
29
|
+
import { Durable } from '@hotmeshio/hotmesh';
|
|
30
|
+
import type * as activities from './activities';
|
|
31
|
+
const { greet } = Durable.workflow.proxyActivities<typeof activities>({
|
|
32
|
+
startToCloseTimeout: '1 minute',
|
|
33
|
+
retryPolicy: {
|
|
34
|
+
initialInterval: '5 seconds', // Initial delay between retries
|
|
35
|
+
maximumAttempts: 3, // Max number of retry attempts
|
|
36
|
+
backoffCoefficient: 2.0, // Backoff factor for delay between retries: delay = initialInterval * (backoffCoefficient ^ retry_attempt)
|
|
37
|
+
maximumInterval: '30 seconds', // Max delay between retries
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export async function example(name: string): Promise<string> {
|
|
42
|
+
return await greet(name);
|
|
43
|
+
}
|
|
44
|
+
*/
|
|
45
|
+
export class WorkflowService {
|
|
46
|
+
static async executeChild(options) {
|
|
47
|
+
const store = asyncLocalStorage.getStore();
|
|
48
|
+
if (!store) {
|
|
49
|
+
throw new Error('durable-store-not-found');
|
|
50
|
+
}
|
|
51
|
+
const workflowId = store.get('workflowId');
|
|
52
|
+
const workflowTrace = store.get('workflowTrace');
|
|
53
|
+
const workflowSpan = store.get('workflowSpan');
|
|
54
|
+
const client = new Client({
|
|
55
|
+
connection: await Connection.connect(WorkerService.connection),
|
|
56
|
+
});
|
|
57
|
+
//todo: should I allow-cross/app callback (pj:'@DURABLE@hello-world@<pjid>'/pa: <paid>/pd: <pdad>)
|
|
58
|
+
const handle = await client.workflow.start({
|
|
59
|
+
...options,
|
|
60
|
+
workflowId: `${workflowId}${options.workflowId}`,
|
|
61
|
+
workflowTrace,
|
|
62
|
+
workflowSpan,
|
|
63
|
+
});
|
|
64
|
+
const result = await handle.result();
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
static proxyActivities(options) {
|
|
68
|
+
const proxy = {};
|
|
69
|
+
const keys = Object.keys(WorkerService.activityRegistry);
|
|
70
|
+
if (keys.length) {
|
|
71
|
+
keys.forEach((key) => {
|
|
72
|
+
const activityFunction = WorkerService.activityRegistry[key];
|
|
73
|
+
proxy[key] = WorkflowService.wrapActivity(key, options);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return proxy;
|
|
77
|
+
}
|
|
78
|
+
static wrapActivity(activityName, options) {
|
|
79
|
+
return async function () {
|
|
80
|
+
const store = asyncLocalStorage.getStore();
|
|
81
|
+
if (!store) {
|
|
82
|
+
throw new Error('durable-store-not-found');
|
|
83
|
+
}
|
|
84
|
+
const COUNTER = store.get('counter');
|
|
85
|
+
//increment by state (not value) to avoid race conditions
|
|
86
|
+
const execIndex = COUNTER.counter = COUNTER.counter + 1;
|
|
87
|
+
const workflowId = store.get('workflowId');
|
|
88
|
+
const workflowTopic = store.get('workflowTopic');
|
|
89
|
+
const trc = store.get('workflowTrace');
|
|
90
|
+
const spn = store.get('workflowSpan');
|
|
91
|
+
const activityTopic = `${workflowTopic}-activity`;
|
|
92
|
+
const activityJobId = `${workflowId}-${activityName}-${execIndex}`;
|
|
93
|
+
let activityState;
|
|
94
|
+
try {
|
|
95
|
+
const hmshInstance = await WorkerService.getHotMesh(activityTopic);
|
|
96
|
+
activityState = await hmshInstance.getState(activityTopic, activityJobId);
|
|
97
|
+
if (activityState.metadata.js == 1) {
|
|
98
|
+
//return immediately
|
|
99
|
+
return activityState.data?.response;
|
|
100
|
+
}
|
|
101
|
+
//one time subscription
|
|
102
|
+
return await new Promise((resolve, reject) => {
|
|
103
|
+
hmshInstance.sub(activityTopic, async (topic, message) => {
|
|
104
|
+
const response = message.data?.response;
|
|
105
|
+
hmshInstance.unsub(activityTopic);
|
|
106
|
+
// Resolve the Promise when the callback is triggered with a message
|
|
107
|
+
resolve(response);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
//expected; thrown by `getState` when the job cannot be found
|
|
113
|
+
const duration = ms(options?.startToCloseTimeout || '1 minute');
|
|
114
|
+
const payload = {
|
|
115
|
+
arguments: Array.from(arguments),
|
|
116
|
+
workflowId: activityJobId,
|
|
117
|
+
workflowTopic,
|
|
118
|
+
activityName,
|
|
119
|
+
};
|
|
120
|
+
//start the job
|
|
121
|
+
const hmshInstance = await WorkerService.getHotMesh(activityTopic);
|
|
122
|
+
const context = { metadata: { trc, spn }, data: {} };
|
|
123
|
+
const jobOutput = await hmshInstance.pubsub(activityTopic, payload, context, duration);
|
|
124
|
+
return jobOutput.data.response;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Activity } from '../activities/activity';
|
|
2
|
+
import { ILogger } from '../logger';
|
|
3
|
+
import { StoreSignaler } from '../signaler/store';
|
|
4
|
+
import { StreamSignaler } from '../signaler/stream';
|
|
5
|
+
import { StoreService } from '../store';
|
|
6
|
+
import { StreamService } from '../stream';
|
|
7
|
+
import { SubService } from '../sub';
|
|
8
|
+
import { TaskService } from '../task';
|
|
9
|
+
import { AppVID } from '../../types/app';
|
|
10
|
+
import { ActivityType } from '../../types/activity';
|
|
11
|
+
import { CacheMode } from '../../types/cache';
|
|
12
|
+
import { JobState, JobData, JobMetadata, JobOutput, JobStatus } from '../../types/job';
|
|
13
|
+
import { HotMeshApps, HotMeshConfig, HotMeshManifest, HotMeshSettings } from '../../types/hotmesh';
|
|
14
|
+
import { JobMessageCallback } from '../../types/quorum';
|
|
15
|
+
import { RedisClient, RedisMulti } from '../../types/redis';
|
|
16
|
+
import { GetStatsOptions, IdsResponse, JobStatsInput, StatsResponse } from '../../types/stats';
|
|
17
|
+
import { StreamData, StreamDataResponse, StreamError } from '../../types/stream';
|
|
18
|
+
declare class EngineService {
|
|
19
|
+
namespace: string;
|
|
20
|
+
apps: HotMeshApps | null;
|
|
21
|
+
appId: string;
|
|
22
|
+
guid: string;
|
|
23
|
+
store: StoreService<RedisClient, RedisMulti> | null;
|
|
24
|
+
stream: StreamService<RedisClient, RedisMulti> | null;
|
|
25
|
+
subscribe: SubService<RedisClient, RedisMulti> | null;
|
|
26
|
+
storeSignaler: StoreSignaler | null;
|
|
27
|
+
streamSignaler: StreamSignaler | null;
|
|
28
|
+
task: TaskService | null;
|
|
29
|
+
logger: ILogger;
|
|
30
|
+
cacheMode: CacheMode;
|
|
31
|
+
untilVersion: string | null;
|
|
32
|
+
jobCallbacks: Record<string, JobMessageCallback>;
|
|
33
|
+
reporting: boolean;
|
|
34
|
+
jobId: number;
|
|
35
|
+
static init(namespace: string, appId: string, guid: string, config: HotMeshConfig, logger: ILogger): Promise<EngineService>;
|
|
36
|
+
verifyEngineFields(config: HotMeshConfig): void;
|
|
37
|
+
initStoreChannel(store: RedisClient): Promise<void>;
|
|
38
|
+
initSubChannel(sub: RedisClient): Promise<void>;
|
|
39
|
+
initStreamChannel(stream: RedisClient): Promise<void>;
|
|
40
|
+
initStreamSignaler(config: HotMeshConfig): StreamSignaler;
|
|
41
|
+
getVID(vid?: AppVID): Promise<AppVID>;
|
|
42
|
+
setCacheMode(cacheMode: CacheMode, untilVersion: string): void;
|
|
43
|
+
routeToSubscribers(topic: string, message: JobOutput): Promise<void>;
|
|
44
|
+
processWebHooks(): Promise<void>;
|
|
45
|
+
processTimeHooks(): Promise<void>;
|
|
46
|
+
throttle(delayInMillis: number): Promise<void>;
|
|
47
|
+
initActivity(topic: string, data?: JobData, context?: JobState): Promise<Activity>;
|
|
48
|
+
getSchema(topic: string): Promise<[activityId: string, schema: ActivityType]>;
|
|
49
|
+
getSettings(): Promise<HotMeshSettings>;
|
|
50
|
+
isPrivate(topic: string): boolean;
|
|
51
|
+
plan(pathOrYAML: string): Promise<HotMeshManifest>;
|
|
52
|
+
deploy(pathOrYAML: string): Promise<HotMeshManifest>;
|
|
53
|
+
getStats(topic: string, query: JobStatsInput): Promise<StatsResponse>;
|
|
54
|
+
getIds(topic: string, query: JobStatsInput, queryFacets?: any[]): Promise<IdsResponse>;
|
|
55
|
+
resolveQuery(topic: string, query: JobStatsInput): Promise<GetStatsOptions>;
|
|
56
|
+
processStreamMessage(streamData: StreamDataResponse): Promise<void>;
|
|
57
|
+
execAdjacentParent(context: JobState, jobOutput: JobOutput): Promise<string>;
|
|
58
|
+
hasParentJob(context: JobState): boolean;
|
|
59
|
+
resolveError(metadata: JobMetadata): StreamError | undefined;
|
|
60
|
+
scrub(jobId: string): Promise<void>;
|
|
61
|
+
hook(topic: string, data: JobData, dad?: string): Promise<JobStatus | void>;
|
|
62
|
+
hookTime(jobId: string, activityId: string): Promise<JobStatus | void>;
|
|
63
|
+
hookAll(hookTopic: string, data: JobData, query: JobStatsInput, queryFacets?: string[]): Promise<string[]>;
|
|
64
|
+
pub(topic: string, data: JobData, context?: JobState): Promise<string>;
|
|
65
|
+
sub(topic: string, callback: JobMessageCallback): Promise<void>;
|
|
66
|
+
unsub(topic: string): Promise<void>;
|
|
67
|
+
psub(wild: string, callback: JobMessageCallback): Promise<void>;
|
|
68
|
+
punsub(wild: string): Promise<void>;
|
|
69
|
+
pubsub(topic: string, data: JobData, context?: JobState | null, timeout?: number): Promise<JobOutput>;
|
|
70
|
+
resolveOneTimeSubscription(context: JobState, jobOutput: JobOutput): Promise<void>;
|
|
71
|
+
getPublishesTopic(context: JobState): Promise<string>;
|
|
72
|
+
resolvePersistentSubscriptions(context: JobState, jobOutput: JobOutput): Promise<void>;
|
|
73
|
+
add(streamData: StreamData | StreamDataResponse): Promise<string>;
|
|
74
|
+
registerJobCallback(jobId: string, jobCallback: JobMessageCallback): void;
|
|
75
|
+
delistJobCallback(jobId: string): void;
|
|
76
|
+
hasOneTimeSubscription(context: JobState): boolean;
|
|
77
|
+
runJobCompletionTasks(context: JobState): Promise<void>;
|
|
78
|
+
getStatus(jobId: string): Promise<JobStatus>;
|
|
79
|
+
getState(topic: string, jobId: string): Promise<JobOutput>;
|
|
80
|
+
compress(terms: string[]): Promise<boolean>;
|
|
81
|
+
}
|
|
82
|
+
export { EngineService };
|