grpc.io icon indicating copy to clipboard operation
grpc.io copied to clipboard

Node.js basics: `Reader` interface or `Readable` interface

Open souris-dev opened this issue 4 years ago • 4 comments

While going through the docs for Node.js basics tutorial, I found a slight inconsistency. Under the subsection "Implementing RouteGuide", it says the following under the listFeatures(call) function definition code:

As you can see, instead of getting the call object and callback in our method parameters, this time we get a call object that implements the Writable interface. In the method, we create as many Feature objects as we need to return, writing them to the call using its write() method. Finally, we call call.end() to indicate that we have sent all messages.

If you look at the client-side streaming method RecordRoute you’ll see it’s quite similar to the unary call, except this time the call parameter implements the Reader interface. The call’s 'data' event fires every time there is new data, and the 'end' event fires when all data has been read. Like the unary case, we respond by calling the callback...

In the first paragraph, the name of the interface is Writable, while in the second paragraph it is the Reader interface. For clarification, I looked at the example code referenced in this article, where the word Readable has been used.

Is Reader something separate, or is it just a minor inconsistency? If it's the latter, I would be happy to fix it (that is, if Readable was the intended name.)

souris-dev avatar Oct 17 '21 11:10 souris-dev

CC @murgatroid99

gnossen avatar Oct 27 '21 17:10 gnossen

Yes, it's supposed to be Readable. Specifically, this is referring to Node's built in stream.Writable and stream.Readable classes.

murgatroid99 avatar Oct 27 '21 18:10 murgatroid99

@murgatroid99, you can change https://github.com/grpc/grpc.io/blob/main/content/en/docs/languages/node/basics.md

ejona86 avatar Jun 22 '22 18:06 ejona86

Ping @murgatroid99

dfawley avatar Jul 27 '22 18:07 dfawley