mirror of https://github.com/grpc/grpc-web.git
Adding some groundwork for generic client
This commit is contained in:
parent
86d67cf8e1
commit
2ae8118d78
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* @fileoverview base interface for grpc web GenericClient.
|
||||
*/
|
||||
|
||||
goog.module('grpc.web.GenericClient');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
const Metadata = goog.require('grpc.web.Metadata');
|
||||
const MethodDescriptor = goog.require('grpc.web.MethodDescriptor');
|
||||
const UnaryResponse = goog.require('grpc.web.UnaryResponse');
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
const GenericClient = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {!REQUEST} request The request proto message
|
||||
* @param {!MethodDescriptor<REQUEST, RESPONSE>} methodDescriptor Information of
|
||||
* this RPC method
|
||||
* @param {!Metadata} metadata The user defined request metadata.
|
||||
* @return {!Promise<!UnaryResponse<RESPONSE>>} A promise that resolves to the
|
||||
* response message
|
||||
* @template REQUEST, RESPONSE
|
||||
*/
|
||||
GenericClient.prototype.unaryCall = goog.abstractMethod;
|
||||
|
||||
exports = GenericClient;
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* @fileoverview grpc-web request/response metadata.
|
||||
*
|
||||
* Request and response headers will be included in the Metadata.
|
||||
*/
|
||||
|
||||
goog.module('grpc.web.Metadata');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
/**
|
||||
* @typedef {!Object<string,string>}
|
||||
*/
|
||||
let Metadata;
|
||||
|
||||
exports = Metadata;
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @fileoverview gRPC web client UnaryResponse returned the by grpc unary calls.
|
||||
* It consists of response message and response metadata(headers).
|
||||
*/
|
||||
|
||||
goog.module('grpc.web.UnaryResponse');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
const Metadata = goog.require('grpc.web.Metadata');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @struct
|
||||
* @template RESPONSE
|
||||
* @param {RESPONSE} message
|
||||
* @param {!Metadata=} metadata
|
||||
*/
|
||||
const UnaryResponse = function(message, metadata) {
|
||||
/** @const {RESPONSE} */
|
||||
this.message = message;
|
||||
/** @const {!Metadata|undefined} */
|
||||
this.metadata = metadata;
|
||||
};
|
||||
|
||||
exports = UnaryResponse;
|
Loading…
Reference in New Issue