Last active
June 20, 2017 18:59
-
-
Save stephenplusplus/d95b525964495293c24830ed6452e5b9 to your computer and use it in GitHub Desktop.
grpc-request.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var pumpify = require('pumpify') | |
| var through = require('through2') | |
| function makeGrpcStreamingRequest() { | |
| var transformStream = through.obj(function(obj, enc, next) { | |
| obj.transformed = true | |
| next(null, obj) | |
| }) | |
| var grpcRequestStream = through.obj() | |
| return pumpify.obj(transformStream, grpcRequestStream) | |
| } | |
| var stream = makeGrpcStreamingRequest() | |
| stream.on('data', console.log) | |
| var request = { | |
| configurationSetting: true, | |
| anotherSetting: false | |
| } | |
| stream.write(request) | |
| var anotherRequest = { | |
| configurationSetting: false, | |
| anotherSetting: true | |
| } | |
| stream.write(anotherRequest) | |
| stream.end() | |
| // Actual requests sent (output from `console.log`): | |
| // { | |
| // configurationSetting: true, | |
| // anotherSetting: false, | |
| // transformed: true | |
| // } | |
| // | |
| // { | |
| // configurationSetting: false, | |
| // anotherSetting: true, | |
| // transformed: true | |
| // } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment