Skip to content

Commit 80bdd95

Browse files
committed
2 parents 866f49d + 2a5f0c2 commit 80bdd95

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/TaskStatusRedis/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
## Job notification mechanism example
2-
This example demonstrates how remote job executors can notify the HyperFlow engine about job completion using Redis.
2+
This example demonstrates how HyperFlow can communicate with remote job executors using Redis.
33

4-
- The workflow invokes function `task_status_redis_test` from `functions.js` 100 times. This function simulates submission of jobs by starting 100 parallel processes of `handler.js`.
4+
- The workflow invokes function `job_status_redis_test` from `functions.js` 100 times. This function simulates submission of jobs by starting 100 parallel processes of `handler.js`.
55
- `handler.js` represents a remote job executor which is passed two parameters: `taskId` and `redis_url`.
6-
- In order to notify that the job has completed, `handler.js` connects to Redis and performs a `RPUSH` operation on the `taskId` key.
7-
- On the HyperFlow engine side, the Process Function is passed `context.taskStatus` function which can be used to wait for the notification. This function returns a [`Promise`](https://javascript.info/promise-basics), so the async/await syntax can be used as shown in the example.
8-
- The Process Function also gets the Redis URL in `context.redis_url` which can be passed to the remote executors.
6+
- `handler.js` gets `jobMessage` from Redis, and then sends back a notification that the job has completed; `taskId` is used to construct appropriate Redis keys.
7+
- On the HyperFlow engine side, the Process Function can use two functions: `context.sendMsgToJob` to send a message to the job, and `context.taskStatus` to wait for the notification. These functions return a [`Promise`](https://javascript.info/promise-basics), so the async/await syntax can be used as shown in the example.
98
- The parameter to the `context.taskStatus` function is a timeout in seconds (0 denotes infinity). One can use a retry library, such as [promise-retry](https://www.npmjs.com/package/promise-retry), to implement an exponential retry strategy.
9+
- The Process Function also gets the Redis URL in `context.redis_url` which can be passed to the remote job executors.
1010

11-
To run the workflow, simply do `hflow run .` in this directory.
11+
To run the workflow, simply do `hflow run .` in this directory. You might need to run once `npm install` to install dependencies.
1212

0 commit comments

Comments
 (0)