@hotmeshio/hotmesh 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -7
- package/README.md +37 -46
- package/build/{esm/package.json → package.json} +6 -11
- package/build/{cjs/services → services}/activities/activity.d.ts +6 -0
- package/build/{cjs/services → services}/activities/activity.js +83 -7
- package/build/{cjs/services → services}/activities/await.d.ts +2 -2
- package/build/{cjs/services → services}/activities/await.js +5 -5
- package/build/services/activities/cycle.d.ts +19 -0
- package/build/services/activities/cycle.js +77 -0
- package/build/{esm/services → services}/activities/index.d.ts +4 -2
- package/build/{cjs/services → services}/activities/index.js +4 -2
- package/build/{cjs/services → services}/activities/worker.d.ts +0 -8
- package/build/services/activities/worker.js +73 -0
- package/build/{esm/services → services}/collator/index.d.ts +18 -1
- package/build/{cjs/services → services}/collator/index.js +41 -11
- package/build/{cjs/services → services}/durable/factory.js +17 -1
- package/build/{cjs/services → services}/durable/native.js +2 -2
- package/build/{cjs/services → services}/durable/worker.d.ts +2 -3
- package/build/{esm/services → services}/durable/worker.js +35 -37
- package/build/{cjs/services → services}/durable/workflow.js +11 -2
- package/build/{cjs/services → services}/mapper/index.js +3 -0
- package/build/{cjs/services → services}/signaler/stream.js +0 -1
- package/build/{esm/types → types}/activity.d.ts +7 -2
- package/build/{cjs/types → types}/durable.d.ts +4 -6
- package/build/{cjs/types → types}/index.d.ts +1 -1
- package/package.json +6 -11
- package/services/activities/activity.ts +90 -7
- package/services/activities/await.ts +5 -5
- package/services/activities/cycle.ts +96 -0
- package/services/activities/index.ts +4 -2
- package/services/activities/worker.ts +2 -93
- package/services/collator/index.ts +43 -11
- package/services/durable/factory.ts +17 -1
- package/services/durable/native.ts +2 -2
- package/services/durable/worker.ts +19 -22
- package/services/durable/workflow.ts +11 -2
- package/services/mapper/index.ts +3 -0
- package/services/signaler/stream.ts +0 -1
- package/types/activity.ts +8 -1
- package/types/durable.ts +4 -4
- package/types/index.ts +1 -0
- package/build/cjs/package.json +0 -80
- package/build/cjs/services/activities/index.d.ts +0 -15
- package/build/cjs/services/activities/worker.js +0 -159
- package/build/cjs/services/collator/index.d.ts +0 -56
- package/build/cjs/services/durable/worker.js +0 -298
- package/build/cjs/types/activity.d.ts +0 -87
- package/build/esm/index.d.ts +0 -4
- package/build/esm/index.js +0 -3
- package/build/esm/modules/errors.d.ts +0 -28
- package/build/esm/modules/errors.js +0 -41
- package/build/esm/modules/key.d.ts +0 -75
- package/build/esm/modules/key.js +0 -111
- package/build/esm/modules/utils.d.ts +0 -34
- package/build/esm/modules/utils.js +0 -154
- package/build/esm/services/activities/activity.d.ts +0 -61
- package/build/esm/services/activities/activity.js +0 -410
- package/build/esm/services/activities/await.d.ts +0 -16
- package/build/esm/services/activities/await.js +0 -140
- package/build/esm/services/activities/emit.d.ts +0 -9
- package/build/esm/services/activities/emit.js +0 -10
- package/build/esm/services/activities/index.js +0 -14
- package/build/esm/services/activities/iterate.d.ts +0 -9
- package/build/esm/services/activities/iterate.js +0 -10
- package/build/esm/services/activities/trigger.d.ts +0 -22
- package/build/esm/services/activities/trigger.js +0 -158
- package/build/esm/services/activities/worker.d.ts +0 -19
- package/build/esm/services/activities/worker.js +0 -156
- package/build/esm/services/collator/index.js +0 -191
- package/build/esm/services/compiler/deployer.d.ts +0 -36
- package/build/esm/services/compiler/deployer.js +0 -423
- package/build/esm/services/compiler/index.d.ts +0 -30
- package/build/esm/services/compiler/index.js +0 -82
- package/build/esm/services/compiler/validator.d.ts +0 -32
- package/build/esm/services/compiler/validator.js +0 -131
- package/build/esm/services/connector/clients/ioredis.d.ts +0 -13
- package/build/esm/services/connector/clients/ioredis.js +0 -47
- package/build/esm/services/connector/clients/redis.d.ts +0 -13
- package/build/esm/services/connector/clients/redis.js +0 -59
- package/build/esm/services/connector/index.d.ts +0 -5
- package/build/esm/services/connector/index.js +0 -27
- package/build/esm/services/dimension/index.d.ts +0 -29
- package/build/esm/services/dimension/index.js +0 -32
- package/build/esm/services/durable/asyncLocalStorage.d.ts +0 -3
- package/build/esm/services/durable/asyncLocalStorage.js +0 -2
- package/build/esm/services/durable/client.d.ts +0 -15
- package/build/esm/services/durable/client.js +0 -114
- package/build/esm/services/durable/connection.d.ts +0 -4
- package/build/esm/services/durable/connection.js +0 -47
- package/build/esm/services/durable/factory.d.ts +0 -3
- package/build/esm/services/durable/factory.js +0 -119
- package/build/esm/services/durable/handle.d.ts +0 -8
- package/build/esm/services/durable/handle.js +0 -34
- package/build/esm/services/durable/index.d.ts +0 -57
- package/build/esm/services/durable/index.js +0 -55
- package/build/esm/services/durable/native.d.ts +0 -4
- package/build/esm/services/durable/native.js +0 -43
- package/build/esm/services/durable/worker.d.ts +0 -37
- package/build/esm/services/durable/workflow.d.ts +0 -6
- package/build/esm/services/durable/workflow.js +0 -128
- package/build/esm/services/engine/index.d.ts +0 -82
- package/build/esm/services/engine/index.js +0 -522
- package/build/esm/services/hotmesh/index.d.ts +0 -45
- package/build/esm/services/hotmesh/index.js +0 -131
- package/build/esm/services/logger/index.d.ts +0 -17
- package/build/esm/services/logger/index.js +0 -70
- package/build/esm/services/mapper/index.d.ts +0 -24
- package/build/esm/services/mapper/index.js +0 -69
- package/build/esm/services/pipe/functions/array.d.ts +0 -24
- package/build/esm/services/pipe/functions/array.js +0 -66
- package/build/esm/services/pipe/functions/bitwise.d.ts +0 -9
- package/build/esm/services/pipe/functions/bitwise.js +0 -21
- package/build/esm/services/pipe/functions/conditional.d.ts +0 -10
- package/build/esm/services/pipe/functions/conditional.js +0 -24
- package/build/esm/services/pipe/functions/date.d.ts +0 -57
- package/build/esm/services/pipe/functions/date.js +0 -164
- package/build/esm/services/pipe/functions/index.d.ts +0 -25
- package/build/esm/services/pipe/functions/index.js +0 -24
- package/build/esm/services/pipe/functions/json.d.ts +0 -5
- package/build/esm/services/pipe/functions/json.js +0 -9
- package/build/esm/services/pipe/functions/math.d.ts +0 -38
- package/build/esm/services/pipe/functions/math.js +0 -108
- package/build/esm/services/pipe/functions/number.d.ts +0 -25
- package/build/esm/services/pipe/functions/number.js +0 -130
- package/build/esm/services/pipe/functions/object.d.ts +0 -22
- package/build/esm/services/pipe/functions/object.js +0 -60
- package/build/esm/services/pipe/functions/string.d.ts +0 -23
- package/build/esm/services/pipe/functions/string.js +0 -66
- package/build/esm/services/pipe/functions/symbol.d.ts +0 -12
- package/build/esm/services/pipe/functions/symbol.js +0 -30
- package/build/esm/services/pipe/functions/unary.d.ts +0 -7
- package/build/esm/services/pipe/functions/unary.js +0 -15
- package/build/esm/services/pipe/index.d.ts +0 -30
- package/build/esm/services/pipe/index.js +0 -122
- package/build/esm/services/quorum/index.d.ts +0 -34
- package/build/esm/services/quorum/index.js +0 -144
- package/build/esm/services/reporter/index.d.ts +0 -47
- package/build/esm/services/reporter/index.js +0 -327
- package/build/esm/services/serializer/index.d.ts +0 -41
- package/build/esm/services/serializer/index.js +0 -251
- package/build/esm/services/signaler/store.d.ts +0 -15
- package/build/esm/services/signaler/store.js +0 -50
- package/build/esm/services/signaler/stream.d.ts +0 -43
- package/build/esm/services/signaler/stream.js +0 -315
- package/build/esm/services/store/cache.d.ts +0 -66
- package/build/esm/services/store/cache.js +0 -124
- package/build/esm/services/store/clients/ioredis.d.ts +0 -27
- package/build/esm/services/store/clients/ioredis.js +0 -93
- package/build/esm/services/store/clients/redis.d.ts +0 -29
- package/build/esm/services/store/clients/redis.js +0 -140
- package/build/esm/services/store/index.d.ts +0 -88
- package/build/esm/services/store/index.js +0 -623
- package/build/esm/services/stream/clients/ioredis.d.ts +0 -23
- package/build/esm/services/stream/clients/ioredis.js +0 -112
- package/build/esm/services/stream/clients/redis.d.ts +0 -23
- package/build/esm/services/stream/clients/redis.js +0 -116
- package/build/esm/services/stream/index.d.ts +0 -21
- package/build/esm/services/stream/index.js +0 -6
- package/build/esm/services/sub/clients/ioredis.d.ts +0 -20
- package/build/esm/services/sub/clients/ioredis.js +0 -69
- package/build/esm/services/sub/clients/redis.d.ts +0 -20
- package/build/esm/services/sub/clients/redis.js +0 -60
- package/build/esm/services/sub/index.d.ts +0 -18
- package/build/esm/services/sub/index.js +0 -6
- package/build/esm/services/task/index.d.ts +0 -18
- package/build/esm/services/task/index.js +0 -70
- package/build/esm/services/telemetry/index.d.ts +0 -49
- package/build/esm/services/telemetry/index.js +0 -217
- package/build/esm/services/worker/index.d.ts +0 -30
- package/build/esm/services/worker/index.js +0 -102
- package/build/esm/types/activity.js +0 -1
- package/build/esm/types/app.d.ts +0 -16
- package/build/esm/types/app.js +0 -1
- package/build/esm/types/async.d.ts +0 -5
- package/build/esm/types/async.js +0 -1
- package/build/esm/types/cache.d.ts +0 -1
- package/build/esm/types/cache.js +0 -1
- package/build/esm/types/collator.d.ts +0 -8
- package/build/esm/types/collator.js +0 -8
- package/build/esm/types/durable.d.ts +0 -59
- package/build/esm/types/durable.js +0 -1
- package/build/esm/types/hook.d.ts +0 -31
- package/build/esm/types/hook.js +0 -6
- package/build/esm/types/hotmesh.d.ts +0 -82
- package/build/esm/types/hotmesh.js +0 -1
- package/build/esm/types/index.d.ts +0 -20
- package/build/esm/types/index.js +0 -5
- package/build/esm/types/ioredisclient.d.ts +0 -5
- package/build/esm/types/ioredisclient.js +0 -2
- package/build/esm/types/job.d.ts +0 -50
- package/build/esm/types/job.js +0 -1
- package/build/esm/types/logger.d.ts +0 -6
- package/build/esm/types/logger.js +0 -1
- package/build/esm/types/map.d.ts +0 -4
- package/build/esm/types/map.js +0 -1
- package/build/esm/types/pipe.d.ts +0 -4
- package/build/esm/types/pipe.js +0 -1
- package/build/esm/types/quorum.d.ts +0 -46
- package/build/esm/types/quorum.js +0 -1
- package/build/esm/types/redis.d.ts +0 -8
- package/build/esm/types/redis.js +0 -1
- package/build/esm/types/redisclient.d.ts +0 -25
- package/build/esm/types/redisclient.js +0 -1
- package/build/esm/types/serializer.d.ts +0 -33
- package/build/esm/types/serializer.js +0 -1
- package/build/esm/types/stats.d.ts +0 -83
- package/build/esm/types/stats.js +0 -1
- package/build/esm/types/stream.d.ts +0 -67
- package/build/esm/types/stream.js +0 -22
- package/build/esm/types/telemetry.d.ts +0 -1
- package/build/esm/types/telemetry.js +0 -1
- package/build/esm/types/transition.d.ts +0 -17
- package/build/esm/types/transition.js +0 -1
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.esm.json +0 -9
- /package/build/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/build/{cjs/index.js → index.js} +0 -0
- /package/build/{cjs/modules → modules}/errors.d.ts +0 -0
- /package/build/{cjs/modules → modules}/errors.js +0 -0
- /package/build/{cjs/modules → modules}/key.d.ts +0 -0
- /package/build/{cjs/modules → modules}/key.js +0 -0
- /package/build/{cjs/modules → modules}/utils.d.ts +0 -0
- /package/build/{cjs/modules → modules}/utils.js +0 -0
- /package/build/{cjs/services → services}/activities/emit.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/emit.js +0 -0
- /package/build/{cjs/services → services}/activities/iterate.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/iterate.js +0 -0
- /package/build/{cjs/services → services}/activities/trigger.d.ts +0 -0
- /package/build/{cjs/services → services}/activities/trigger.js +0 -0
- /package/build/{cjs/services → services}/compiler/deployer.d.ts +0 -0
- /package/build/{cjs/services → services}/compiler/deployer.js +0 -0
- /package/build/{cjs/services → services}/compiler/index.d.ts +0 -0
- /package/build/{cjs/services → services}/compiler/index.js +0 -0
- /package/build/{cjs/services → services}/compiler/validator.d.ts +0 -0
- /package/build/{cjs/services → services}/compiler/validator.js +0 -0
- /package/build/{cjs/services → services}/connector/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/connector/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/connector/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/connector/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/connector/index.d.ts +0 -0
- /package/build/{cjs/services → services}/connector/index.js +0 -0
- /package/build/{cjs/services → services}/dimension/index.d.ts +0 -0
- /package/build/{cjs/services → services}/dimension/index.js +0 -0
- /package/build/{cjs/services → services}/durable/asyncLocalStorage.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/asyncLocalStorage.js +0 -0
- /package/build/{cjs/services → services}/durable/client.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/client.js +0 -0
- /package/build/{cjs/services → services}/durable/connection.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/connection.js +0 -0
- /package/build/{cjs/services → services}/durable/factory.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/handle.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/handle.js +0 -0
- /package/build/{cjs/services → services}/durable/index.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/index.js +0 -0
- /package/build/{cjs/services → services}/durable/native.d.ts +0 -0
- /package/build/{cjs/services → services}/durable/workflow.d.ts +0 -0
- /package/build/{cjs/services → services}/engine/index.d.ts +0 -0
- /package/build/{cjs/services → services}/engine/index.js +0 -0
- /package/build/{cjs/services → services}/hotmesh/index.d.ts +0 -0
- /package/build/{cjs/services → services}/hotmesh/index.js +0 -0
- /package/build/{cjs/services → services}/logger/index.d.ts +0 -0
- /package/build/{cjs/services → services}/logger/index.js +0 -0
- /package/build/{cjs/services → services}/mapper/index.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/array.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/array.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/bitwise.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/bitwise.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/conditional.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/conditional.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/date.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/date.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/index.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/index.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/json.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/json.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/math.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/math.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/number.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/number.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/object.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/object.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/string.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/string.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/symbol.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/symbol.js +0 -0
- /package/build/{cjs/services → services}/pipe/functions/unary.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/functions/unary.js +0 -0
- /package/build/{cjs/services → services}/pipe/index.d.ts +0 -0
- /package/build/{cjs/services → services}/pipe/index.js +0 -0
- /package/build/{cjs/services → services}/quorum/index.d.ts +0 -0
- /package/build/{cjs/services → services}/quorum/index.js +0 -0
- /package/build/{cjs/services → services}/reporter/index.d.ts +0 -0
- /package/build/{cjs/services → services}/reporter/index.js +0 -0
- /package/build/{cjs/services → services}/serializer/index.d.ts +0 -0
- /package/build/{cjs/services → services}/serializer/index.js +0 -0
- /package/build/{cjs/services → services}/signaler/store.d.ts +0 -0
- /package/build/{cjs/services → services}/signaler/store.js +0 -0
- /package/build/{cjs/services → services}/signaler/stream.d.ts +0 -0
- /package/build/{cjs/services → services}/store/cache.d.ts +0 -0
- /package/build/{cjs/services → services}/store/cache.js +0 -0
- /package/build/{cjs/services → services}/store/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/store/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/store/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/store/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/store/index.d.ts +0 -0
- /package/build/{cjs/services → services}/store/index.js +0 -0
- /package/build/{cjs/services → services}/stream/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/stream/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/stream/index.d.ts +0 -0
- /package/build/{cjs/services → services}/stream/index.js +0 -0
- /package/build/{cjs/services → services}/sub/clients/ioredis.d.ts +0 -0
- /package/build/{cjs/services → services}/sub/clients/ioredis.js +0 -0
- /package/build/{cjs/services → services}/sub/clients/redis.d.ts +0 -0
- /package/build/{cjs/services → services}/sub/clients/redis.js +0 -0
- /package/build/{cjs/services → services}/sub/index.d.ts +0 -0
- /package/build/{cjs/services → services}/sub/index.js +0 -0
- /package/build/{cjs/services → services}/task/index.d.ts +0 -0
- /package/build/{cjs/services → services}/task/index.js +0 -0
- /package/build/{cjs/services → services}/telemetry/index.d.ts +0 -0
- /package/build/{cjs/services → services}/telemetry/index.js +0 -0
- /package/build/{cjs/services → services}/worker/index.d.ts +0 -0
- /package/build/{cjs/services → services}/worker/index.js +0 -0
- /package/build/{cjs/types → types}/activity.js +0 -0
- /package/build/{cjs/types → types}/app.d.ts +0 -0
- /package/build/{cjs/types → types}/app.js +0 -0
- /package/build/{cjs/types → types}/async.d.ts +0 -0
- /package/build/{cjs/types → types}/async.js +0 -0
- /package/build/{cjs/types → types}/cache.d.ts +0 -0
- /package/build/{cjs/types → types}/cache.js +0 -0
- /package/build/{cjs/types → types}/collator.d.ts +0 -0
- /package/build/{cjs/types → types}/collator.js +0 -0
- /package/build/{cjs/types → types}/durable.js +0 -0
- /package/build/{cjs/types → types}/hook.d.ts +0 -0
- /package/build/{cjs/types → types}/hook.js +0 -0
- /package/build/{cjs/types → types}/hotmesh.d.ts +0 -0
- /package/build/{cjs/types → types}/hotmesh.js +0 -0
- /package/build/{cjs/types → types}/index.js +0 -0
- /package/build/{cjs/types → types}/ioredisclient.d.ts +0 -0
- /package/build/{cjs/types → types}/ioredisclient.js +0 -0
- /package/build/{cjs/types → types}/job.d.ts +0 -0
- /package/build/{cjs/types → types}/job.js +0 -0
- /package/build/{cjs/types → types}/logger.d.ts +0 -0
- /package/build/{cjs/types → types}/logger.js +0 -0
- /package/build/{cjs/types → types}/map.d.ts +0 -0
- /package/build/{cjs/types → types}/map.js +0 -0
- /package/build/{cjs/types → types}/pipe.d.ts +0 -0
- /package/build/{cjs/types → types}/pipe.js +0 -0
- /package/build/{cjs/types → types}/quorum.d.ts +0 -0
- /package/build/{cjs/types → types}/quorum.js +0 -0
- /package/build/{cjs/types → types}/redis.d.ts +0 -0
- /package/build/{cjs/types → types}/redis.js +0 -0
- /package/build/{cjs/types → types}/redisclient.d.ts +0 -0
- /package/build/{cjs/types → types}/redisclient.js +0 -0
- /package/build/{cjs/types → types}/serializer.d.ts +0 -0
- /package/build/{cjs/types → types}/serializer.js +0 -0
- /package/build/{cjs/types → types}/stats.d.ts +0 -0
- /package/build/{cjs/types → types}/stats.js +0 -0
- /package/build/{cjs/types → types}/stream.d.ts +0 -0
- /package/build/{cjs/types → types}/stream.js +0 -0
- /package/build/{cjs/types → types}/telemetry.d.ts +0 -0
- /package/build/{cjs/types → types}/telemetry.js +0 -0
- /package/build/{cjs/types → types}/transition.d.ts +0 -0
- /package/build/{cjs/types → types}/transition.js +0 -0
package/build/cjs/package.json
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hotmeshio/hotmesh",
|
|
3
|
-
"version": "0.0.7",
|
|
4
|
-
"description": "Durable Workflows",
|
|
5
|
-
"main": "build/cjs/index.js",
|
|
6
|
-
"module": "build/esm/index.js",
|
|
7
|
-
"types": "build/cjs/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
"import": "./build/esm/index.js",
|
|
10
|
-
"require": "./build/cjs/index.js"
|
|
11
|
-
},
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/hotmeshio/sdk-typescript.git"
|
|
15
|
-
},
|
|
16
|
-
"homepage": "https://github.com/hotmeshio/sdk-typescript#readme",
|
|
17
|
-
"publishConfig": {
|
|
18
|
-
"access": "public"
|
|
19
|
-
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"clean": "rimraf ./build",
|
|
22
|
-
"build:cjs": "tsc --build tsconfig.cjs.json",
|
|
23
|
-
"build:esm": "tsc --build tsconfig.esm.json",
|
|
24
|
-
"build": "npm run build:cjs && npm run build:esm",
|
|
25
|
-
"clean-build": "npm run clean && npm run build",
|
|
26
|
-
"lint": "eslint . --ext .ts",
|
|
27
|
-
"lint:fix": "eslint . --fix --ext .ts",
|
|
28
|
-
"start": "ts-node src/index.ts",
|
|
29
|
-
"test": "NODE_ENV=test jest --detectOpenHandles --forceExit --verbose",
|
|
30
|
-
"test:hmsh": "NODE_ENV=test jest ./tests/functional/index.test.ts --detectOpenHandles --verbose",
|
|
31
|
-
"test:compile": "NODE_ENV=test jest ./tests/functional/compile/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
32
|
-
"test:connect": "NODE_ENV=test jest ./tests/unit/services/connector/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
33
|
-
"test:connect:redis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
34
|
-
"test:connect:ioredis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
35
|
-
"test:parallel": "NODE_ENV=test jest ./tests/functional/parallel/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
36
|
-
"test:sequence": "NODE_ENV=test jest ./tests/functional/sequence/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
37
|
-
"test:quorum": "NODE_ENV=test jest ./tests/functional/quorum/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
38
|
-
"test:reclaim": "NODE_ENV=test jest ./tests/functional/reclaim/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
39
|
-
"test:redeploy": "NODE_ENV=test jest ./tests/functional/redeploy/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
40
|
-
"test:retry": "NODE_ENV=test jest ./tests/functional/retry/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
41
|
-
"test:status": "NODE_ENV=test jest ./tests/functional/status/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
42
|
-
"test:store:redis": "NODE_ENV=test jest ./tests/functional/store/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
43
|
-
"test:store:ioredis": "NODE_ENV=test jest ./tests/functional/store/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
44
|
-
"test:stream:redis": "NODE_ENV=test jest ./tests/functional/stream/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
45
|
-
"test:stream:ioredis": "NODE_ENV=test jest ./tests/functional/stream/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
46
|
-
"test:sub:redis": "NODE_ENV=test jest ./tests/functional/sub/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
47
|
-
"test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
48
|
-
"test:durable": "NODE_ENV=test jest ./tests/durable/*/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
49
|
-
"test:durable:hello": "NODE_ENV=test jest ./tests/durable/helloworld/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
50
|
-
"test:durable:goodbye": "NODE_ENV=test jest ./tests/durable/goodbye/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
51
|
-
"test:durable:loopactivity": "NODE_ENV=test jest ./tests/durable/loopactivity/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
52
|
-
"test:durable:nested": "NODE_ENV=test jest ./tests/durable/nested/index.test.ts --detectOpenHandles --forceExit --verbose"
|
|
53
|
-
},
|
|
54
|
-
"keywords": [],
|
|
55
|
-
"author": "luke.birdeau@gmail.com",
|
|
56
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
57
|
-
"dependencies": {
|
|
58
|
-
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
59
|
-
"@opentelemetry/api": "^1.4.1",
|
|
60
|
-
"js-yaml": "^4.1.0",
|
|
61
|
-
"ms": "^2.1.3",
|
|
62
|
-
"uuid": "^9.0.1",
|
|
63
|
-
"winston": "^3.8.2"
|
|
64
|
-
},
|
|
65
|
-
"devDependencies": {
|
|
66
|
-
"@types/jest": "^29.5.0",
|
|
67
|
-
"@types/node": "^18.15.11",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
69
|
-
"@typescript-eslint/parser": "^5.56.0",
|
|
70
|
-
"eslint": "^8.36.0",
|
|
71
|
-
"ioredis": "^5.3.2",
|
|
72
|
-
"jest": "^29.5.0",
|
|
73
|
-
"redis": "^4.6.6",
|
|
74
|
-
"rimraf": "^4.4.1",
|
|
75
|
-
"ts-jest": "^29.0.5",
|
|
76
|
-
"ts-node": "^10.9.1",
|
|
77
|
-
"ts-node-dev": "^2.0.0",
|
|
78
|
-
"typescript": "^5.0.4"
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Activity } from './activity';
|
|
2
|
-
import { Await } from './await';
|
|
3
|
-
import { Worker } from './worker';
|
|
4
|
-
import { Iterate } from './iterate';
|
|
5
|
-
import { Emit } from './emit';
|
|
6
|
-
import { Trigger } from './trigger';
|
|
7
|
-
declare const _default: {
|
|
8
|
-
activity: typeof Activity;
|
|
9
|
-
await: typeof Await;
|
|
10
|
-
iterate: typeof Iterate;
|
|
11
|
-
emit: typeof Emit;
|
|
12
|
-
trigger: typeof Trigger;
|
|
13
|
-
worker: typeof Worker;
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Worker = void 0;
|
|
4
|
-
const errors_1 = require("../../modules/errors");
|
|
5
|
-
const activity_1 = require("./activity");
|
|
6
|
-
const collator_1 = require("../collator");
|
|
7
|
-
const stream_1 = require("../../types/stream");
|
|
8
|
-
const telemetry_1 = require("../telemetry");
|
|
9
|
-
class Worker extends activity_1.Activity {
|
|
10
|
-
constructor(config, data, metadata, hook, engine, context) {
|
|
11
|
-
super(config, data, metadata, hook, engine, context);
|
|
12
|
-
}
|
|
13
|
-
//******** INITIAL ENTRY POINT (A) ********//
|
|
14
|
-
async process() {
|
|
15
|
-
this.logger.debug('worker-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
16
|
-
let telemetry;
|
|
17
|
-
try {
|
|
18
|
-
this.setLeg(1);
|
|
19
|
-
await collator_1.CollatorService.notarizeEntry(this);
|
|
20
|
-
await this.getState();
|
|
21
|
-
telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
22
|
-
telemetry.startActivitySpan(this.leg);
|
|
23
|
-
this.mapInputData();
|
|
24
|
-
const multi = this.store.getMulti();
|
|
25
|
-
//await this.registerTimeout();
|
|
26
|
-
await collator_1.CollatorService.authorizeReentry(this, multi);
|
|
27
|
-
await this.setState(multi);
|
|
28
|
-
await this.setStatus(0, multi);
|
|
29
|
-
const multiResponse = await multi.exec();
|
|
30
|
-
telemetry.mapActivityAttributes();
|
|
31
|
-
const jobStatus = this.resolveStatus(multiResponse);
|
|
32
|
-
const messageId = await this.execActivity();
|
|
33
|
-
telemetry.setActivityAttributes({
|
|
34
|
-
'app.activity.mid': messageId,
|
|
35
|
-
'app.job.jss': jobStatus
|
|
36
|
-
});
|
|
37
|
-
//TODO: UPDATE ACTIVITY STATE (LEG 1 EXIT)
|
|
38
|
-
return this.context.metadata.aid;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
if (error instanceof errors_1.GetStateError) {
|
|
42
|
-
this.logger.error('worker-get-state-error', error);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
console.error(error);
|
|
46
|
-
this.logger.error('worker-process-error', error);
|
|
47
|
-
}
|
|
48
|
-
telemetry.setActivityError(error.message);
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
telemetry.endActivitySpan();
|
|
53
|
-
this.logger.debug('worker-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async execActivity() {
|
|
57
|
-
const streamData = {
|
|
58
|
-
metadata: {
|
|
59
|
-
jid: this.context.metadata.jid,
|
|
60
|
-
dad: this.metadata.dad,
|
|
61
|
-
aid: this.metadata.aid,
|
|
62
|
-
topic: this.config.subtype,
|
|
63
|
-
spn: this.context['$self'].output.metadata.l1s,
|
|
64
|
-
trc: this.context.metadata.trc,
|
|
65
|
-
},
|
|
66
|
-
data: this.context.data
|
|
67
|
-
};
|
|
68
|
-
if (this.config.retry) {
|
|
69
|
-
streamData.policies = {
|
|
70
|
-
retry: this.config.retry
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return (await this.engine.streamSignaler?.publishMessage(this.config.subtype, streamData));
|
|
74
|
-
}
|
|
75
|
-
//******** SIGNAL RE-ENTRY POINT (DUPLEX LEG 2 of 2) ********//
|
|
76
|
-
async processEvent(status = stream_1.StreamStatus.SUCCESS, code = 200) {
|
|
77
|
-
this.setLeg(2);
|
|
78
|
-
const jid = this.context.metadata.jid;
|
|
79
|
-
const aid = this.metadata.aid;
|
|
80
|
-
this.status = status;
|
|
81
|
-
this.code = code;
|
|
82
|
-
this.logger.debug('worker-process-event', { topic: this.config.subtype, jid, aid, status, code });
|
|
83
|
-
let telemetry;
|
|
84
|
-
try {
|
|
85
|
-
await this.getState();
|
|
86
|
-
const aState = await collator_1.CollatorService.notarizeReentry(this);
|
|
87
|
-
this.adjacentIndex = collator_1.CollatorService.getDimensionalIndex(aState);
|
|
88
|
-
telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
89
|
-
let isComplete = collator_1.CollatorService.isActivityComplete(this.context.metadata.js);
|
|
90
|
-
if (isComplete) {
|
|
91
|
-
this.logger.warn('worker-process-event-duplicate', { jid, aid });
|
|
92
|
-
this.logger.debug('worker-process-event-duplicate-resolution', { resolution: 'Increase HotMesh config `reclaimDelay` timeout.' });
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
telemetry.startActivitySpan(this.leg);
|
|
96
|
-
if (status === stream_1.StreamStatus.PENDING) {
|
|
97
|
-
await this.processPending(telemetry);
|
|
98
|
-
}
|
|
99
|
-
else if (status === stream_1.StreamStatus.SUCCESS) {
|
|
100
|
-
await this.processSuccess(telemetry);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
await this.processError(telemetry);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
this.logger.error('worker-process-event-error', error);
|
|
108
|
-
telemetry.setActivityError(error.message);
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
finally {
|
|
112
|
-
telemetry.endActivitySpan();
|
|
113
|
-
this.logger.debug('worker-process-event-end', { jid, aid });
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async processPending(telemetry) {
|
|
117
|
-
this.bindActivityData('output');
|
|
118
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
119
|
-
this.mapJobData();
|
|
120
|
-
const multi = this.store.getMulti();
|
|
121
|
-
await this.setState(multi);
|
|
122
|
-
await collator_1.CollatorService.notarizeContinuation(this, multi);
|
|
123
|
-
await this.setStatus(this.adjacencyList.length, multi);
|
|
124
|
-
const multiResponse = await multi.exec();
|
|
125
|
-
this.transitionAdjacent(multiResponse, telemetry);
|
|
126
|
-
}
|
|
127
|
-
async processSuccess(telemetry) {
|
|
128
|
-
this.bindActivityData('output');
|
|
129
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
130
|
-
this.mapJobData();
|
|
131
|
-
const multi = this.store.getMulti();
|
|
132
|
-
await this.setState(multi);
|
|
133
|
-
await collator_1.CollatorService.notarizeCompletion(this, multi);
|
|
134
|
-
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
135
|
-
const multiResponse = await multi.exec();
|
|
136
|
-
this.transitionAdjacent(multiResponse, telemetry);
|
|
137
|
-
}
|
|
138
|
-
async processError(telemetry) {
|
|
139
|
-
this.bindActivityError(this.data);
|
|
140
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
141
|
-
const multi = this.store.getMulti();
|
|
142
|
-
await this.setState(multi);
|
|
143
|
-
await collator_1.CollatorService.notarizeCompletion(this, multi);
|
|
144
|
-
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
145
|
-
const multiResponse = await multi.exec();
|
|
146
|
-
this.transitionAdjacent(multiResponse, telemetry);
|
|
147
|
-
}
|
|
148
|
-
async transitionAdjacent(multiResponse, telemetry) {
|
|
149
|
-
telemetry.mapActivityAttributes();
|
|
150
|
-
const jobStatus = this.resolveStatus(multiResponse);
|
|
151
|
-
const attrs = { 'app.job.jss': jobStatus };
|
|
152
|
-
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
153
|
-
if (messageIds.length) {
|
|
154
|
-
attrs['app.activity.mids'] = messageIds.join(',');
|
|
155
|
-
}
|
|
156
|
-
telemetry.setActivityAttributes(attrs);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
exports.Worker = Worker;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { RedisMulti } from '../../types/redis';
|
|
2
|
-
import { CollationStage } from '../../types/collator';
|
|
3
|
-
import { ActivityDuplex } from '../../types/activity';
|
|
4
|
-
import { HotMeshGraph } from '../../types/hotmesh';
|
|
5
|
-
import { Activity } from '../activities/activity';
|
|
6
|
-
declare class CollatorService {
|
|
7
|
-
static targetLength: number;
|
|
8
|
-
static getDimensionalAddress(activity: Activity): Record<string, string>;
|
|
9
|
-
static notarizeEntry(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
10
|
-
static authorizeReentry(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
11
|
-
static notarizeEarlyCompletion(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
12
|
-
static notarizeReentry(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
13
|
-
static notarizeContinuation(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
14
|
-
static notarizeCompletion(activity: Activity, multi?: RedisMulti): Promise<number>;
|
|
15
|
-
static getDigitAtIndex(num: number, targetDigitIndex: number): number | null;
|
|
16
|
-
static getDimensionalIndex(num: number): number | null;
|
|
17
|
-
static isDuplicate(num: number, targetDigitIndex: number): boolean;
|
|
18
|
-
static isInactive(num: number): boolean;
|
|
19
|
-
static isPrimed(amount: number, leg: ActivityDuplex): boolean;
|
|
20
|
-
static verifyInteger(amount: number, leg: ActivityDuplex, stage: CollationStage): void;
|
|
21
|
-
static getDimensionsById(ancestors: string[], dad: string): Record<string, string>;
|
|
22
|
-
/**
|
|
23
|
-
* All non-trigger activities are assigned a status seed by their parent
|
|
24
|
-
*/
|
|
25
|
-
static getSeed(): string;
|
|
26
|
-
/**
|
|
27
|
-
* All trigger activities are assigned a status seed in a completed state
|
|
28
|
-
*/
|
|
29
|
-
static getTriggerSeed(): string;
|
|
30
|
-
/**
|
|
31
|
-
* entry point for compiler-type activities. This is called by the compiler
|
|
32
|
-
* to bind the sorted activity IDs to the trigger activity. These are then used
|
|
33
|
-
* at runtime by the activities to track job/activity status.
|
|
34
|
-
* @param graphs
|
|
35
|
-
*/
|
|
36
|
-
static compile(graphs: HotMeshGraph[]): void;
|
|
37
|
-
/**
|
|
38
|
-
* binds the ancestor array to each activity.
|
|
39
|
-
* Used in conjunction with the dimensional
|
|
40
|
-
* address (dad). If dad is `,0,1,0,0` and the
|
|
41
|
-
* ancestor array is `['t1', 'a1', 'a2']` for
|
|
42
|
-
* activity 'a3', then the SAVED DAD
|
|
43
|
-
* will always have the trailing
|
|
44
|
-
* 0's removed. This ensures that the addressing
|
|
45
|
-
* remains consistent even if the graph changes.
|
|
46
|
-
* id DAD SAVED DAD
|
|
47
|
-
* * t1 => ,0 => [empty]
|
|
48
|
-
* * a1 => ,0,1 => ,0,1
|
|
49
|
-
* * a2 => ,0,1,0 => ,0,1
|
|
50
|
-
* * a3 => ,0,1,0,0 => ,0,1
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
static bindAncestorArray(graphs: HotMeshGraph[]): void;
|
|
54
|
-
static isActivityComplete(status: number): boolean;
|
|
55
|
-
}
|
|
56
|
-
export { CollatorService };
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var _a;
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.WorkerService = void 0;
|
|
28
|
-
const asyncLocalStorage_1 = require("./asyncLocalStorage");
|
|
29
|
-
const hotmesh_1 = require("../hotmesh");
|
|
30
|
-
const stream_1 = require("../../types/stream");
|
|
31
|
-
const factory_1 = require("./factory");
|
|
32
|
-
/*
|
|
33
|
-
Here is an example of how the methods in this file are used:
|
|
34
|
-
|
|
35
|
-
./worker.ts
|
|
36
|
-
|
|
37
|
-
import { Durable: { NativeConnection, Worker } } from '@hotmeshio/hotmesh';
|
|
38
|
-
import Redis from 'ioredis'; //OR `import * as Redis from 'redis';`
|
|
39
|
-
|
|
40
|
-
import * as activities from './activities';
|
|
41
|
-
|
|
42
|
-
async function run() {
|
|
43
|
-
const connection = await NativeConnection.connect({
|
|
44
|
-
class: Redis,
|
|
45
|
-
options: {
|
|
46
|
-
host: 'localhost',
|
|
47
|
-
port: 6379,
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
const worker = await Worker.create({
|
|
51
|
-
connection,
|
|
52
|
-
namespace: 'default',
|
|
53
|
-
taskQueue: 'hello-world',
|
|
54
|
-
workflowsPath: require.resolve('./workflows'),
|
|
55
|
-
activities,
|
|
56
|
-
});
|
|
57
|
-
await worker.run();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
run().catch((err) => {
|
|
61
|
-
console.error(err);
|
|
62
|
-
process.exit(1);
|
|
63
|
-
});
|
|
64
|
-
*/
|
|
65
|
-
class WorkerService {
|
|
66
|
-
static async activateWorkflow(hotMesh, topic, factory) {
|
|
67
|
-
const version = '1';
|
|
68
|
-
const app = await hotMesh.engine.store.getApp(topic);
|
|
69
|
-
const appVersion = app?.version;
|
|
70
|
-
if (!appVersion) {
|
|
71
|
-
try {
|
|
72
|
-
await hotMesh.deploy(factory(topic, version));
|
|
73
|
-
await hotMesh.activate(version);
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
hotMesh.engine.logger.error('durable-worker-deploy-activate-err', err);
|
|
77
|
-
throw err;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else if (app && !app.active) {
|
|
81
|
-
try {
|
|
82
|
-
await hotMesh.activate(version);
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
hotMesh.engine.logger.error('durable-worker-activate-err', err);
|
|
86
|
-
throw err;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* The `worker` calls `registerActivities` immediately BEFORE
|
|
92
|
-
* dynamically importing the user's workflow module. That file
|
|
93
|
-
* contains a call, `proxyActivities`, which needs this info.
|
|
94
|
-
*
|
|
95
|
-
* NOTE: The `worker` and `client` both call `proxyActivities`,
|
|
96
|
-
* as a natural result of importing worflows.ts. However,
|
|
97
|
-
* because the worker imports the workflows dynamically AFTER
|
|
98
|
-
* the activities are loaded, there will be items in the registry,
|
|
99
|
-
* allowing proxyActivities to succeed.
|
|
100
|
-
*/
|
|
101
|
-
static registerActivities(activities) {
|
|
102
|
-
if (typeof activities === 'function') {
|
|
103
|
-
WorkerService.activityRegistry[activities.name] = activities;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
Object.keys(activities).forEach(key => {
|
|
107
|
-
WorkerService.activityRegistry[activities[key].name] = activities[key];
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
return WorkerService.activityRegistry;
|
|
111
|
-
}
|
|
112
|
-
static async create(config) {
|
|
113
|
-
//always call `registerActivities` before `import`
|
|
114
|
-
WorkerService.connection = config.connection;
|
|
115
|
-
WorkerService.registerActivities(config.activities);
|
|
116
|
-
const workflow = await Promise.resolve(`${config.workflowsPath}`).then(s => __importStar(require(s)));
|
|
117
|
-
const [workflowFunctionName, workflowFunction] = WorkerService.resolveWorkflowTarget(workflow);
|
|
118
|
-
const baseTopic = `${config.taskQueue}-${workflowFunctionName}`;
|
|
119
|
-
const activityTopic = `${baseTopic}-activity`;
|
|
120
|
-
const workflowTopic = `${baseTopic}`;
|
|
121
|
-
//initialize supporting workflows
|
|
122
|
-
const worker = new WorkerService();
|
|
123
|
-
const activityRunner = await worker.initActivityWorkflow(config, activityTopic);
|
|
124
|
-
await WorkerService.activateWorkflow(activityRunner, activityTopic, factory_1.getActivityYAML);
|
|
125
|
-
worker.workflowRunner = await worker.initWorkerWorkflow(config, workflowTopic, workflowFunction);
|
|
126
|
-
await WorkerService.activateWorkflow(worker.workflowRunner, workflowTopic, factory_1.getWorkflowYAML);
|
|
127
|
-
return worker;
|
|
128
|
-
}
|
|
129
|
-
static resolveWorkflowTarget(workflow) {
|
|
130
|
-
let workflowFunction;
|
|
131
|
-
if (typeof workflow === 'function') {
|
|
132
|
-
workflowFunction = workflow;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
const workflowFunctionNames = Object.keys(workflow);
|
|
136
|
-
workflowFunction = workflow[workflowFunctionNames[workflowFunctionNames.length - 1]];
|
|
137
|
-
return WorkerService.resolveWorkflowTarget(workflowFunction);
|
|
138
|
-
}
|
|
139
|
-
return [workflowFunction.name, workflowFunction];
|
|
140
|
-
}
|
|
141
|
-
async run() {
|
|
142
|
-
if (this.workflowRunner) {
|
|
143
|
-
this.workflowRunner.engine.logger.info('WorkerService is running');
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
console.log('WorkerService is running');
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
async initActivityWorkflow(config, activityTopic) {
|
|
150
|
-
const redisConfig = {
|
|
151
|
-
class: config.connection.class,
|
|
152
|
-
options: config.connection.options
|
|
153
|
-
};
|
|
154
|
-
const hmshInstance = await hotmesh_1.HotMeshService.init({
|
|
155
|
-
appId: activityTopic,
|
|
156
|
-
engine: { redis: redisConfig },
|
|
157
|
-
workers: [
|
|
158
|
-
{ topic: activityTopic,
|
|
159
|
-
redis: redisConfig,
|
|
160
|
-
callback: this.wrapActivityFunctions().bind(this)
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
});
|
|
164
|
-
WorkerService.instances.set(activityTopic, hmshInstance);
|
|
165
|
-
return hmshInstance;
|
|
166
|
-
}
|
|
167
|
-
wrapActivityFunctions() {
|
|
168
|
-
return async (data) => {
|
|
169
|
-
try {
|
|
170
|
-
//always run the activity function when instructed; return the response
|
|
171
|
-
const activityInput = data.data;
|
|
172
|
-
const activityName = activityInput.activityName;
|
|
173
|
-
const activityFunction = WorkerService.activityRegistry[activityName];
|
|
174
|
-
const pojoResponse = await activityFunction.apply(this, activityInput.arguments);
|
|
175
|
-
return {
|
|
176
|
-
status: stream_1.StreamStatus.SUCCESS,
|
|
177
|
-
metadata: { ...data.metadata },
|
|
178
|
-
data: { response: pojoResponse }
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
catch (err) {
|
|
182
|
-
console.error(err);
|
|
183
|
-
//todo (make retry configurable)
|
|
184
|
-
return {
|
|
185
|
-
status: stream_1.StreamStatus.PENDING,
|
|
186
|
-
metadata: { ...data.metadata },
|
|
187
|
-
data: { error: err }
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
async activateActivityWorkflow(hotMesh, activityTopic) {
|
|
193
|
-
const version = '1';
|
|
194
|
-
const app = await hotMesh.engine.store.getApp(activityTopic);
|
|
195
|
-
const appVersion = app?.version;
|
|
196
|
-
if (isNaN(appVersion)) {
|
|
197
|
-
try {
|
|
198
|
-
await hotMesh.deploy((0, factory_1.getActivityYAML)(activityTopic, version));
|
|
199
|
-
await hotMesh.activate(version);
|
|
200
|
-
}
|
|
201
|
-
catch (err) {
|
|
202
|
-
console.log('durable-worker-activity-deploy-activate-error', err);
|
|
203
|
-
throw err;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
else if (app && !app.active) {
|
|
207
|
-
try {
|
|
208
|
-
await hotMesh.activate(version);
|
|
209
|
-
}
|
|
210
|
-
catch (err) {
|
|
211
|
-
hotMesh.engine.logger.error('durable-worker-activity-activate-err', err);
|
|
212
|
-
throw err;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
async initWorkerWorkflow(config, workflowTopic, workflowFunction) {
|
|
217
|
-
const redisConfig = {
|
|
218
|
-
class: config.connection.class,
|
|
219
|
-
options: config.connection.options
|
|
220
|
-
};
|
|
221
|
-
const hmshInstance = await hotmesh_1.HotMeshService.init({
|
|
222
|
-
appId: workflowTopic,
|
|
223
|
-
engine: { redis: redisConfig },
|
|
224
|
-
workers: [
|
|
225
|
-
{ topic: workflowTopic,
|
|
226
|
-
redis: redisConfig,
|
|
227
|
-
callback: this.wrapWorkflowFunction(workflowFunction, workflowTopic).bind(this)
|
|
228
|
-
}
|
|
229
|
-
]
|
|
230
|
-
});
|
|
231
|
-
WorkerService.instances.set(workflowTopic, hmshInstance);
|
|
232
|
-
return hmshInstance;
|
|
233
|
-
}
|
|
234
|
-
wrapWorkflowFunction(workflowFunction, workflowTopic) {
|
|
235
|
-
return async (data) => {
|
|
236
|
-
try {
|
|
237
|
-
//incoming data payload has arguments and workflowId
|
|
238
|
-
const workflowInput = data.data;
|
|
239
|
-
const context = new Map();
|
|
240
|
-
const counter = { counter: 0 };
|
|
241
|
-
context.set('counter', counter);
|
|
242
|
-
context.set('workflowId', workflowInput.workflowId);
|
|
243
|
-
context.set('workflowTopic', workflowTopic);
|
|
244
|
-
context.set('workflowName', workflowTopic.split('-').pop());
|
|
245
|
-
context.set('workflowTrace', data.metadata.trc);
|
|
246
|
-
context.set('workflowSpan', data.metadata.spn);
|
|
247
|
-
const workflowResponse = await asyncLocalStorage_1.asyncLocalStorage.run(context, async () => {
|
|
248
|
-
return await workflowFunction.apply(this, workflowInput.arguments);
|
|
249
|
-
});
|
|
250
|
-
return {
|
|
251
|
-
code: 200,
|
|
252
|
-
status: stream_1.StreamStatus.SUCCESS,
|
|
253
|
-
metadata: { ...data.metadata },
|
|
254
|
-
data: { response: workflowResponse }
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
catch (err) {
|
|
258
|
-
//todo: (retryable error types)
|
|
259
|
-
return {
|
|
260
|
-
code: 500,
|
|
261
|
-
status: stream_1.StreamStatus.PENDING,
|
|
262
|
-
metadata: { ...data.metadata },
|
|
263
|
-
data: { error: err }
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
static async shutdown() {
|
|
269
|
-
for (const [key, value] of WorkerService.instances) {
|
|
270
|
-
const hotMesh = await value;
|
|
271
|
-
await hotMesh.stop();
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
_a = WorkerService;
|
|
276
|
-
WorkerService.activityRegistry = {}; //user's activities
|
|
277
|
-
WorkerService.instances = new Map();
|
|
278
|
-
WorkerService.getHotMesh = async (worflowTopic) => {
|
|
279
|
-
if (WorkerService.instances.has(worflowTopic)) {
|
|
280
|
-
return await WorkerService.instances.get(worflowTopic);
|
|
281
|
-
}
|
|
282
|
-
const hotMesh = hotmesh_1.HotMeshService.init({
|
|
283
|
-
appId: worflowTopic,
|
|
284
|
-
engine: { redis: { ...WorkerService.connection } }
|
|
285
|
-
});
|
|
286
|
-
WorkerService.instances.set(worflowTopic, hotMesh);
|
|
287
|
-
await WorkerService.activateWorkflow(await hotMesh, worflowTopic, factory_1.getWorkflowYAML);
|
|
288
|
-
return hotMesh;
|
|
289
|
-
};
|
|
290
|
-
WorkerService.Context = {
|
|
291
|
-
info: () => {
|
|
292
|
-
return {
|
|
293
|
-
workflowId: '',
|
|
294
|
-
workflowTopic: '',
|
|
295
|
-
};
|
|
296
|
-
},
|
|
297
|
-
};
|
|
298
|
-
exports.WorkerService = WorkerService;
|