@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,140 @@
|
|
|
1
|
+
import { GetStateError } from '../../modules/errors';
|
|
2
|
+
import { Activity } from './activity';
|
|
3
|
+
import { StreamDataType, StreamStatus } from '../../types/stream';
|
|
4
|
+
import { TelemetryService } from '../telemetry';
|
|
5
|
+
import { CollatorService } from '../collator';
|
|
6
|
+
class Await extends Activity {
|
|
7
|
+
constructor(config, data, metadata, hook, engine, context) {
|
|
8
|
+
super(config, data, metadata, hook, engine, context);
|
|
9
|
+
}
|
|
10
|
+
//******** INITIAL ENTRY POINT (A) ********//
|
|
11
|
+
async process() {
|
|
12
|
+
this.logger.debug('await-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
13
|
+
let telemetry;
|
|
14
|
+
try {
|
|
15
|
+
this.setLeg(1);
|
|
16
|
+
await CollatorService.notarizeEntry(this);
|
|
17
|
+
await this.getState();
|
|
18
|
+
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
19
|
+
telemetry.startActivitySpan(this.leg);
|
|
20
|
+
this.mapInputData();
|
|
21
|
+
const multi = this.store.getMulti();
|
|
22
|
+
//await this.registerTimeout();
|
|
23
|
+
await CollatorService.authorizeReentry(this, multi);
|
|
24
|
+
await this.setState(multi);
|
|
25
|
+
await this.setStatus(0, multi);
|
|
26
|
+
const multiResponse = await multi.exec();
|
|
27
|
+
telemetry.mapActivityAttributes();
|
|
28
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
29
|
+
const messageId = await this.execActivity();
|
|
30
|
+
telemetry.setActivityAttributes({
|
|
31
|
+
'app.activity.mid': messageId,
|
|
32
|
+
'app.job.jss': jobStatus
|
|
33
|
+
});
|
|
34
|
+
return this.context.metadata.aid;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
telemetry.setActivityError(error.message);
|
|
38
|
+
if (error instanceof GetStateError) {
|
|
39
|
+
this.logger.error('await-get-state-error', error);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.logger.error('await-process-error', error);
|
|
43
|
+
}
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
telemetry.endActivitySpan();
|
|
48
|
+
this.logger.debug('await-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async execActivity() {
|
|
52
|
+
const streamData = {
|
|
53
|
+
metadata: {
|
|
54
|
+
jid: this.context.metadata.jid,
|
|
55
|
+
dad: this.metadata.dad,
|
|
56
|
+
aid: this.metadata.aid,
|
|
57
|
+
topic: this.config.subtype,
|
|
58
|
+
spn: this.context['$self'].output.metadata?.l1s,
|
|
59
|
+
trc: this.context.metadata.trc,
|
|
60
|
+
},
|
|
61
|
+
type: StreamDataType.AWAIT,
|
|
62
|
+
data: this.context.data
|
|
63
|
+
};
|
|
64
|
+
if (this.config.retry) {
|
|
65
|
+
streamData.policies = {
|
|
66
|
+
retry: this.config.retry
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return (await this.engine.streamSignaler?.publishMessage(null, streamData));
|
|
70
|
+
}
|
|
71
|
+
//******** `RESOLVE` ENTRY POINT (B) ********//
|
|
72
|
+
//this method is invoked when the job spawned by this job ends;
|
|
73
|
+
//`this.data` is the job data produced by the spawned job
|
|
74
|
+
async processEvent(status = StreamStatus.SUCCESS, code = 200) {
|
|
75
|
+
this.setLeg(2);
|
|
76
|
+
const jid = this.context.metadata.jid;
|
|
77
|
+
const aid = this.metadata.aid;
|
|
78
|
+
if (!jid) {
|
|
79
|
+
throw new Error('await-process-event-error');
|
|
80
|
+
}
|
|
81
|
+
this.logger.debug('await-resolve-await', { jid, aid, status, code });
|
|
82
|
+
this.status = status;
|
|
83
|
+
this.code = code;
|
|
84
|
+
let telemetry;
|
|
85
|
+
try {
|
|
86
|
+
await this.getState();
|
|
87
|
+
const aState = await CollatorService.notarizeReentry(this);
|
|
88
|
+
this.adjacentIndex = CollatorService.getDimensionalIndex(aState);
|
|
89
|
+
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
90
|
+
telemetry.startActivitySpan(this.leg);
|
|
91
|
+
let multiResponse = [];
|
|
92
|
+
if (status === StreamStatus.SUCCESS) {
|
|
93
|
+
this.bindActivityData('output');
|
|
94
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
95
|
+
multiResponse = await this.processSuccess(this.adjacencyList);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.bindActivityError(this.data);
|
|
99
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
100
|
+
multiResponse = await this.processError(this.adjacencyList);
|
|
101
|
+
}
|
|
102
|
+
telemetry.mapActivityAttributes();
|
|
103
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
104
|
+
const attrs = { 'app.job.jss': jobStatus };
|
|
105
|
+
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
106
|
+
if (messageIds.length) {
|
|
107
|
+
attrs['app.activity.mids'] = messageIds.join(',');
|
|
108
|
+
}
|
|
109
|
+
telemetry.setActivityAttributes(attrs);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
this.logger.error('await-resolve-await-error', error);
|
|
113
|
+
telemetry.setActivityError(error.message);
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
telemetry.endActivitySpan();
|
|
118
|
+
this.logger.debug('await-resolve-await-end', { jid, aid, status, code });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async processSuccess(adjacencyList) {
|
|
122
|
+
this.mapJobData();
|
|
123
|
+
const multi = this.store.getMulti();
|
|
124
|
+
await this.setState(multi);
|
|
125
|
+
await CollatorService.notarizeCompletion(this, multi);
|
|
126
|
+
await this.setStatus(adjacencyList.length - 1, multi);
|
|
127
|
+
return await multi.exec();
|
|
128
|
+
}
|
|
129
|
+
async processError(adjacencyList) {
|
|
130
|
+
//todo: if adjacencyList.length == 0, then map to the job output
|
|
131
|
+
// this method would be added to Base activity class
|
|
132
|
+
//this.mapJobData();
|
|
133
|
+
const multi = this.store.getMulti();
|
|
134
|
+
await this.setState(multi);
|
|
135
|
+
await CollatorService.notarizeCompletion(this, multi);
|
|
136
|
+
await this.setStatus(adjacencyList.length - 1, multi);
|
|
137
|
+
return await multi.exec();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export { Await };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EngineService } from '../engine';
|
|
2
|
+
import { Activity, ActivityType } from './activity';
|
|
3
|
+
import { ActivityData, ActivityMetadata, EmitActivity } from '../../types/activity';
|
|
4
|
+
declare class Emit extends Activity {
|
|
5
|
+
config: EmitActivity;
|
|
6
|
+
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService);
|
|
7
|
+
mapInputData(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export { Emit };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Activity } from './activity';
|
|
2
|
+
class Emit extends Activity {
|
|
3
|
+
constructor(config, data, metadata, hook, engine) {
|
|
4
|
+
super(config, data, metadata, hook, engine);
|
|
5
|
+
}
|
|
6
|
+
async mapInputData() {
|
|
7
|
+
this.logger.info('emit-map-input-data');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export { Emit };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Activity } from './activity';
|
|
2
|
+
import { Await } from './await';
|
|
3
|
+
import { Worker } from './worker';
|
|
4
|
+
import { Iterate } from './iterate';
|
|
5
|
+
import { Emit } from './emit';
|
|
6
|
+
import { Trigger } from './trigger';
|
|
7
|
+
declare const _default: {
|
|
8
|
+
activity: typeof Activity;
|
|
9
|
+
await: typeof Await;
|
|
10
|
+
iterate: typeof Iterate;
|
|
11
|
+
emit: typeof Emit;
|
|
12
|
+
trigger: typeof Trigger;
|
|
13
|
+
worker: typeof Worker;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Activity } from './activity';
|
|
2
|
+
import { Await } from './await';
|
|
3
|
+
import { Worker } from './worker';
|
|
4
|
+
import { Iterate } from './iterate';
|
|
5
|
+
import { Emit } from './emit';
|
|
6
|
+
import { Trigger } from './trigger';
|
|
7
|
+
export default {
|
|
8
|
+
activity: Activity,
|
|
9
|
+
await: Await,
|
|
10
|
+
iterate: Iterate,
|
|
11
|
+
emit: Emit,
|
|
12
|
+
trigger: Trigger,
|
|
13
|
+
worker: Worker,
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EngineService } from '../engine';
|
|
2
|
+
import { Activity, ActivityType } from './activity';
|
|
3
|
+
import { ActivityData, ActivityMetadata, IterateActivity } from '../../types/activity';
|
|
4
|
+
declare class Iterate extends Activity {
|
|
5
|
+
config: IterateActivity;
|
|
6
|
+
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService);
|
|
7
|
+
mapInputData(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export { Iterate };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Activity } from './activity';
|
|
2
|
+
class Iterate extends Activity {
|
|
3
|
+
constructor(config, data, metadata, hook, engine) {
|
|
4
|
+
super(config, data, metadata, hook, engine);
|
|
5
|
+
}
|
|
6
|
+
async mapInputData() {
|
|
7
|
+
this.logger.info('iterate-map-input-data');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export { Iterate };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Activity } from './activity';
|
|
2
|
+
import { EngineService } from '../engine';
|
|
3
|
+
import { ActivityData, ActivityMetadata, ActivityType, TriggerActivity } from '../../types/activity';
|
|
4
|
+
import { JobState } from '../../types/job';
|
|
5
|
+
import { RedisMulti } from '../../types/redis';
|
|
6
|
+
declare class Trigger extends Activity {
|
|
7
|
+
config: TriggerActivity;
|
|
8
|
+
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
9
|
+
process(): Promise<string>;
|
|
10
|
+
setStatus(amount: number): Promise<void>;
|
|
11
|
+
createInputContext(): Partial<JobState>;
|
|
12
|
+
getState(): Promise<void>;
|
|
13
|
+
bindJobMetadataPaths(): string[];
|
|
14
|
+
bindActivityMetadataPaths(): string[];
|
|
15
|
+
resolveGranularity(): string;
|
|
16
|
+
getJobStatus(): number;
|
|
17
|
+
resolveJobId(context: Partial<JobState>): string;
|
|
18
|
+
resolveJobKey(context: Partial<JobState>): string;
|
|
19
|
+
setStateNX(): Promise<void>;
|
|
20
|
+
setStats(multi?: RedisMulti): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export { Trigger };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { DuplicateJobError } from '../../modules/errors';
|
|
3
|
+
import { formatISODate, getTimeSeries } from '../../modules/utils';
|
|
4
|
+
import { Activity } from './activity';
|
|
5
|
+
import { CollatorService } from '../collator';
|
|
6
|
+
import { DimensionService } from '../dimension';
|
|
7
|
+
import { Pipe } from '../pipe';
|
|
8
|
+
import { ReporterService } from '../reporter';
|
|
9
|
+
import { MDATA_SYMBOLS } from '../serializer';
|
|
10
|
+
import { TelemetryService } from '../telemetry';
|
|
11
|
+
class Trigger extends Activity {
|
|
12
|
+
constructor(config, data, metadata, hook, engine, context) {
|
|
13
|
+
super(config, data, metadata, hook, engine, context);
|
|
14
|
+
}
|
|
15
|
+
async process() {
|
|
16
|
+
this.logger.debug('trigger-process', { subscribes: this.config.subscribes });
|
|
17
|
+
let telemetry;
|
|
18
|
+
try {
|
|
19
|
+
this.setLeg(2);
|
|
20
|
+
await this.getState();
|
|
21
|
+
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
22
|
+
telemetry.startJobSpan();
|
|
23
|
+
telemetry.startActivitySpan(this.leg);
|
|
24
|
+
this.mapJobData();
|
|
25
|
+
await this.setStateNX();
|
|
26
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
27
|
+
await this.setStatus(this.adjacencyList.length);
|
|
28
|
+
const multi = this.store.getMulti();
|
|
29
|
+
await this.setState(multi);
|
|
30
|
+
await this.setStats(multi);
|
|
31
|
+
await multi.exec();
|
|
32
|
+
telemetry.mapActivityAttributes();
|
|
33
|
+
const jobStatus = Number(this.context.metadata.js);
|
|
34
|
+
telemetry.setJobAttributes({ 'app.job.jss': jobStatus });
|
|
35
|
+
const attrs = { 'app.job.jss': jobStatus };
|
|
36
|
+
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
37
|
+
if (messageIds.length) {
|
|
38
|
+
attrs['app.activity.mids'] = messageIds.join(',');
|
|
39
|
+
}
|
|
40
|
+
telemetry.setActivityAttributes(attrs);
|
|
41
|
+
return this.context.metadata.jid;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (error instanceof DuplicateJobError) {
|
|
45
|
+
this.logger.error('duplicate-job-error', error);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.logger.error('trigger-process-error', error);
|
|
49
|
+
}
|
|
50
|
+
telemetry.setActivityError(error.message);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
telemetry.endJobSpan();
|
|
55
|
+
telemetry.endActivitySpan();
|
|
56
|
+
this.logger.debug('trigger-process-end', { subscribes: this.config.subscribes, jid: this.context.metadata.jid });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async setStatus(amount) {
|
|
60
|
+
this.context.metadata.js = amount;
|
|
61
|
+
}
|
|
62
|
+
createInputContext() {
|
|
63
|
+
const input = {
|
|
64
|
+
[this.metadata.aid]: {
|
|
65
|
+
input: { data: this.data }
|
|
66
|
+
},
|
|
67
|
+
'$self': {
|
|
68
|
+
input: { data: this.data },
|
|
69
|
+
output: { data: this.data }
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
return input;
|
|
73
|
+
}
|
|
74
|
+
async getState() {
|
|
75
|
+
const inputContext = this.createInputContext();
|
|
76
|
+
const jobId = this.resolveJobId(inputContext);
|
|
77
|
+
const jobKey = this.resolveJobKey(inputContext);
|
|
78
|
+
const utc = formatISODate(new Date());
|
|
79
|
+
const { id, version } = await this.engine.getVID();
|
|
80
|
+
this.initDimensionalAddress(DimensionService.getSeed());
|
|
81
|
+
const activityMetadata = {
|
|
82
|
+
...this.metadata,
|
|
83
|
+
jid: jobId,
|
|
84
|
+
key: jobKey,
|
|
85
|
+
as: CollatorService.getTriggerSeed(),
|
|
86
|
+
};
|
|
87
|
+
this.context = {
|
|
88
|
+
metadata: {
|
|
89
|
+
...this.metadata,
|
|
90
|
+
ngn: this.context.metadata.ngn,
|
|
91
|
+
pj: this.context.metadata.pj,
|
|
92
|
+
pd: this.context.metadata.pd,
|
|
93
|
+
pa: this.context.metadata.pa,
|
|
94
|
+
app: id,
|
|
95
|
+
vrs: version,
|
|
96
|
+
tpc: this.config.subscribes,
|
|
97
|
+
trc: this.context.metadata.trc,
|
|
98
|
+
spn: this.context.metadata.spn,
|
|
99
|
+
jid: jobId,
|
|
100
|
+
dad: DimensionService.getSeed(),
|
|
101
|
+
key: jobKey,
|
|
102
|
+
jc: utc,
|
|
103
|
+
ju: utc,
|
|
104
|
+
ts: getTimeSeries(this.resolveGranularity()),
|
|
105
|
+
js: 0,
|
|
106
|
+
},
|
|
107
|
+
data: {},
|
|
108
|
+
[this.metadata.aid]: {
|
|
109
|
+
input: {
|
|
110
|
+
data: this.data,
|
|
111
|
+
metadata: activityMetadata
|
|
112
|
+
},
|
|
113
|
+
output: {
|
|
114
|
+
data: this.data,
|
|
115
|
+
metadata: activityMetadata
|
|
116
|
+
},
|
|
117
|
+
settings: { data: {} },
|
|
118
|
+
errors: { data: {} },
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
this.context['$self'] = this.context[this.metadata.aid];
|
|
122
|
+
}
|
|
123
|
+
bindJobMetadataPaths() {
|
|
124
|
+
return MDATA_SYMBOLS.JOB.KEYS.map((key) => `metadata/${key}`);
|
|
125
|
+
}
|
|
126
|
+
bindActivityMetadataPaths() {
|
|
127
|
+
return MDATA_SYMBOLS.ACTIVITY.KEYS.map((key) => `output/metadata/${key}`);
|
|
128
|
+
}
|
|
129
|
+
resolveGranularity() {
|
|
130
|
+
return ReporterService.DEFAULT_GRANULARITY;
|
|
131
|
+
}
|
|
132
|
+
getJobStatus() {
|
|
133
|
+
return this.context.metadata.js;
|
|
134
|
+
}
|
|
135
|
+
resolveJobId(context) {
|
|
136
|
+
const jobId = this.config.stats?.id;
|
|
137
|
+
return jobId ? Pipe.resolve(jobId, context) : uuidv4();
|
|
138
|
+
}
|
|
139
|
+
resolveJobKey(context) {
|
|
140
|
+
const jobKey = this.config.stats?.key;
|
|
141
|
+
return jobKey ? Pipe.resolve(jobKey, context) : '';
|
|
142
|
+
}
|
|
143
|
+
async setStateNX() {
|
|
144
|
+
const jobId = this.context.metadata.jid;
|
|
145
|
+
if (!await this.store.setStateNX(jobId, this.engine.appId)) {
|
|
146
|
+
throw new DuplicateJobError(jobId);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async setStats(multi) {
|
|
150
|
+
const md = this.context.metadata;
|
|
151
|
+
if (this.config.stats?.measures) {
|
|
152
|
+
const config = await this.engine.getVID();
|
|
153
|
+
const reporter = new ReporterService(config, this.store, this.logger);
|
|
154
|
+
await this.store.setStats(md.key, md.jid, md.ts, reporter.resolveTriggerStatistics(this.config, this.context), config, multi);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export { Trigger };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Activity } from './activity';
|
|
2
|
+
import { EngineService } from '../engine';
|
|
3
|
+
import { ActivityData, ActivityMetadata, ActivityType, WorkerActivity } from '../../types/activity';
|
|
4
|
+
import { JobState } from '../../types/job';
|
|
5
|
+
import { StreamCode, StreamStatus } from '../../types/stream';
|
|
6
|
+
import { TelemetryService } from '../telemetry';
|
|
7
|
+
declare class Worker extends Activity {
|
|
8
|
+
config: WorkerActivity;
|
|
9
|
+
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
10
|
+
process(): Promise<string>;
|
|
11
|
+
execActivity(): Promise<string>;
|
|
12
|
+
processEvent(status?: StreamStatus, code?: StreamCode): Promise<void>;
|
|
13
|
+
processPending(telemetry: TelemetryService): Promise<void>;
|
|
14
|
+
processSuccess(telemetry: TelemetryService): Promise<void>;
|
|
15
|
+
processError(telemetry: TelemetryService): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export { Worker };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { GetStateError } from '../../modules/errors';
|
|
2
|
+
import { Activity } from './activity';
|
|
3
|
+
import { CollatorService } from '../collator';
|
|
4
|
+
import { StreamStatus } from '../../types/stream';
|
|
5
|
+
import { TelemetryService } from '../telemetry';
|
|
6
|
+
class Worker extends Activity {
|
|
7
|
+
constructor(config, data, metadata, hook, engine, context) {
|
|
8
|
+
super(config, data, metadata, hook, engine, context);
|
|
9
|
+
}
|
|
10
|
+
//******** INITIAL ENTRY POINT (A) ********//
|
|
11
|
+
async process() {
|
|
12
|
+
this.logger.debug('worker-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
13
|
+
let telemetry;
|
|
14
|
+
try {
|
|
15
|
+
this.setLeg(1);
|
|
16
|
+
await CollatorService.notarizeEntry(this);
|
|
17
|
+
await this.getState();
|
|
18
|
+
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
19
|
+
telemetry.startActivitySpan(this.leg);
|
|
20
|
+
this.mapInputData();
|
|
21
|
+
const multi = this.store.getMulti();
|
|
22
|
+
//await this.registerTimeout();
|
|
23
|
+
await CollatorService.authorizeReentry(this, multi);
|
|
24
|
+
await this.setState(multi);
|
|
25
|
+
await this.setStatus(0, multi);
|
|
26
|
+
const multiResponse = await multi.exec();
|
|
27
|
+
telemetry.mapActivityAttributes();
|
|
28
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
29
|
+
const messageId = await this.execActivity();
|
|
30
|
+
telemetry.setActivityAttributes({
|
|
31
|
+
'app.activity.mid': messageId,
|
|
32
|
+
'app.job.jss': jobStatus
|
|
33
|
+
});
|
|
34
|
+
//TODO: UPDATE ACTIVITY STATE (LEG 1 EXIT)
|
|
35
|
+
return this.context.metadata.aid;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof GetStateError) {
|
|
39
|
+
this.logger.error('worker-get-state-error', error);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.error(error);
|
|
43
|
+
this.logger.error('worker-process-error', error);
|
|
44
|
+
}
|
|
45
|
+
telemetry.setActivityError(error.message);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
telemetry.endActivitySpan();
|
|
50
|
+
this.logger.debug('worker-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async execActivity() {
|
|
54
|
+
const streamData = {
|
|
55
|
+
metadata: {
|
|
56
|
+
jid: this.context.metadata.jid,
|
|
57
|
+
dad: this.metadata.dad,
|
|
58
|
+
aid: this.metadata.aid,
|
|
59
|
+
topic: this.config.subtype,
|
|
60
|
+
spn: this.context['$self'].output.metadata.l1s,
|
|
61
|
+
trc: this.context.metadata.trc,
|
|
62
|
+
},
|
|
63
|
+
data: this.context.data
|
|
64
|
+
};
|
|
65
|
+
if (this.config.retry) {
|
|
66
|
+
streamData.policies = {
|
|
67
|
+
retry: this.config.retry
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return (await this.engine.streamSignaler?.publishMessage(this.config.subtype, streamData));
|
|
71
|
+
}
|
|
72
|
+
//******** SIGNAL RE-ENTRY POINT (DUPLEX LEG 2 of 2) ********//
|
|
73
|
+
async processEvent(status = StreamStatus.SUCCESS, code = 200) {
|
|
74
|
+
this.setLeg(2);
|
|
75
|
+
const jid = this.context.metadata.jid;
|
|
76
|
+
const aid = this.metadata.aid;
|
|
77
|
+
this.status = status;
|
|
78
|
+
this.code = code;
|
|
79
|
+
this.logger.debug('worker-process-event', { topic: this.config.subtype, jid, aid, status, code });
|
|
80
|
+
let telemetry;
|
|
81
|
+
try {
|
|
82
|
+
await this.getState();
|
|
83
|
+
const aState = await CollatorService.notarizeReentry(this);
|
|
84
|
+
this.adjacentIndex = CollatorService.getDimensionalIndex(aState);
|
|
85
|
+
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
86
|
+
let isComplete = CollatorService.isActivityComplete(this.context.metadata.js);
|
|
87
|
+
if (isComplete) {
|
|
88
|
+
this.logger.warn('worker-process-event-duplicate', { jid, aid });
|
|
89
|
+
this.logger.debug('worker-process-event-duplicate-resolution', { resolution: 'Increase HotMesh config `reclaimDelay` timeout.' });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
telemetry.startActivitySpan(this.leg);
|
|
93
|
+
if (status === StreamStatus.PENDING) {
|
|
94
|
+
await this.processPending(telemetry);
|
|
95
|
+
}
|
|
96
|
+
else if (status === StreamStatus.SUCCESS) {
|
|
97
|
+
await this.processSuccess(telemetry);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
await this.processError(telemetry);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
this.logger.error('worker-process-event-error', error);
|
|
105
|
+
telemetry.setActivityError(error.message);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
telemetry.endActivitySpan();
|
|
110
|
+
this.logger.debug('worker-process-event-end', { jid, aid });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async processPending(telemetry) {
|
|
114
|
+
this.bindActivityData('output');
|
|
115
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
116
|
+
this.mapJobData();
|
|
117
|
+
const multi = this.store.getMulti();
|
|
118
|
+
await this.setState(multi);
|
|
119
|
+
await CollatorService.notarizeContinuation(this, multi);
|
|
120
|
+
await this.setStatus(0, multi);
|
|
121
|
+
const multiResponse = await multi.exec();
|
|
122
|
+
telemetry.mapActivityAttributes();
|
|
123
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
124
|
+
telemetry.setActivityAttributes({ 'app.job.jss': jobStatus });
|
|
125
|
+
}
|
|
126
|
+
async processSuccess(telemetry) {
|
|
127
|
+
this.bindActivityData('output');
|
|
128
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
129
|
+
this.mapJobData();
|
|
130
|
+
const multi = this.store.getMulti();
|
|
131
|
+
await this.setState(multi);
|
|
132
|
+
await CollatorService.notarizeCompletion(this, multi);
|
|
133
|
+
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
134
|
+
const multiResponse = await multi.exec();
|
|
135
|
+
telemetry.mapActivityAttributes();
|
|
136
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
137
|
+
const attrs = { 'app.job.jss': jobStatus };
|
|
138
|
+
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
139
|
+
if (messageIds.length) {
|
|
140
|
+
attrs['app.activity.mids'] = messageIds.join(',');
|
|
141
|
+
}
|
|
142
|
+
telemetry.setActivityAttributes(attrs);
|
|
143
|
+
}
|
|
144
|
+
async processError(telemetry) {
|
|
145
|
+
this.bindActivityError(this.data);
|
|
146
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
147
|
+
const multi = this.store.getMulti();
|
|
148
|
+
await this.setState(multi);
|
|
149
|
+
await CollatorService.notarizeCompletion(this, multi);
|
|
150
|
+
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
151
|
+
const multiResponse = await multi.exec();
|
|
152
|
+
telemetry.mapActivityAttributes();
|
|
153
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
154
|
+
const attrs = { 'app.job.jss': jobStatus };
|
|
155
|
+
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
156
|
+
if (messageIds.length) {
|
|
157
|
+
attrs['app.activity.mids'] = messageIds.join(',');
|
|
158
|
+
}
|
|
159
|
+
telemetry.setActivityAttributes(attrs);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export { Worker };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { RedisMulti } from '../../types/redis';
|
|
2
|
+
import { CollationStage } from '../../types/collator';
|
|
3
|
+
import { ActivityDuplex } from '../../types/activity';
|
|
4
|
+
import { HotMeshGraph } from '../../types/hotmesh';
|
|
5
|
+
import { Activity } from '../activities/activity';
|
|
6
|
+
declare class CollatorService {
|
|
7
|
+
static targetLength: number;
|
|
8
|
+
static getDimensionalAddress(activity: Activity): Record<string, string>;
|
|
9
|
+
static notarizeEntry(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
10
|
+
static authorizeReentry(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
11
|
+
static notarizeEarlyCompletion(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
12
|
+
static notarizeReentry(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
13
|
+
static notarizeContinuation(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
14
|
+
static notarizeCompletion(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
15
|
+
static getDigitAtIndex(num: number, targetDigitIndex: number): number | null;
|
|
16
|
+
static getDimensionalIndex(num: number): number | null;
|
|
17
|
+
static isDuplicate(num: number, targetDigitIndex: number): boolean;
|
|
18
|
+
static isInactive(num: number): boolean;
|
|
19
|
+
static isPrimed(amount: number, leg: ActivityDuplex): boolean;
|
|
20
|
+
static verifyInteger(amount: number, leg: ActivityDuplex, stage: CollationStage): void;
|
|
21
|
+
static getDimensionsById(ancestors: string[], dad: string): Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* All non-trigger activities are assigned a status seed by their parent
|
|
24
|
+
*/
|
|
25
|
+
static getSeed(): string;
|
|
26
|
+
/**
|
|
27
|
+
* All trigger activities are assigned a status seed in a completed state
|
|
28
|
+
*/
|
|
29
|
+
static getTriggerSeed(): string;
|
|
30
|
+
/**
|
|
31
|
+
* entry point for compiler-type activities. This is called by the compiler
|
|
32
|
+
* to bind the sorted activity IDs to the trigger activity. These are then used
|
|
33
|
+
* at runtime by the activities to track job/activity status.
|
|
34
|
+
* @param graphs
|
|
35
|
+
*/
|
|
36
|
+
static compile(graphs: HotMeshGraph[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* binds the ancestor array to each activity.
|
|
39
|
+
* Used in conjunction with the dimensional
|
|
40
|
+
* address (dad). If dad is `,0,1,0,0` and the
|
|
41
|
+
* ancestor array is `['t1', 'a1', 'a2']` for
|
|
42
|
+
* activity 'a3', then the SAVED DAD
|
|
43
|
+
* will always have the trailing
|
|
44
|
+
* 0's removed. This ensures that the addressing
|
|
45
|
+
* remains consistent even if the graph changes.
|
|
46
|
+
* id DAD SAVED DAD
|
|
47
|
+
* * t1 => ,0 => [empty]
|
|
48
|
+
* * a1 => ,0,1 => ,0,1
|
|
49
|
+
* * a2 => ,0,1,0 => ,0,1
|
|
50
|
+
* * a3 => ,0,1,0,0 => ,0,1
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
static bindAncestorArray(graphs: HotMeshGraph[]): void;
|
|
54
|
+
static isActivityComplete(status: number): boolean;
|
|
55
|
+
}
|
|
56
|
+
export { CollatorService };
|