@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,43 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ILogger } from '../logger';
|
|
3
|
-
import { StoreService } from '../store';
|
|
4
|
-
import { StreamService } from '../stream';
|
|
5
|
-
import { RedisClient, RedisMulti } from '../../types/redis';
|
|
6
|
-
import { ReclaimedMessageType, StreamConfig, StreamData, StreamDataResponse, StreamRole } from '../../types/stream';
|
|
7
|
-
declare class StreamSignaler {
|
|
8
|
-
static signalers: Set<StreamSignaler>;
|
|
9
|
-
appId: string;
|
|
10
|
-
guid: string;
|
|
11
|
-
role: StreamRole;
|
|
12
|
-
topic: string | undefined;
|
|
13
|
-
store: StoreService<RedisClient, RedisMulti>;
|
|
14
|
-
stream: StreamService<RedisClient, RedisMulti>;
|
|
15
|
-
reclaimDelay: number;
|
|
16
|
-
reclaimCount: number;
|
|
17
|
-
logger: ILogger;
|
|
18
|
-
throttle: number;
|
|
19
|
-
errorCount: number;
|
|
20
|
-
currentTimerId: NodeJS.Timeout | null;
|
|
21
|
-
shouldConsume: boolean;
|
|
22
|
-
constructor(config: StreamConfig, stream: StreamService<RedisClient, RedisMulti>, store: StoreService<RedisClient, RedisMulti>, logger: ILogger);
|
|
23
|
-
createGroup(stream: string, group: string): Promise<void>;
|
|
24
|
-
publishMessage(topic: string, streamData: StreamData | StreamDataResponse, multi?: RedisMulti): Promise<string | RedisMulti>;
|
|
25
|
-
consumeMessages(stream: string, group: string, consumer: string, callback: (streamData: StreamData) => Promise<StreamDataResponse | void>): Promise<void>;
|
|
26
|
-
isStreamMessage(result: any): boolean;
|
|
27
|
-
consumeOne(stream: string, group: string, id: string, message: string[], callback: (streamData: StreamData) => Promise<StreamDataResponse | void>): Promise<void>;
|
|
28
|
-
execStreamLeg(input: StreamData, stream: string, id: string, callback: (streamData: StreamData) => Promise<StreamDataResponse | void>): Promise<StreamDataResponse>;
|
|
29
|
-
ackAndDelete(stream: string, group: string, id: string): Promise<void>;
|
|
30
|
-
publishResponse(input: StreamData, output: StreamDataResponse | void): Promise<string>;
|
|
31
|
-
shouldRetry(input: StreamData, output: StreamDataResponse): [boolean, number];
|
|
32
|
-
structureUnhandledError(input: StreamData, err: Error): StreamDataResponse;
|
|
33
|
-
structureUnacknowledgedError(input: StreamData): StreamDataResponse;
|
|
34
|
-
structureError(input: StreamData, output: StreamDataResponse): StreamDataResponse;
|
|
35
|
-
static stopConsuming(): Promise<void>;
|
|
36
|
-
stopConsuming(): Promise<void>;
|
|
37
|
-
cancelThrottle(): void;
|
|
38
|
-
setThrottle(delayInMillis: number): void;
|
|
39
|
-
claimUnacknowledged(stream: string, group: string, consumer: string, idleTimeMs?: number, limit?: number): Promise<[string, [string, string]][]>;
|
|
40
|
-
expireUnacknowledged(reclaimedMessage: ReclaimedMessageType, stream: string, group: string, consumer: string, id: string, count: number): Promise<void>;
|
|
41
|
-
parseStreamData(str: string): [undefined, StreamData] | [Error];
|
|
42
|
-
}
|
|
43
|
-
export { StreamSignaler };
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import { KeyType } from '../../modules/key';
|
|
2
|
-
import { XSleepFor, sleepFor } from '../../modules/utils';
|
|
3
|
-
import { TelemetryService } from '../telemetry';
|
|
4
|
-
import { StreamDataType, StreamRole, StreamStatus } from '../../types/stream';
|
|
5
|
-
const MAX_RETRIES = 4; //max delay (10s using exponential backoff);
|
|
6
|
-
const MAX_TIMEOUT_MS = 60000;
|
|
7
|
-
const GRADUATED_INTERVAL_MS = 5000;
|
|
8
|
-
const BLOCK_DURATION = 15000; //Set to `15` so SIGINT/SIGTERM can interrupt; set to `0` to BLOCK indefinitely
|
|
9
|
-
const TEST_BLOCK_DURATION = 1000; //Set to `1000` so tests can interrupt quickly
|
|
10
|
-
const BLOCK_TIME_MS = process.env.NODE_ENV === 'test' ? TEST_BLOCK_DURATION : BLOCK_DURATION;
|
|
11
|
-
const SYSTEM_STATUS_CODE = 999;
|
|
12
|
-
const UNKNOWN_STATUS_CODE = 500;
|
|
13
|
-
const UNKNOWN_STATUS_MESSAGE = 'unknown';
|
|
14
|
-
const XCLAIM_DELAY_MS = 1000 * 60; //max time a message can be unacked before it is claimed by another
|
|
15
|
-
const XCLAIM_COUNT = 3; //max number of times a message can be claimed by another before it is dead-lettered
|
|
16
|
-
const XPENDING_COUNT = 10;
|
|
17
|
-
class StreamSignaler {
|
|
18
|
-
constructor(config, stream, store, logger) {
|
|
19
|
-
this.throttle = 0;
|
|
20
|
-
this.errorCount = 0;
|
|
21
|
-
this.currentTimerId = null;
|
|
22
|
-
this.appId = config.appId;
|
|
23
|
-
this.guid = config.guid;
|
|
24
|
-
this.role = config.role;
|
|
25
|
-
this.topic = config.topic;
|
|
26
|
-
this.stream = stream;
|
|
27
|
-
this.store = store;
|
|
28
|
-
this.reclaimDelay = config.reclaimDelay || XCLAIM_DELAY_MS;
|
|
29
|
-
this.reclaimCount = config.reclaimCount || XCLAIM_COUNT;
|
|
30
|
-
this.logger = logger;
|
|
31
|
-
}
|
|
32
|
-
async createGroup(stream, group) {
|
|
33
|
-
try {
|
|
34
|
-
await this.store.xgroup('CREATE', stream, group, '$', 'MKSTREAM');
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
this.logger.info('consumer-group-exists', { stream, group });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async publishMessage(topic, streamData, multi) {
|
|
41
|
-
const stream = this.store.mintKey(KeyType.STREAMS, { appId: this.store.appId, topic });
|
|
42
|
-
return await this.store.xadd(stream, '*', 'message', JSON.stringify(streamData), multi);
|
|
43
|
-
}
|
|
44
|
-
async consumeMessages(stream, group, consumer, callback) {
|
|
45
|
-
this.logger.info(`stream-consumer-starting`, { group, consumer, stream });
|
|
46
|
-
StreamSignaler.signalers.add(this);
|
|
47
|
-
this.shouldConsume = true;
|
|
48
|
-
await this.createGroup(stream, group);
|
|
49
|
-
let lastCheckedPendingMessagesAt = Date.now();
|
|
50
|
-
async function consume() {
|
|
51
|
-
let sleep = XSleepFor(this.throttle);
|
|
52
|
-
this.currentTimerId = sleep.timerId;
|
|
53
|
-
await sleep.promise;
|
|
54
|
-
if (!this.shouldConsume) {
|
|
55
|
-
this.logger.info(`stream-consumer-stopping`, { group, consumer, stream });
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
const result = await this.stream.xreadgroup('GROUP', group, consumer, 'BLOCK', BLOCK_TIME_MS, 'STREAMS', stream, '>');
|
|
60
|
-
if (this.isStreamMessage(result)) {
|
|
61
|
-
const [[, messages]] = result;
|
|
62
|
-
for (const [id, message] of messages) {
|
|
63
|
-
await this.consumeOne(stream, group, id, message, callback);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// Check for pending messages (note: Redis 6.2 simplifies)
|
|
67
|
-
const now = Date.now();
|
|
68
|
-
if (now - lastCheckedPendingMessagesAt > this.reclaimDelay) {
|
|
69
|
-
lastCheckedPendingMessagesAt = now;
|
|
70
|
-
const pendingMessages = await this.claimUnacknowledged(stream, group, consumer);
|
|
71
|
-
for (const [id, message] of pendingMessages) {
|
|
72
|
-
await this.consumeOne(stream, group, id, message, callback);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
setImmediate(consume.bind(this));
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
if (this.shouldConsume && process.env.NODE_ENV !== 'test') {
|
|
79
|
-
this.logger.error(`stream-consume-message-error`, { err, stream, group, consumer });
|
|
80
|
-
this.errorCount++;
|
|
81
|
-
const timeout = Math.min(GRADUATED_INTERVAL_MS * (2 ** this.errorCount), MAX_TIMEOUT_MS);
|
|
82
|
-
setTimeout(consume.bind(this), timeout);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
consume.call(this);
|
|
87
|
-
}
|
|
88
|
-
isStreamMessage(result) {
|
|
89
|
-
return Array.isArray(result) && Array.isArray(result[0]);
|
|
90
|
-
}
|
|
91
|
-
async consumeOne(stream, group, id, message, callback) {
|
|
92
|
-
this.logger.debug(`stream-consume-one`, { group, stream, id });
|
|
93
|
-
const [err, input] = this.parseStreamData(message[1]);
|
|
94
|
-
let output;
|
|
95
|
-
let telemetry;
|
|
96
|
-
try {
|
|
97
|
-
telemetry = new TelemetryService(this.appId);
|
|
98
|
-
telemetry.startStreamSpan(input, this.role);
|
|
99
|
-
output = await this.execStreamLeg(input, stream, id, callback.bind(this));
|
|
100
|
-
if (output?.status === StreamStatus.ERROR) {
|
|
101
|
-
telemetry.setStreamError(`Function Status Code ${output.code || UNKNOWN_STATUS_CODE}`);
|
|
102
|
-
}
|
|
103
|
-
this.errorCount = 0;
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
this.logger.error(`stream-consume-one-error`, { group, stream, id, err });
|
|
107
|
-
telemetry.setStreamError(err.message);
|
|
108
|
-
}
|
|
109
|
-
const messageId = await this.publishResponse(input, output);
|
|
110
|
-
telemetry.setStreamAttributes({ 'app.worker.mid': messageId });
|
|
111
|
-
await this.ackAndDelete(stream, group, id);
|
|
112
|
-
telemetry.endStreamSpan();
|
|
113
|
-
this.logger.debug(`stream-consume-one-end`, { group, stream, id });
|
|
114
|
-
}
|
|
115
|
-
async execStreamLeg(input, stream, id, callback) {
|
|
116
|
-
let output;
|
|
117
|
-
try {
|
|
118
|
-
output = await callback(input);
|
|
119
|
-
}
|
|
120
|
-
catch (err) {
|
|
121
|
-
this.logger.error(`stream-call-function-error`, { stream, id, err });
|
|
122
|
-
output = this.structureUnhandledError(input, err);
|
|
123
|
-
}
|
|
124
|
-
return output;
|
|
125
|
-
}
|
|
126
|
-
async ackAndDelete(stream, group, id) {
|
|
127
|
-
const multi = this.stream.getMulti();
|
|
128
|
-
await this.stream.xack(stream, group, id, multi);
|
|
129
|
-
await this.stream.xdel(stream, id, multi);
|
|
130
|
-
await multi.exec();
|
|
131
|
-
}
|
|
132
|
-
async publishResponse(input, output) {
|
|
133
|
-
if (output && typeof output === 'object') {
|
|
134
|
-
if (output.status === 'error') {
|
|
135
|
-
const [shouldRetry, timeout] = this.shouldRetry(input, output);
|
|
136
|
-
if (shouldRetry) {
|
|
137
|
-
await sleepFor(timeout);
|
|
138
|
-
return await this.publishMessage(input.metadata.topic, {
|
|
139
|
-
data: input.data,
|
|
140
|
-
metadata: { ...input.metadata, try: (input.metadata.try || 0) + 1 },
|
|
141
|
-
policies: input.policies,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
output = this.structureError(input, output);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
output.type = StreamDataType.RESPONSE;
|
|
149
|
-
return await this.publishMessage(null, output);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
shouldRetry(input, output) {
|
|
153
|
-
const policies = input.policies?.retry;
|
|
154
|
-
const errorCode = output.code.toString();
|
|
155
|
-
const policy = policies?.[errorCode];
|
|
156
|
-
const maxRetries = policy?.[0];
|
|
157
|
-
const tryCount = Math.min(input.metadata.try || 0, MAX_RETRIES);
|
|
158
|
-
if (maxRetries >= tryCount) {
|
|
159
|
-
return [true, Math.pow(10, tryCount)];
|
|
160
|
-
}
|
|
161
|
-
return [false, 0];
|
|
162
|
-
}
|
|
163
|
-
structureUnhandledError(input, err) {
|
|
164
|
-
let error = {};
|
|
165
|
-
if (typeof err.message === 'string') {
|
|
166
|
-
error.message = err.message;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
error.message = UNKNOWN_STATUS_MESSAGE;
|
|
170
|
-
}
|
|
171
|
-
if (typeof err.stack === 'string') {
|
|
172
|
-
error.stack = err.stack;
|
|
173
|
-
}
|
|
174
|
-
if (typeof err.name === 'string') {
|
|
175
|
-
error.name = err.name;
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
status: 'error',
|
|
179
|
-
code: UNKNOWN_STATUS_CODE,
|
|
180
|
-
metadata: { ...input.metadata },
|
|
181
|
-
data: error
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
structureUnacknowledgedError(input) {
|
|
185
|
-
const message = 'stream message max delivery count exceeded';
|
|
186
|
-
const code = SYSTEM_STATUS_CODE;
|
|
187
|
-
const data = { message, code };
|
|
188
|
-
const output = {
|
|
189
|
-
metadata: { ...input.metadata },
|
|
190
|
-
status: StreamStatus.ERROR,
|
|
191
|
-
code,
|
|
192
|
-
data,
|
|
193
|
-
};
|
|
194
|
-
//send unacknowleded errors to the engine (it has no topic)
|
|
195
|
-
delete output.metadata.topic;
|
|
196
|
-
return output;
|
|
197
|
-
}
|
|
198
|
-
structureError(input, output) {
|
|
199
|
-
const message = output.data?.message ? output.data?.message.toString() : UNKNOWN_STATUS_MESSAGE;
|
|
200
|
-
const statusCode = output.code || output.data?.code;
|
|
201
|
-
const code = isNaN(statusCode) ? UNKNOWN_STATUS_CODE : parseInt(statusCode.toString());
|
|
202
|
-
const data = { message, code };
|
|
203
|
-
if (typeof output.data?.error === 'object') {
|
|
204
|
-
data.error = { ...output.data.error };
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
status: StreamStatus.ERROR,
|
|
208
|
-
code,
|
|
209
|
-
metadata: { ...input.metadata },
|
|
210
|
-
data
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
static async stopConsuming() {
|
|
214
|
-
for (const instance of [...StreamSignaler.signalers]) {
|
|
215
|
-
instance.stopConsuming();
|
|
216
|
-
}
|
|
217
|
-
await sleepFor(BLOCK_TIME_MS);
|
|
218
|
-
}
|
|
219
|
-
async stopConsuming() {
|
|
220
|
-
this.shouldConsume = false;
|
|
221
|
-
this.logger.info(`stream-consumer-stopping`, this.topic ? { topic: this.topic } : undefined);
|
|
222
|
-
this.cancelThrottle();
|
|
223
|
-
await sleepFor(BLOCK_TIME_MS);
|
|
224
|
-
}
|
|
225
|
-
cancelThrottle() {
|
|
226
|
-
if (this.currentTimerId !== undefined) {
|
|
227
|
-
clearTimeout(this.currentTimerId);
|
|
228
|
-
this.currentTimerId = undefined;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
setThrottle(delayInMillis) {
|
|
232
|
-
if (!Number.isInteger(delayInMillis) || delayInMillis < 0) {
|
|
233
|
-
throw new Error('Throttle must be a non-negative integer');
|
|
234
|
-
}
|
|
235
|
-
this.throttle = delayInMillis;
|
|
236
|
-
this.logger.info(`stream-throttle-reset`, { delay: this.throttle, topic: this.topic });
|
|
237
|
-
}
|
|
238
|
-
async claimUnacknowledged(stream, group, consumer, idleTimeMs = this.reclaimDelay, limit = XPENDING_COUNT) {
|
|
239
|
-
let pendingMessages = [];
|
|
240
|
-
const pendingMessagesInfo = await this.stream.xpending(stream, group, '-', '+', limit); //[[ '1688768134881-0', 'testConsumer1', 1017, 1 ]]
|
|
241
|
-
for (const pendingMessageInfo of pendingMessagesInfo) {
|
|
242
|
-
if (Array.isArray(pendingMessageInfo)) {
|
|
243
|
-
const [id, , elapsedTimeMs, deliveryCount] = pendingMessageInfo;
|
|
244
|
-
if (elapsedTimeMs > idleTimeMs) {
|
|
245
|
-
const reclaimedMessage = await this.stream.xclaim(stream, group, consumer, idleTimeMs, id);
|
|
246
|
-
if (reclaimedMessage.length) {
|
|
247
|
-
if (deliveryCount <= this.reclaimCount) {
|
|
248
|
-
pendingMessages = pendingMessages.concat(reclaimedMessage);
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
await this.expireUnacknowledged(reclaimedMessage, stream, group, consumer, id, deliveryCount);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return pendingMessages;
|
|
258
|
-
}
|
|
259
|
-
async expireUnacknowledged(reclaimedMessage, stream, group, consumer, id, count) {
|
|
260
|
-
//The stream activity was not processed within established limits. Possibilities Include:
|
|
261
|
-
// 1) user error: the workers were not properly configured and are timing out
|
|
262
|
-
// 2a) system error: JSON is corrupt
|
|
263
|
-
// i) bad/unwitting actor
|
|
264
|
-
// ii) corrupt hardware/network/transport/etc
|
|
265
|
-
// 3b) system error: Redis unable to accept `xadd` request
|
|
266
|
-
// 4c) system error: Redis unable to accept `xdel`/`xack` request
|
|
267
|
-
this.logger.error('stream-message-max-delivery-count-exceeded', { id, stream, group, consumer, code: SYSTEM_STATUS_CODE, count });
|
|
268
|
-
const streamData = reclaimedMessage[0]?.[1]?.[1];
|
|
269
|
-
//fatal risk point 1 of 3): json is corrupt
|
|
270
|
-
const [err, input] = this.parseStreamData(streamData);
|
|
271
|
-
if (err) {
|
|
272
|
-
return this.logger.error('expire-unacknowledged-parse-fatal-error', { id, err });
|
|
273
|
-
}
|
|
274
|
-
else if (!input || !input.metadata) {
|
|
275
|
-
return this.logger.error('expire-unacknowledged-parse-fatal-error', { id });
|
|
276
|
-
}
|
|
277
|
-
let telemetry;
|
|
278
|
-
let messageId;
|
|
279
|
-
try {
|
|
280
|
-
telemetry = new TelemetryService(this.appId);
|
|
281
|
-
telemetry.startStreamSpan(input, StreamRole.SYSTEM);
|
|
282
|
-
telemetry.setStreamError(`Stream Message Max Delivery Count Exceeded`);
|
|
283
|
-
//fatal risk point 2 of 3): unable to publish error message (to notify the parent job)
|
|
284
|
-
const output = this.structureUnacknowledgedError(input);
|
|
285
|
-
messageId = await this.publishResponse(input, output);
|
|
286
|
-
telemetry.setStreamAttributes({ 'app.worker.mid': messageId });
|
|
287
|
-
//fatal risk point 3 of 3): unable to ack and delete stream message
|
|
288
|
-
await this.ackAndDelete(stream, group, id);
|
|
289
|
-
}
|
|
290
|
-
catch (err) {
|
|
291
|
-
if (messageId) {
|
|
292
|
-
this.logger.error('expire-unacknowledged-pub-fatal-error', { id, err, ...input.metadata });
|
|
293
|
-
telemetry.setStreamAttributes({ 'app.system.fatal': 'expire-unacknowledged-pub-fatal-error' });
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
this.logger.error('expire-unacknowledged-ack-fatal-error', { id, err, ...input.metadata });
|
|
297
|
-
telemetry.setStreamAttributes({ 'app.system.fatal': 'expire-unacknowledged-ack-fatal-error' });
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
finally {
|
|
301
|
-
telemetry.endStreamSpan();
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
parseStreamData(str) {
|
|
305
|
-
try {
|
|
306
|
-
return [, JSON.parse(str)];
|
|
307
|
-
}
|
|
308
|
-
catch (e) {
|
|
309
|
-
return [e];
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
StreamSignaler.signalers = new Set();
|
|
314
|
-
export { StreamSignaler };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Cache is a key/value store and used to store commonly accessed Redis metadata
|
|
3
|
-
* (mainly the execution rules for the app) to save time accessing them as they
|
|
4
|
-
* are immutable per verison. The only time the rules are ejected are when
|
|
5
|
-
* a new version is deployed to the quorum and the cache is invalidated/cleared.
|
|
6
|
-
*/
|
|
7
|
-
import { ActivityType } from "../../types/activity";
|
|
8
|
-
import { HookRule } from "../../types/hook";
|
|
9
|
-
import { HotMeshApp, HotMeshSettings } from "../../types/hotmesh";
|
|
10
|
-
import { Symbols } from "../../types/serializer";
|
|
11
|
-
import { Transitions } from "../../types/transition";
|
|
12
|
-
declare class Cache {
|
|
13
|
-
settings: HotMeshSettings;
|
|
14
|
-
appId: string;
|
|
15
|
-
apps: Record<string, HotMeshApp>;
|
|
16
|
-
schemas: Record<string, ActivityType>;
|
|
17
|
-
subscriptions: Record<string, Record<string, string>>;
|
|
18
|
-
symbols: Record<string, Symbols>;
|
|
19
|
-
symvals: Record<string, Symbols>;
|
|
20
|
-
transitions: Record<string, Record<string, unknown>>;
|
|
21
|
-
hookRules: Record<string, Record<string, HookRule[]>>;
|
|
22
|
-
workItems: Record<string, string>;
|
|
23
|
-
/**
|
|
24
|
-
* The cache is ALWAYS initialized with HotMeshSettings. The other parameters are optional.
|
|
25
|
-
* @param settings
|
|
26
|
-
* @param apps
|
|
27
|
-
* @param schemas
|
|
28
|
-
* @param subscriptions
|
|
29
|
-
* @param transitions
|
|
30
|
-
* @param hookRules
|
|
31
|
-
*/
|
|
32
|
-
constructor(appId: string, settings: HotMeshSettings, apps?: Record<string, HotMeshApp>, schemas?: Record<string, ActivityType>, subscriptions?: Record<string, Record<string, string>>, symbols?: Record<string, Symbols>, symvals?: Record<string, Symbols>, transitions?: Record<string, Record<string, unknown>>, hookRules?: Record<string, Record<string, HookRule[]>>, workItems?: Record<string, string>);
|
|
33
|
-
/**
|
|
34
|
-
* invalidate the cache; settings are not invalidated!
|
|
35
|
-
*/
|
|
36
|
-
invalidate(): void;
|
|
37
|
-
getSettings(): HotMeshSettings;
|
|
38
|
-
setSettings(settings: HotMeshSettings): void;
|
|
39
|
-
getApps(): Record<string, HotMeshApp>;
|
|
40
|
-
getApp(appId: string): HotMeshApp;
|
|
41
|
-
setApps(apps: Record<string, HotMeshApp>): void;
|
|
42
|
-
setApp(appId: string, app: HotMeshApp): void;
|
|
43
|
-
getSchemas(appId: string, version: string): Record<string, ActivityType>;
|
|
44
|
-
getSchema(appId: string, version: string, activityId: string): ActivityType;
|
|
45
|
-
setSchemas(appId: string, version: string, schemas: Record<string, ActivityType>): void;
|
|
46
|
-
setSchema(appId: string, version: string, activityId: string, schema: ActivityType): void;
|
|
47
|
-
getSubscriptions(appId: string, version: string): Record<string, string>;
|
|
48
|
-
getSubscription(appId: string, version: string, topic: string): unknown;
|
|
49
|
-
setSubscriptions(appId: string, version: string, subscriptions: Record<string, string>): void;
|
|
50
|
-
getSymbols(appId: string, targetEntityId: string): Symbols;
|
|
51
|
-
setSymbols(appId: string, targetEntityId: string, symbols: Symbols): void;
|
|
52
|
-
deleteSymbols(appId: string, targetEntityId: string): void;
|
|
53
|
-
getSymbolValues(appId: string): Symbols;
|
|
54
|
-
setSymbolValues(appId: string, symvals: Symbols): void;
|
|
55
|
-
deleteSymbolValues(appId: string): void;
|
|
56
|
-
getTransitions(appId: string, version: string): Transitions;
|
|
57
|
-
setTransitions(appId: string, version: string, transitions: Transitions): void;
|
|
58
|
-
getHookRules(appId: string): Record<string, HookRule[]>;
|
|
59
|
-
setHookRules(appId: string, hookRules: Record<string, HookRule[]>): void;
|
|
60
|
-
getSignals(appId: string, version: string): Record<string, unknown>;
|
|
61
|
-
setSignals(appId: string, version: string): Record<string, unknown>;
|
|
62
|
-
getActiveTaskQueue(appId: string): string;
|
|
63
|
-
setWorkItem(appId: string, workItem: string): void;
|
|
64
|
-
removeWorkItem(appId: string): void;
|
|
65
|
-
}
|
|
66
|
-
export { Cache };
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Cache is a key/value store and used to store commonly accessed Redis metadata
|
|
3
|
-
* (mainly the execution rules for the app) to save time accessing them as they
|
|
4
|
-
* are immutable per verison. The only time the rules are ejected are when
|
|
5
|
-
* a new version is deployed to the quorum and the cache is invalidated/cleared.
|
|
6
|
-
*/
|
|
7
|
-
class Cache {
|
|
8
|
-
/**
|
|
9
|
-
* The cache is ALWAYS initialized with HotMeshSettings. The other parameters are optional.
|
|
10
|
-
* @param settings
|
|
11
|
-
* @param apps
|
|
12
|
-
* @param schemas
|
|
13
|
-
* @param subscriptions
|
|
14
|
-
* @param transitions
|
|
15
|
-
* @param hookRules
|
|
16
|
-
*/
|
|
17
|
-
constructor(appId, settings, apps = {}, schemas = {}, subscriptions = {}, symbols = {}, symvals = {}, transitions = {}, hookRules = {}, workItems = {}) {
|
|
18
|
-
this.appId = appId;
|
|
19
|
-
this.settings = settings;
|
|
20
|
-
this.apps = apps;
|
|
21
|
-
this.schemas = schemas;
|
|
22
|
-
this.subscriptions = subscriptions;
|
|
23
|
-
this.symbols = symbols;
|
|
24
|
-
this.symvals = symvals;
|
|
25
|
-
this.transitions = transitions;
|
|
26
|
-
this.hookRules = hookRules;
|
|
27
|
-
this.workItems = workItems;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* invalidate the cache; settings are not invalidated!
|
|
31
|
-
*/
|
|
32
|
-
invalidate() {
|
|
33
|
-
this.apps = {};
|
|
34
|
-
this.schemas = {};
|
|
35
|
-
this.subscriptions = {};
|
|
36
|
-
this.transitions = {};
|
|
37
|
-
this.hookRules = {};
|
|
38
|
-
}
|
|
39
|
-
getSettings() {
|
|
40
|
-
return this.settings;
|
|
41
|
-
}
|
|
42
|
-
setSettings(settings) {
|
|
43
|
-
this.settings = settings;
|
|
44
|
-
}
|
|
45
|
-
getApps() {
|
|
46
|
-
return this.apps;
|
|
47
|
-
}
|
|
48
|
-
getApp(appId) {
|
|
49
|
-
return this.apps[appId];
|
|
50
|
-
}
|
|
51
|
-
setApps(apps) {
|
|
52
|
-
this.apps = apps;
|
|
53
|
-
}
|
|
54
|
-
setApp(appId, app) {
|
|
55
|
-
this.apps[appId] = app;
|
|
56
|
-
}
|
|
57
|
-
getSchemas(appId, version) {
|
|
58
|
-
return this.schemas[`${appId}/${version}`];
|
|
59
|
-
}
|
|
60
|
-
getSchema(appId, version, activityId) {
|
|
61
|
-
return this.schemas?.[`${appId}/${version}`]?.[activityId];
|
|
62
|
-
}
|
|
63
|
-
setSchemas(appId, version, schemas) {
|
|
64
|
-
this.schemas[`${appId}/${version}`] = schemas;
|
|
65
|
-
}
|
|
66
|
-
setSchema(appId, version, activityId, schema) {
|
|
67
|
-
this.schemas[`${appId}/${version}`][activityId] = schema;
|
|
68
|
-
}
|
|
69
|
-
getSubscriptions(appId, version) {
|
|
70
|
-
return this.subscriptions[`${appId}/${version}`];
|
|
71
|
-
}
|
|
72
|
-
getSubscription(appId, version, topic) {
|
|
73
|
-
return this.subscriptions?.[`${appId}/${version}`]?.[topic];
|
|
74
|
-
}
|
|
75
|
-
setSubscriptions(appId, version, subscriptions) {
|
|
76
|
-
this.subscriptions[`${appId}/${version}`] = subscriptions;
|
|
77
|
-
}
|
|
78
|
-
getSymbols(appId, targetEntityId) {
|
|
79
|
-
return this.symbols[`${appId}/${targetEntityId}`];
|
|
80
|
-
}
|
|
81
|
-
setSymbols(appId, targetEntityId, symbols) {
|
|
82
|
-
this.symbols[`${appId}/${targetEntityId}`] = symbols;
|
|
83
|
-
}
|
|
84
|
-
deleteSymbols(appId, targetEntityId) {
|
|
85
|
-
delete this.symbols[`${appId}/${targetEntityId}`];
|
|
86
|
-
}
|
|
87
|
-
getSymbolValues(appId) {
|
|
88
|
-
return this.symvals[`${appId}`];
|
|
89
|
-
}
|
|
90
|
-
setSymbolValues(appId, symvals) {
|
|
91
|
-
this.symvals[`${appId}`] = symvals;
|
|
92
|
-
}
|
|
93
|
-
deleteSymbolValues(appId) {
|
|
94
|
-
delete this.symvals[`${appId}`];
|
|
95
|
-
}
|
|
96
|
-
getTransitions(appId, version) {
|
|
97
|
-
return this.transitions[`${appId}/${version}`];
|
|
98
|
-
}
|
|
99
|
-
setTransitions(appId, version, transitions) {
|
|
100
|
-
this.transitions[`${appId}/${version}`] = transitions;
|
|
101
|
-
}
|
|
102
|
-
getHookRules(appId) {
|
|
103
|
-
return this.hookRules[`${appId}`];
|
|
104
|
-
}
|
|
105
|
-
setHookRules(appId, hookRules) {
|
|
106
|
-
this.hookRules[`${appId}`] = hookRules;
|
|
107
|
-
}
|
|
108
|
-
getSignals(appId, version) {
|
|
109
|
-
throw new Error("SIGNAL (getHooks) is not supported");
|
|
110
|
-
}
|
|
111
|
-
setSignals(appId, version) {
|
|
112
|
-
throw new Error("SIGNAL (setHook) is not supported");
|
|
113
|
-
}
|
|
114
|
-
getActiveTaskQueue(appId) {
|
|
115
|
-
return this.workItems[appId];
|
|
116
|
-
}
|
|
117
|
-
setWorkItem(appId, workItem) {
|
|
118
|
-
this.workItems[appId] = workItem;
|
|
119
|
-
}
|
|
120
|
-
removeWorkItem(appId) {
|
|
121
|
-
delete this.workItems[appId];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
export { Cache };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { KeyType } from '../../../modules/key';
|
|
2
|
-
import { ILogger } from '../../logger';
|
|
3
|
-
import { SerializerService as Serializer } from '../../serializer';
|
|
4
|
-
import { Cache } from '../cache';
|
|
5
|
-
import { StoreService } from '../index';
|
|
6
|
-
import { RedisClientType, RedisMultiType } from '../../../types/ioredisclient';
|
|
7
|
-
import { ReclaimedMessageType } from '../../../types/stream';
|
|
8
|
-
declare class IORedisStoreService extends StoreService<RedisClientType, RedisMultiType> {
|
|
9
|
-
redisClient: RedisClientType;
|
|
10
|
-
cache: Cache;
|
|
11
|
-
namespace: string;
|
|
12
|
-
appId: string;
|
|
13
|
-
logger: ILogger;
|
|
14
|
-
serializer: Serializer;
|
|
15
|
-
constructor(redisClient: RedisClientType);
|
|
16
|
-
getMulti(): RedisMultiType;
|
|
17
|
-
hGetAllResult(result: any): any;
|
|
18
|
-
addTaskQueues(keys: string[]): Promise<void>;
|
|
19
|
-
publish(keyType: KeyType.QUORUM, message: Record<string, any>, appId: string, engineId?: string): Promise<boolean>;
|
|
20
|
-
xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<boolean>;
|
|
21
|
-
xadd(key: string, id: string, messageId: string, messageValue: string, multi?: RedisMultiType): Promise<string | RedisMultiType>;
|
|
22
|
-
xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
|
|
23
|
-
xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): Promise<ReclaimedMessageType>;
|
|
24
|
-
xack(key: string, group: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
25
|
-
xdel(key: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
26
|
-
}
|
|
27
|
-
export { IORedisStoreService };
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { KeyType } from '../../../modules/key';
|
|
2
|
-
import { StoreService } from '../index';
|
|
3
|
-
class IORedisStoreService extends StoreService {
|
|
4
|
-
constructor(redisClient) {
|
|
5
|
-
super(redisClient);
|
|
6
|
-
}
|
|
7
|
-
getMulti() {
|
|
8
|
-
return this.redisClient.multi();
|
|
9
|
-
}
|
|
10
|
-
hGetAllResult(result) {
|
|
11
|
-
//ioredis response signature is [null, {}] or [null, null]
|
|
12
|
-
return result[1];
|
|
13
|
-
}
|
|
14
|
-
async addTaskQueues(keys) {
|
|
15
|
-
const multi = this.redisClient.multi();
|
|
16
|
-
const zsetKey = this.mintKey(KeyType.WORK_ITEMS, { appId: this.appId });
|
|
17
|
-
for (const key of keys) {
|
|
18
|
-
multi.zadd(zsetKey, 'NX', Date.now(), key);
|
|
19
|
-
}
|
|
20
|
-
await multi.exec();
|
|
21
|
-
}
|
|
22
|
-
async publish(keyType, message, appId, engineId) {
|
|
23
|
-
const topic = this.mintKey(keyType, { appId, engineId });
|
|
24
|
-
const status = await this.redisClient.publish(topic, JSON.stringify(message));
|
|
25
|
-
return status === 1;
|
|
26
|
-
}
|
|
27
|
-
async xgroup(command, key, groupName, id, mkStream) {
|
|
28
|
-
if (mkStream === 'MKSTREAM') {
|
|
29
|
-
try {
|
|
30
|
-
return (await this.redisClient.xgroup(command, key, groupName, id, mkStream)) === 'OK';
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
this.logger.info(`Consumer group not created with MKSTREAM for key: ${key} and group: ${groupName}`);
|
|
34
|
-
throw err;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
try {
|
|
39
|
-
return (await this.redisClient.xgroup(command, key, groupName, id)) === 'OK';
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
this.logger.info(`Consumer group not created for key: ${key} and group: ${groupName}`);
|
|
43
|
-
throw err;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async xadd(key, id, messageId, messageValue, multi) {
|
|
48
|
-
try {
|
|
49
|
-
return await (multi || this.redisClient).xadd(key, id, messageId, messageValue);
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
this.logger.error(`Error publishing 'xadd'; key: ${key}`, err);
|
|
53
|
-
throw err;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async xpending(key, group, start, end, count, consumer) {
|
|
57
|
-
try {
|
|
58
|
-
return await this.redisClient.xpending(key, group, start, end, count, consumer);
|
|
59
|
-
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
this.logger.error(`Error in retrieving pending messages for [stream ${key}], [group ${group}]`, err);
|
|
62
|
-
throw err;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async xclaim(key, group, consumer, minIdleTime, id, ...args) {
|
|
66
|
-
try {
|
|
67
|
-
return await this.redisClient.xclaim(key, group, consumer, minIdleTime, id, ...args);
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
this.logger.error(`Error in claiming message with id: ${id} in group: ${group} for key: ${key}`, err);
|
|
71
|
-
throw err;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async xack(key, group, id, multi) {
|
|
75
|
-
try {
|
|
76
|
-
return await (multi || this.redisClient).xack(key, group, id);
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
this.logger.error(`Error in acknowledging messages in group: ${group} for key: ${key}`, err);
|
|
80
|
-
throw err;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async xdel(key, id, multi) {
|
|
84
|
-
try {
|
|
85
|
-
return await (multi || this.redisClient).xdel(key, id);
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
this.logger.error(`Error in deleting messages with id: ${id} for key: ${key}`, err);
|
|
89
|
-
throw err;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
export { IORedisStoreService };
|