aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/config.h5
-rw-r--r--include/grpc++/impl/call.h10
-rw-r--r--include/grpc++/server.h7
-rw-r--r--include/grpc++/server_builder.h6
4 files changed, 26 insertions, 2 deletions
diff --git a/include/grpc++/config.h b/include/grpc++/config.h
index 0f3d69289f..b6c1705621 100644
--- a/include/grpc++/config.h
+++ b/include/grpc++/config.h
@@ -93,13 +93,17 @@
#endif
#ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
#define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM \
::google::protobuf::io::ZeroCopyOutputStream
#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \
::google::protobuf::io::ZeroCopyInputStream
+#define GRPC_CUSTOM_CODEDINPUTSTREAM \
+ ::google::protobuf::io::CodedInputStream
#endif
+
#ifdef GRPC_CXX0X_NO_NULLPTR
#include <memory>
const class {
@@ -126,6 +130,7 @@ typedef GRPC_CUSTOM_PROTOBUF_INT64 int64;
namespace io {
typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream;
typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream;
+typedef GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream;
} // namespace io
} // namespace protobuf
diff --git a/include/grpc++/impl/call.h b/include/grpc++/impl/call.h
index b14c41dfa6..d76ef61dd2 100644
--- a/include/grpc++/impl/call.h
+++ b/include/grpc++/impl/call.h
@@ -80,6 +80,10 @@ class CallOpBuffer : public CompletionQueueTag {
// Called by completion queue just prior to returning from Next() or Pluck()
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE;
+ void set_max_message_size(int max_message_size) {
+ max_message_size_ = max_message_size;
+ }
+
bool got_message;
private:
@@ -99,6 +103,7 @@ class CallOpBuffer : public CompletionQueueTag {
grpc::protobuf::Message* recv_message_;
ByteBuffer* recv_message_buffer_;
grpc_byte_buffer* recv_buf_;
+ int max_message_size_;
// Client send close
bool client_send_close_;
// Client recv status
@@ -130,16 +135,21 @@ class Call GRPC_FINAL {
public:
/* call is owned by the caller */
Call(grpc_call* call, CallHook* call_hook_, CompletionQueue* cq);
+ Call(grpc_call* call, CallHook* call_hook_, CompletionQueue* cq,
+ int max_message_size);
void PerformOps(CallOpBuffer* buffer);
grpc_call* call() { return call_; }
CompletionQueue* cq() { return cq_; }
+ int max_message_size() { return max_message_size_; }
+
private:
CallHook* call_hook_;
CompletionQueue* cq_;
grpc_call* call_;
+ int max_message_size_;
};
} // namespace grpc
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index c686474702..b2b9044dca 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -79,7 +79,8 @@ class Server GRPC_FINAL : public GrpcLibrary,
class AsyncRequest;
// ServerBuilder use only
- Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned);
+ Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned,
+ int max_message_size);
// Register a service. This call does not take ownership of the service.
// The service must exist for the lifetime of the Server instance.
bool RegisterService(RpcService* service);
@@ -106,6 +107,8 @@ class Server GRPC_FINAL : public GrpcLibrary,
ServerAsyncStreamingInterface* stream,
CompletionQueue* cq, void* tag);
+ const int max_message_size_;
+
// Completion queue.
CompletionQueue cq_;
@@ -126,7 +129,7 @@ class Server GRPC_FINAL : public GrpcLibrary,
// Whether the thread pool is created and owned by the server.
bool thread_pool_owned_;
private:
- Server() : server_(NULL) { abort(); }
+ Server() : max_message_size_(-1), server_(NULL) { abort(); }
};
} // namespace grpc
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h
index 9a9932ebe0..7155c7fd46 100644
--- a/include/grpc++/server_builder.h
+++ b/include/grpc++/server_builder.h
@@ -68,6 +68,11 @@ class ServerBuilder {
// Register a generic service.
void RegisterAsyncGenericService(AsyncGenericService* service);
+ // Set max message size in bytes.
+ void SetMaxMessageSize(int max_message_size) {
+ max_message_size_ = max_message_size;
+ }
+
// Add a listening port. Can be called multiple times.
void AddListeningPort(const grpc::string& addr,
std::shared_ptr<ServerCredentials> creds,
@@ -87,6 +92,7 @@ class ServerBuilder {
int* selected_port;
};
+ int max_message_size_;
std::vector<RpcService*> services_;
std::vector<AsynchronousService*> async_services_;
std::vector<Port> ports_;