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

skej

v0.0.3

Published

OpenFaaS function scheduler, backed by Redis

Downloads

4

Readme

OpenFaaS

skej

a simple event schedular for OpenFaaS

Skej allows you to declaratively schedule events for OpenFaaS functions.

How To

Prerequisites

Redis should be running on port 6379. This is easy to do with docker

docker run -d -p 6379:6379 redis

skej will try to autoconfigure redis to support expiring keys, but you may need to use redis-cli if it doesn't cooperate.

$ redis-cli
> config set notify-keyspace-events Ex
Install
$ npm install skej
Import skej
const skej = require('skej')
Write the schedule

Declare your schedule as a JSON object.

There are two types of scheduled functions single and pipe. One off and recurring functions would fall under single and can be scheduled like so.

// index.js
const schedule = {
	single: [
		{
			name: 'func_nodeinfo',
			initialRun: 5,
			onFinished: x => console.log(x.body)
		},
		{
			name: 'func_echoit',
			data: 'hello world',
			initialRun: 2,
			recurring: 10,
			onFinished: x => console.log(x.body)
		},
	],
}

Notice that the func_echoit function has an addition property, recurring. If the function should run more than once, at a regular interval, set the recurring flag to the appropriate duration in seconds. skej will handle the rest.

Adding a chain of functions requires grouping functions as pipe functions. Give the 'pipeline' a name, include and initial data that should be passed to the first function, and list the function names under pipeline

// index.js
  ...
	pipe: [
		{
			name: 'test',
			data: '',
			initialRun: 8,
			pipeline: [
				'func_nodeinfo',
				'func_wordcount'
			],
			onFinished: x => console.log(x.body)
		}
	]
}

// wrap schedule in the skej() function
skej(schedule)

See the example.js file for the completed description.

Launching
node index.js
ToDo
  • Remove hardcoded gateway URL
  • Ability to schedule to same function multiple times, name and function name should be seperate properties
Additional

Give it a try and please submit issues as you have them.