Skip to content
Snippets Groups Projects
Commit d76ea837 authored by kpayson64's avatar kpayson64 Committed by GitHub
Browse files

Merge pull request #7798 from y-zeng/ServerReaderWriterInterface

Add ServerReaderWriterInterface
parents bacaceb5 59e835d4
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,15 @@ class ClientStreamingInterface { ...@@ -64,6 +64,15 @@ class ClientStreamingInterface {
virtual Status Finish() = 0; virtual Status Finish() = 0;
}; };
/// Common interface for all synchronous server side streaming.
class ServerStreamingInterface {
public:
virtual ~ServerStreamingInterface() {}
/// Blocking send initial metadata to client.
virtual void SendInitialMetadata() = 0;
};
/// An interface that yields a sequence of messages of type \a R. /// An interface that yields a sequence of messages of type \a R.
template <class R> template <class R>
class ReaderInterface { class ReaderInterface {
...@@ -336,12 +345,17 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> { ...@@ -336,12 +345,17 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> {
Call call_; Call call_;
}; };
/// Server-side interface for streaming reads of message of type \a R.
template <class R>
class ServerReaderInterface : public ServerStreamingInterface,
public ReaderInterface<R> {};
template <class R> template <class R>
class ServerReader GRPC_FINAL : public ReaderInterface<R> { class ServerReader GRPC_FINAL : public ServerReaderInterface<R> {
public: public:
ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
void SendInitialMetadata() { void SendInitialMetadata() GRPC_OVERRIDE {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
CallOpSet<CallOpSendInitialMetadata> ops; CallOpSet<CallOpSendInitialMetadata> ops;
...@@ -367,12 +381,17 @@ class ServerReader GRPC_FINAL : public ReaderInterface<R> { ...@@ -367,12 +381,17 @@ class ServerReader GRPC_FINAL : public ReaderInterface<R> {
ServerContext* const ctx_; ServerContext* const ctx_;
}; };
/// Server-side interface for streaming writes of message of type \a W.
template <class W> template <class W>
class ServerWriter GRPC_FINAL : public WriterInterface<W> { class ServerWriterInterface : public ServerStreamingInterface,
public WriterInterface<W> {};
template <class W>
class ServerWriter GRPC_FINAL : public ServerWriterInterface<W> {
public: public:
ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
void SendInitialMetadata() { void SendInitialMetadata() GRPC_OVERRIDE {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
CallOpSet<CallOpSendInitialMetadata> ops; CallOpSet<CallOpSendInitialMetadata> ops;
...@@ -411,12 +430,16 @@ class ServerWriter GRPC_FINAL : public WriterInterface<W> { ...@@ -411,12 +430,16 @@ class ServerWriter GRPC_FINAL : public WriterInterface<W> {
/// Server-side interface for bi-directional streaming. /// Server-side interface for bi-directional streaming.
template <class W, class R> template <class W, class R>
class ServerReaderWriter GRPC_FINAL : public WriterInterface<W>, class ServerReaderWriterInterface : public ServerStreamingInterface,
public ReaderInterface<R> { public WriterInterface<W>,
public ReaderInterface<R> {};
template <class W, class R>
class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface<W, R> {
public: public:
ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
void SendInitialMetadata() { void SendInitialMetadata() GRPC_OVERRIDE {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
CallOpSet<CallOpSendInitialMetadata> ops; CallOpSet<CallOpSendInitialMetadata> ops;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment