-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
373304e
commit b7d509f
Showing
18 changed files
with
826 additions
and
561 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
# enchannel-zmq-backend | ||
[](https://github.com/nteract/enchannel-zmq-backend/releases) | ||
[](https://github.com/nteract/enchannel/releases) | ||
[](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) | | ||
|
@@ -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 | ||
|
||
|
@@ -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` : | ||
|
@@ -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 [email protected] or post an issue on GitHub. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
Oops, something went wrong.