diff --git a/LICENSE.txt b/LICENSE.txt index a1640b6..0f7fd6a 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2013 Peter Elger +Copyright (c) 2014 jsChan Contributors, as listed in the README Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index e5f8f40..ca73d99 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,14 @@ # jsChan -### A Node.js port for docker/libchan +__jsChan__ is a Node.js port for docker/libchan based around node streams -__Warning: This project is still in the very early stages of development, and not usable yet__ +__Warning: This project is still in the very early stages of development, and not production ready yet__ + +## Install + +```bash +npm install jschan --save +``` ## Example @@ -24,7 +30,7 @@ session.on('channel', function server(chan) { function client() { // chan is a Writable stream - var chan = session.sendChannel(); + var chan = session.createWriteChannel(); var ret = chan.createReadChannel(); var called = false; @@ -43,26 +49,68 @@ function client() { client(); ``` -#### About LibChan + +## API + + * Session Interface + * Channel Interface + * jschan.memorySession() + * session.createWriteChannel() + * channel.createReadChannel() + * channel.createWriteChannel() + * channel.createBinaryStream() + +------------------------------------------------------- + +### Session Interface + +------------------------------------------------------- + +### Channel Interface + +------------------------------------------------------- + +### jschan.memorySession() + +------------------------------------------------------- + +### session.createWriteChannel() -It's most unique characteristic is that it replicates the semantics of go channels across network connections, while allowing for nested channels to be transferred in messages. This would let you to do things like attach a reference to a remote file on an HTTP response, that could be opened on the client side for reading or writing. +------------------------------------------------------- + +### channel.createReadChannel() -The protocol uses SPDY as it's default transport with MSGPACK as it's default serialization format. Both are able to be switched out, with http1+websockets and protobuf fallbacks planned. +------------------------------------------------------- + +### channel.createWriteChannel() -While the RequestResponse pattern is the primary focus, Asynchronous Message Passing is still possible, due to the low level nature of the protocol. +------------------------------------------------------- + +### channel.createBinaryStream() -### About Graft +## About LibChan -The Graft project is formed to explore the possibilities of a web where servers and clients are able to communicate freely through a microservices architecture. +It's most unique characteristic is that it replicates the semantics of go channels across network connections, while allowing for nested channels to be transferred in messages. This would let you to do things like attach a reference to a remote file on an HTTP response, that could be opened on the client side for reading or writing. -> "instead of pretending everything is a local function even over the network (which turned out to be a bad idea), what if we did it the other way around? Pretend your components are communicating over a network even when they aren't." +The protocol uses SPDY as it's default transport with MSGPACK as it's default serialization format. Both are able to be switched out, with http1+websockets and protobuf fallbacks planned. + +While the RequestResponse pattern is the primary focus, Asynchronous Message Passing is still possible, due to the low level nature of the protocol. + +## About Graft + +The Graft project is formed to explore the possibilities of a web where servers and clients are able to communicate freely through a microservices architecture. + +> "instead of pretending everything is a local function even over the network (which turned out to be a bad idea), what if we did it the other way around? Pretend your components are communicating over a network even when they aren't." > [Solomon Hykes](http://github.com/shykes) (of Docker fame) on LibChan - [[link]](https://news.ycombinator.com/item?id=7874317) [Find out more about Graft](https://github.com/GraftJS/graft) - -#### Contributors +## Contributors * [Adrian Rossouw](http://github.com/Vertice) * [Peter Elgers](https://github.com/pelger) * [Matteo Collina](https://github.com/mcollina) + +## License + +MIT diff --git a/example.js b/example.js index 1b4d81a..a08e1c6 100644 --- a/example.js +++ b/example.js @@ -14,7 +14,7 @@ session.on('channel', function server(chan) { }); function client() { - var chan = session.sendChannel(); + var chan = session.createWriteChannel(); var ret = chan.createReadChannel(); var called = false; diff --git a/lib/memorySession.js b/lib/memorySession.js index 686a006..eeeadc4 100644 --- a/lib/memorySession.js +++ b/lib/memorySession.js @@ -84,7 +84,7 @@ function MemorySession(server) { util.inherits(MemorySession, EventEmitter); -MemorySession.prototype.sendChannel = function sendChannel() { +MemorySession.prototype.createWriteChannel = function createWriteChannel() { var chan = new MemoryChannel(this); var count = EventEmitter.listenerCount(this, 'channel'); diff --git a/test/abstract_session.js b/test/abstract_session.js index 1203bfe..50e5d2b 100644 --- a/test/abstract_session.js +++ b/test/abstract_session.js @@ -17,7 +17,7 @@ module.exports = function abstractSession(inBuilder, outBuilder) { describe('basic reply subChannel', function() { function client(done) { - var chan = outSession.sendChannel(); + var chan = outSession.createWriteChannel(); var ret = chan.createReadChannel(); ret.on('data', function(res) { @@ -68,7 +68,7 @@ module.exports = function abstractSession(inBuilder, outBuilder) { describe('write subChannel', function() { function client() { - var chan = outSession.sendChannel(); + var chan = outSession.createWriteChannel(); var more = chan.createWriteChannel(); chan.write({ @@ -125,7 +125,7 @@ module.exports = function abstractSession(inBuilder, outBuilder) { describe('binaryStream', function() { function client(done) { - var chan = outSession.sendChannel(); + var chan = outSession.createWriteChannel(); var bin = chan.createBinaryStream(); chan.write({