@hotmeshio/hotmesh 0.0.7 → 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} +6 -11
- package/build/{cjs/services → services}/activities/activity.d.ts +6 -0
- package/build/{cjs/services → services}/activities/activity.js +83 -7
- package/build/{cjs/services → services}/activities/await.d.ts +2 -2
- package/build/{cjs/services → services}/activities/await.js +5 -5
- package/build/services/activities/cycle.d.ts +19 -0
- package/build/services/activities/cycle.js +77 -0
- package/build/{esm/services → services}/activities/index.d.ts +4 -2
- package/build/{cjs/services → services}/activities/index.js +4 -2
- package/build/{cjs/services → services}/activities/worker.d.ts +0 -8
- package/build/services/activities/worker.js +73 -0
- package/build/{esm/services → services}/collator/index.d.ts +18 -1
- package/build/{cjs/services → services}/collator/index.js +41 -11
- package/build/{cjs/services → services}/durable/factory.js +17 -1
- package/build/{cjs/services → services}/durable/native.js +2 -2
- package/build/{cjs/services → services}/durable/worker.d.ts +2 -3
- package/build/{esm/services → services}/durable/worker.js +35 -37
- package/build/{cjs/services → services}/durable/workflow.js +11 -2
- package/build/{cjs/services → services}/mapper/index.js +3 -0
- package/build/{cjs/services → services}/signaler/stream.js +0 -1
- package/build/{esm/types → types}/activity.d.ts +7 -2
- package/build/{cjs/types → types}/durable.d.ts +4 -6
- package/build/{cjs/types → types}/index.d.ts +1 -1
- package/package.json +6 -11
- package/services/activities/activity.ts +90 -7
- package/services/activities/await.ts +5 -5
- package/services/activities/cycle.ts +96 -0
- package/services/activities/index.ts +4 -2
- package/services/activities/worker.ts +2 -93
- package/services/collator/index.ts +43 -11
- package/services/durable/factory.ts +17 -1
- package/services/durable/native.ts +2 -2
- package/services/durable/worker.ts +19 -22
- package/services/durable/workflow.ts +11 -2
- package/services/mapper/index.ts +3 -0
- package/services/signaler/stream.ts +0 -1
- package/types/activity.ts +8 -1
- package/types/durable.ts +4 -4
- package/types/index.ts +1 -0
- package/build/cjs/package.json +0 -80
- package/build/cjs/services/activities/index.d.ts +0 -15
- package/build/cjs/services/activities/worker.js +0 -159
- package/build/cjs/services/collator/index.d.ts +0 -56
- package/build/cjs/services/durable/worker.js +0 -298
- package/build/cjs/types/activity.d.ts +0 -87
- 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 -61
- package/build/esm/services/activities/activity.js +0 -410
- package/build/esm/services/activities/await.d.ts +0 -16
- package/build/esm/services/activities/await.js +0 -140
- 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.js +0 -14
- 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 -19
- package/build/esm/services/activities/worker.js +0 -156
- package/build/esm/services/collator/index.js +0 -191
- 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 -119
- 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.d.ts +0 -37
- package/build/esm/services/durable/workflow.d.ts +0 -6
- package/build/esm/services/durable/workflow.js +0 -128
- 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 -69
- 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 -315
- 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.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/emit.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/emit.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}/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/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}/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}/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.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.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,410 +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
|
-
//******** SIGNALER RE-ENTRY POINT (B) ********//
|
|
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
|
-
//todo: hooks are currently singletons. but they can support
|
|
126
|
-
// dimensional threads like `await` and `worker` do.
|
|
127
|
-
// Copy code from those activities to support cyclical
|
|
128
|
-
// timehook and eventhook inputs by adding a 'pending'
|
|
129
|
-
// flag to hooks that allows for repeated signals
|
|
130
|
-
async processHookEvent(jobId) {
|
|
131
|
-
this.logger.debug('activity-process-hook-event', { jobId });
|
|
132
|
-
let telemetry;
|
|
133
|
-
try {
|
|
134
|
-
this.setLeg(2);
|
|
135
|
-
await this.getState(jobId);
|
|
136
|
-
const aState = await CollatorService.notarizeReentry(this);
|
|
137
|
-
this.adjacentIndex = CollatorService.getDimensionalIndex(aState);
|
|
138
|
-
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
139
|
-
telemetry.startActivitySpan(this.leg);
|
|
140
|
-
this.bindActivityData('hook');
|
|
141
|
-
this.mapJobData();
|
|
142
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
143
|
-
const multi = this.engine.store.getMulti();
|
|
144
|
-
await this.setState(multi);
|
|
145
|
-
await CollatorService.notarizeCompletion(this, multi);
|
|
146
|
-
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
147
|
-
const multiResponse = await multi.exec();
|
|
148
|
-
telemetry.mapActivityAttributes();
|
|
149
|
-
const jobStatus = this.resolveStatus(multiResponse);
|
|
150
|
-
const attrs = { 'app.job.jss': jobStatus };
|
|
151
|
-
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
152
|
-
if (messageIds.length) {
|
|
153
|
-
attrs['app.activity.mids'] = messageIds.join(',');
|
|
154
|
-
}
|
|
155
|
-
telemetry.setActivityAttributes(attrs);
|
|
156
|
-
return jobStatus;
|
|
157
|
-
}
|
|
158
|
-
catch (error) {
|
|
159
|
-
console.error('this error?', error);
|
|
160
|
-
this.logger.error('engine-process-hook-event-error', error);
|
|
161
|
-
telemetry.setActivityError(error.message);
|
|
162
|
-
throw error;
|
|
163
|
-
}
|
|
164
|
-
finally {
|
|
165
|
-
telemetry.endActivitySpan();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
resolveStatus(multiResponse) {
|
|
169
|
-
const activityStatus = multiResponse[multiResponse.length - 1];
|
|
170
|
-
if (Array.isArray(activityStatus)) {
|
|
171
|
-
return Number(activityStatus[1]);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
return Number(activityStatus);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
mapJobData() {
|
|
178
|
-
if (this.config.job?.maps) {
|
|
179
|
-
const mapper = new MapperService(this.config.job.maps, this.context);
|
|
180
|
-
this.context.data = mapper.mapRules();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
mapInputData() {
|
|
184
|
-
if (this.config.input?.maps) {
|
|
185
|
-
const mapper = new MapperService(this.config.input.maps, this.context);
|
|
186
|
-
this.context.data = mapper.mapRules();
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
async registerTimeout() {
|
|
190
|
-
//set timeout in support of hook and/or duplex
|
|
191
|
-
}
|
|
192
|
-
bindActivityError(data) {
|
|
193
|
-
//todo: map activity error data into the job error (if defined)
|
|
194
|
-
// map job status via: (500: [3**, 4**, 5**], 202: [$pending])
|
|
195
|
-
this.context.metadata.err = JSON.stringify(data);
|
|
196
|
-
}
|
|
197
|
-
async getTriggerConfig() {
|
|
198
|
-
return await this.store.getSchema(this.config.trigger, await this.engine.getVID());
|
|
199
|
-
}
|
|
200
|
-
getJobStatus() {
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
async setStatus(amount, multi) {
|
|
204
|
-
const { id: appId } = await this.engine.getVID();
|
|
205
|
-
await this.store.setStatus(amount, this.context.metadata.jid, appId, multi);
|
|
206
|
-
}
|
|
207
|
-
authorizeEntry(state) {
|
|
208
|
-
//pre-authorize activity state to allow entry for adjacent activities
|
|
209
|
-
return this.adjacencyList?.map((streamData) => {
|
|
210
|
-
const { metadata: { aid } } = streamData;
|
|
211
|
-
state[`${aid}/output/metadata/as`] = CollatorService.getSeed();
|
|
212
|
-
return aid;
|
|
213
|
-
}) ?? [];
|
|
214
|
-
}
|
|
215
|
-
bindDimensionalAddress(state) {
|
|
216
|
-
const dad = this.resolveDad();
|
|
217
|
-
state[`${this.metadata.aid}/output/metadata/dad`] = dad;
|
|
218
|
-
}
|
|
219
|
-
async setState(multi) {
|
|
220
|
-
const jobId = this.context.metadata.jid;
|
|
221
|
-
this.bindJobMetadata();
|
|
222
|
-
this.bindActivityMetadata();
|
|
223
|
-
let state = {};
|
|
224
|
-
await this.bindJobState(state);
|
|
225
|
-
const presets = this.authorizeEntry(state);
|
|
226
|
-
this.bindDimensionalAddress(state);
|
|
227
|
-
this.bindActivityState(state);
|
|
228
|
-
//symbolNames holds symkeys
|
|
229
|
-
const symbolNames = [
|
|
230
|
-
`$${this.config.subscribes}`,
|
|
231
|
-
this.metadata.aid,
|
|
232
|
-
...presets
|
|
233
|
-
];
|
|
234
|
-
const dIds = CollatorService.getDimensionsById([...this.config.ancestors, this.metadata.aid], this.resolveDad());
|
|
235
|
-
return await this.store.setState(state, this.getJobStatus(), jobId, symbolNames, dIds, multi);
|
|
236
|
-
}
|
|
237
|
-
bindJobMetadata() {
|
|
238
|
-
//both legs of the most recently run activity (1 and 2) modify ju (job_updated)
|
|
239
|
-
this.context.metadata.ju = formatISODate(new Date());
|
|
240
|
-
}
|
|
241
|
-
bindActivityMetadata() {
|
|
242
|
-
const self = this.context['$self'];
|
|
243
|
-
if (!self.output.metadata) {
|
|
244
|
-
self.output.metadata = {};
|
|
245
|
-
}
|
|
246
|
-
if (this.status === StreamStatus.ERROR) {
|
|
247
|
-
self.output.metadata.err = JSON.stringify(this.data);
|
|
248
|
-
}
|
|
249
|
-
//todo: verify leg2 never overwrites leg1 `ac`
|
|
250
|
-
self.output.metadata.ac =
|
|
251
|
-
self.output.metadata.au = formatISODate(new Date());
|
|
252
|
-
self.output.metadata.atp = this.config.type;
|
|
253
|
-
if (this.config.subtype) {
|
|
254
|
-
self.output.metadata.stp = this.config.subtype;
|
|
255
|
-
}
|
|
256
|
-
self.output.metadata.aid = this.metadata.aid;
|
|
257
|
-
}
|
|
258
|
-
async bindJobState(state) {
|
|
259
|
-
const triggerConfig = await this.getTriggerConfig();
|
|
260
|
-
const PRODUCES = [
|
|
261
|
-
...(triggerConfig.PRODUCES || []),
|
|
262
|
-
...this.bindJobMetadataPaths()
|
|
263
|
-
];
|
|
264
|
-
for (const path of PRODUCES) {
|
|
265
|
-
const value = getValueByPath(this.context, path);
|
|
266
|
-
if (value !== undefined) {
|
|
267
|
-
state[path] = value;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
TelemetryService.bindJobTelemetryToState(state, this.config, this.context);
|
|
271
|
-
}
|
|
272
|
-
bindActivityState(state) {
|
|
273
|
-
const produces = [
|
|
274
|
-
...this.config.produces,
|
|
275
|
-
...this.bindActivityMetadataPaths()
|
|
276
|
-
];
|
|
277
|
-
for (const path of produces) {
|
|
278
|
-
const prefixedPath = `${this.metadata.aid}/${path}`;
|
|
279
|
-
const value = getValueByPath(this.context, prefixedPath);
|
|
280
|
-
if (value !== undefined) {
|
|
281
|
-
state[prefixedPath] = value;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
TelemetryService.bindActivityTelemetryToState(state, this.config, this.metadata, this.context, this.leg);
|
|
285
|
-
}
|
|
286
|
-
bindJobMetadataPaths() {
|
|
287
|
-
return MDATA_SYMBOLS.JOB_UPDATE.KEYS.map((key) => `metadata/${key}`);
|
|
288
|
-
}
|
|
289
|
-
bindActivityMetadataPaths() {
|
|
290
|
-
const keys_to_save = this.leg === 1 ? 'ACTIVITY' : 'ACTIVITY_UPDATE';
|
|
291
|
-
return MDATA_SYMBOLS[keys_to_save].KEYS.map((key) => `output/metadata/${key}`);
|
|
292
|
-
}
|
|
293
|
-
async getState(jobId) {
|
|
294
|
-
//assemble list of paths necessary to create 'job state' from the 'symbol hash'
|
|
295
|
-
const jobSymbolHashName = `$${this.config.subscribes}`;
|
|
296
|
-
const consumes = {
|
|
297
|
-
[jobSymbolHashName]: MDATA_SYMBOLS.JOB.KEYS.map((key) => `metadata/${key}`)
|
|
298
|
-
};
|
|
299
|
-
for (let [activityId, paths] of Object.entries(this.config.consumes)) {
|
|
300
|
-
if (activityId === '$job') {
|
|
301
|
-
for (const path of paths) {
|
|
302
|
-
consumes[jobSymbolHashName].push(path);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
if (activityId === '$self') {
|
|
307
|
-
activityId = this.metadata.aid;
|
|
308
|
-
}
|
|
309
|
-
if (!consumes[activityId]) {
|
|
310
|
-
consumes[activityId] = [];
|
|
311
|
-
}
|
|
312
|
-
for (const path of paths) {
|
|
313
|
-
consumes[activityId].push(`${activityId}/${path}`);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
TelemetryService.addTargetTelemetryPaths(consumes, this.config, this.metadata, this.leg);
|
|
318
|
-
let { dad, jid } = this.context.metadata;
|
|
319
|
-
jobId = jobId || jid;
|
|
320
|
-
const dIds = CollatorService.getDimensionsById([...this.config.ancestors, this.metadata.aid], dad);
|
|
321
|
-
//`state` is a flat hash; context is a tree
|
|
322
|
-
const [state, status] = await this.store.getState(jobId, consumes, dIds);
|
|
323
|
-
this.context = restoreHierarchy(state);
|
|
324
|
-
this.initDimensionalAddress(dad);
|
|
325
|
-
this.initSelf(this.context);
|
|
326
|
-
this.initPolicies(this.context);
|
|
327
|
-
}
|
|
328
|
-
initDimensionalAddress(dad) {
|
|
329
|
-
this.metadata.dad = dad;
|
|
330
|
-
}
|
|
331
|
-
initSelf(context) {
|
|
332
|
-
const activityId = this.metadata.aid;
|
|
333
|
-
if (!context[activityId]) {
|
|
334
|
-
context[activityId] = {};
|
|
335
|
-
}
|
|
336
|
-
const self = context[activityId];
|
|
337
|
-
if (!self.output) {
|
|
338
|
-
self.output = {};
|
|
339
|
-
}
|
|
340
|
-
if (!self.input) {
|
|
341
|
-
self.input = {};
|
|
342
|
-
}
|
|
343
|
-
if (!self.hook) {
|
|
344
|
-
self.hook = {};
|
|
345
|
-
}
|
|
346
|
-
context['$self'] = self;
|
|
347
|
-
context['$job'] = context; //NEVER call STRINGIFY! (circular)
|
|
348
|
-
return context;
|
|
349
|
-
}
|
|
350
|
-
initPolicies(context) {
|
|
351
|
-
context.metadata.expire = this.config.expire;
|
|
352
|
-
}
|
|
353
|
-
bindActivityData(type) {
|
|
354
|
-
this.context[this.metadata.aid][type].data = this.data;
|
|
355
|
-
}
|
|
356
|
-
resolveDad() {
|
|
357
|
-
let dad = this.metadata.dad;
|
|
358
|
-
if (this.adjacentIndex > 0) {
|
|
359
|
-
//if adjacent index > 0 the activity is cycling; replace last index with cycle index
|
|
360
|
-
dad = `${dad.substring(0, dad.lastIndexOf(','))},${this.adjacentIndex}`;
|
|
361
|
-
}
|
|
362
|
-
return dad;
|
|
363
|
-
}
|
|
364
|
-
resolveAdjacentDad() {
|
|
365
|
-
//concat self and child dimension (all children (leg 1) begin life at 0)
|
|
366
|
-
return `${this.resolveDad()}${DimensionService.getSeed(0)}`;
|
|
367
|
-
}
|
|
368
|
-
;
|
|
369
|
-
async filterAdjacent() {
|
|
370
|
-
const adjacencyList = [];
|
|
371
|
-
const transitions = await this.store.getTransitions(await this.engine.getVID());
|
|
372
|
-
const transition = transitions[`.${this.metadata.aid}`];
|
|
373
|
-
//resolve the dimensional address for adjacent children
|
|
374
|
-
const adjacentDad = this.resolveAdjacentDad();
|
|
375
|
-
if (transition) {
|
|
376
|
-
for (const toActivityId in transition) {
|
|
377
|
-
const transitionRule = transition[toActivityId];
|
|
378
|
-
if (MapperService.evaluate(transitionRule, this.context, this.code)) {
|
|
379
|
-
adjacencyList.push({
|
|
380
|
-
metadata: {
|
|
381
|
-
jid: this.context.metadata.jid,
|
|
382
|
-
dad: adjacentDad,
|
|
383
|
-
aid: toActivityId,
|
|
384
|
-
spn: this.context['$self'].output.metadata?.l2s,
|
|
385
|
-
trc: this.context.metadata.trc,
|
|
386
|
-
},
|
|
387
|
-
type: StreamDataType.TRANSITION,
|
|
388
|
-
data: {}
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return adjacencyList;
|
|
394
|
-
}
|
|
395
|
-
async transition(adjacencyList, jobStatus) {
|
|
396
|
-
let mIds = [];
|
|
397
|
-
if (adjacencyList.length) {
|
|
398
|
-
const multi = this.store.getMulti();
|
|
399
|
-
for (const execSignal of adjacencyList) {
|
|
400
|
-
await this.engine.streamSignaler?.publishMessage(null, execSignal, multi);
|
|
401
|
-
}
|
|
402
|
-
mIds = (await multi.exec());
|
|
403
|
-
}
|
|
404
|
-
else if (jobStatus <= 0) {
|
|
405
|
-
await this.engine.runJobCompletionTasks(this.context);
|
|
406
|
-
}
|
|
407
|
-
return mIds;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
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
|
-
processSuccess(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
|
|
14
|
-
processError(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
|
-
//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 };
|
|
@@ -1,9 +0,0 @@
|
|
|
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 };
|
|
@@ -1,10 +0,0 @@
|
|
|
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 };
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
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 };
|
|
@@ -1,10 +0,0 @@
|
|
|
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 };
|
|
@@ -1,22 +0,0 @@
|
|
|
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 };
|