|
|
|
@ -178,8 +178,7 @@ template <class Streamer, bool WriteNeeded> |
|
|
|
|
class TemplatedBidiStreamingHandler : public MethodHandler { |
|
|
|
|
public: |
|
|
|
|
TemplatedBidiStreamingHandler( |
|
|
|
|
std::function<Status(ServerContext*, Streamer*)> |
|
|
|
|
func) |
|
|
|
|
std::function<Status(ServerContext*, Streamer*)> func) |
|
|
|
|
: func_(func), write_needed_(WriteNeeded) {} |
|
|
|
|
|
|
|
|
|
void RunHandler(const HandlerParameter& param) GRPC_FINAL { |
|
|
|
@ -206,23 +205,36 @@ class TemplatedBidiStreamingHandler : public MethodHandler { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
std::function<Status(ServerContext*, Streamer*)> |
|
|
|
|
func_; |
|
|
|
|
std::function<Status(ServerContext*, Streamer*)> func_; |
|
|
|
|
const bool write_needed_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <class ServiceType, class RequestType, class ResponseType> |
|
|
|
|
class BidiStreamingHandler : public TemplatedBidiStreamingHandler<ServerReaderWriter<ResponseType, RequestType>, false> { |
|
|
|
|
class BidiStreamingHandler |
|
|
|
|
: public TemplatedBidiStreamingHandler< |
|
|
|
|
ServerReaderWriter<ResponseType, RequestType>, false> { |
|
|
|
|
public: |
|
|
|
|
BidiStreamingHandler(std::function<Status(ServiceType*, ServerContext*, |
|
|
|
|
ServerReaderWriter<ResponseType,RequestType>*)> func, ServiceType* service): TemplatedBidiStreamingHandler<ServerReaderWriter<ResponseType, RequestType>,false>(std::bind(func, service, std::placeholders::_1, std::placeholders::_2)) {} |
|
|
|
|
BidiStreamingHandler( |
|
|
|
|
std::function<Status(ServiceType*, ServerContext*, |
|
|
|
|
ServerReaderWriter<ResponseType, RequestType>*)> |
|
|
|
|
func, |
|
|
|
|
ServiceType* service) |
|
|
|
|
: TemplatedBidiStreamingHandler< |
|
|
|
|
ServerReaderWriter<ResponseType, RequestType>, false>(std::bind( |
|
|
|
|
func, service, std::placeholders::_1, std::placeholders::_2)) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <class RequestType, class ResponseType> |
|
|
|
|
class StreamedUnaryHandler : public TemplatedBidiStreamingHandler<ServerUnaryStreamer<RequestType, ResponseType>, true> { |
|
|
|
|
class StreamedUnaryHandler |
|
|
|
|
: public TemplatedBidiStreamingHandler< |
|
|
|
|
ServerUnaryStreamer<RequestType, ResponseType>, true> { |
|
|
|
|
public: |
|
|
|
|
explicit StreamedUnaryHandler(std::function<Status(ServerContext*, |
|
|
|
|
ServerUnaryStreamer<RequestType,ResponseType>*)> func): TemplatedBidiStreamingHandler<ServerUnaryStreamer<RequestType, ResponseType>, true>(func) {} |
|
|
|
|
explicit StreamedUnaryHandler( |
|
|
|
|
std::function<Status(ServerContext*, |
|
|
|
|
ServerUnaryStreamer<RequestType, ResponseType>*)> |
|
|
|
|
func) |
|
|
|
|
: TemplatedBidiStreamingHandler< |
|
|
|
|
ServerUnaryStreamer<RequestType, ResponseType>, true>(func) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Handle unknown method by returning UNIMPLEMENTED error.
|
|
|
|
|