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

asdaasbdjasbdbasdbashjdbashjbdhajsbdjashbdlasdsdasd

v0.8.0

Published

Zenaton library

Downloads

4

Readme

Zenaton library for Node

Zenaton helps developers to easily run, monitor and orchestrate background jobs on your workers without managing a queuing system.

Build workflows using Zenaton functions to build control flows around your busines logic and tasks - managing time, events and external services within one class. The zenaton engine orchestrates the timing of executions on your workers. Functions include 'wait for a specific time or event', 'react to external events', 'run parallel tasks, 'create schedules' and more all by writing one line of code. More about Zenaton Functions

Key capabilities: Single Tasks - dispatch or schedule an asyncbusiness hronous job with just one line of code Workflows as code - Combine Zenaton functions and Node.js to create infinite possibilities of logic. Real time Monitoring - Get a real time view of workers and tasks - scheduled, processing and executed. Scheduler - Schedule recurrent tasks and workflows and automatically retry tasks that fail or get alerts when there are errors or timeouts. Error Handling: - Alerts for errors and timeouts and retry, resume or kill processes. React to errors by writing logic into workflow code to trigger retries or other actions.

You can sign up for an account on Zenaton and go through the tutorial in Node.

Node Documentation

You can find all details on Zenaton's website.

Requirements

Node 8 and later.

Getting started

Installation

Install the Zenaton Agent

To install the Zenaton agent, run the following command:

curl https://install.zenaton.com/ | sh

Install the library

To add the latest version of the library to your project, run the following command:

npm install zenaton --save

TypeScript typings

For Typescript developers:

npm install @types/zenaton --save-dev

Quick start

Client Initialization

To start, you need to initialize the client. To do this, you need your Application ID and API Token. You can find both on your Zenaton account.

Then, initialize your Zenaton client:

/* client.js */

const { Client } = require("zenaton");

module.exports = new Client(
  "YourApplicationId",
  "YourApiToken",
  "YourApplicationEnv", // Use "dev" as default
);

Boot file

The next step is to have your Zenaton Agent listen to your application.

The Agent needs to be pointed to a boot file which will allow it to infer your programming language (here JavaScript) but also to figure out where your jobs are located when the time comes to run them.

/* boot.js */

// Import here all your tasks and workflows as you go
// require("./tasks/HelloWorldTask");
// require("./workflows/MyFirstWorkflow");

To run the listen command:

zenaton listen --app_id=YourApplicationId --api_token=YourApiToken --app_env=YourApplicationEnv --boot=boot.js

Executing a background job

A job in Zenaton is created through the Task function.

Let's start by implementing a first task printing something, and returning a value:

/* tasks/HelloWorldTask.js */
const { task } = require("zenaton");

module.exports = task("HelloWorldTask",
  async function handle(name="World") {
    return `Hello ${name}`!;
  }
);

Now, when you want to run this task as a background job, you need to do the following:

/* launchHelloWorldTask.js */
const { run } = require("./client.js");

run.task("HelloWorldTask", "Me");

That's all you need to get started. With this, you can run many background jobs. However, the real power of Zenaton is to be able to orchestrate these jobs. The next section will introduce you to job orchestration.

Orchestrating background jobs

Job orchestration is what allows you to write complex business workflows in a simple way. You can execute jobs sequentially, in parallel, conditionally based on the result of a previous job, and you can even use loops to repeat some tasks.

We wrote about some use-cases of job orchestration, you can take a look at these articles to see how people use job orchestration.

Using workflows

A workflow in Zenaton is created through the workflow function.

We will implement a very simple workflow that will execute sequentialy the HelloWorld task 3 times.

One important thing to remember is that your workflow implementation must be idempotent. You can read more about that in our documentation.

The implementation looks like this:

/* workflows/MyFirstWorkflow.js */
const { Workflow } = require("zenaton");

module.exports = workflow("MyFirstWorkflow", function* handle(name) {
  yield this.run.task("HelloWorldTask", name);
  yield this.run.task("HelloWorldTask", "Me");
  yield this.run.task("HelloWorldTask", "All");
});

Now that your workflow is implemented, you can ask for its processing like this:

/* launchMyFirstWorkflow.js */
const { run } = require("./client.js");

run.workflow("MyFirstWorkflow", "Gilles");

There are many more features usable in workflows in order to get the orchestration done right. You can learn more in our documentation.

Getting help

Need help? Feel free to contact us by chat on Zenaton.

Found a bug? You can open a GitHub issue.