@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
|
@@ -44,7 +44,7 @@ class Await extends Activity {
|
|
|
44
44
|
this.mapInputData();
|
|
45
45
|
|
|
46
46
|
const multi = this.store.getMulti();
|
|
47
|
-
//await this.registerTimeout();
|
|
47
|
+
//todo: await this.registerTimeout();
|
|
48
48
|
await CollatorService.authorizeReentry(this, multi);
|
|
49
49
|
await this.setState(multi);
|
|
50
50
|
await this.setStatus(0, multi);
|
|
@@ -121,11 +121,11 @@ class Await extends Activity {
|
|
|
121
121
|
if (status === StreamStatus.SUCCESS) {
|
|
122
122
|
this.bindActivityData('output');
|
|
123
123
|
this.adjacencyList = await this.filterAdjacent();
|
|
124
|
-
multiResponse = await this.
|
|
124
|
+
multiResponse = await this.processSuccessResponse(this.adjacencyList);
|
|
125
125
|
} else {
|
|
126
126
|
this.bindActivityError(this.data);
|
|
127
127
|
this.adjacencyList = await this.filterAdjacent();
|
|
128
|
-
multiResponse = await this.
|
|
128
|
+
multiResponse = await this.processErrorResponse(this.adjacencyList);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
telemetry.mapActivityAttributes();
|
|
@@ -146,7 +146,7 @@ class Await extends Activity {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
async
|
|
149
|
+
async processSuccessResponse(adjacencyList: StreamData[]): Promise<MultiResponseFlags> {
|
|
150
150
|
this.mapJobData();
|
|
151
151
|
const multi = this.store.getMulti();
|
|
152
152
|
await this.setState(multi);
|
|
@@ -156,7 +156,7 @@ class Await extends Activity {
|
|
|
156
156
|
return await multi.exec() as MultiResponseFlags;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
async
|
|
159
|
+
async processErrorResponse(adjacencyList: StreamData[]): Promise<MultiResponseFlags> {
|
|
160
160
|
//todo: if adjacencyList.length == 0, then map to the job output
|
|
161
161
|
// this method would be added to Base activity class
|
|
162
162
|
//this.mapJobData();
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { GetStateError } from '../../modules/errors';
|
|
2
|
+
import { CollatorService } from '../collator';
|
|
3
|
+
import { EngineService } from '../engine';
|
|
4
|
+
import { Activity, ActivityType } from './activity';
|
|
5
|
+
import {
|
|
6
|
+
ActivityData,
|
|
7
|
+
ActivityMetadata,
|
|
8
|
+
CycleActivity } from '../../types/activity';
|
|
9
|
+
import { JobState } from '../../types/job';
|
|
10
|
+
import { MultiResponseFlags, RedisMulti } from '../../types/redis';
|
|
11
|
+
import { StreamData } from '../../types/stream';
|
|
12
|
+
import { TelemetryService } from '../telemetry';
|
|
13
|
+
|
|
14
|
+
class Cycle extends Activity {
|
|
15
|
+
config: CycleActivity;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
config: ActivityType,
|
|
19
|
+
data: ActivityData,
|
|
20
|
+
metadata: ActivityMetadata,
|
|
21
|
+
hook: ActivityData | null,
|
|
22
|
+
engine: EngineService,
|
|
23
|
+
context?: JobState) {
|
|
24
|
+
super(config, data, metadata, hook, engine, context);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
//******** LEG 1 ENTRY ********//
|
|
29
|
+
async process(): Promise<string> {
|
|
30
|
+
this.logger.debug('cycle-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
31
|
+
let telemetry: TelemetryService;
|
|
32
|
+
try {
|
|
33
|
+
//verify entry is allowed
|
|
34
|
+
this.setLeg(1);
|
|
35
|
+
await CollatorService.notarizeEntry(this);
|
|
36
|
+
await this.getState();
|
|
37
|
+
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
38
|
+
telemetry.startActivitySpan(this.leg);
|
|
39
|
+
this.mapInputData();
|
|
40
|
+
|
|
41
|
+
//set state/status
|
|
42
|
+
let multi = this.store.getMulti();
|
|
43
|
+
await this.setState(multi);
|
|
44
|
+
await this.setStatus(0, multi); //leg 1 never changes job status
|
|
45
|
+
const multiResponse = await multi.exec() as MultiResponseFlags;
|
|
46
|
+
telemetry.mapActivityAttributes();
|
|
47
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
48
|
+
|
|
49
|
+
//cycle the target ancestor
|
|
50
|
+
multi = this.store.getMulti();
|
|
51
|
+
const messageId = await this.cycleAncestorActivity(multi);
|
|
52
|
+
telemetry.setActivityAttributes({
|
|
53
|
+
'app.activity.mid': messageId,
|
|
54
|
+
'app.job.jss': jobStatus
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
//exit early (`Cycle` activities only execute Leg 1)
|
|
58
|
+
await CollatorService.notarizeEarlyExit(this, multi);
|
|
59
|
+
await multi.exec() as MultiResponseFlags;
|
|
60
|
+
|
|
61
|
+
return this.context.metadata.aid;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (error instanceof GetStateError) {
|
|
64
|
+
this.logger.error('cycle-get-state-error', error);
|
|
65
|
+
} else {
|
|
66
|
+
this.logger.error('cycle-process-error', error);
|
|
67
|
+
}
|
|
68
|
+
telemetry.setActivityError(error.message);
|
|
69
|
+
throw error;
|
|
70
|
+
} finally {
|
|
71
|
+
telemetry.endActivitySpan();
|
|
72
|
+
this.logger.debug('cycle-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Trigger the target ancestor to execute in a cycle,
|
|
78
|
+
* without violating the constraints of the DAG. Immutable
|
|
79
|
+
* `individual activity state` will execute in a new dimensional
|
|
80
|
+
* thread while `shared job state` can change. This
|
|
81
|
+
* pattern allows for retries without violating the DAG.
|
|
82
|
+
*/
|
|
83
|
+
async cycleAncestorActivity(multi: RedisMulti): Promise<string> {
|
|
84
|
+
const streamData: StreamData = {
|
|
85
|
+
metadata: {
|
|
86
|
+
dad: CollatorService.resolveReentryDimension(this),
|
|
87
|
+
jid: this.context.metadata.jid,
|
|
88
|
+
aid: this.config.ancestor,
|
|
89
|
+
},
|
|
90
|
+
data: {} //todo: verify immutability, before enabling: `this.context.data`
|
|
91
|
+
};
|
|
92
|
+
return (await this.engine.streamSignaler?.publishMessage(null, streamData, multi)) as string;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { Cycle };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Activity } from './activity';
|
|
2
2
|
import { Await } from './await';
|
|
3
|
-
import {
|
|
4
|
-
import { Iterate } from './iterate';
|
|
3
|
+
import { Cycle } from './cycle';
|
|
5
4
|
import { Emit } from './emit';
|
|
5
|
+
import { Iterate } from './iterate';
|
|
6
6
|
import { Trigger } from './trigger';
|
|
7
|
+
import { Worker } from './worker';
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
activity: Activity,
|
|
10
11
|
await: Await,
|
|
12
|
+
cycle: Cycle,
|
|
11
13
|
iterate: Iterate,
|
|
12
14
|
emit: Emit,
|
|
13
15
|
trigger: Trigger,
|
|
@@ -43,7 +43,7 @@ class Worker extends Activity {
|
|
|
43
43
|
this.mapInputData();
|
|
44
44
|
|
|
45
45
|
const multi = this.store.getMulti();
|
|
46
|
-
//await this.registerTimeout();
|
|
46
|
+
//todo: await this.registerTimeout();
|
|
47
47
|
await CollatorService.authorizeReentry(this, multi);
|
|
48
48
|
await this.setState(multi);
|
|
49
49
|
await this.setStatus(0, multi);
|
|
@@ -56,13 +56,12 @@ class Worker extends Activity {
|
|
|
56
56
|
'app.activity.mid': messageId,
|
|
57
57
|
'app.job.jss': jobStatus
|
|
58
58
|
});
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
return this.context.metadata.aid;
|
|
61
61
|
} catch (error) {
|
|
62
62
|
if (error instanceof GetStateError) {
|
|
63
63
|
this.logger.error('worker-get-state-error', error);
|
|
64
64
|
} else {
|
|
65
|
-
console.error(error);
|
|
66
65
|
this.logger.error('worker-process-error', error);
|
|
67
66
|
}
|
|
68
67
|
telemetry.setActivityError(error.message);
|
|
@@ -92,96 +91,6 @@ class Worker extends Activity {
|
|
|
92
91
|
}
|
|
93
92
|
return (await this.engine.streamSignaler?.publishMessage(this.config.subtype, streamData)) as string;
|
|
94
93
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//******** SIGNAL RE-ENTRY POINT (DUPLEX LEG 2 of 2) ********//
|
|
98
|
-
async processEvent(status: StreamStatus = StreamStatus.SUCCESS, code: StreamCode = 200): Promise<void> {
|
|
99
|
-
this.setLeg(2);
|
|
100
|
-
const jid = this.context.metadata.jid;
|
|
101
|
-
const aid = this.metadata.aid;
|
|
102
|
-
this.status = status;
|
|
103
|
-
this.code = code;
|
|
104
|
-
this.logger.debug('worker-process-event', { topic: this.config.subtype, jid, aid, status, code });
|
|
105
|
-
let telemetry: TelemetryService;
|
|
106
|
-
try {
|
|
107
|
-
await this.getState();
|
|
108
|
-
const aState = await CollatorService.notarizeReentry(this);
|
|
109
|
-
this.adjacentIndex = CollatorService.getDimensionalIndex(aState);
|
|
110
|
-
|
|
111
|
-
telemetry = new TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
112
|
-
let isComplete = CollatorService.isActivityComplete(this.context.metadata.js);
|
|
113
|
-
|
|
114
|
-
if (isComplete) {
|
|
115
|
-
this.logger.warn('worker-process-event-duplicate', { jid, aid });
|
|
116
|
-
this.logger.debug('worker-process-event-duplicate-resolution', { resolution: 'Increase HotMesh config `reclaimDelay` timeout.' });
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
telemetry.startActivitySpan(this.leg);
|
|
120
|
-
if (status === StreamStatus.PENDING) {
|
|
121
|
-
await this.processPending(telemetry);
|
|
122
|
-
} else if (status === StreamStatus.SUCCESS) {
|
|
123
|
-
await this.processSuccess(telemetry);
|
|
124
|
-
} else {
|
|
125
|
-
await this.processError(telemetry);
|
|
126
|
-
}
|
|
127
|
-
} catch (error) {
|
|
128
|
-
this.logger.error('worker-process-event-error', error);
|
|
129
|
-
telemetry.setActivityError(error.message);
|
|
130
|
-
throw error;
|
|
131
|
-
} finally {
|
|
132
|
-
telemetry.endActivitySpan();
|
|
133
|
-
this.logger.debug('worker-process-event-end', { jid, aid });
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
async processPending(telemetry: TelemetryService): Promise<void> {
|
|
138
|
-
this.bindActivityData('output');
|
|
139
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
140
|
-
this.mapJobData();
|
|
141
|
-
const multi = this.store.getMulti();
|
|
142
|
-
await this.setState(multi);
|
|
143
|
-
await CollatorService.notarizeContinuation(this, multi);
|
|
144
|
-
|
|
145
|
-
await this.setStatus(this.adjacencyList.length, multi);
|
|
146
|
-
const multiResponse = await multi.exec() as MultiResponseFlags;
|
|
147
|
-
this.transitionAdjacent(multiResponse, telemetry);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async processSuccess(telemetry: TelemetryService): Promise<void> {
|
|
151
|
-
this.bindActivityData('output');
|
|
152
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
153
|
-
this.mapJobData();
|
|
154
|
-
const multi = this.store.getMulti();
|
|
155
|
-
await this.setState(multi);
|
|
156
|
-
await CollatorService.notarizeCompletion(this, multi);
|
|
157
|
-
|
|
158
|
-
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
159
|
-
const multiResponse = await multi.exec() as MultiResponseFlags;
|
|
160
|
-
this.transitionAdjacent(multiResponse, telemetry);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async processError(telemetry: TelemetryService): Promise<void> {
|
|
164
|
-
this.bindActivityError(this.data);
|
|
165
|
-
this.adjacencyList = await this.filterAdjacent();
|
|
166
|
-
const multi = this.store.getMulti();
|
|
167
|
-
await this.setState(multi);
|
|
168
|
-
await CollatorService.notarizeCompletion(this, multi);
|
|
169
|
-
|
|
170
|
-
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
171
|
-
const multiResponse = await multi.exec() as MultiResponseFlags;
|
|
172
|
-
this.transitionAdjacent(multiResponse, telemetry);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
async transitionAdjacent(multiResponse: MultiResponseFlags, telemetry: TelemetryService): Promise<void> {
|
|
176
|
-
telemetry.mapActivityAttributes();
|
|
177
|
-
const jobStatus = this.resolveStatus(multiResponse);
|
|
178
|
-
const attrs: StringScalarType = { 'app.job.jss': jobStatus };
|
|
179
|
-
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
180
|
-
if (messageIds.length) {
|
|
181
|
-
attrs['app.activity.mids'] = messageIds.join(',')
|
|
182
|
-
}
|
|
183
|
-
telemetry.setActivityAttributes(attrs);
|
|
184
|
-
}
|
|
185
94
|
}
|
|
186
95
|
|
|
187
96
|
export { Worker };
|
|
@@ -4,22 +4,45 @@ import { CollationFaultType, CollationStage } from '../../types/collator';
|
|
|
4
4
|
import { ActivityDuplex } from '../../types/activity';
|
|
5
5
|
import { HotMeshGraph } from '../../types/hotmesh';
|
|
6
6
|
import { Activity } from '../activities/activity';
|
|
7
|
+
import { Cycle } from '../activities/cycle';
|
|
7
8
|
|
|
8
9
|
class CollatorService {
|
|
9
10
|
|
|
10
11
|
//max int digit count that supports `hincrby`
|
|
11
12
|
static targetLength = 15;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* returns the dimensional address (dad) for the target; due
|
|
16
|
+
* to the nature of the notary system, the dad for leg 2 entry
|
|
17
|
+
* must target the `0` index while leg 2 exit must target the
|
|
18
|
+
* current index (0)
|
|
19
|
+
*/
|
|
20
|
+
static getDimensionalAddress(activity: Activity, isEntry = false): Record<string, string> {
|
|
14
21
|
let dad = activity.context.metadata.dad || activity.metadata.dad;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// dad = `${dad.substring(0, dad.lastIndexOf(','))},0`;
|
|
19
|
-
// }
|
|
22
|
+
if (isEntry && dad && activity.leg === 2) {
|
|
23
|
+
dad = `${dad.substring(0, dad.lastIndexOf(','))},0`;
|
|
24
|
+
}
|
|
20
25
|
return CollatorService.getDimensionsById([...activity.config.ancestors, activity.metadata.aid], dad);
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
/**
|
|
29
|
+
* resolves the dimensional address for the
|
|
30
|
+
* ancestor in the graph to go back to. this address
|
|
31
|
+
* is determined by trimming the last digits from
|
|
32
|
+
* the `dad` (including the target).
|
|
33
|
+
* the target activity index is then set to `0`, so that
|
|
34
|
+
* the origin node can be queried for approval/entry.
|
|
35
|
+
*/
|
|
36
|
+
static resolveReentryDimension(activity: Cycle) {
|
|
37
|
+
const targetActivityId = activity.config.ancestor;
|
|
38
|
+
const ancestors = activity.config.ancestors;
|
|
39
|
+
const ancestorIndex = ancestors.indexOf(targetActivityId);
|
|
40
|
+
const dimensions = activity.metadata.dad.split(','); //e.g., `,0,0,1,0`
|
|
41
|
+
dimensions.length = ancestorIndex + 1;
|
|
42
|
+
dimensions.push('0');
|
|
43
|
+
return dimensions.join(',');
|
|
44
|
+
}
|
|
45
|
+
|
|
23
46
|
static async notarizeEntry(activity: Activity, multi?: RedisMulti): Promise<number> {
|
|
24
47
|
//decrement by -100_000_000_000_000
|
|
25
48
|
const amount = await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, -100_000_000_000_000, this.getDimensionalAddress(activity), multi);
|
|
@@ -35,14 +58,21 @@ class CollatorService {
|
|
|
35
58
|
return amount;
|
|
36
59
|
}
|
|
37
60
|
|
|
61
|
+
static async notarizeEarlyExit(activity: Activity, multi?: RedisMulti): Promise<number> {
|
|
62
|
+
//decrement the 2nd and 3rd digits to fully deactivate (`cycle` activities use this command to fully exit after leg 1) (should result in `888000000000000`)
|
|
63
|
+
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, -11_000_000_000_000, this.getDimensionalAddress(activity), multi);
|
|
64
|
+
};
|
|
65
|
+
|
|
38
66
|
static async notarizeEarlyCompletion(activity: Activity, multi?: RedisMulti): Promise<number> {
|
|
39
|
-
//initialize both `possible` (1m) and `actualized` (1) zero dimension, while decrementing the 2nd
|
|
40
|
-
|
|
67
|
+
//initialize both `possible` (1m) and `actualized` (1) zero dimension, while decrementing the 2nd
|
|
68
|
+
//3rd digit is optionally kept open if the activity might be used in a cycle
|
|
69
|
+
const decrement = activity.config.cycle ? 10_000_000_000_000 : 11_000_000_000_000;
|
|
70
|
+
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1_000_001 - decrement, this.getDimensionalAddress(activity), multi);
|
|
41
71
|
};
|
|
42
72
|
|
|
43
73
|
static async notarizeReentry(activity: Activity, multi?: RedisMulti): Promise<number> {
|
|
44
74
|
//increment by 1_000_000 (indicates re-entry and is used to drive the 'dimensional address' for adjacent activities (minus 1))
|
|
45
|
-
const amount = await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1_000_000, this.getDimensionalAddress(activity), multi);
|
|
75
|
+
const amount = await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1_000_000, this.getDimensionalAddress(activity, true), multi);
|
|
46
76
|
this.verifyInteger(amount, 2, 'enter');
|
|
47
77
|
return amount;
|
|
48
78
|
};
|
|
@@ -53,8 +83,10 @@ class CollatorService {
|
|
|
53
83
|
};
|
|
54
84
|
|
|
55
85
|
static async notarizeCompletion(activity: Activity, multi?: RedisMulti): Promise<number> {
|
|
56
|
-
//
|
|
57
|
-
|
|
86
|
+
//1) ALWAYS actualize leg2 dimension (+1)
|
|
87
|
+
//2) IF the activity is used in a cycle, don't close leg 2!
|
|
88
|
+
const decrement = activity.config.cycle ? 0 : -1_000_000_000_000;
|
|
89
|
+
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1 - decrement, this.getDimensionalAddress(activity), multi);
|
|
58
90
|
};
|
|
59
91
|
|
|
60
92
|
static getDigitAtIndex(num: number, targetDigitIndex: number): number | null {
|
|
@@ -26,7 +26,12 @@ const getWorkflowYAML = (topic: string, version = '1') => {
|
|
|
26
26
|
type: trigger
|
|
27
27
|
stats:
|
|
28
28
|
id: '{$self.input.data.workflowId}'
|
|
29
|
+
|
|
29
30
|
a1:
|
|
31
|
+
type: activity
|
|
32
|
+
cycle: true
|
|
33
|
+
|
|
34
|
+
w1:
|
|
30
35
|
type: worker
|
|
31
36
|
topic: ${topic}
|
|
32
37
|
input:
|
|
@@ -49,9 +54,20 @@ const getWorkflowYAML = (topic: string, version = '1') => {
|
|
|
49
54
|
job:
|
|
50
55
|
maps:
|
|
51
56
|
response: '{$self.output.data.response}'
|
|
57
|
+
|
|
58
|
+
c1:
|
|
59
|
+
type: cycle
|
|
60
|
+
ancestor: a1
|
|
52
61
|
transitions:
|
|
53
62
|
t1:
|
|
54
|
-
- to: a1
|
|
63
|
+
- to: a1
|
|
64
|
+
a1:
|
|
65
|
+
- to: w1
|
|
66
|
+
w1:
|
|
67
|
+
- to: c1
|
|
68
|
+
conditions:
|
|
69
|
+
code: 500
|
|
70
|
+
`;
|
|
55
71
|
}
|
|
56
72
|
|
|
57
73
|
const getActivityYAML = (topic: string, version = '1') => {
|
|
@@ -9,7 +9,7 @@ Here is an example of how the methods in this file are used:
|
|
|
9
9
|
import { Durable: { NativeConnection, Worker } } from '@hotmeshio/hotmesh';
|
|
10
10
|
import Redis from 'ioredis'; //OR `import * as Redis from 'redis';`
|
|
11
11
|
|
|
12
|
-
import * as
|
|
12
|
+
import * as workflows from './workflows';
|
|
13
13
|
|
|
14
14
|
async function run() {
|
|
15
15
|
const connection = await NativeConnection.connect({
|
|
@@ -23,7 +23,7 @@ async function run() {
|
|
|
23
23
|
connection,
|
|
24
24
|
namespace: 'default',
|
|
25
25
|
taskQueue: 'hello-world',
|
|
26
|
-
|
|
26
|
+
workflow: workflows.example,
|
|
27
27
|
activities,
|
|
28
28
|
});
|
|
29
29
|
await worker.run();
|
|
@@ -13,7 +13,7 @@ Here is an example of how the methods in this file are used:
|
|
|
13
13
|
import { Durable: { NativeConnection, Worker } } from '@hotmeshio/hotmesh';
|
|
14
14
|
import Redis from 'ioredis'; //OR `import * as Redis from 'redis';`
|
|
15
15
|
|
|
16
|
-
import * as
|
|
16
|
+
import * as workflows from './workflows';
|
|
17
17
|
|
|
18
18
|
async function run() {
|
|
19
19
|
const connection = await NativeConnection.connect({
|
|
@@ -27,7 +27,7 @@ async function run() {
|
|
|
27
27
|
connection,
|
|
28
28
|
namespace: 'default',
|
|
29
29
|
taskQueue: 'hello-world',
|
|
30
|
-
|
|
30
|
+
workflow: workflows.example,
|
|
31
31
|
activities,
|
|
32
32
|
});
|
|
33
33
|
await worker.run();
|
|
@@ -44,6 +44,7 @@ export class WorkerService {
|
|
|
44
44
|
static connection: Connection;
|
|
45
45
|
static instances = new Map<string, HotMesh | Promise<HotMesh>>();
|
|
46
46
|
workflowRunner: HotMesh;
|
|
47
|
+
activityRunner: HotMesh;
|
|
47
48
|
|
|
48
49
|
static getHotMesh = async (worflowTopic: string) => {
|
|
49
50
|
if (WorkerService.instances.has(worflowTopic)) {
|
|
@@ -85,18 +86,18 @@ export class WorkerService {
|
|
|
85
86
|
* dynamically importing the user's workflow module. That file
|
|
86
87
|
* contains a call, `proxyActivities`, which needs this info.
|
|
87
88
|
*
|
|
88
|
-
* NOTE:
|
|
89
|
-
* as a natural result of importing worflows.ts. However,
|
|
90
|
-
* because the worker imports the workflows dynamically AFTER
|
|
89
|
+
* NOTE: Because the worker imports the workflows dynamically AFTER
|
|
91
90
|
* the activities are loaded, there will be items in the registry,
|
|
92
91
|
* allowing proxyActivities to succeed.
|
|
93
92
|
*/
|
|
94
93
|
static registerActivities<ACT>(activities: ACT): Registry {
|
|
95
|
-
if (typeof activities === 'function') {
|
|
94
|
+
if (typeof activities === 'function' && typeof WorkerService.activityRegistry[activities.name] !== 'function') {
|
|
96
95
|
WorkerService.activityRegistry[activities.name] = activities as Function;
|
|
97
96
|
} else {
|
|
98
97
|
Object.keys(activities).forEach(key => {
|
|
99
|
-
WorkerService.activityRegistry[activities[key].name]
|
|
98
|
+
if (activities[key].name && typeof WorkerService.activityRegistry[activities[key].name] !== 'function') {
|
|
99
|
+
WorkerService.activityRegistry[activities[key].name] = (activities as any)[key] as Function;
|
|
100
|
+
}
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
return WorkerService.activityRegistry;
|
|
@@ -105,8 +106,8 @@ export class WorkerService {
|
|
|
105
106
|
static async create(config: WorkerConfig) {
|
|
106
107
|
//always call `registerActivities` before `import`
|
|
107
108
|
WorkerService.connection = config.connection;
|
|
108
|
-
|
|
109
|
-
const workflow =
|
|
109
|
+
//user can provide the workflow file directly
|
|
110
|
+
const workflow = config.workflow;
|
|
110
111
|
const [workflowFunctionName, workflowFunction] = WorkerService.resolveWorkflowTarget(workflow);
|
|
111
112
|
const baseTopic = `${config.taskQueue}-${workflowFunctionName}`;
|
|
112
113
|
const activityTopic = `${baseTopic}-activity`;
|
|
@@ -114,8 +115,8 @@ export class WorkerService {
|
|
|
114
115
|
|
|
115
116
|
//initialize supporting workflows
|
|
116
117
|
const worker = new WorkerService();
|
|
117
|
-
|
|
118
|
-
await WorkerService.activateWorkflow(activityRunner, activityTopic, getActivityYAML);
|
|
118
|
+
worker.activityRunner = await worker.initActivityWorkflow(config, activityTopic);
|
|
119
|
+
await WorkerService.activateWorkflow(worker.activityRunner, activityTopic, getActivityYAML);
|
|
119
120
|
worker.workflowRunner = await worker.initWorkerWorkflow(config, workflowTopic, workflowFunction);
|
|
120
121
|
await WorkerService.activateWorkflow(worker.workflowRunner, workflowTopic, getWorkflowYAML);
|
|
121
122
|
return worker;
|
|
@@ -134,11 +135,7 @@ export class WorkerService {
|
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
async run() {
|
|
137
|
-
|
|
138
|
-
this.workflowRunner.engine.logger.info('WorkerService is running');
|
|
139
|
-
} else {
|
|
140
|
-
console.log('WorkerService is running');
|
|
141
|
-
}
|
|
138
|
+
this.workflowRunner.engine.logger.info('WorkerService is running');
|
|
142
139
|
}
|
|
143
140
|
|
|
144
141
|
async initActivityWorkflow(config: WorkerConfig, activityTopic: string): Promise<HotMesh> {
|
|
@@ -175,10 +172,11 @@ export class WorkerService {
|
|
|
175
172
|
data: { response: pojoResponse }
|
|
176
173
|
};
|
|
177
174
|
} catch (err) {
|
|
178
|
-
|
|
179
|
-
//todo (make retry configurable)
|
|
175
|
+
this.activityRunner.engine.logger.error('durable-worker-activity-err', err);
|
|
180
176
|
return {
|
|
181
|
-
status: StreamStatus.
|
|
177
|
+
status: StreamStatus.ERROR,
|
|
178
|
+
code: 500,
|
|
179
|
+
message: err.message,
|
|
182
180
|
metadata: { ...data.metadata },
|
|
183
181
|
data: { error: err }
|
|
184
182
|
} as StreamDataResponse;
|
|
@@ -195,7 +193,7 @@ export class WorkerService {
|
|
|
195
193
|
await hotMesh.deploy(getActivityYAML(activityTopic, version));
|
|
196
194
|
await hotMesh.activate(version);
|
|
197
195
|
} catch (err) {
|
|
198
|
-
|
|
196
|
+
hotMesh.engine.logger.error('durable-worker-activity-deploy-activate-error', err);
|
|
199
197
|
throw err;
|
|
200
198
|
}
|
|
201
199
|
} else if(app && !app.active) {
|
|
@@ -260,10 +258,9 @@ export class WorkerService {
|
|
|
260
258
|
data: { response: workflowResponse }
|
|
261
259
|
};
|
|
262
260
|
} catch (err) {
|
|
263
|
-
//todo: (retryable error types)
|
|
264
261
|
return {
|
|
262
|
+
status: StreamStatus.ERROR,
|
|
265
263
|
code: 500,
|
|
266
|
-
status: StreamStatus.PENDING,
|
|
267
264
|
metadata: { ...data.metadata },
|
|
268
265
|
data: { error: err }
|
|
269
266
|
} as StreamDataResponse;
|
|
@@ -31,8 +31,10 @@ Here is an example of how the methods in this file are used:
|
|
|
31
31
|
./workflows.ts
|
|
32
32
|
|
|
33
33
|
import { Durable } from '@hotmeshio/hotmesh';
|
|
34
|
-
import
|
|
34
|
+
import * as activities from './activities';
|
|
35
|
+
|
|
35
36
|
const { greet } = Durable.workflow.proxyActivities<typeof activities>({
|
|
37
|
+
activities: activities,
|
|
36
38
|
startToCloseTimeout: '1 minute',
|
|
37
39
|
retryPolicy: {
|
|
38
40
|
initialInterval: '5 seconds', // Initial delay between retries
|
|
@@ -72,6 +74,10 @@ export class WorkflowService {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
static proxyActivities<ACT>(options?: ActivityConfig): ProxyType<ACT> {
|
|
77
|
+
if (options.activities) {
|
|
78
|
+
WorkerService.registerActivities(options.activities)
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
const proxy: any = {};
|
|
76
82
|
const keys = Object.keys(WorkerService.activityRegistry);
|
|
77
83
|
if (keys.length) {
|
|
@@ -103,7 +109,10 @@ export class WorkflowService {
|
|
|
103
109
|
try {
|
|
104
110
|
const hmshInstance = await WorkerService.getHotMesh(activityTopic);
|
|
105
111
|
activityState = await hmshInstance.getState(activityTopic, activityJobId);
|
|
106
|
-
if (activityState.metadata.
|
|
112
|
+
if (activityState.metadata.err) {
|
|
113
|
+
await hmshInstance.scrub(activityJobId);
|
|
114
|
+
throw new Error(activityState.metadata.err);
|
|
115
|
+
} else if (activityState.metadata.js === 0) {
|
|
107
116
|
//return immediately
|
|
108
117
|
return activityState.data?.response as T;
|
|
109
118
|
}
|
package/services/mapper/index.ts
CHANGED
|
@@ -60,6 +60,9 @@ class MapperService {
|
|
|
60
60
|
return transitionRule;
|
|
61
61
|
}
|
|
62
62
|
if (code.toString() === (transitionRule.code || 200).toString()) {
|
|
63
|
+
if (!transitionRule.match) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
63
66
|
const orGate = transitionRule.gate === 'or';
|
|
64
67
|
let allAreTrue = true;
|
|
65
68
|
let someAreTrue = false;
|
package/types/activity.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MetricTypes } from "./stats";
|
|
2
2
|
import { StreamRetryPolicy } from "./stream";
|
|
3
3
|
|
|
4
|
-
type ActivityExecutionType = 'trigger' | 'await' | 'worker' | 'activity' | 'emit' | 'iterate';
|
|
4
|
+
type ActivityExecutionType = 'trigger' | 'await' | 'worker' | 'activity' | 'emit' | 'iterate' | 'cycle';
|
|
5
5
|
|
|
6
6
|
type Consumes = Record<string, string[]>;
|
|
7
7
|
|
|
@@ -18,6 +18,7 @@ interface BaseActivity {
|
|
|
18
18
|
sleep?: number; //@pipe /in seconds
|
|
19
19
|
expire?: number; //-1 forever (15 seconds default); todo: make globally configurable
|
|
20
20
|
retry?: StreamRetryPolicy
|
|
21
|
+
cycle?: boolean; //if true, the `notary` will leave leg 2 open, so it can be re/cycled
|
|
21
22
|
collationInt?: number; //compiler
|
|
22
23
|
consumes?: Consumes; //compiler
|
|
23
24
|
PRODUCES?: string[]; //compiler
|
|
@@ -61,6 +62,11 @@ interface EmitActivity extends BaseActivity {
|
|
|
61
62
|
type: 'emit';
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
interface CycleActivity extends BaseActivity {
|
|
66
|
+
type: 'cycle';
|
|
67
|
+
ancestor: string; //ancestor activity id
|
|
68
|
+
}
|
|
69
|
+
|
|
64
70
|
interface IterateActivity extends BaseActivity {
|
|
65
71
|
type: 'iterate';
|
|
66
72
|
}
|
|
@@ -108,6 +114,7 @@ export {
|
|
|
108
114
|
Consumes,
|
|
109
115
|
TriggerActivityStats,
|
|
110
116
|
AwaitActivity,
|
|
117
|
+
CycleActivity,
|
|
111
118
|
BaseActivity,
|
|
112
119
|
EmitActivity,
|
|
113
120
|
IterateActivity,
|
package/types/durable.ts
CHANGED
|
@@ -41,8 +41,7 @@ type WorkerConfig = {
|
|
|
41
41
|
connection: Connection;
|
|
42
42
|
namespace: string; //`appid` in the YAML (e.g, 'default')
|
|
43
43
|
taskQueue: string; //`subscribes` in the YAML (e.g, 'hello-world')
|
|
44
|
-
|
|
45
|
-
activities: { [key: string]: Function }; //vanilla activity exports
|
|
44
|
+
workflow: Function //target function to run
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
type ContextType = {
|
|
@@ -56,8 +55,9 @@ type ProxyType<ACT> = {
|
|
|
56
55
|
};
|
|
57
56
|
|
|
58
57
|
type ActivityConfig = {
|
|
59
|
-
startToCloseTimeout
|
|
60
|
-
|
|
58
|
+
startToCloseTimeout?: string;
|
|
59
|
+
activities?: any;
|
|
60
|
+
retryPolicy?: {
|
|
61
61
|
initialInterval: string;
|
|
62
62
|
maximumAttempts: number;
|
|
63
63
|
backoffCoefficient: number;
|