grpc-js节点库中的ClientWritableStream实现与grpc/node API参考中提到的不同。

huangapple go评论83阅读模式
英文:

ClientWritableStream implementation in grpc-js node library is different from whats mentioned in grpc/node API reference

问题

grpc-js reference
write方法的第二个参数是编码(encoding)。

_write(chunk: RequestType, encoding: string, cb: WriteCallback) {
    const context: MessageContext = {
      callback: cb,
    };
    const flags = Number(encoding);
    if (!Number.isNaN(flags)) {
      context.flags = flags;
    }
    this.call?.sendMessageWithContext(context, chunk);
}

grpc/node API reference中的flags是第二个参数。这两者应该是相同的吗?

这是我第一次查阅GitHub上的文档,请告诉我是否有更好的文档可供参考。

公平的解释,如果有的话,请提供文档链接。

英文:

grpc-js reference
Where write method has encoding as second argument


_write(chunk: RequestType, encoding: string, cb: WriteCallback) {
    const context: MessageContext = {
      callback: cb,
    };
    const flags = Number(encoding);
    if (!Number.isNaN(flags)) {
      context.flags = flags;
    }
    this.call?.sendMessageWithContext(context, chunk);
  }

While grpc/node API reference has flags as second argument. Aren't these two should be same?
This is my first time referring github for documentation please help if there is better documentation for the same.

Fair explanation, Link for documentations if available.

答案1

得分: 1

你可以看到问题中引用的实现尝试将encoding参数解释为数字并将其用作标志。实际声明的类型受现有内置定义的限制,该定义位于Writable中,而ClientWritableStream是其子类。

英文:

You can see that the implementation quoted in the question tries to interpret the encoding argument as a number and use it as the flags. The actual declared types are constrained by the existing built in definition of the Writable class, which ClientWritableStream is a subclass of.

huangapple
  • 本文由 发表于 2023年7月24日 18:32:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76753601.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定