New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

skyring

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skyring

Distributed timers as a service

  • 3.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-84.62%
Maintainers
1
Weekly downloads
 
Created
Source

skyring

Travis npm npm David Code Climate Docker Repository on Quay

Skyring

A distributed reliable timer service providing similar functionality to using setTimeout. Skyring servers are clustered into a hashring using consistent hashing to partition timers to specific nodes in the ring. Skyring exposes a simple HTTP API That allows to you create and cancel timers. Timer execution comes in to the form of an HTTP webhook ( more transports to come )

Architechture Overview

Install

npm install -s skyring

Run A Local Cluster

Start a nats instance

Download the nats binary and start it using the defaults

$ gnats -D -V

To verify that it is working, you can telnet directly to the server and ping it.

$ telnet localhost 42222
> ping
PONG

Skyring CLI

If you intend to run skyring as is, it may be preferable to use the included binary over cloning the project.

npm install -g skyring

DEBUG=skyring:* skyring run -p 3000 -s localhost:3456 -s localhost:3455

Clone Skyring

Alternatively to the CLI, you can clone and install the project manually

$ git clone https://github.com/esatterwhite/skyring.git
$ cd skyring
$ npm install
$ DEBUG=* node index.js

The default settings expect a minimum of 2 servers on port 3455 and 3456 respectively. Start each server in a different terminal session

# Seed node 1
$ DEBUG=skyring:* node index.js --channel:port=3455 -p 3000
# Seed node 2
$ DEBUG=skyring:* node index.js --channel:port=3456 -p 3001

If all goes well you should see a message like this

skyring:ring ring bootstraped [ '127.0.0.1:3455', '127.0.0.1:3456' ] +1ms

Thats it, you have 2 instances running w/ HTTP servers running on ports 3000 and 3001

Run via Docker Compose

The Easiest way to run a small cluster is to use the included compose files. It is also a good way to see how to quickly configure a cluster

$ npm start

That is it! You have a 5 node Skyring cluster with a 3 node nats cluster behind an nginx proxy listening on port 8080

Timer API

A request can be issued to any active node in the cluster. If that node is not responsible for the timer in question, it will forward the request directly to the node that is keeping network latency to a minimum. This makes Skyring very suitable for high performance, stateless, and distributed environments. The minimum recommended cluster size is 3 nodes, 2 of which being seed or bootstrapping nodes. A cluster of this size can average between 2K - 5K requests per second.

Create a timer

POST /timer

Request

curl -i -XPOST http://localhost:8080/timer -d '{
  "timout": 6000,
  "data" : "{\"foo\":\"bar\"}",
  "callback": {
    "transport": "http",
    "method": "post",
    "uri": "http://api.someservice.com/hook/timout"
  }
}'

Response Headers

For performance considerations, a body is not included in responses. Rather, HTTP headers are used to relay information about timer status. In the case of a Create request, the uri to the timer instance is returned in the Location header.

HTTP/1.1 201 CREATED
location: /timer/4adb026b-6ef3-44a8-af16-4d6be0343ecf
Date: Fri, 23 Dec 2016 00:19:13 GMT
Connection: keep-alive
Content-Length: 0

Cancel A Timer

DELETE /timer/:id

Request

curl -i -XDELETE http://localhost:8080/timer/4adb026b-6ef3-44a8-af16-4d6be0343ecf

Response Headers

HTTP/1.1 202 Accepted
Date: Fri, 23 Dec 2016 00:22:12 GMT
Connection: keep-alive
Content-Length: 0

FAQs

Package last updated on 14 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc