@hotmeshio/hotmesh 0.0.8 → 0.0.10
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 +82 -85
- package/build/{cjs/modules → modules}/key.d.ts +2 -2
- package/build/{cjs/modules → modules}/key.js +3 -3
- package/build/{esm/package.json → package.json} +4 -11
- package/build/{cjs/services → services}/durable/native.js +2 -3
- package/build/{esm/services → services}/durable/worker.d.ts +1 -3
- package/build/{cjs/services → services}/durable/worker.js +9 -33
- package/build/{cjs/services → services}/durable/workflow.js +6 -1
- package/build/{cjs/services → services}/hotmesh/index.js +1 -1
- package/build/{cjs/services → services}/store/index.js +2 -2
- package/build/{cjs/services → services}/stream/clients/ioredis.js +1 -1
- package/build/{cjs/services → services}/stream/clients/redis.js +1 -1
- package/build/{cjs/services → services}/sub/clients/ioredis.js +1 -1
- package/build/{cjs/services → services}/sub/clients/redis.js +1 -1
- package/build/{cjs/types → types}/durable.d.ts +5 -7
- package/modules/key.ts +2 -2
- package/package.json +4 -11
- package/services/durable/native.ts +2 -3
- package/services/durable/worker.ts +9 -10
- package/services/durable/workflow.ts +7 -1
- package/services/hotmesh/index.ts +2 -2
- package/services/store/index.ts +3 -3
- package/services/stream/clients/ioredis.ts +2 -2
- package/services/stream/clients/redis.ts +2 -2
- package/services/sub/clients/ioredis.ts +2 -2
- package/services/sub/clients/redis.ts +2 -2
- package/types/durable.ts +5 -5
- 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}/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}/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}/stream/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/clients/redis.d.ts +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/redis.d.ts +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,522 +0,0 @@
|
|
|
1
|
-
import { KeyType } from '../../modules/key';
|
|
2
|
-
import { formatISODate, getSubscriptionTopic, identifyRedisType, restoreHierarchy } from '../../modules/utils';
|
|
3
|
-
import Activities from '../activities';
|
|
4
|
-
import { CompilerService } from '../compiler';
|
|
5
|
-
import { ReporterService } from '../reporter';
|
|
6
|
-
import { SerializerService } from '../serializer';
|
|
7
|
-
import { StoreSignaler } from '../signaler/store';
|
|
8
|
-
import { StreamSignaler } from '../signaler/stream';
|
|
9
|
-
import { RedisStoreService as RedisStore } from '../store/clients/redis';
|
|
10
|
-
import { IORedisStoreService as IORedisStore } from '../store/clients/ioredis';
|
|
11
|
-
import { RedisStreamService as RedisStream } from '../stream/clients/redis';
|
|
12
|
-
import { IORedisStreamService as IORedisStream } from '../stream/clients/ioredis';
|
|
13
|
-
import { IORedisSubService as IORedisSub } from '../sub/clients/ioredis';
|
|
14
|
-
import { RedisSubService as RedisSub } from '../sub/clients/redis';
|
|
15
|
-
import { TaskService } from '../task';
|
|
16
|
-
import { StreamDataType, StreamRole, StreamStatus } from '../../types/stream';
|
|
17
|
-
//wait time to see if a job is complete
|
|
18
|
-
const OTT_WAIT_TIME = 1000;
|
|
19
|
-
const STATUS_CODE_SUCCESS = 200;
|
|
20
|
-
const STATUS_CODE_TIMEOUT = 504;
|
|
21
|
-
class EngineService {
|
|
22
|
-
constructor() {
|
|
23
|
-
this.cacheMode = 'cache';
|
|
24
|
-
this.untilVersion = null;
|
|
25
|
-
this.jobCallbacks = {};
|
|
26
|
-
this.reporting = false;
|
|
27
|
-
this.jobId = 1;
|
|
28
|
-
}
|
|
29
|
-
static async init(namespace, appId, guid, config, logger) {
|
|
30
|
-
if (config.engine) {
|
|
31
|
-
const instance = new EngineService();
|
|
32
|
-
instance.verifyEngineFields(config);
|
|
33
|
-
instance.namespace = namespace;
|
|
34
|
-
instance.appId = appId;
|
|
35
|
-
instance.guid = guid;
|
|
36
|
-
instance.logger = logger;
|
|
37
|
-
await instance.initStoreChannel(config.engine.store);
|
|
38
|
-
await instance.initSubChannel(config.engine.sub);
|
|
39
|
-
await instance.initStreamChannel(config.engine.stream);
|
|
40
|
-
instance.streamSignaler = instance.initStreamSignaler(config);
|
|
41
|
-
instance.streamSignaler.consumeMessages(instance.stream.mintKey(KeyType.STREAMS, { appId: instance.appId }), 'ENGINE', instance.guid, instance.processStreamMessage.bind(instance));
|
|
42
|
-
//the storeSignaler service is used by the engine to create `webhooks`
|
|
43
|
-
//todo: unify/move to the task service (it manages all `signal` types)
|
|
44
|
-
instance.storeSignaler = new StoreSignaler(instance.store, logger);
|
|
45
|
-
//the task service is used by the engine to process `webhooks` and `timehooks`
|
|
46
|
-
instance.task = new TaskService(instance.store, logger);
|
|
47
|
-
return instance;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
verifyEngineFields(config) {
|
|
51
|
-
if (!identifyRedisType(config.engine.store) ||
|
|
52
|
-
!identifyRedisType(config.engine.stream) ||
|
|
53
|
-
!identifyRedisType(config.engine.sub)) {
|
|
54
|
-
throw new Error('engine config must reference 3 redis client instances');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async initStoreChannel(store) {
|
|
58
|
-
if (identifyRedisType(store) === 'redis') {
|
|
59
|
-
this.store = new RedisStore(store);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.store = new IORedisStore(store);
|
|
63
|
-
}
|
|
64
|
-
await this.store.init(this.namespace, this.appId, this.logger);
|
|
65
|
-
}
|
|
66
|
-
async initSubChannel(sub) {
|
|
67
|
-
if (identifyRedisType(sub) === 'redis') {
|
|
68
|
-
this.subscribe = new RedisSub(sub);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
this.subscribe = new IORedisSub(sub);
|
|
72
|
-
}
|
|
73
|
-
await this.subscribe.init(this.namespace, this.appId, this.guid, this.logger);
|
|
74
|
-
}
|
|
75
|
-
async initStreamChannel(stream) {
|
|
76
|
-
if (identifyRedisType(stream) === 'redis') {
|
|
77
|
-
this.stream = new RedisStream(stream);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
this.stream = new IORedisStream(stream);
|
|
81
|
-
}
|
|
82
|
-
await this.stream.init(this.namespace, this.appId, this.logger);
|
|
83
|
-
}
|
|
84
|
-
initStreamSignaler(config) {
|
|
85
|
-
return new StreamSignaler({
|
|
86
|
-
namespace: this.namespace,
|
|
87
|
-
appId: this.appId,
|
|
88
|
-
guid: this.guid,
|
|
89
|
-
role: StreamRole.ENGINE,
|
|
90
|
-
reclaimDelay: config.engine.reclaimDelay,
|
|
91
|
-
reclaimCount: config.engine.reclaimCount,
|
|
92
|
-
}, this.stream, this.store, this.logger);
|
|
93
|
-
}
|
|
94
|
-
async getVID(vid) {
|
|
95
|
-
if (this.cacheMode === 'nocache') {
|
|
96
|
-
const app = await this.store.getApp(this.appId, true);
|
|
97
|
-
if (app.version.toString() === this.untilVersion.toString()) {
|
|
98
|
-
//new version is deployed; OK to cache again
|
|
99
|
-
if (!this.apps)
|
|
100
|
-
this.apps = {};
|
|
101
|
-
this.apps[this.appId] = app;
|
|
102
|
-
this.setCacheMode('cache', app.version.toString());
|
|
103
|
-
}
|
|
104
|
-
return { id: this.appId, version: app.version };
|
|
105
|
-
}
|
|
106
|
-
else if (!this.apps && vid) {
|
|
107
|
-
this.apps = {};
|
|
108
|
-
this.apps[this.appId] = vid;
|
|
109
|
-
return vid;
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
return { id: this.appId, version: this.apps?.[this.appId].version };
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
setCacheMode(cacheMode, untilVersion) {
|
|
116
|
-
this.logger.info(`engine-rule-cache-updated`, { mode: cacheMode, until: untilVersion });
|
|
117
|
-
this.cacheMode = cacheMode;
|
|
118
|
-
this.untilVersion = untilVersion;
|
|
119
|
-
}
|
|
120
|
-
async routeToSubscribers(topic, message) {
|
|
121
|
-
const jobCallback = this.jobCallbacks[message.metadata.jid];
|
|
122
|
-
if (jobCallback) {
|
|
123
|
-
this.delistJobCallback(message.metadata.jid);
|
|
124
|
-
jobCallback(topic, message);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
async processWebHooks() {
|
|
128
|
-
this.task.processWebHooks((this.hook).bind(this));
|
|
129
|
-
}
|
|
130
|
-
async processTimeHooks() {
|
|
131
|
-
this.task.processTimeHooks((this.hookTime).bind(this));
|
|
132
|
-
}
|
|
133
|
-
async throttle(delayInMillis) {
|
|
134
|
-
this.streamSignaler.setThrottle(delayInMillis);
|
|
135
|
-
}
|
|
136
|
-
// ************* METADATA/MODEL METHODS *************
|
|
137
|
-
async initActivity(topic, data = {}, context) {
|
|
138
|
-
const [activityId, schema] = await this.getSchema(topic);
|
|
139
|
-
const ActivityHandler = Activities[schema.type];
|
|
140
|
-
if (ActivityHandler) {
|
|
141
|
-
const utc = formatISODate(new Date());
|
|
142
|
-
const metadata = {
|
|
143
|
-
aid: activityId,
|
|
144
|
-
atp: schema.type,
|
|
145
|
-
stp: schema.subtype,
|
|
146
|
-
ac: utc,
|
|
147
|
-
au: utc
|
|
148
|
-
};
|
|
149
|
-
const hook = null;
|
|
150
|
-
return new ActivityHandler(schema, data, metadata, hook, this, context);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
throw new Error(`activity type ${schema.type} not found`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
async getSchema(topic) {
|
|
157
|
-
const app = await this.store.getApp(this.appId);
|
|
158
|
-
if (!app) {
|
|
159
|
-
throw new Error(`no app found for id ${this.appId}`);
|
|
160
|
-
}
|
|
161
|
-
if (this.isPrivate(topic)) {
|
|
162
|
-
//private subscriptions use the schema id (.activityId)
|
|
163
|
-
const activityId = topic.substring(1);
|
|
164
|
-
const schema = await this.store.getSchema(activityId, await this.getVID(app));
|
|
165
|
-
return [activityId, schema];
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
//public subscriptions use a topic (a.b.c) that is associated with a schema id
|
|
169
|
-
const activityId = await this.store.getSubscription(topic, await this.getVID(app));
|
|
170
|
-
if (activityId) {
|
|
171
|
-
const schema = await this.store.getSchema(activityId, await this.getVID(app));
|
|
172
|
-
return [activityId, schema];
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
throw new Error(`no subscription found for topic ${topic} in app ${this.appId} for app version ${app.version}`);
|
|
176
|
-
}
|
|
177
|
-
async getSettings() {
|
|
178
|
-
return await this.store.getSettings();
|
|
179
|
-
}
|
|
180
|
-
isPrivate(topic) {
|
|
181
|
-
return topic.startsWith('.');
|
|
182
|
-
}
|
|
183
|
-
// ************* COMPILER METHODS *************
|
|
184
|
-
async plan(pathOrYAML) {
|
|
185
|
-
const compiler = new CompilerService(this.store, this.logger);
|
|
186
|
-
return await compiler.plan(pathOrYAML);
|
|
187
|
-
}
|
|
188
|
-
async deploy(pathOrYAML) {
|
|
189
|
-
const compiler = new CompilerService(this.store, this.logger);
|
|
190
|
-
return await compiler.deploy(pathOrYAML);
|
|
191
|
-
}
|
|
192
|
-
// ************* REPORTER METHODS *************
|
|
193
|
-
async getStats(topic, query) {
|
|
194
|
-
const { id, version } = await this.getVID();
|
|
195
|
-
const reporter = new ReporterService({ id, version }, this.store, this.logger);
|
|
196
|
-
const resolvedQuery = await this.resolveQuery(topic, query);
|
|
197
|
-
return await reporter.getStats(resolvedQuery);
|
|
198
|
-
}
|
|
199
|
-
async getIds(topic, query, queryFacets = []) {
|
|
200
|
-
const { id, version } = await this.getVID();
|
|
201
|
-
const reporter = new ReporterService({ id, version }, this.store, this.logger);
|
|
202
|
-
const resolvedQuery = await this.resolveQuery(topic, query);
|
|
203
|
-
return await reporter.getIds(resolvedQuery, queryFacets);
|
|
204
|
-
}
|
|
205
|
-
async resolveQuery(topic, query) {
|
|
206
|
-
const trigger = await this.initActivity(topic, query.data);
|
|
207
|
-
await trigger.getState();
|
|
208
|
-
return {
|
|
209
|
-
end: query.end,
|
|
210
|
-
start: query.start,
|
|
211
|
-
range: query.range,
|
|
212
|
-
granularity: trigger.resolveGranularity(),
|
|
213
|
-
key: trigger.resolveJobKey(trigger.createInputContext()),
|
|
214
|
-
sparse: query.sparse,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
// ****************** STREAM RE-ENTRY POINT *****************
|
|
218
|
-
async processStreamMessage(streamData) {
|
|
219
|
-
this.logger.debug('engine-process-stream-message', {
|
|
220
|
-
jid: streamData.metadata.jid,
|
|
221
|
-
dad: streamData.metadata.dad,
|
|
222
|
-
aid: streamData.metadata.aid,
|
|
223
|
-
status: streamData.status || StreamStatus.SUCCESS,
|
|
224
|
-
code: streamData.code || 200,
|
|
225
|
-
});
|
|
226
|
-
const context = {
|
|
227
|
-
metadata: {
|
|
228
|
-
jid: streamData.metadata.jid,
|
|
229
|
-
dad: streamData.metadata.dad,
|
|
230
|
-
aid: streamData.metadata.aid,
|
|
231
|
-
},
|
|
232
|
-
data: streamData.data,
|
|
233
|
-
};
|
|
234
|
-
if (streamData.type === StreamDataType.TIMEHOOK || streamData.type === StreamDataType.WEBHOOK || streamData.type === StreamDataType.TRANSITION) {
|
|
235
|
-
const activityHandler = await this.initActivity(`.${streamData.metadata.aid}`, context.data, context);
|
|
236
|
-
if (streamData.type === StreamDataType.TIMEHOOK) {
|
|
237
|
-
await activityHandler.processTimeHookEvent(streamData.metadata.jid);
|
|
238
|
-
}
|
|
239
|
-
else if (streamData.type === StreamDataType.TRANSITION) {
|
|
240
|
-
await activityHandler.process();
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
await activityHandler.processWebHookEvent();
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
else if (streamData.type === StreamDataType.AWAIT) {
|
|
247
|
-
context.metadata = {
|
|
248
|
-
...context.metadata,
|
|
249
|
-
pj: streamData.metadata.jid,
|
|
250
|
-
pd: streamData.metadata.dad,
|
|
251
|
-
pa: streamData.metadata.aid,
|
|
252
|
-
trc: streamData.metadata.trc,
|
|
253
|
-
spn: streamData.metadata.spn,
|
|
254
|
-
};
|
|
255
|
-
const activityHandler = await this.initActivity(streamData.metadata.topic, streamData.data, context);
|
|
256
|
-
await activityHandler.process();
|
|
257
|
-
}
|
|
258
|
-
else if (streamData.type === StreamDataType.RESULT) {
|
|
259
|
-
const activityHandler = await this.initActivity(`.${context.metadata.aid}`, streamData.data, context);
|
|
260
|
-
await activityHandler.processEvent(streamData.status, streamData.code);
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
const activityHandler = await this.initActivity(`.${streamData.metadata.aid}`, streamData.data, context);
|
|
264
|
-
await activityHandler.processEvent(streamData.status, streamData.code);
|
|
265
|
-
}
|
|
266
|
-
this.logger.debug('engine-process-stream-message-end', {
|
|
267
|
-
jid: streamData.metadata.jid,
|
|
268
|
-
aid: streamData.metadata.aid
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
// ***************** `AWAIT` ACTIVITY RETURN RESPONSE ****************
|
|
272
|
-
async execAdjacentParent(context, jobOutput) {
|
|
273
|
-
if (this.hasParentJob(context)) {
|
|
274
|
-
//errors are stringified `StreamError` objects
|
|
275
|
-
const error = this.resolveError(jobOutput.metadata);
|
|
276
|
-
const spn = context['$self']?.output?.metadata?.l2s || context['$self']?.output?.metadata?.l1s;
|
|
277
|
-
const streamData = {
|
|
278
|
-
metadata: {
|
|
279
|
-
jid: context.metadata.pj,
|
|
280
|
-
dad: context.metadata.pd,
|
|
281
|
-
aid: context.metadata.pa,
|
|
282
|
-
trc: context.metadata.trc,
|
|
283
|
-
spn,
|
|
284
|
-
},
|
|
285
|
-
type: StreamDataType.RESULT,
|
|
286
|
-
data: jobOutput.data,
|
|
287
|
-
};
|
|
288
|
-
if (error && error.code) {
|
|
289
|
-
streamData.status = StreamStatus.ERROR;
|
|
290
|
-
streamData.data = error;
|
|
291
|
-
streamData.code = error.code;
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
streamData.status = StreamStatus.SUCCESS;
|
|
295
|
-
streamData.code = STATUS_CODE_SUCCESS;
|
|
296
|
-
}
|
|
297
|
-
return (await this.streamSignaler?.publishMessage(null, streamData));
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
hasParentJob(context) {
|
|
301
|
-
//todo: include the dimensional address (pd)
|
|
302
|
-
return Boolean(context.metadata.pj && context.metadata.pa);
|
|
303
|
-
}
|
|
304
|
-
resolveError(metadata) {
|
|
305
|
-
if (metadata && metadata.err) {
|
|
306
|
-
return JSON.parse(metadata.err);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
// ****************** `SCRUB` CLEAN COMPLETED JOBS *****************
|
|
310
|
-
async scrub(jobId) {
|
|
311
|
-
await this.store.scrub(jobId);
|
|
312
|
-
}
|
|
313
|
-
// ****************** `HOOK` ACTIVITY RE-ENTRY POINT *****************
|
|
314
|
-
async hook(topic, data, dad) {
|
|
315
|
-
const hookRule = await this.storeSignaler.getHookRule(topic);
|
|
316
|
-
const [aid, schema] = await this.getSchema(`.${hookRule.to}`);
|
|
317
|
-
if (!dad) {
|
|
318
|
-
//assume dimensional address is singular (0)
|
|
319
|
-
// for ancestors and self if not provided
|
|
320
|
-
// todo: register
|
|
321
|
-
dad = ',0'.repeat(schema.ancestors.length + 1);
|
|
322
|
-
}
|
|
323
|
-
const streamData = {
|
|
324
|
-
type: StreamDataType.WEBHOOK,
|
|
325
|
-
metadata: {
|
|
326
|
-
//jid is unknown at this point; will be resolved using the data
|
|
327
|
-
aid,
|
|
328
|
-
dad,
|
|
329
|
-
topic
|
|
330
|
-
},
|
|
331
|
-
data,
|
|
332
|
-
};
|
|
333
|
-
await this.streamSignaler.publishMessage(null, streamData);
|
|
334
|
-
}
|
|
335
|
-
async hookTime(jobId, activityId) {
|
|
336
|
-
//the activityid is concatenated with its dimensional address (dad); split to resolve
|
|
337
|
-
const [aid, ...dimensions] = activityId.split(',');
|
|
338
|
-
const dad = `,${dimensions.join(',')}`;
|
|
339
|
-
const streamData = {
|
|
340
|
-
type: StreamDataType.TIMEHOOK,
|
|
341
|
-
metadata: {
|
|
342
|
-
jid: jobId,
|
|
343
|
-
aid,
|
|
344
|
-
dad,
|
|
345
|
-
},
|
|
346
|
-
data: { timestamp: Date.now() },
|
|
347
|
-
};
|
|
348
|
-
await this.streamSignaler.publishMessage(null, streamData);
|
|
349
|
-
}
|
|
350
|
-
async hookAll(hookTopic, data, query, queryFacets = []) {
|
|
351
|
-
const config = await this.getVID();
|
|
352
|
-
const hookRule = await this.storeSignaler.getHookRule(hookTopic);
|
|
353
|
-
if (hookRule) {
|
|
354
|
-
const subscriptionTopic = await getSubscriptionTopic(hookRule.to, this.store, config);
|
|
355
|
-
const resolvedQuery = await this.resolveQuery(subscriptionTopic, query);
|
|
356
|
-
const reporter = new ReporterService(config, this.store, this.logger);
|
|
357
|
-
const workItems = await reporter.getWorkItems(resolvedQuery, queryFacets);
|
|
358
|
-
const taskService = new TaskService(this.store, this.logger);
|
|
359
|
-
await taskService.enqueueWorkItems(workItems.map(workItem => `${hookTopic}::${workItem}::${JSON.stringify(data)}`));
|
|
360
|
-
this.store.publish(KeyType.QUORUM, { type: 'work', originator: this.guid }, this.appId);
|
|
361
|
-
return workItems;
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
throw new Error(`unable to find hook rule for topic ${hookTopic}`);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
// ********************** PUB/SUB ENTRY POINT **********************
|
|
368
|
-
//publish (returns just the job id)
|
|
369
|
-
async pub(topic, data, context) {
|
|
370
|
-
const activityHandler = await this.initActivity(topic, data, context);
|
|
371
|
-
if (activityHandler) {
|
|
372
|
-
return await activityHandler.process();
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
throw new Error(`unable to process activity for topic ${topic}`);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
//subscribe to all jobs for a topic
|
|
379
|
-
async sub(topic, callback) {
|
|
380
|
-
const subscriptionCallback = async (topic, message) => {
|
|
381
|
-
callback(message.topic, message.job);
|
|
382
|
-
};
|
|
383
|
-
return await this.subscribe.subscribe(KeyType.QUORUM, subscriptionCallback, this.appId, topic);
|
|
384
|
-
}
|
|
385
|
-
//unsubscribe to all jobs for a topic
|
|
386
|
-
async unsub(topic) {
|
|
387
|
-
return await this.subscribe.unsubscribe(KeyType.QUORUM, this.appId, topic);
|
|
388
|
-
}
|
|
389
|
-
//subscribe to all jobs for a wildcard topic
|
|
390
|
-
async psub(wild, callback) {
|
|
391
|
-
const subscriptionCallback = async (topic, message) => {
|
|
392
|
-
callback(message.topic, message.job);
|
|
393
|
-
};
|
|
394
|
-
return await this.subscribe.psubscribe(KeyType.QUORUM, subscriptionCallback, this.appId, wild);
|
|
395
|
-
}
|
|
396
|
-
//unsubscribe to all jobs for a wildcard topic
|
|
397
|
-
async punsub(wild) {
|
|
398
|
-
return await this.subscribe.punsubscribe(KeyType.QUORUM, this.appId, wild);
|
|
399
|
-
}
|
|
400
|
-
//publish and await (returns the job and data (if ready)); throws error with jobid if not
|
|
401
|
-
async pubsub(topic, data, context, timeout = OTT_WAIT_TIME) {
|
|
402
|
-
context = {
|
|
403
|
-
metadata: {
|
|
404
|
-
ngn: this.guid,
|
|
405
|
-
trc: context?.metadata?.trc,
|
|
406
|
-
spn: context?.metadata?.spn
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
const jobId = await this.pub(topic, data, context);
|
|
410
|
-
return new Promise((resolve, reject) => {
|
|
411
|
-
this.registerJobCallback(jobId, (topic, output) => {
|
|
412
|
-
if (output.metadata.err) {
|
|
413
|
-
const error = JSON.parse(output.metadata.err);
|
|
414
|
-
reject({
|
|
415
|
-
...error,
|
|
416
|
-
job_id: output.metadata.jid,
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
resolve(output);
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
setTimeout(() => {
|
|
424
|
-
this.delistJobCallback(jobId);
|
|
425
|
-
reject({
|
|
426
|
-
code: STATUS_CODE_TIMEOUT,
|
|
427
|
-
message: 'timeout',
|
|
428
|
-
job_id: jobId
|
|
429
|
-
});
|
|
430
|
-
}, timeout);
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
async resolveOneTimeSubscription(context, jobOutput) {
|
|
434
|
-
//todo: subscriber should query for the job...only publish minimum context needed
|
|
435
|
-
if (this.hasOneTimeSubscription(context)) {
|
|
436
|
-
const message = {
|
|
437
|
-
type: 'job',
|
|
438
|
-
topic: context.metadata.jid,
|
|
439
|
-
job: restoreHierarchy(jobOutput),
|
|
440
|
-
};
|
|
441
|
-
this.store.publish(KeyType.QUORUM, message, this.appId, context.metadata.ngn);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
async getPublishesTopic(context) {
|
|
445
|
-
const config = await this.getVID();
|
|
446
|
-
const activityId = context.metadata.aid || context['$self']?.output?.metadata?.aid;
|
|
447
|
-
const schema = await this.store.getSchema(activityId, config);
|
|
448
|
-
return schema.publishes;
|
|
449
|
-
}
|
|
450
|
-
async resolvePersistentSubscriptions(context, jobOutput) {
|
|
451
|
-
const topic = await this.getPublishesTopic(context);
|
|
452
|
-
if (topic) {
|
|
453
|
-
const message = {
|
|
454
|
-
type: 'job',
|
|
455
|
-
topic,
|
|
456
|
-
job: restoreHierarchy(jobOutput),
|
|
457
|
-
};
|
|
458
|
-
this.store.publish(KeyType.QUORUM, message, this.appId, `${topic}.${context.metadata.jid}`);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
async add(streamData) {
|
|
462
|
-
return await this.streamSignaler.publishMessage(null, streamData);
|
|
463
|
-
}
|
|
464
|
-
registerJobCallback(jobId, jobCallback) {
|
|
465
|
-
this.jobCallbacks[jobId] = jobCallback;
|
|
466
|
-
}
|
|
467
|
-
delistJobCallback(jobId) {
|
|
468
|
-
delete this.jobCallbacks[jobId];
|
|
469
|
-
}
|
|
470
|
-
hasOneTimeSubscription(context) {
|
|
471
|
-
return Boolean(context.metadata.ngn);
|
|
472
|
-
}
|
|
473
|
-
// ***************** JOB COMPLETION/CLEANUP *****************
|
|
474
|
-
async runJobCompletionTasks(context) {
|
|
475
|
-
const isAwait = this.hasParentJob(context);
|
|
476
|
-
const isOneTimeSubscription = this.hasOneTimeSubscription(context);
|
|
477
|
-
const topic = await this.getPublishesTopic(context);
|
|
478
|
-
if (isAwait || isOneTimeSubscription || topic) {
|
|
479
|
-
const jobOutput = await this.getState(context.metadata.tpc, context.metadata.jid);
|
|
480
|
-
//always wait for stream pub/sub
|
|
481
|
-
await this.execAdjacentParent(context, jobOutput);
|
|
482
|
-
//no need to wait for standard pub/sub
|
|
483
|
-
this.resolveOneTimeSubscription(context, jobOutput);
|
|
484
|
-
this.resolvePersistentSubscriptions(context, jobOutput);
|
|
485
|
-
}
|
|
486
|
-
this.task.registerJobForCleanup(context.metadata.jid, context.metadata.expire);
|
|
487
|
-
}
|
|
488
|
-
// ****** GET JOB STATE/COLLATION STATUS BY ID *********
|
|
489
|
-
async getStatus(jobId) {
|
|
490
|
-
const { id: appId } = await this.getVID();
|
|
491
|
-
return this.store.getStatus(jobId, appId);
|
|
492
|
-
}
|
|
493
|
-
//todo: add 'options' parameter;
|
|
494
|
-
// (e.g, if {dimensions:true}, use hscan to deliver
|
|
495
|
-
// the full set of dimensional job data)
|
|
496
|
-
async getState(topic, jobId) {
|
|
497
|
-
const jobSymbols = await this.store.getSymbols(`$${topic}`);
|
|
498
|
-
const consumes = {
|
|
499
|
-
[`$${topic}`]: Object.keys(jobSymbols)
|
|
500
|
-
};
|
|
501
|
-
//job data exists at the 'zero' dimension; pass an empty object
|
|
502
|
-
const dIds = {};
|
|
503
|
-
const output = await this.store.getState(jobId, consumes, dIds);
|
|
504
|
-
if (!output) {
|
|
505
|
-
throw new Error(`not found ${jobId}`);
|
|
506
|
-
}
|
|
507
|
-
const [state, status] = output;
|
|
508
|
-
const stateTree = restoreHierarchy(state);
|
|
509
|
-
if (status && stateTree.metadata) {
|
|
510
|
-
stateTree.metadata.js = status;
|
|
511
|
-
}
|
|
512
|
-
return stateTree;
|
|
513
|
-
}
|
|
514
|
-
async compress(terms) {
|
|
515
|
-
const existingSymbols = await this.store.getSymbolValues();
|
|
516
|
-
const startIndex = Object.keys(existingSymbols).length;
|
|
517
|
-
const maxIndex = Math.pow(52, 2) - 1;
|
|
518
|
-
const newSymbols = SerializerService.filterSymVals(startIndex, maxIndex, existingSymbols, new Set(terms));
|
|
519
|
-
return await this.store.addSymbolValues(newSymbols);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
export { EngineService };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { EngineService } from '../engine';
|
|
2
|
-
import { ILogger } from '../logger';
|
|
3
|
-
import { QuorumService } from '../quorum';
|
|
4
|
-
import { WorkerService } from '../worker';
|
|
5
|
-
import { JobState, JobData, JobOutput, JobStatus } from '../../types/job';
|
|
6
|
-
import { HotMeshConfig, HotMeshManifest } from '../../types/hotmesh';
|
|
7
|
-
import { JobMessageCallback } from '../../types/quorum';
|
|
8
|
-
import { JobStatsInput, GetStatsOptions, IdsResponse, StatsResponse } from '../../types/stats';
|
|
9
|
-
import { StreamData, StreamDataResponse } from '../../types/stream';
|
|
10
|
-
declare class HotMeshService {
|
|
11
|
-
namespace: string;
|
|
12
|
-
appId: string;
|
|
13
|
-
guid: string;
|
|
14
|
-
engine: EngineService | null;
|
|
15
|
-
quorum: QuorumService | null;
|
|
16
|
-
workers: WorkerService[];
|
|
17
|
-
logger: ILogger;
|
|
18
|
-
verifyAndSetNamespace(namespace?: string): void;
|
|
19
|
-
verifyAndSetAppId(appId: string): void;
|
|
20
|
-
static init(config: HotMeshConfig): Promise<HotMeshService>;
|
|
21
|
-
initEngine(config: HotMeshConfig, logger: ILogger): Promise<void>;
|
|
22
|
-
initQuorum(config: HotMeshConfig, engine: EngineService, logger: ILogger): Promise<void>;
|
|
23
|
-
initWorkers(config: HotMeshConfig, logger: ILogger): Promise<void>;
|
|
24
|
-
pub(topic: string, data?: JobData, context?: JobState): Promise<string>;
|
|
25
|
-
sub(topic: string, callback: JobMessageCallback): Promise<void>;
|
|
26
|
-
unsub(topic: string): Promise<void>;
|
|
27
|
-
psub(wild: string, callback: JobMessageCallback): Promise<void>;
|
|
28
|
-
punsub(wild: string): Promise<void>;
|
|
29
|
-
pubsub(topic: string, data?: JobData, context?: JobState | null, timeout?: number): Promise<JobOutput>;
|
|
30
|
-
add(streamData: StreamData | StreamDataResponse): Promise<string>;
|
|
31
|
-
plan(path: string): Promise<HotMeshManifest>;
|
|
32
|
-
deploy(pathOrYAML: string): Promise<HotMeshManifest>;
|
|
33
|
-
activate(version: string, delay?: number): Promise<boolean>;
|
|
34
|
-
getStats(topic: string, query: JobStatsInput): Promise<StatsResponse>;
|
|
35
|
-
getStatus(jobId: string): Promise<JobStatus>;
|
|
36
|
-
getState(topic: string, jobId: string): Promise<JobOutput>;
|
|
37
|
-
getIds(topic: string, query: JobStatsInput, queryFacets?: any[]): Promise<IdsResponse>;
|
|
38
|
-
resolveQuery(topic: string, query: JobStatsInput): Promise<GetStatsOptions>;
|
|
39
|
-
scrub(jobId: string): Promise<void>;
|
|
40
|
-
hook(topic: string, data: JobData, dad?: string): Promise<JobStatus | void>;
|
|
41
|
-
hookAll(hookTopic: string, data: JobData, query: JobStatsInput, queryFacets?: string[]): Promise<string[]>;
|
|
42
|
-
stop(): Promise<void>;
|
|
43
|
-
compress(terms: string[]): Promise<boolean>;
|
|
44
|
-
}
|
|
45
|
-
export { HotMeshService };
|