stream-url
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "stream-url", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"homepage": "http://github.com/gritzko/stream-url", | ||
@@ -5,0 +5,0 @@ "repository": { |
Stream URLs | ||
=========== | ||
unite two powerful universal concepts: streams and URLs | ||
`connect` | ||
`listen` | ||
The package aims to unite two powerful universal concepts: streams and | ||
URLs. It is mostly driven by desire to create modular istributed | ||
applications connected by asynchronous interfaces. | ||
Consider typical microservices. Those are connected by HTTP | ||
request-response calls thus emulating a synchronous call graph in a | ||
fundamentally asynchronous environment. Stream-connected | ||
architectures can be seen as distributed [go channels][go] instead. | ||
Streams allow to pipeline operations, provide flow control, and, most | ||
importantly, the concept of a stream is universal enough to use in | ||
very different settings. | ||
For example, one may use loopback streams for testing, filesystem sockets | ||
to connect local processes, WebSockets to pass data over the internet | ||
and raw TCP streams for low-overhead inner network transmissions. | ||
Considering isomorphic apps, inside the browser one may use postMessage | ||
(frame to frame) or WebStorage (tab to tab) based streams. | ||
This approach fits event sourcing architectures extremely well, as | ||
all app's events are well serializable then. | ||
So, stream-url encapsulates details of a particular medium and allows | ||
the app to open *data streams to URLs*. | ||
stream-url is a syntactic sugar, in a sense, or maybe even syntactic | ||
cocaine, but it definitely helps to clear a subsystem's code out of | ||
technical details and make it easily pluggable. | ||
## API | ||
* `listen(url [,options] [,callback])` start a server (stream factory) | ||
listening at the `url`, using `options`. Invoke `callback` when | ||
ready. The server will emit `connection` event for every new | ||
incoming connection/stream. | ||
* `connect(url [,options] [,callback])` connect to a server at (create | ||
a stream to) `url`. Invoke `callback` once ready to write. | ||
The stream will emit all the [usual events][stream]: | ||
`data`, `end`, `error`. | ||
[go]: https://gobyexample.com/channels | ||
[stream]: https://iojs.org/api/stream.html |
"use strict"; | ||
var url = require('url'); | ||
var adaptors; | ||
if (typeof(window)==='object') { | ||
adaptors = window.stream_url_adaptors = window.stream_url_adaptors || {}; | ||
} else { | ||
adaptors = process.stream_url_adaptors = process.stream_url_adaptors || {}; | ||
} | ||
// returns some "handler object" that has .close() method | ||
@@ -32,3 +39,2 @@ // and emits 'connection' event | ||
var adaptors = {}; | ||
@@ -35,0 +41,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5600
62
45