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 🙏

© 2026 – Pkg Stats / Ryan Hefner

karya-client

v1.1.7

Published

Client to interract with Karya, the open sourced distributed job scheduler

Readme

Karya Javascript Client

This here is the Javascript client to interract with Karya - the open sourced distributed job scheduler


Getting Started

This section highlights the steps to get started with the Karya Python client.

Installation

Download the client as a dependency from npm

    npm install karya-client

The distribution files can also be found here - Github Release.

Useage Examples

A list of samples to configure different plans with various actions and hooks can be found here

Using the Client

  1. Create a config object:

     import { ClientConfig } from 'karya-client/client/config.js';
    
    ## point this to where the Karya server is running
    const config = new ClientConfig(new URL('http://localhost:8080'));
    
    ## For localsetup, a default config is provided as: ClientConfig.dev()
  2. Create a client object:

     import { KaryaRestClient } from 'karya-client/client/karya-rest-client.js';
    
     const client = new KaryaRestClient(config);
  3. Creat a user. Only a user configured in the Karya server can be used to create a client object.

    import { CreateUserRequest } from 'karya-client/client/requests.js';
       
    const create_user_request = new CreateUserRequest({name: "javascript-client"});
    const user = await client.create_user(create_user_request);
  4. Specify the action that you would want to trigger once the task is scheduled.

    import { RestApiRequest } from 'karya-client/entities/actions.js';
    import { Protocol, Method } from 'karya-client/entities/constants.js';
    
    const restAction = new RestApiRequest(
    'localhost', // The base URL for the REST API request
    new RestApiRequest.JsonBody({ message: 'Hello from typescript client' }), // JSON body for the request
    Protocol.HTTPS, // The protocol to be used for the request (HTTPS)
    Method.POST, // The HTTP method to be used (POST)
    { 'content-type': 'application/json' }, // HTTP headers for the request
    2000, // Timeout for the request in milliseconds (2 seconds)
    );
  5. Submit the plan to Karya.

    period_time has to be in the ISO 8601 format.

     import { SubmitPlanRequest } from 'karya-client/client/requests.js';
     import { Recurring } from 'karya-client/entities/plan-types.js';
    
    const request = new SubmitPlanRequest(
         user.id, // The user ID for the plan
         'recurring api plan', // The description of the plan
         'PT7S', // The period time (in ISO 8601 duration format) for the recurring plan
         new Recurring(Date.now() + 10000), // Recurring plan type with an end date 10 seconds from now
         restAction, // The REST API action to be executed
     );
     const plan = await client.submitPlan(request);
  6. And you're done! The plan will be executed as per the schedule:

    • The action will be triggered every 7 seconds.
    • The action will make a POST request to localhost with the JSON body {"message": "Hello from python client"}
    • The request will have a timeout of 2 seconds.

Plan Type

Karya supports the following plan types:

One Time

This can be used to trigger a delayed action.

import { OneTime } from 'karya-client';

const oneTime = new OneTime();

Recurring

This can be used to trigger an action at regular intervals.

import { Recurring } from 'karya-client';

const recurring = new Recurring(Date.now() + 10000);

Actions

Actions define what Karya should do once it has to execute the plan. The client supports the following actions:

REST API Request

Make a REST API request to a specified URL with the given parameters.

import { RestApiRequest, Protocol, Method } from 'karya-client';

const restAction = new RestApiRequest(
    'localhost', // The base URL for the REST API request
    new RestApiRequest.JsonBody({ message: 'Hello from typescript client' }), // JSON body for the request
    Protocol.HTTPS, // The protocol to be used for the request (HTTPS)
    Method.POST, // The HTTP method to be used (POST)
    { 'content-type': 'application/json' }, // HTTP headers for the request
    2000, // Timeout for the request in milliseconds (2 seconds)
);

Push to Kafka

Push a message to a Kafka topic.

import { KafkaProducerRequest } from 'karya-client';

const kafkaAction = new KafkaProducerRequest(
    'kafka-topic', // The Kafka topic to push the message to
    'Hello from typescript client', // The message to be pushed
);

Send Email

Send an email to a specified email address.

import { EmailRequest } from 'karya-client';

const emailAction = new EmailRequest(
    '[email protected]', // The recipient's email address
    'Hello from karya typescript client', // The subject of the email
    'Hello', // The body of the email
);

Send a Slack Message

Send a message to a specified Slack channel.

import { SlackMessage } from 'karya-client';

const slackAction = new SlackMessage(
    'slack-channel', // The Slack channel to send the message to
    'Hello from typescript client', // The message to be sent
);

Chain another job

Chain another job to the current job.

import { ChainedRequest  } from 'karya-client';

const chained_action = new ChainedRequest(
  new SubmitPlanRequest(
    user.id, // The ID of the user for whom the plan is being created
    'recurring api plan', // A description of the plan
    'PT7S', // The period time (7 seconds)
    new Recurring(Date.now() + 10000), // The plan type (Recurring), with an end time in 10 seconds
    new RestApiRequest('eox7wbcodh9parh.m.pipedream.net'), // The action for the plan (sending an API request)
  ),
);

Hooks

import { Hook, HookType } from 'karya-client';

const hook = new Hook(
    HookType.ON_FAILURE, // The type of hook (ON_FAILURE)
    restAction, // The action to be triggered
);

Hooks are used to trigger actions on certain triggers. The client supports the following hooks:

  • ON_FAILURE: Trigger an action when the plan fails.
  • ON_COMPLETION: Trigger an action when the plan completes successfully.