async-monitor.js v1.1.13
async-monitor.js
(pseudo code)
<script>
const watches = new Group();
watches.addWatch({
parent: undefined,
child: 'a',
f: function_to_watch
});
...watches.addWatch();
console.log(watches.tree);
watches.watchAll()
.then(()=>console.log('All went well!'))
.catch(()=>console.log('Oops, at least 1 promise was rejected!'));
</script>
<pre>
── preparation step
├─ fetch data from ETL store: s1, fetch data from ETL store: s2
│ └─ build snowflake s1 and s2
│ └─ publish snowflake s1 and s2 ───────────────────────────┐
└─ fetch data from ETL store: s3 │
└─ build snowflake from s3 │
└─ publish snowflake s3 ──────────────────────────────────┤
└─ completed
</pre>
Features
A lightweight and efficient monitoring engine designed to seamlessly track and manage hierarchically organized asynchronous JavaScript functions. Perfect for developers looking to streamline and gain insights into complex async workflows, ensuring reliable performance and easy debugging.
new in v1.1
The watchAll
function is now an async
function. This enhancement allows you to nest groups as needed and utilize then
, catch
, and finally
for improved functionality and better control over your asynchronous workflows.
Examples
Explore various examples showcasing random hierarchies of asynchronous functions, graphically represented for better understanding and visualization. These examples demonstrate the flexibility and robustness of the monitoring engine in handling complex async workflows, making it easier to debug and optimize your code.
For demonstration purposes, an asynchronous function sleep(seconds, fail)
is used to simulate an async operation. This function helps illustrate how the monitoring engine handles asynchronous tasks.
seconds
: The number of seconds to wait before resolving (default is a random number between 0 and 3).fail
: A boolean indicating whether the function should reject (default isfalse
). If undefined, there is a 50% chance of rejection.returns
: A promise that resolves after the specifiedseconds
or rejects based on thefail
condition.
In example 'demo04', descriptions ending with double exclamation marks (!!) contain a sleep
function that is likely to reject. This highlights the monitoring engine's ability to handle and report failed asynchronous operations effectively.
Tests
npm install
To run the tests run:
npm test
If you want to add any feature or change existing features, you must run the
tests to make sure you didn't break anything else. Any pull request (PR) needs
to have updated passing tests for feature changes (or new passing tests for new
features or fixes) in src/<file>.test.ts
to be accepted. See
People
Maintainers: Manu Vanneste.
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago