mirror of https://github.com/grpc/grpc-node.git
grpc-js: make serdes APIs consistent
During initial implementation, the serialize and deserialize APIs of ServerReadableStream, ServerWritableStream, and ServerDuplexStream became inconsistent. This commit brings back consistency.
This commit is contained in:
parent
2bb268afdb
commit
212439eb83
|
@ -104,8 +104,7 @@ export class ServerReadableStreamImpl<RequestType, ResponseType> extends
|
|||
|
||||
constructor(
|
||||
private call: Http2ServerCallStream<RequestType, ResponseType>,
|
||||
public metadata: Metadata,
|
||||
private _deserialize: Deserialize<RequestType>) {
|
||||
public metadata: Metadata, public deserialize: Deserialize<RequestType>) {
|
||||
super({objectMode: true});
|
||||
this.cancelled = false;
|
||||
this.call.setupReadable(this);
|
||||
|
@ -115,10 +114,6 @@ export class ServerReadableStreamImpl<RequestType, ResponseType> extends
|
|||
this.call.resume();
|
||||
}
|
||||
|
||||
deserialize(input: Buffer): RequestType {
|
||||
return this._deserialize(input);
|
||||
}
|
||||
|
||||
getPeer(): string {
|
||||
throw new Error('not implemented yet');
|
||||
}
|
||||
|
@ -137,7 +132,7 @@ export class ServerWritableStreamImpl<RequestType, ResponseType> extends
|
|||
|
||||
constructor(
|
||||
private call: Http2ServerCallStream<RequestType, ResponseType>,
|
||||
public metadata: Metadata, private _serialize: Serialize<ResponseType>) {
|
||||
public metadata: Metadata, public serialize: Serialize<ResponseType>) {
|
||||
super({objectMode: true});
|
||||
this.cancelled = false;
|
||||
this.request = null;
|
||||
|
@ -190,14 +185,6 @@ export class ServerWritableStreamImpl<RequestType, ResponseType> extends
|
|||
|
||||
super.end();
|
||||
}
|
||||
|
||||
serialize(input: ResponseType): Buffer|null {
|
||||
if (input === null || input === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this._serialize(input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue