GithubHelp home page GithubHelp logo

Expose .createStream() about axon HOT 7 OPEN

tj avatar tj commented on May 17, 2024
Expose .createStream()

from axon.

Comments (7)

gjohnson avatar gjohnson commented on May 17, 2024

Probably not, @visionmedia can correct me but exposing the stream (for the use of composing new streams) wouldn't really mesh well with the protocol, really even with the messaging paradigm in general because of the whole <length> + <body>.

from axon.

tj avatar tj commented on May 17, 2024

I dont recall us even having a .createStream() anywhere

from axon.

juliangruber avatar juliangruber commented on May 17, 2024

I just wondered if it would be possible. I want to use axon-rcp for auth stuff and thus need encryption, that's my use case...

from axon.

gjohnson avatar gjohnson commented on May 17, 2024

Yeah, I assumed @juliangruber meant add one to the api. Like mongoose or something, ala:

subSocket.stream().pipe(whatever);

Right?

from axon.

juliangruber avatar juliangruber commented on May 17, 2024

server:

var rpc = require('axon-rpc')
  , axon = require('axon')
  , rep = axon.socket('rep')
  , net = require('net');

var server = new rpc.Server(rep);

// instead of this: rep.bind(4000);

net.createServer(function (socket) {
  socket.pipe(server.createStream()).pipe(socket)
}).listen(4000)

client:

var rpc = require('axon-rpc')
  , axon = require('axon')
  , req = axon.socket('req')
  , net = require('net');

var client = new rpc.Client(req);
var clientStream = client.createStream();

// with the net module
clientStream.pipe(net.connect(4000)).pipe(clientStream());

// or with dominictarr's reconnect:
reconnect(function (stream) {
  clientStream.pipe(stream).pipe(clientStream)
}).connect(4000)

This way you make it transport agnostic and it will also work in the browser over websockets, or whatevs!

from axon.

tj avatar tj commented on May 17, 2024

im fine with it as long as:

  • a) we dont overly complicate internals to abstract out accepting socket connections etc
  • b) we dont change the existing default api
  • c) performance is retained

though personally there wouldn't really be many use-cases to use it for anything but regular tcp, not all transports have the same capabilities, via stdin etc would be leaky

from axon.

CoderPuppy avatar CoderPuppy commented on May 17, 2024

👍

from axon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.