@hotmeshio/hotmesh 0.0.8 → 0.0.9
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/LICENSE +4 -7
- package/README.md +37 -46
- package/build/{esm/package.json → package.json} +4 -11
- package/build/{cjs/services → services}/durable/native.js +2 -2
- package/build/{esm/services → services}/durable/worker.d.ts +1 -3
- package/build/{cjs/services → services}/durable/worker.js +9 -32
- package/build/{cjs/services → services}/durable/workflow.js +6 -1
- package/build/{cjs/types → types}/durable.d.ts +4 -6
- package/package.json +4 -11
- package/services/durable/native.ts +2 -2
- package/services/durable/worker.ts +9 -9
- package/services/durable/workflow.ts +7 -1
- package/types/durable.ts +4 -4
- package/build/cjs/package.json +0 -82
- package/build/cjs/services/durable/worker.d.ts +0 -38
- package/build/esm/index.d.ts +0 -4
- package/build/esm/index.js +0 -3
- package/build/esm/modules/errors.d.ts +0 -28
- package/build/esm/modules/errors.js +0 -41
- package/build/esm/modules/key.d.ts +0 -75
- package/build/esm/modules/key.js +0 -111
- package/build/esm/modules/utils.d.ts +0 -34
- package/build/esm/modules/utils.js +0 -154
- package/build/esm/services/activities/activity.d.ts +0 -67
- package/build/esm/services/activities/activity.js +0 -486
- package/build/esm/services/activities/await.d.ts +0 -16
- package/build/esm/services/activities/await.js +0 -140
- package/build/esm/services/activities/cycle.d.ts +0 -19
- package/build/esm/services/activities/cycle.js +0 -74
- package/build/esm/services/activities/emit.d.ts +0 -9
- package/build/esm/services/activities/emit.js +0 -10
- package/build/esm/services/activities/index.d.ts +0 -17
- package/build/esm/services/activities/index.js +0 -16
- package/build/esm/services/activities/iterate.d.ts +0 -9
- package/build/esm/services/activities/iterate.js +0 -10
- package/build/esm/services/activities/trigger.d.ts +0 -22
- package/build/esm/services/activities/trigger.js +0 -158
- package/build/esm/services/activities/worker.d.ts +0 -11
- package/build/esm/services/activities/worker.js +0 -70
- package/build/esm/services/collator/index.d.ts +0 -73
- package/build/esm/services/collator/index.js +0 -221
- package/build/esm/services/compiler/deployer.d.ts +0 -36
- package/build/esm/services/compiler/deployer.js +0 -423
- package/build/esm/services/compiler/index.d.ts +0 -30
- package/build/esm/services/compiler/index.js +0 -82
- package/build/esm/services/compiler/validator.d.ts +0 -32
- package/build/esm/services/compiler/validator.js +0 -131
- package/build/esm/services/connector/clients/ioredis.d.ts +0 -13
- package/build/esm/services/connector/clients/ioredis.js +0 -47
- package/build/esm/services/connector/clients/redis.d.ts +0 -13
- package/build/esm/services/connector/clients/redis.js +0 -59
- package/build/esm/services/connector/index.d.ts +0 -5
- package/build/esm/services/connector/index.js +0 -27
- package/build/esm/services/dimension/index.d.ts +0 -29
- package/build/esm/services/dimension/index.js +0 -32
- package/build/esm/services/durable/asyncLocalStorage.d.ts +0 -3
- package/build/esm/services/durable/asyncLocalStorage.js +0 -2
- package/build/esm/services/durable/client.d.ts +0 -15
- package/build/esm/services/durable/client.js +0 -114
- package/build/esm/services/durable/connection.d.ts +0 -4
- package/build/esm/services/durable/connection.js +0 -47
- package/build/esm/services/durable/factory.d.ts +0 -3
- package/build/esm/services/durable/factory.js +0 -135
- package/build/esm/services/durable/handle.d.ts +0 -8
- package/build/esm/services/durable/handle.js +0 -34
- package/build/esm/services/durable/index.d.ts +0 -57
- package/build/esm/services/durable/index.js +0 -55
- package/build/esm/services/durable/native.d.ts +0 -4
- package/build/esm/services/durable/native.js +0 -43
- package/build/esm/services/durable/worker.js +0 -267
- package/build/esm/services/durable/workflow.d.ts +0 -6
- package/build/esm/services/durable/workflow.js +0 -132
- package/build/esm/services/engine/index.d.ts +0 -82
- package/build/esm/services/engine/index.js +0 -522
- package/build/esm/services/hotmesh/index.d.ts +0 -45
- package/build/esm/services/hotmesh/index.js +0 -131
- package/build/esm/services/logger/index.d.ts +0 -17
- package/build/esm/services/logger/index.js +0 -70
- package/build/esm/services/mapper/index.d.ts +0 -24
- package/build/esm/services/mapper/index.js +0 -72
- package/build/esm/services/pipe/functions/array.d.ts +0 -24
- package/build/esm/services/pipe/functions/array.js +0 -66
- package/build/esm/services/pipe/functions/bitwise.d.ts +0 -9
- package/build/esm/services/pipe/functions/bitwise.js +0 -21
- package/build/esm/services/pipe/functions/conditional.d.ts +0 -10
- package/build/esm/services/pipe/functions/conditional.js +0 -24
- package/build/esm/services/pipe/functions/date.d.ts +0 -57
- package/build/esm/services/pipe/functions/date.js +0 -164
- package/build/esm/services/pipe/functions/index.d.ts +0 -25
- package/build/esm/services/pipe/functions/index.js +0 -24
- package/build/esm/services/pipe/functions/json.d.ts +0 -5
- package/build/esm/services/pipe/functions/json.js +0 -9
- package/build/esm/services/pipe/functions/math.d.ts +0 -38
- package/build/esm/services/pipe/functions/math.js +0 -108
- package/build/esm/services/pipe/functions/number.d.ts +0 -25
- package/build/esm/services/pipe/functions/number.js +0 -130
- package/build/esm/services/pipe/functions/object.d.ts +0 -22
- package/build/esm/services/pipe/functions/object.js +0 -60
- package/build/esm/services/pipe/functions/string.d.ts +0 -23
- package/build/esm/services/pipe/functions/string.js +0 -66
- package/build/esm/services/pipe/functions/symbol.d.ts +0 -12
- package/build/esm/services/pipe/functions/symbol.js +0 -30
- package/build/esm/services/pipe/functions/unary.d.ts +0 -7
- package/build/esm/services/pipe/functions/unary.js +0 -15
- package/build/esm/services/pipe/index.d.ts +0 -30
- package/build/esm/services/pipe/index.js +0 -122
- package/build/esm/services/quorum/index.d.ts +0 -34
- package/build/esm/services/quorum/index.js +0 -144
- package/build/esm/services/reporter/index.d.ts +0 -47
- package/build/esm/services/reporter/index.js +0 -327
- package/build/esm/services/serializer/index.d.ts +0 -41
- package/build/esm/services/serializer/index.js +0 -251
- package/build/esm/services/signaler/store.d.ts +0 -15
- package/build/esm/services/signaler/store.js +0 -50
- package/build/esm/services/signaler/stream.d.ts +0 -43
- package/build/esm/services/signaler/stream.js +0 -314
- package/build/esm/services/store/cache.d.ts +0 -66
- package/build/esm/services/store/cache.js +0 -124
- package/build/esm/services/store/clients/ioredis.d.ts +0 -27
- package/build/esm/services/store/clients/ioredis.js +0 -93
- package/build/esm/services/store/clients/redis.d.ts +0 -29
- package/build/esm/services/store/clients/redis.js +0 -140
- package/build/esm/services/store/index.d.ts +0 -88
- package/build/esm/services/store/index.js +0 -623
- package/build/esm/services/stream/clients/ioredis.d.ts +0 -23
- package/build/esm/services/stream/clients/ioredis.js +0 -112
- package/build/esm/services/stream/clients/redis.d.ts +0 -23
- package/build/esm/services/stream/clients/redis.js +0 -116
- package/build/esm/services/stream/index.d.ts +0 -21
- package/build/esm/services/stream/index.js +0 -6
- package/build/esm/services/sub/clients/ioredis.d.ts +0 -20
- package/build/esm/services/sub/clients/ioredis.js +0 -69
- package/build/esm/services/sub/clients/redis.d.ts +0 -20
- package/build/esm/services/sub/clients/redis.js +0 -60
- package/build/esm/services/sub/index.d.ts +0 -18
- package/build/esm/services/sub/index.js +0 -6
- package/build/esm/services/task/index.d.ts +0 -18
- package/build/esm/services/task/index.js +0 -70
- package/build/esm/services/telemetry/index.d.ts +0 -49
- package/build/esm/services/telemetry/index.js +0 -217
- package/build/esm/services/worker/index.d.ts +0 -30
- package/build/esm/services/worker/index.js +0 -102
- package/build/esm/types/activity.d.ts +0 -92
- package/build/esm/types/activity.js +0 -1
- package/build/esm/types/app.d.ts +0 -16
- package/build/esm/types/app.js +0 -1
- package/build/esm/types/async.d.ts +0 -5
- package/build/esm/types/async.js +0 -1
- package/build/esm/types/cache.d.ts +0 -1
- package/build/esm/types/cache.js +0 -1
- package/build/esm/types/collator.d.ts +0 -8
- package/build/esm/types/collator.js +0 -8
- package/build/esm/types/durable.d.ts +0 -59
- package/build/esm/types/durable.js +0 -1
- package/build/esm/types/hook.d.ts +0 -31
- package/build/esm/types/hook.js +0 -6
- package/build/esm/types/hotmesh.d.ts +0 -82
- package/build/esm/types/hotmesh.js +0 -1
- package/build/esm/types/index.d.ts +0 -20
- package/build/esm/types/index.js +0 -5
- package/build/esm/types/ioredisclient.d.ts +0 -5
- package/build/esm/types/ioredisclient.js +0 -2
- package/build/esm/types/job.d.ts +0 -50
- package/build/esm/types/job.js +0 -1
- package/build/esm/types/logger.d.ts +0 -6
- package/build/esm/types/logger.js +0 -1
- package/build/esm/types/map.d.ts +0 -4
- package/build/esm/types/map.js +0 -1
- package/build/esm/types/pipe.d.ts +0 -4
- package/build/esm/types/pipe.js +0 -1
- package/build/esm/types/quorum.d.ts +0 -46
- package/build/esm/types/quorum.js +0 -1
- package/build/esm/types/redis.d.ts +0 -8
- package/build/esm/types/redis.js +0 -1
- package/build/esm/types/redisclient.d.ts +0 -25
- package/build/esm/types/redisclient.js +0 -1
- package/build/esm/types/serializer.d.ts +0 -33
- package/build/esm/types/serializer.js +0 -1
- package/build/esm/types/stats.d.ts +0 -83
- package/build/esm/types/stats.js +0 -1
- package/build/esm/types/stream.d.ts +0 -67
- package/build/esm/types/stream.js +0 -22
- package/build/esm/types/telemetry.d.ts +0 -1
- package/build/esm/types/telemetry.js +0 -1
- package/build/esm/types/transition.d.ts +0 -17
- package/build/esm/types/transition.js +0 -1
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.esm.json +0 -9
- /package/build/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/build/{cjs/index.js → index.js} +0 -0
- /package/build/{cjs/modules → modules}/errors.d.ts +0 -0
- /package/build/{cjs/modules → modules}/errors.js +0 -0
- /package/build/{cjs/modules → modules}/key.d.ts +0 -0
- /package/build/{cjs/modules → modules}/key.js +0 -0
- /package/build/{cjs/modules → modules}/utils.d.ts +0 -0
- /package/build/{cjs/modules → modules}/utils.js +0 -0
- /package/build/{cjs/services → services}/activities/activity.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/activity.js +0 -0
- /package/build/{cjs/services → services}/activities/await.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/await.js +0 -0
- /package/build/{cjs/services → services}/activities/cycle.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/cycle.js +0 -0
- /package/build/{cjs/services → services}/activities/emit.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/emit.js +0 -0
- /package/build/{cjs/services → services}/activities/index.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/index.js +0 -0
- /package/build/{cjs/services → services}/activities/iterate.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/iterate.js +0 -0
- /package/build/{cjs/services → services}/activities/trigger.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/trigger.js +0 -0
- /package/build/{cjs/services → services}/activities/worker.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/worker.js +0 -0
- /package/build/{cjs/services → services}/collator/index.d.ts +0 -0
- /package/build/{cjs/services → services}/collator/index.js +0 -0
- /package/build/{cjs/services → services}/compiler/deployer.d.ts +0 -0
- /package/build/{cjs/services → services}/compiler/deployer.js +0 -0
- /package/build/{cjs/services → services}/compiler/index.d.ts +0 -0
- /package/build/{cjs/services → services}/compiler/index.js +0 -0
- /package/build/{cjs/services → services}/compiler/validator.d.ts +0 -0
- /package/build/{cjs/services → services}/compiler/validator.js +0 -0
- /package/build/{cjs/services → services}/connector/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/connector/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/connector/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/connector/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/connector/index.d.ts +0 -0
- /package/build/{cjs/services → services}/connector/index.js +0 -0
- /package/build/{cjs/services → services}/dimension/index.d.ts +0 -0
- /package/build/{cjs/services → services}/dimension/index.js +0 -0
- /package/build/{cjs/services → services}/durable/asyncLocalStorage.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/asyncLocalStorage.js +0 -0
- /package/build/{cjs/services → services}/durable/client.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/client.js +0 -0
- /package/build/{cjs/services → services}/durable/connection.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/connection.js +0 -0
- /package/build/{cjs/services → services}/durable/factory.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/factory.js +0 -0
- /package/build/{cjs/services → services}/durable/handle.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/handle.js +0 -0
- /package/build/{cjs/services → services}/durable/index.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/index.js +0 -0
- /package/build/{cjs/services → services}/durable/native.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/workflow.d.ts +0 -0
- /package/build/{cjs/services → services}/engine/index.d.ts +0 -0
- /package/build/{cjs/services → services}/engine/index.js +0 -0
- /package/build/{cjs/services → services}/hotmesh/index.d.ts +0 -0
- /package/build/{cjs/services → services}/hotmesh/index.js +0 -0
- /package/build/{cjs/services → services}/logger/index.d.ts +0 -0
- /package/build/{cjs/services → services}/logger/index.js +0 -0
- /package/build/{cjs/services → services}/mapper/index.d.ts +0 -0
- /package/build/{cjs/services → services}/mapper/index.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/array.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/array.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/bitwise.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/bitwise.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/conditional.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/conditional.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/date.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/date.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/index.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/index.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/json.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/json.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/math.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/math.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/number.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/number.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/object.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/object.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/string.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/string.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/symbol.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/symbol.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/unary.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/unary.js +0 -0
- /package/build/{cjs/services → services}/pipe/index.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/index.js +0 -0
- /package/build/{cjs/services → services}/quorum/index.d.ts +0 -0
- /package/build/{cjs/services → services}/quorum/index.js +0 -0
- /package/build/{cjs/services → services}/reporter/index.d.ts +0 -0
- /package/build/{cjs/services → services}/reporter/index.js +0 -0
- /package/build/{cjs/services → services}/serializer/index.d.ts +0 -0
- /package/build/{cjs/services → services}/serializer/index.js +0 -0
- /package/build/{cjs/services → services}/signaler/store.d.ts +0 -0
- /package/build/{cjs/services → services}/signaler/store.js +0 -0
- /package/build/{cjs/services → services}/signaler/stream.d.ts +0 -0
- /package/build/{cjs/services → services}/signaler/stream.js +0 -0
- /package/build/{cjs/services → services}/store/cache.d.ts +0 -0
- /package/build/{cjs/services → services}/store/cache.js +0 -0
- /package/build/{cjs/services → services}/store/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/store/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/store/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/store/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/store/index.d.ts +0 -0
- /package/build/{cjs/services → services}/store/index.js +0 -0
- /package/build/{cjs/services → services}/stream/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/stream/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/stream/index.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/index.js +0 -0
- /package/build/{cjs/services → services}/sub/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/sub/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/sub/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/sub/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/sub/index.d.ts +0 -0
- /package/build/{cjs/services → services}/sub/index.js +0 -0
- /package/build/{cjs/services → services}/task/index.d.ts +0 -0
- /package/build/{cjs/services → services}/task/index.js +0 -0
- /package/build/{cjs/services → services}/telemetry/index.d.ts +0 -0
- /package/build/{cjs/services → services}/telemetry/index.js +0 -0
- /package/build/{cjs/services → services}/worker/index.d.ts +0 -0
- /package/build/{cjs/services → services}/worker/index.js +0 -0
- /package/build/{cjs/types → types}/activity.d.ts +0 -0
- /package/build/{cjs/types → types}/activity.js +0 -0
- /package/build/{cjs/types → types}/app.d.ts +0 -0
- /package/build/{cjs/types → types}/app.js +0 -0
- /package/build/{cjs/types → types}/async.d.ts +0 -0
- /package/build/{cjs/types → types}/async.js +0 -0
- /package/build/{cjs/types → types}/cache.d.ts +0 -0
- /package/build/{cjs/types → types}/cache.js +0 -0
- /package/build/{cjs/types → types}/collator.d.ts +0 -0
- /package/build/{cjs/types → types}/collator.js +0 -0
- /package/build/{cjs/types → types}/durable.js +0 -0
- /package/build/{cjs/types → types}/hook.d.ts +0 -0
- /package/build/{cjs/types → types}/hook.js +0 -0
- /package/build/{cjs/types → types}/hotmesh.d.ts +0 -0
- /package/build/{cjs/types → types}/hotmesh.js +0 -0
- /package/build/{cjs/types → types}/index.d.ts +0 -0
- /package/build/{cjs/types → types}/index.js +0 -0
- /package/build/{cjs/types → types}/ioredisclient.d.ts +0 -0
- /package/build/{cjs/types → types}/ioredisclient.js +0 -0
- /package/build/{cjs/types → types}/job.d.ts +0 -0
- /package/build/{cjs/types → types}/job.js +0 -0
- /package/build/{cjs/types → types}/logger.d.ts +0 -0
- /package/build/{cjs/types → types}/logger.js +0 -0
- /package/build/{cjs/types → types}/map.d.ts +0 -0
- /package/build/{cjs/types → types}/map.js +0 -0
- /package/build/{cjs/types → types}/pipe.d.ts +0 -0
- /package/build/{cjs/types → types}/pipe.js +0 -0
- /package/build/{cjs/types → types}/quorum.d.ts +0 -0
- /package/build/{cjs/types → types}/quorum.js +0 -0
- /package/build/{cjs/types → types}/redis.d.ts +0 -0
- /package/build/{cjs/types → types}/redis.js +0 -0
- /package/build/{cjs/types → types}/redisclient.d.ts +0 -0
- /package/build/{cjs/types → types}/redisclient.js +0 -0
- /package/build/{cjs/types → types}/serializer.d.ts +0 -0
- /package/build/{cjs/types → types}/serializer.js +0 -0
- /package/build/{cjs/types → types}/stats.d.ts +0 -0
- /package/build/{cjs/types → types}/stats.js +0 -0
- /package/build/{cjs/types → types}/stream.d.ts +0 -0
- /package/build/{cjs/types → types}/stream.js +0 -0
- /package/build/{cjs/types → types}/telemetry.d.ts +0 -0
- /package/build/{cjs/types → types}/telemetry.js +0 -0
- /package/build/{cjs/types → types}/transition.d.ts +0 -0
- /package/build/{cjs/types → types}/transition.js +0 -0
|
@@ -1,486 +0,0 @@
|
|
|
1
|
-
import { GetStateError } from '../../modules/errors';
|
|
2
|
-
import { formatISODate, getValueByPath, restoreHierarchy } from '../../modules/utils';
|
|
3
|
-
import { CollatorService } from '../collator';
|
|
4
|
-
import { DimensionService } from '../dimension';
|
|
5
|
-
import { MapperService } from '../mapper';
|
|
6
|
-
import { Pipe } from '../pipe';
|
|
7
|
-
import { MDATA_SYMBOLS } from '../serializer';
|
|
8
|
-
import { StoreSignaler } from '../signaler/store';
|
|
9
|
-
import { TelemetryService } from '../telemetry';
|
|
10
|
-
import { StreamDataType, StreamStatus } from '../../types/stream';
|
|
11
|
-
/**
|
|
12
|
-
* The base class for all activities
|
|
13
|
-
*/
|
|
14
|
-
class Activity {
|
|
15
|
-
constructor(config, data, metadata, hook, engine, context) {
|
|
16
|
-
this.status = StreamStatus.SUCCESS;
|
|
17
|
-
this.code = 200;
|
|
18
|
-
this.adjacentIndex = 0; //can be updated by leg2 using 'as' metadata hincrby output
|
|
19
|
-
this.config = config;
|
|
20
|
-
this.data = data;
|
|
21
|
-
this.metadata = metadata;
|
|
22
|
-
this.hook = hook;
|
|
23
|
-
this.engine = engine;
|
|
24
|
-
this.context = context || { data: {}, metadata: {} };
|
|
25
|
-
this.logger = engine.logger;
|
|
26
|
-
this.store = engine.store;
|
|
27
|
-
}
|
|
28
|
-
//******** INITIAL ENTRY POINT (A) ********//
|
|
29
|
-
async process() {
|
|
30
|
-
this.logger.debug('activity-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
31
|
-
let telemetry;
|
|
32
|
-
try {
|
|
33
|
-
this.setLeg(1);
|
|
34
|
-
await CollatorService.notarizeEntry(this);
|
|
35
|
-
await this.getState();
|
|
36
|
-
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
37
|
-
telemetry.startActivitySpan(this.leg);
|
|
38
|
-
let multiResponse;
|
|
39
|
-
const multi = this.store.getMulti();
|
|
40
|
-
if (this.doesHook()) {
|
|
41
|
-
//sleep and wait to awaken upon a signal
|
|
42
|
-
await this.registerHook(multi);
|
|
43
|
-
this.mapJobData();
|
|
44
|
-
await this.setState(multi);
|
|
45
|
-
await CollatorService.authorizeReentry(this, multi);
|
|
46
|
-
await this.setStatus(0, multi);
|
|
47
|
-
await multi.exec();
|
|
48
|
-
telemetry.mapActivityAttributes();
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
//end the activity and transition to its children
|
|
52
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
53
|
-
this.mapJobData();
|
|
54
|
-
await this.setState(multi);
|
|
55
|
-
await CollatorService.notarizeEarlyCompletion(this, multi);
|
|
56
|
-
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
57
|
-
multiResponse = await multi.exec();
|
|
58
|
-
telemetry.mapActivityAttributes();
|
|
59
|
-
const jobStatus = this.resolveStatus(multiResponse);
|
|
60
|
-
const attrs = { 'app.job.jss': jobStatus };
|
|
61
|
-
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
62
|
-
if (messageIds.length) {
|
|
63
|
-
attrs['app.activity.mids'] = messageIds.join(',');
|
|
64
|
-
}
|
|
65
|
-
telemetry.setActivityAttributes(attrs);
|
|
66
|
-
}
|
|
67
|
-
return this.context.metadata.aid;
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
if (error instanceof GetStateError) {
|
|
71
|
-
this.logger.error('activity-get-state-error', error);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
this.logger.error('activity-process-error', error);
|
|
75
|
-
}
|
|
76
|
-
telemetry.setActivityError(error.message);
|
|
77
|
-
throw error;
|
|
78
|
-
}
|
|
79
|
-
finally {
|
|
80
|
-
telemetry.endActivitySpan();
|
|
81
|
-
this.logger.debug('activity-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
setLeg(leg) {
|
|
85
|
-
this.leg = leg;
|
|
86
|
-
}
|
|
87
|
-
//******** SIGNAL RE-ENTRY POINT ********//
|
|
88
|
-
doesHook() {
|
|
89
|
-
return !!(this.config.hook?.topic || this.config.sleep);
|
|
90
|
-
}
|
|
91
|
-
async registerHook(multi) {
|
|
92
|
-
if (this.config.hook?.topic) {
|
|
93
|
-
const signaler = new StoreSignaler(this.store, this.logger);
|
|
94
|
-
return await signaler.registerWebHook(this.config.hook.topic, this.context, multi);
|
|
95
|
-
}
|
|
96
|
-
else if (this.config.sleep) {
|
|
97
|
-
const durationInSeconds = Pipe.resolve(this.config.sleep, this.context);
|
|
98
|
-
const jobId = this.context.metadata.jid;
|
|
99
|
-
const activityId = this.metadata.aid;
|
|
100
|
-
const dId = this.metadata.dad;
|
|
101
|
-
await this.engine.task.registerTimeHook(jobId, `${activityId}${dId || ''}`, 'sleep', durationInSeconds);
|
|
102
|
-
return jobId;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async processWebHookEvent() {
|
|
106
|
-
this.logger.debug('engine-process-web-hook-event', {
|
|
107
|
-
topic: this.config.hook.topic,
|
|
108
|
-
aid: this.metadata.aid
|
|
109
|
-
});
|
|
110
|
-
const signaler = new StoreSignaler(this.store, this.logger);
|
|
111
|
-
const data = { ...this.data };
|
|
112
|
-
const jobId = await signaler.processWebHookSignal(this.config.hook.topic, data);
|
|
113
|
-
if (jobId) {
|
|
114
|
-
await this.processHookEvent(jobId);
|
|
115
|
-
await signaler.deleteWebHookSignal(this.config.hook.topic, data);
|
|
116
|
-
} //else => already resolved
|
|
117
|
-
}
|
|
118
|
-
async processTimeHookEvent(jobId) {
|
|
119
|
-
this.logger.debug('engine-process-time-hook-event', {
|
|
120
|
-
jid: jobId,
|
|
121
|
-
aid: this.metadata.aid
|
|
122
|
-
});
|
|
123
|
-
return await this.processHookEvent(jobId);
|
|
124
|
-
}
|
|
125
|
-
async processHookEvent(jobId) {
|
|
126
|
-
this.logger.debug('activity-process-hook-event', { jobId });
|
|
127
|
-
let telemetry;
|
|
128
|
-
try {
|
|
129
|
-
this.setLeg(2);
|
|
130
|
-
await this.getState(jobId);
|
|
131
|
-
const aState = await CollatorService.notarizeReentry(this);
|
|
132
|
-
this.adjacentIndex = CollatorService.getDimensionalIndex(aState);
|
|
133
|
-
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
134
|
-
telemetry.startActivitySpan(this.leg);
|
|
135
|
-
this.bindActivityData('hook');
|
|
136
|
-
this.mapJobData();
|
|
137
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
138
|
-
const multi = this.engine.store.getMulti();
|
|
139
|
-
await this.setState(multi);
|
|
140
|
-
await CollatorService.notarizeCompletion(this, multi);
|
|
141
|
-
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
142
|
-
const multiResponse = await multi.exec();
|
|
143
|
-
telemetry.mapActivityAttributes();
|
|
144
|
-
const jobStatus = this.resolveStatus(multiResponse);
|
|
145
|
-
const attrs = { 'app.job.jss': jobStatus };
|
|
146
|
-
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
147
|
-
if (messageIds.length) {
|
|
148
|
-
attrs['app.activity.mids'] = messageIds.join(',');
|
|
149
|
-
}
|
|
150
|
-
telemetry.setActivityAttributes(attrs);
|
|
151
|
-
return jobStatus;
|
|
152
|
-
}
|
|
153
|
-
catch (error) {
|
|
154
|
-
this.logger.error('engine-process-hook-event-error', error);
|
|
155
|
-
telemetry.setActivityError(error.message);
|
|
156
|
-
throw error;
|
|
157
|
-
}
|
|
158
|
-
finally {
|
|
159
|
-
telemetry.endActivitySpan();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
//******** DUPLEX RE-ENTRY POINT ********//
|
|
163
|
-
async processEvent(status = StreamStatus.SUCCESS, code = 200) {
|
|
164
|
-
this.setLeg(2);
|
|
165
|
-
const jid = this.context.metadata.jid;
|
|
166
|
-
const aid = this.metadata.aid;
|
|
167
|
-
this.status = status;
|
|
168
|
-
this.code = code;
|
|
169
|
-
this.logger.debug('activity-process-event', { topic: this.config.subtype, jid, aid, status, code });
|
|
170
|
-
let telemetry;
|
|
171
|
-
try {
|
|
172
|
-
await this.getState();
|
|
173
|
-
const aState = await CollatorService.notarizeReentry(this);
|
|
174
|
-
this.adjacentIndex = CollatorService.getDimensionalIndex(aState);
|
|
175
|
-
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
176
|
-
let isComplete = CollatorService.isActivityComplete(this.context.metadata.js);
|
|
177
|
-
if (isComplete) {
|
|
178
|
-
this.logger.warn('activity-process-event-duplicate', { jid, aid });
|
|
179
|
-
this.logger.debug('activity-process-event-duplicate-resolution', { resolution: 'Increase HotMesh config `reclaimDelay` timeout.' });
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
telemetry.startActivitySpan(this.leg);
|
|
183
|
-
let multiResponse;
|
|
184
|
-
if (status === StreamStatus.PENDING) {
|
|
185
|
-
multiResponse = await this.processPending(telemetry);
|
|
186
|
-
}
|
|
187
|
-
else if (status === StreamStatus.SUCCESS) {
|
|
188
|
-
multiResponse = await this.processSuccess(telemetry);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
multiResponse = await this.processError(telemetry);
|
|
192
|
-
}
|
|
193
|
-
this.transitionAdjacent(multiResponse, telemetry);
|
|
194
|
-
}
|
|
195
|
-
catch (error) {
|
|
196
|
-
this.logger.error('activity-process-event-error', error);
|
|
197
|
-
telemetry.setActivityError(error.message);
|
|
198
|
-
throw error;
|
|
199
|
-
}
|
|
200
|
-
finally {
|
|
201
|
-
telemetry.endActivitySpan();
|
|
202
|
-
this.logger.debug('activity-process-event-end', { jid, aid });
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
async processPending(telemetry) {
|
|
206
|
-
this.bindActivityData('output');
|
|
207
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
208
|
-
this.mapJobData();
|
|
209
|
-
const multi = this.store.getMulti();
|
|
210
|
-
await this.setState(multi);
|
|
211
|
-
await CollatorService.notarizeContinuation(this, multi);
|
|
212
|
-
await this.setStatus(this.adjacencyList.length, multi);
|
|
213
|
-
return await multi.exec();
|
|
214
|
-
}
|
|
215
|
-
async processSuccess(telemetry) {
|
|
216
|
-
this.bindActivityData('output');
|
|
217
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
218
|
-
this.mapJobData();
|
|
219
|
-
const multi = this.store.getMulti();
|
|
220
|
-
await this.setState(multi);
|
|
221
|
-
await CollatorService.notarizeCompletion(this, multi);
|
|
222
|
-
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
223
|
-
return await multi.exec();
|
|
224
|
-
}
|
|
225
|
-
async processError(telemetry) {
|
|
226
|
-
this.bindActivityError(this.data);
|
|
227
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
228
|
-
const multi = this.store.getMulti();
|
|
229
|
-
await this.setState(multi);
|
|
230
|
-
await CollatorService.notarizeCompletion(this, multi);
|
|
231
|
-
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
232
|
-
return await multi.exec();
|
|
233
|
-
}
|
|
234
|
-
async transitionAdjacent(multiResponse, telemetry) {
|
|
235
|
-
telemetry.mapActivityAttributes();
|
|
236
|
-
const jobStatus = this.resolveStatus(multiResponse);
|
|
237
|
-
const attrs = { 'app.job.jss': jobStatus };
|
|
238
|
-
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
239
|
-
if (messageIds.length) {
|
|
240
|
-
attrs['app.activity.mids'] = messageIds.join(',');
|
|
241
|
-
}
|
|
242
|
-
telemetry.setActivityAttributes(attrs);
|
|
243
|
-
}
|
|
244
|
-
resolveStatus(multiResponse) {
|
|
245
|
-
const activityStatus = multiResponse[multiResponse.length - 1];
|
|
246
|
-
if (Array.isArray(activityStatus)) {
|
|
247
|
-
return Number(activityStatus[1]);
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
return Number(activityStatus);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
mapJobData() {
|
|
254
|
-
if (this.config.job?.maps) {
|
|
255
|
-
const mapper = new MapperService(this.config.job.maps, this.context);
|
|
256
|
-
this.context.data = mapper.mapRules();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
mapInputData() {
|
|
260
|
-
if (this.config.input?.maps) {
|
|
261
|
-
const mapper = new MapperService(this.config.input.maps, this.context);
|
|
262
|
-
this.context.data = mapper.mapRules();
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
async registerTimeout() {
|
|
266
|
-
//set timeout in support of hook and/or duplex
|
|
267
|
-
}
|
|
268
|
-
bindActivityError(data) {
|
|
269
|
-
//todo: map activity error data into the job error (if defined)
|
|
270
|
-
// map job status via: (500: [3**, 4**, 5**], 202: [$pending])
|
|
271
|
-
this.context.metadata.err = JSON.stringify(data);
|
|
272
|
-
}
|
|
273
|
-
async getTriggerConfig() {
|
|
274
|
-
return await this.store.getSchema(this.config.trigger, await this.engine.getVID());
|
|
275
|
-
}
|
|
276
|
-
getJobStatus() {
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
async setStatus(amount, multi) {
|
|
280
|
-
const { id: appId } = await this.engine.getVID();
|
|
281
|
-
await this.store.setStatus(amount, this.context.metadata.jid, appId, multi);
|
|
282
|
-
}
|
|
283
|
-
authorizeEntry(state) {
|
|
284
|
-
//pre-authorize activity state to allow entry for adjacent activities
|
|
285
|
-
return this.adjacencyList?.map((streamData) => {
|
|
286
|
-
const { metadata: { aid } } = streamData;
|
|
287
|
-
state[`${aid}/output/metadata/as`] = CollatorService.getSeed();
|
|
288
|
-
return aid;
|
|
289
|
-
}) ?? [];
|
|
290
|
-
}
|
|
291
|
-
bindDimensionalAddress(state) {
|
|
292
|
-
const dad = this.resolveDad();
|
|
293
|
-
state[`${this.metadata.aid}/output/metadata/dad`] = dad;
|
|
294
|
-
}
|
|
295
|
-
async setState(multi) {
|
|
296
|
-
const jobId = this.context.metadata.jid;
|
|
297
|
-
this.bindJobMetadata();
|
|
298
|
-
this.bindActivityMetadata();
|
|
299
|
-
let state = {};
|
|
300
|
-
await this.bindJobState(state);
|
|
301
|
-
const presets = this.authorizeEntry(state);
|
|
302
|
-
this.bindDimensionalAddress(state);
|
|
303
|
-
this.bindActivityState(state);
|
|
304
|
-
//symbolNames holds symkeys
|
|
305
|
-
const symbolNames = [
|
|
306
|
-
`$${this.config.subscribes}`,
|
|
307
|
-
this.metadata.aid,
|
|
308
|
-
...presets
|
|
309
|
-
];
|
|
310
|
-
const dIds = CollatorService.getDimensionsById([...this.config.ancestors, this.metadata.aid], this.resolveDad());
|
|
311
|
-
return await this.store.setState(state, this.getJobStatus(), jobId, symbolNames, dIds, multi);
|
|
312
|
-
}
|
|
313
|
-
bindJobMetadata() {
|
|
314
|
-
//both legs of the most recently run activity (1 and 2) modify ju (job_updated)
|
|
315
|
-
this.context.metadata.ju = formatISODate(new Date());
|
|
316
|
-
}
|
|
317
|
-
bindActivityMetadata() {
|
|
318
|
-
const self = this.context['$self'];
|
|
319
|
-
if (!self.output.metadata) {
|
|
320
|
-
self.output.metadata = {};
|
|
321
|
-
}
|
|
322
|
-
if (this.status === StreamStatus.ERROR) {
|
|
323
|
-
self.output.metadata.err = JSON.stringify(this.data);
|
|
324
|
-
}
|
|
325
|
-
//todo: verify leg2 never overwrites leg1 `ac`
|
|
326
|
-
self.output.metadata.ac =
|
|
327
|
-
self.output.metadata.au = formatISODate(new Date());
|
|
328
|
-
self.output.metadata.atp = this.config.type;
|
|
329
|
-
if (this.config.subtype) {
|
|
330
|
-
self.output.metadata.stp = this.config.subtype;
|
|
331
|
-
}
|
|
332
|
-
self.output.metadata.aid = this.metadata.aid;
|
|
333
|
-
}
|
|
334
|
-
async bindJobState(state) {
|
|
335
|
-
const triggerConfig = await this.getTriggerConfig();
|
|
336
|
-
const PRODUCES = [
|
|
337
|
-
...(triggerConfig.PRODUCES || []),
|
|
338
|
-
...this.bindJobMetadataPaths()
|
|
339
|
-
];
|
|
340
|
-
for (const path of PRODUCES) {
|
|
341
|
-
const value = getValueByPath(this.context, path);
|
|
342
|
-
if (value !== undefined) {
|
|
343
|
-
state[path] = value;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
TelemetryService.bindJobTelemetryToState(state, this.config, this.context);
|
|
347
|
-
}
|
|
348
|
-
bindActivityState(state) {
|
|
349
|
-
const produces = [
|
|
350
|
-
...this.config.produces,
|
|
351
|
-
...this.bindActivityMetadataPaths()
|
|
352
|
-
];
|
|
353
|
-
for (const path of produces) {
|
|
354
|
-
const prefixedPath = `${this.metadata.aid}/${path}`;
|
|
355
|
-
const value = getValueByPath(this.context, prefixedPath);
|
|
356
|
-
if (value !== undefined) {
|
|
357
|
-
state[prefixedPath] = value;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
TelemetryService.bindActivityTelemetryToState(state, this.config, this.metadata, this.context, this.leg);
|
|
361
|
-
}
|
|
362
|
-
bindJobMetadataPaths() {
|
|
363
|
-
return MDATA_SYMBOLS.JOB_UPDATE.KEYS.map((key) => `metadata/${key}`);
|
|
364
|
-
}
|
|
365
|
-
bindActivityMetadataPaths() {
|
|
366
|
-
const keys_to_save = this.leg === 1 ? 'ACTIVITY' : 'ACTIVITY_UPDATE';
|
|
367
|
-
return MDATA_SYMBOLS[keys_to_save].KEYS.map((key) => `output/metadata/${key}`);
|
|
368
|
-
}
|
|
369
|
-
async getState(jobId) {
|
|
370
|
-
//assemble list of paths necessary to create 'job state' from the 'symbol hash'
|
|
371
|
-
const jobSymbolHashName = `$${this.config.subscribes}`;
|
|
372
|
-
const consumes = {
|
|
373
|
-
[jobSymbolHashName]: MDATA_SYMBOLS.JOB.KEYS.map((key) => `metadata/${key}`)
|
|
374
|
-
};
|
|
375
|
-
for (let [activityId, paths] of Object.entries(this.config.consumes)) {
|
|
376
|
-
if (activityId === '$job') {
|
|
377
|
-
for (const path of paths) {
|
|
378
|
-
consumes[jobSymbolHashName].push(path);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
if (activityId === '$self') {
|
|
383
|
-
activityId = this.metadata.aid;
|
|
384
|
-
}
|
|
385
|
-
if (!consumes[activityId]) {
|
|
386
|
-
consumes[activityId] = [];
|
|
387
|
-
}
|
|
388
|
-
for (const path of paths) {
|
|
389
|
-
consumes[activityId].push(`${activityId}/${path}`);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
TelemetryService.addTargetTelemetryPaths(consumes, this.config, this.metadata, this.leg);
|
|
394
|
-
let { dad, jid } = this.context.metadata;
|
|
395
|
-
jobId = jobId || jid;
|
|
396
|
-
const dIds = CollatorService.getDimensionsById([...this.config.ancestors, this.metadata.aid], dad);
|
|
397
|
-
//`state` is a flat hash; context is a tree
|
|
398
|
-
const [state, status] = await this.store.getState(jobId, consumes, dIds);
|
|
399
|
-
this.context = restoreHierarchy(state);
|
|
400
|
-
this.initDimensionalAddress(dad);
|
|
401
|
-
this.initSelf(this.context);
|
|
402
|
-
this.initPolicies(this.context);
|
|
403
|
-
}
|
|
404
|
-
initDimensionalAddress(dad) {
|
|
405
|
-
this.metadata.dad = dad;
|
|
406
|
-
}
|
|
407
|
-
initSelf(context) {
|
|
408
|
-
const activityId = this.metadata.aid;
|
|
409
|
-
if (!context[activityId]) {
|
|
410
|
-
context[activityId] = {};
|
|
411
|
-
}
|
|
412
|
-
const self = context[activityId];
|
|
413
|
-
if (!self.output) {
|
|
414
|
-
self.output = {};
|
|
415
|
-
}
|
|
416
|
-
if (!self.input) {
|
|
417
|
-
self.input = {};
|
|
418
|
-
}
|
|
419
|
-
if (!self.hook) {
|
|
420
|
-
self.hook = {};
|
|
421
|
-
}
|
|
422
|
-
context['$self'] = self;
|
|
423
|
-
context['$job'] = context; //NEVER call STRINGIFY! (circular)
|
|
424
|
-
return context;
|
|
425
|
-
}
|
|
426
|
-
initPolicies(context) {
|
|
427
|
-
context.metadata.expire = this.config.expire;
|
|
428
|
-
}
|
|
429
|
-
bindActivityData(type) {
|
|
430
|
-
this.context[this.metadata.aid][type].data = this.data;
|
|
431
|
-
}
|
|
432
|
-
resolveDad() {
|
|
433
|
-
let dad = this.metadata.dad;
|
|
434
|
-
if (this.adjacentIndex > 0) {
|
|
435
|
-
//if adjacent index > 0 the activity is cycling; replace last index with cycle index
|
|
436
|
-
dad = `${dad.substring(0, dad.lastIndexOf(','))},${this.adjacentIndex}`;
|
|
437
|
-
}
|
|
438
|
-
return dad;
|
|
439
|
-
}
|
|
440
|
-
resolveAdjacentDad() {
|
|
441
|
-
//concat self and child dimension (all children (leg 1) begin life at 0)
|
|
442
|
-
return `${this.resolveDad()}${DimensionService.getSeed(0)}`;
|
|
443
|
-
}
|
|
444
|
-
;
|
|
445
|
-
async filterAdjacent() {
|
|
446
|
-
const adjacencyList = [];
|
|
447
|
-
const transitions = await this.store.getTransitions(await this.engine.getVID());
|
|
448
|
-
const transition = transitions[`.${this.metadata.aid}`];
|
|
449
|
-
//resolve the dimensional address for adjacent children
|
|
450
|
-
const adjacentDad = this.resolveAdjacentDad();
|
|
451
|
-
if (transition) {
|
|
452
|
-
for (const toActivityId in transition) {
|
|
453
|
-
const transitionRule = transition[toActivityId];
|
|
454
|
-
if (MapperService.evaluate(transitionRule, this.context, this.code)) {
|
|
455
|
-
adjacencyList.push({
|
|
456
|
-
metadata: {
|
|
457
|
-
jid: this.context.metadata.jid,
|
|
458
|
-
dad: adjacentDad,
|
|
459
|
-
aid: toActivityId,
|
|
460
|
-
spn: this.context['$self'].output.metadata?.l2s,
|
|
461
|
-
trc: this.context.metadata.trc,
|
|
462
|
-
},
|
|
463
|
-
type: StreamDataType.TRANSITION,
|
|
464
|
-
data: {}
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
return adjacencyList;
|
|
470
|
-
}
|
|
471
|
-
async transition(adjacencyList, jobStatus) {
|
|
472
|
-
let mIds = [];
|
|
473
|
-
if (adjacencyList.length) {
|
|
474
|
-
const multi = this.store.getMulti();
|
|
475
|
-
for (const execSignal of adjacencyList) {
|
|
476
|
-
await this.engine.streamSignaler?.publishMessage(null, execSignal, multi);
|
|
477
|
-
}
|
|
478
|
-
mIds = (await multi.exec());
|
|
479
|
-
}
|
|
480
|
-
else if (jobStatus <= 0) {
|
|
481
|
-
await this.engine.runJobCompletionTasks(this.context);
|
|
482
|
-
}
|
|
483
|
-
return mIds;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
export { Activity };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Activity } from './activity';
|
|
2
|
-
import { EngineService } from '../engine';
|
|
3
|
-
import { ActivityData, ActivityMetadata, AwaitActivity, ActivityType } from '../../types/activity';
|
|
4
|
-
import { JobState } from '../../types/job';
|
|
5
|
-
import { MultiResponseFlags } from '../../types/redis';
|
|
6
|
-
import { StreamCode, StreamData, StreamStatus } from '../../types/stream';
|
|
7
|
-
declare class Await extends Activity {
|
|
8
|
-
config: AwaitActivity;
|
|
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
|
-
processSuccessResponse(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
|
|
14
|
-
processErrorResponse(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
|
|
15
|
-
}
|
|
16
|
-
export { Await };
|
|
@@ -1,140 +0,0 @@
|
|
|
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
|
-
//todo: 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.processSuccessResponse(this.adjacencyList);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
this.bindActivityError(this.data);
|
|
99
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
100
|
-
multiResponse = await this.processErrorResponse(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 processSuccessResponse(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 processErrorResponse(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 };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EngineService } from '../engine';
|
|
2
|
-
import { Activity, ActivityType } from './activity';
|
|
3
|
-
import { ActivityData, ActivityMetadata, CycleActivity } from '../../types/activity';
|
|
4
|
-
import { JobState } from '../../types/job';
|
|
5
|
-
import { RedisMulti } from '../../types/redis';
|
|
6
|
-
declare class Cycle extends Activity {
|
|
7
|
-
config: CycleActivity;
|
|
8
|
-
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
9
|
-
process(): Promise<string>;
|
|
10
|
-
/**
|
|
11
|
-
* Trigger the target ancestor to execute in a cycle,
|
|
12
|
-
* without violating the constraints of the DAG. Immutable
|
|
13
|
-
* `individual activity state` will execute in a new dimensional
|
|
14
|
-
* thread while `shared job state` can change. This
|
|
15
|
-
* pattern allows for retries without violating the DAG.
|
|
16
|
-
*/
|
|
17
|
-
cycleAncestorActivity(multi: RedisMulti): Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
export { Cycle };
|