Comments (19)
imo this is a fairly obvious footgun — things like writing startup messages immediately and such should be simple.
from godot.
@nathan7 agreed, I will make it handle those cases.
from godot.
-1 to generic buffering, but +1 to pre-connect buffering.
from godot.
Why should those have radically different semantics, @indexzero?
from godot.
I don't think they do. Let me rephrase: godot should never do any buffering. The "pre-connect buffering" I was referring to would be the godot instance writing immediately to a net TCP or UDP stream which (thanks to streams2 and streams3) does the buffering for us if we haven't yet connected.
from godot.
Yes. Going to close this. We should always write immediately which will be easily buffered by Socket instances returned from net.connect
from godot.
@indexzero i brought this up for the case of before we have created a socket but we have a godot client instance.
from godot.
Sockets are instantly created by node. They may not immediately connect, but their internal buffering mechanism is available immediately:
var sock = net.connect('127.0.0.1', 7731);
from godot.
Hmm, I'm thinking the godot client itself should just be a simple stream itself and auto connect when initialized to prevent the need for this
from godot.
@indexzero yes but godot.createClient(options)
does not create a socket. this is the behavior I want to change.
from godot.
Oh yeah? Well that's definitely worth changing.
from godot.
Mmmmmmm ... I see the problem here. Maybe we should change the syntax from
var client = godot.createClient(options);
to
var client = godot.connect(options);
The difference in semantics here is subtle but important. Overall my goal here is to push the buffering logic onto core as much as possible.
from godot.
@indexzero yea i like it. keeps us semantically the same as core and gives an easy way to remove the connect method from the internal client prototype since we would just be constructing a client instance.
from godot.
I would actually say keep the connect method on the client instance. The semantic in the docs would be:
How does Buffering work in godot?
Both the server and client instances of godot do no internal buffering themselves. For connected clients buffering is performed by Node.js core net and dgram modules. Connected clients are created by calling:
var client = godot.connect(options);
Or
var client = godot.createClient(options);
I'm not opposed to dropping createClient and the connect prototype method, but we should evaluate if we want to make that kind of breaking change first.
from godot.
Can't edit the comment from my phone but the second code sample above should be:
var client = godot.createClient(options);
clients.connect();
from godot.
@indexzero we could technically keep it but just have it called in the constructor if we truly want to have buffering handled by the tcp socket (udp won't buffer since its not a stream). I personally say its worth it for simplicity and add it as an extra addition to v1 as we are still in dev there.
The other piece I'm thinking about is having var client = godot.connect()
return an actual stream we can pipe to. This would allow us to hook in buffering for udp if we wanted or we just make it a simple streams1 stream and just have the convenience of a simple pipe. This would just make everything semantically the same which I think would be quite nice.
from godot.
Do we want to go so far as to implement a fully buffered WritableStream instance in godot?
from godot.
@indexzero I'm thinking yes, but at the very least it should be a streams1 stream. From a method standpoint it already meets the requirement.
from godot.
the client is the only place i see it making sense.
from godot.
Related Issues (20)
- Make it possible to listen on UNIX sockets HOT 1
- client.close() does not clear producer intervals HOT 2
- .by(<key>, reactor()) HOT 1
- .diff() HOT 1
- Client reconnect and backoff HOT 1
- How to set sendgrid details ? HOT 4
- Add configuration for emitter.setMaxListeners HOT 3
- Add tests to ensure errors are handled correctly in the reactor pipe chain HOT 1
- [needs investigation] Error listener is only called once. HOT 1
- Scaling rollup HOT 1
- Should work on node 0.10 HOT 4
- Producer event emiting HOT 3
- Error propagation can stall stream HOT 2
- Replace `node-backoff` with a simpler module, `back`
- Add a reactor::error event
- godot needs a new API HOT 3
- .connect(callback) fails
- Is this project still alive ?
- Perhaps rename HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godot.