13#include <rpp/observables/fwd.hpp>
15#include <grpcpp/support/client_callback.h>
16#include <rppgrpc/details/base.hpp>
17#include <rppgrpc/fwd.hpp>
18#include <rppgrpc/utils/exceptions.hpp>
35 template<rpp::constra
int::decayed_type Request, rpp::constra
int::decayed_type Response>
36 class client_bidi_reactor final :
public grpc::ClientBidiReactor<Request, Response>
37 ,
private details::base_writer<Request>
38 ,
private details::base_reader<Response>
40 using Base = grpc::ClientBidiReactor<Request, Response>;
43 client_bidi_reactor() =
default;
48 details::base_reader<Response>::handle_read_done(
true);
51 using details::base_writer<Request>::get_observer;
52 using details::base_reader<Response>::get_observable;
55 void start_read(Response& data)
override
57 Base::StartRead(&data);
60 void start_write(
const Request& v)
override
65 void finish_writes(
const grpc::Status&)
override
67 Base::StartWritesDone();
70 using Base::StartCall;
71 using Base::StartRead;
73 void OnReadDone(
bool ok)
override
78 details::base_reader<Response>::handle_read_done();
81 void OnWriteDone(
bool ok)
override
86 details::base_writer<Request>::handle_write_done();
89 void OnDone(
const grpc::Status& s)
override
91 details::base_writer<Request>::handle_on_done();
92 details::base_reader<Response>::handle_on_done(s.ok() ? std::exception_ptr{} : std::make_exception_ptr(
rppgrpc::utils::reactor_failed{s.error_message()}));
110 template<rpp::constra
int::decayed_type Request>
111 class client_write_reactor final :
public grpc::ClientWriteReactor<Request>
112 ,
private details::base_writer<Request>
113 ,
private details::base_reader<rpp::utils::none>
115 using Base = grpc::ClientWriteReactor<Request>;
118 client_write_reactor() =
default;
125 using details::base_writer<Request>::get_observer;
133 void start_write(
const Request& v)
override
135 Base::StartWrite(&v);
138 void finish_writes(
const grpc::Status&)
override
140 Base::StartWritesDone();
143 using Base::StartCall;
145 void OnWriteDone(
bool ok)
override
150 details::base_writer<Request>::handle_write_done();
153 void OnDone(
const grpc::Status& s)
override
155 details::base_writer<Request>::handle_on_done();
156 details::base_reader<rpp::utils::none>::handle_on_done(s.ok() ? std::exception_ptr{} : std::make_exception_ptr(
rppgrpc::utils::reactor_failed{s.error_message()}));
174 template<rpp::constra
int::decayed_type Response>
175 class client_read_reactor final :
public grpc::ClientReadReactor<Response>
176 ,
private details::base_reader<Response>
178 using Base = grpc::ClientReadReactor<Response>;
181 client_read_reactor() =
default;
186 details::base_reader<Response>::handle_read_done(
true);
189 using details::base_reader<Response>::get_observable;
192 using Base::StartCall;
193 using Base::StartRead;
195 void start_read(Response& data)
override
197 Base::StartRead(&data);
200 void OnReadDone(
bool ok)
override
205 details::base_reader<Response>::handle_read_done();
208 void OnDone(
const grpc::Status& s)
override
210 details::base_reader<Response>::handle_on_done(s.ok() ? std::exception_ptr{} : std::make_exception_ptr(
rppgrpc::utils::reactor_failed{s.error_message()}));
Definition exceptions.hpp:18