npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

workflow-simulator

v0.1.0

Published

A npm module to monitor the progress of chained task in real-time

Downloads

2

Readme

Workflow Simulator

A clould service and a npm module is to monitor the state changes of chained task in real-time. It also provides an interface to connect with the cloud service which is hosted on http://workflow-simulator.herokuapp.com/.

Installing

WorkflowSimulator runs on Node.js and is available as an NPM package. You can install WorkflowSimulator in your project's directory as usual:

npm install --save workflow-simulator

Usage

Initializing the connection

First, you need to initialize an object of WSClient in order to establish a connection with the cloud service. You should have permission to initialize the connection.

const { WSClient } = require("workflow-simulator");

const client = new WSClient({
    host: "-- url to cloud service --",
    secretKey: "-- secret key --",
    groupId: "-- identifier of the task group --"
});

Listening to events

You can listen to events such as connect and disconnect using the initialized client.

// connect
client.on("connect", function() {
    // triggered when the connection is established with the cloud service
});

// disconnect
client.on("disconnect", function() {
    // triggered when the connection is closed with the cloud service
});

Add a listener

You can listen to the state changes, errors, and messages which is related to the chained task mentioned when initializing the WSClient.

client.addListener((error, message) => {
    if (error) {
        return console.log(error);
    }
    console.log(message);
}, (err) => {
    console.log(err);
    client.close();
});

Create a subroutine in the chained task

Subroutines or tasks can be add to the chained task using the initialized client as follows.

client.createTask({
    taskId: "T009",
    groupId: "G001",
    name: "Test",
    description: "Test",
    progress: 0,
    predecessors: ["T003"]
}, (err, res) => {
    if(err){
        return console.log(err);
    }
    console.log(res);
});

update the progress of a task or a subroutine

The state changes occurred when the progress of a task or a subroutine is updated. You also notify the all clients when a state is changed.

client.updateProgress({
    taskId: "T002",
    groupId: "G001",
    progress: 10
}, (err, res) => {
    if(err){
        return console.log(err);
    }
    console.log(res);
});

Notify an error

When a subroutine is executed, errors may occur and it is requires to notify all the client about the error.

client.notifyError({
    timestamp: new Date().getTime(),
    groupId: "G001",
    name: "Info",
    message: "Test Message"
}, (err, res) => {
    if(err){
        return console.log(err);
    }
    console.log(res);
});

Get all the tasks or subroutines

You can get the details of all the task in the chained tasks as follows.

client.getAllTasks((err, res) => {
    if(err){
        return console.log(err);
    }
    console.log(res);
});

Advanced guides and docs

You can refer the API on /* url */ for more details