Refactoring Client to extend Stream.
See original GitHub issueI think client should be build on top of a stream.
so you can do
client.pipe(fs.createWriteStream('protocol.log'))
client.pipe(new Transform({ writableObjectMode: true, transform(chunk, enc, cb) {
this.push(JSON.stringify(chunk,null,2);
cb();
}})).pipe(fs.createWriteStream('protocol.log'));
stream -> [ serializer ] -> [ compressor ] -> framer -> [ cipher ] -> socket
socket -> [ decipher ] -> splitter -> [ decompressor ] -> deseralizer -> stream
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
dmcg/refactoring-to-streams - GitHub
The general workflow while refactoring towards Streams and lambda expressions is like that: Start by replacing the Iterable in the extended for loop...
Read more >Optimize Java 8 Streams Refactoring Tool Demonstration
Streaming APIs are pervasive in mainstream Object-Oriented languages and platforms. For example, the Java 8 Stream API allows for ...
Read more >Safe Automated Refactoring for Intelligent Parallelization of ...
We present a novel refactoring approach for maximizing the efficiency of their Java 8 stream code by automatically determining when it is safe...
Read more >Kayak: Safe Semantic Refactoring to Java Streams
ABSTRACT. Refactorings are structured changes to existing software that leave its externally observable behaviour unchanged. Their intent is to im-.
Read more >A Tool for Optimizing Java 8 Stream Software via Automated ...
for optimizing their stream code to its full potential. Index Terms—refactoring, automatic parallelization, typestate analysis, ordering, Java 8, streams, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah now I see @roblabla point. Yes you still won’t be able to do
directly.
But you will be able to do
well the serializer readable part is object mode https://github.com/ProtoDef-io/node-protodef/blob/master/src/serializer.js#L5 I don’t think that’s a problem.
The difference between the deserializer and your “stream” is only that that “stream” would handle all the states, hence the user of the stream wouldn’t need to care about states.
That just means piping and unpiping the serializer and deserializer to that stream on change of state.
I guess we could then just listen on data of that stream to emit packet event, and write on that stream instead of writing directly on the serializer (for nmp client and server implementation). And expose the stream for people that want to use it directly.