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

enchannel-socketio-backend

v0.1.0

Published

enchannel powered by socket.io, to be used with kernel-relay

Downloads

4

Readme

enchannel-socketio-backend

enchannel version

:electric_plug: enchannel powered by socket.io, designed to be used with kernel-relay.

Installation

npm install enchannel-socketio-backend

Usage

Enchannel-socketio-backend provides an API for spawning, disconnecting, and shutting down remote kernels in addition to implementing the enchannel spec. A typical use would be to spawn a kernel, connect to the kernel and communicate using enchannel and Jupyter message specs, disconnect from the kernel, and optionally shut it down.

The act of connecting and disconnecting is deliberately separate to the act of spawning and shutting down a kernel. This allows one to spawn a kernel, start some compute on it, disconnect and reconnect at a later time, and shutdown the kernel when appropriate.

To use the enchannel-socketio-backend, you must have access to a running kernel-relay server.

spawn

Spawns a remote kernel by name. Takes two arguments:

  • endpoint, string - remote endpoint of the kernel-relay server
  • kernelName, string - name of the kernel to spawn

Returns a promise with the kernel id, string.

spawn(endpoint, kernelName)

Usage example

const enchannelBackend = require('enchannel-socketio-backend');
enchannelBackend.spawn('http://localhost:3000/', 'python3').then(id => {
  console.log('spawned', id);
}).catch(err => {
  console.error('Could not spawn the kernel', err);
});

connect

Connects to a remote kernel by id. Accepts two arguments:

  • endpoint, string - remote endpoint of the kernel-relay server
  • kernelId, string - id of the kernel to connect to

Returns a promise for an enchannel spec channels object

connect(endpoint, kernelId)

Usage example

enchannelBackend.connect('http://localhost:3000/', id).then(channels => {
  console.log('connected', channels);
}).catch(err => {
  console.error('Could not connect to the kernel', err);
});

For API usage of the enchannel channels object, refer to the enchannel spec README.

shutdown

Shuts down a remote kernel by id. Accepts two arguments:

  • endpoint, string - remote endpoint of the kernel-relay server
  • kernelId, string - id of the kernel to shutdown

Returns a promise which resolves when the shutdown is complete.

shutdown(endpoint, kernelId)

Usage example

enchannelBackend.shutdown('http://localhost:3000/', id).then(() => {
  console.log('shutdown');
}).catch(err => {
  console.error('Could not shutdown the kernel', err);
});

disconnect

Disconnects from a kernel by closing the channels. Accepts one argument, the enchannel channels object.

Returns promise which resolves on success.

disconnect(channels)

Usage example

enchannelBackend.disconnect(channels).then(() => {
  console.log('disconnected');
}).catch(err => {
  console.error('Could not close the channels', err);
});

Development

To develop against enchannel-socketio-backend, first clone the repo then from within the cloned folder run:

npm install
npm link

Before opening a pull request, please run the unit tests locally:

npm test