Skip to content

Commit

Permalink
Migrate contents from monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
captainsafia committed Mar 18, 2020
1 parent 373304e commit b7d509f
Show file tree
Hide file tree
Showing 18 changed files with 826 additions and 561 deletions.
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

56 changes: 47 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# enchannel-zmq-backend
[![GitHub release](https://img.shields.io/badge/enchannel--zmq--backend-version--latest-blue.svg)](https://github.com/nteract/enchannel-zmq-backend/releases)
[![enchannel spec version](https://img.shields.io/badge/enchannel%20spec-version%201.1-ff69b4.svg)](https://github.com/nteract/enchannel/releases)
[![Greenkeeper badge](https://badges.greenkeeper.io/nteract/enchannel-zmq-backend.svg)](https://greenkeeper.io/)

:warning: :warning: Moved to the [nteract/nteract monorepo](https://github.com/nteract/nteract/tree/master/packages/enchannel-zmq-backend) :warning: :warning:

[**Installation**](#installation) | [**Usage**](#usage) |
[**Contributors and developers**](#contributors-and-developers) |
Expand Down Expand Up @@ -51,7 +46,13 @@ That's it. Functions for four channels; *simplicity in action*.

Prerequisite: [Node.js and npm](https://docs.npmjs.com/getting-started/installing-node)

`npm install enchannel-zmq-backend`
You may use whichever package manager (`npm` or `yarn`) best suits your workflow. The `nteract` team internally uses `yarn`.

```bash
npm install enchannel-zmq-backend
# OR
yarn add enchannel-zmq-backend
```

## Usage

Expand Down Expand Up @@ -100,6 +101,43 @@ const channels = createChannels(identity, runtimeConfig)
const { shell, iopub, stdin, control } = channels;
```

`enchannel-zmq-backend` also gives access to all of the `channels` via a
single multipled channel exposed via `createMainChannel`.

```javascript
import { createMainChannel } from 'enchannel-zmq-backend';
```

Similar to the `createChannels` function, the `createMainChannel` function
accepts both an identity and a runtime object.

```javascript
const channel = createMainChannel(identity, runtimeConfig);
```

Messages that are sent via the mutliplexed channel need to define a `type`
property that outlines which channel they should be sent under.

```javascript
const body = {
header: {
msg_id: `execute_9ed11a0f-707e-4f71-829c-a19b8ff8eed8`,
username: "rgbkrk",
session: "00000000-0000-0000-0000-000000000000",
msg_type: "execute_request",
version: "5.0"
},
content: {
code: 'print("woo")',
silent: false,
store_history: true,
user_expressions: {},
allow_stdin: false
}
};
const message = { type: "shell", body };
```

`enchannel-zmq-backend` also offers four convenience functions to
easily create the messaging channels for `control`, `stdin`, `iopub`,
and `shell` :
Expand Down Expand Up @@ -220,17 +258,17 @@ Then, fork and clone this repo:
```bash
git clone https://github.com/nteract/enchannel-zmq-backend.git
cd enchannel-zmq-backend
npm install
yarn
```
Develop! We welcome new and first time contributors.
## Learn more about nteract
- Visit our website http://nteract.io/.
- Visit our website https://nteract.io/.
- See our organization on GitHub https://github.com/nteract
- Join us on [Slack](http://slack.nteract.in/) if you need help or have
- Join us on [Slack](https://slack.nteract.io/) if you need help or have
questions. If you have trouble creating an account, either
email rgbkrk@gmail.com or post an issue on GitHub.
Expand Down
50 changes: 50 additions & 0 deletions __mocks__/jmp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { EventEmitter } from "events";
import * as jmp from "jmp";

class Socket extends EventEmitter {
throttle = false;

constructor(public type: any, public scheme: any, public key: any) {
super();
}

monitor() {}
unmonitor() {}
connect() {
if (this.throttle) {
setTimeout(() => this.emit("connect"), 0);
} else {
this.emit("connect");
}
}
close() {}
}

interface MessageProperties {
idents: any[];
header: object;
parent_header: object;
metadata: object;
content: object;
buffers: Uint8Array | null;
}

class Message {
idents: any[];
header: object;
parent_header: object;
metadata: object;
content: object;
buffers: Uint8Array | null;

constructor(properties: Partial<MessageProperties>) {
this.idents = (properties && properties.idents) || [];
this.header = (properties && properties.header) || {};
this.parent_header = (properties && properties.parent_header) || {};
this.metadata = (properties && properties.metadata) || {};
this.content = (properties && properties.content) || {};
this.buffers = (properties && properties.buffers) || new Uint8Array();
}
}

export { Message, Socket };

0 comments on commit b7d509f

Please sign in to comment.