starpc 0.44.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/echo/echo_e2e_test.cpp +794 -35
- package/echo/echo_srpc.pb.cpp +40 -28
- package/echo/echo_srpc.pb.hpp +131 -106
- package/go.mod +2 -2
- package/go.sum +4 -4
- package/mock/mock_srpc.pb.cpp +13 -10
- package/mock/mock_srpc.pb.hpp +34 -28
- package/package.json +5 -4
- package/srpc/client-rpc.cpp +21 -19
- package/srpc/client-rpc.hpp +14 -11
- package/srpc/client.cpp +12 -16
- package/srpc/client.hpp +17 -25
- package/srpc/common-rpc.cpp +13 -14
- package/srpc/common-rpc.hpp +13 -11
- package/srpc/errors.hpp +33 -20
- package/srpc/handler.hpp +3 -3
- package/srpc/invoker.hpp +26 -29
- package/srpc/message.hpp +4 -6
- package/srpc/msg-stream.hpp +13 -11
- package/srpc/mux.cpp +19 -18
- package/srpc/mux.hpp +15 -14
- package/srpc/packet.cpp +25 -27
- package/srpc/packet.hpp +14 -17
- package/srpc/server-rpc.cpp +22 -22
- package/srpc/server-rpc.hpp +15 -13
- package/srpc/starpc.hpp +1 -1
- package/srpc/stream.hpp +18 -16
- package/srpc/writer.hpp +15 -12
package/echo/echo_srpc.pb.cpp
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//go:build deps_only
|
|
1
|
+
// go:build deps_only
|
|
2
2
|
|
|
3
3
|
// Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
|
|
4
4
|
// protoc-gen-starpc-cpp version: v0.43.2-0.20260131104303-1de77bff6409+dirty
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
namespace echo {
|
|
10
10
|
|
|
11
|
-
starpc::Error SRPCEchoerClientImpl::Echo(const echo::EchoMsg&
|
|
11
|
+
starpc::Error SRPCEchoerClientImpl::Echo(const echo::EchoMsg &in,
|
|
12
|
+
echo::EchoMsg *out) {
|
|
12
13
|
return cc_->ExecCall(service_id_, "Echo", in, out);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error>
|
|
16
|
+
std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error>
|
|
17
|
+
SRPCEchoerClientImpl::EchoServerStream(const echo::EchoMsg &in) {
|
|
16
18
|
auto [strm, err] = cc_->NewStream(service_id_, "EchoServerStream", &in);
|
|
17
19
|
if (err != starpc::Error::OK) {
|
|
18
20
|
return {nullptr, err};
|
|
@@ -21,52 +23,56 @@ std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error> SRP
|
|
|
21
23
|
if (err != starpc::Error::OK) {
|
|
22
24
|
return {nullptr, err};
|
|
23
25
|
}
|
|
24
|
-
return {std::make_unique<SRPCEchoer_EchoServerStreamClient>(std::move(strm)),
|
|
26
|
+
return {std::make_unique<SRPCEchoer_EchoServerStreamClient>(std::move(strm)),
|
|
27
|
+
starpc::Error::OK};
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>, starpc::Error>
|
|
30
|
+
std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>, starpc::Error>
|
|
31
|
+
SRPCEchoerClientImpl::EchoClientStream() {
|
|
28
32
|
auto [strm, err] = cc_->NewStream(service_id_, "EchoClientStream", nullptr);
|
|
29
33
|
if (err != starpc::Error::OK) {
|
|
30
34
|
return {nullptr, err};
|
|
31
35
|
}
|
|
32
|
-
return {std::make_unique<SRPCEchoer_EchoClientStreamClient>(std::move(strm)),
|
|
36
|
+
return {std::make_unique<SRPCEchoer_EchoClientStreamClient>(std::move(strm)),
|
|
37
|
+
starpc::Error::OK};
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>, starpc::Error>
|
|
40
|
+
std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>, starpc::Error>
|
|
41
|
+
SRPCEchoerClientImpl::EchoBidiStream() {
|
|
36
42
|
auto [strm, err] = cc_->NewStream(service_id_, "EchoBidiStream", nullptr);
|
|
37
43
|
if (err != starpc::Error::OK) {
|
|
38
44
|
return {nullptr, err};
|
|
39
45
|
}
|
|
40
|
-
return {std::make_unique<SRPCEchoer_EchoBidiStreamClient>(std::move(strm)),
|
|
46
|
+
return {std::make_unique<SRPCEchoer_EchoBidiStreamClient>(std::move(strm)),
|
|
47
|
+
starpc::Error::OK};
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
50
|
+
std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
51
|
+
SRPCEchoerClientImpl::RpcStream() {
|
|
44
52
|
auto [strm, err] = cc_->NewStream(service_id_, "RpcStream", nullptr);
|
|
45
53
|
if (err != starpc::Error::OK) {
|
|
46
54
|
return {nullptr, err};
|
|
47
55
|
}
|
|
48
|
-
return {std::make_unique<SRPCEchoer_RpcStreamClient>(std::move(strm)),
|
|
56
|
+
return {std::make_unique<SRPCEchoer_RpcStreamClient>(std::move(strm)),
|
|
57
|
+
starpc::Error::OK};
|
|
49
58
|
}
|
|
50
59
|
|
|
51
|
-
starpc::Error SRPCEchoerClientImpl::DoNothing(const google::protobuf::Empty&
|
|
60
|
+
starpc::Error SRPCEchoerClientImpl::DoNothing(const google::protobuf::Empty &in,
|
|
61
|
+
google::protobuf::Empty *out) {
|
|
52
62
|
return cc_->ExecCall(service_id_, "DoNothing", in, out);
|
|
53
63
|
}
|
|
54
64
|
|
|
55
65
|
std::vector<std::string> SRPCEchoerHandler::GetMethodIDs() const {
|
|
56
66
|
return {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"EchoClientStream",
|
|
60
|
-
"EchoBidiStream",
|
|
61
|
-
"RpcStream",
|
|
62
|
-
"DoNothing",
|
|
67
|
+
"Echo", "EchoServerStream", "EchoClientStream",
|
|
68
|
+
"EchoBidiStream", "RpcStream", "DoNothing",
|
|
63
69
|
};
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
std::pair<bool, starpc::Error>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
std::pair<bool, starpc::Error>
|
|
73
|
+
SRPCEchoerHandler::InvokeMethod(const std::string &service_id,
|
|
74
|
+
const std::string &method_id,
|
|
75
|
+
starpc::Stream *strm) {
|
|
70
76
|
if (!service_id.empty() && service_id != service_id_) {
|
|
71
77
|
return {false, starpc::Error::OK};
|
|
72
78
|
}
|
|
@@ -74,22 +80,26 @@ std::pair<bool, starpc::Error> SRPCEchoerHandler::InvokeMethod(
|
|
|
74
80
|
if (method_id == "Echo") {
|
|
75
81
|
echo::EchoMsg req;
|
|
76
82
|
starpc::Error err = strm->MsgRecv(&req);
|
|
77
|
-
if (err != starpc::Error::OK)
|
|
83
|
+
if (err != starpc::Error::OK)
|
|
84
|
+
return {true, err};
|
|
78
85
|
echo::EchoMsg resp;
|
|
79
86
|
err = impl_->Echo(req, &resp);
|
|
80
|
-
if (err != starpc::Error::OK)
|
|
87
|
+
if (err != starpc::Error::OK)
|
|
88
|
+
return {true, err};
|
|
81
89
|
return {true, strm->MsgSend(resp)};
|
|
82
90
|
} else if (method_id == "EchoServerStream") {
|
|
83
91
|
echo::EchoMsg req;
|
|
84
92
|
starpc::Error err = strm->MsgRecv(&req);
|
|
85
|
-
if (err != starpc::Error::OK)
|
|
93
|
+
if (err != starpc::Error::OK)
|
|
94
|
+
return {true, err};
|
|
86
95
|
SRPCEchoer_EchoServerStreamStream serverStrm(strm);
|
|
87
96
|
return {true, impl_->EchoServerStream(req, &serverStrm)};
|
|
88
97
|
} else if (method_id == "EchoClientStream") {
|
|
89
98
|
SRPCEchoer_EchoClientStreamStream clientStrm(strm);
|
|
90
99
|
echo::EchoMsg resp;
|
|
91
100
|
starpc::Error err = impl_->EchoClientStream(&clientStrm, &resp);
|
|
92
|
-
if (err != starpc::Error::OK)
|
|
101
|
+
if (err != starpc::Error::OK)
|
|
102
|
+
return {true, err};
|
|
93
103
|
return {true, strm->MsgSend(resp)};
|
|
94
104
|
} else if (method_id == "EchoBidiStream") {
|
|
95
105
|
SRPCEchoer_EchoBidiStreamStream bidiStrm(strm);
|
|
@@ -100,14 +110,16 @@ std::pair<bool, starpc::Error> SRPCEchoerHandler::InvokeMethod(
|
|
|
100
110
|
} else if (method_id == "DoNothing") {
|
|
101
111
|
google::protobuf::Empty req;
|
|
102
112
|
starpc::Error err = strm->MsgRecv(&req);
|
|
103
|
-
if (err != starpc::Error::OK)
|
|
113
|
+
if (err != starpc::Error::OK)
|
|
114
|
+
return {true, err};
|
|
104
115
|
google::protobuf::Empty resp;
|
|
105
116
|
err = impl_->DoNothing(req, &resp);
|
|
106
|
-
if (err != starpc::Error::OK)
|
|
117
|
+
if (err != starpc::Error::OK)
|
|
118
|
+
return {true, err};
|
|
107
119
|
return {true, strm->MsgSend(resp)};
|
|
108
120
|
}
|
|
109
121
|
|
|
110
122
|
return {false, starpc::Error::OK};
|
|
111
123
|
}
|
|
112
124
|
|
|
113
|
-
}
|
|
125
|
+
} // namespace echo
|
package/echo/echo_srpc.pb.hpp
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
namespace echo {
|
|
17
17
|
|
|
18
18
|
// Service ID for Echoer
|
|
19
|
-
constexpr const char*
|
|
19
|
+
constexpr const char *kSRPCEchoerServiceID = "echo.Echoer";
|
|
20
20
|
|
|
21
21
|
class SRPCEchoer_EchoServerStreamClient;
|
|
22
22
|
class SRPCEchoer_EchoServerStreamStream;
|
|
@@ -29,102 +29,130 @@ class SRPCEchoer_RpcStreamStream;
|
|
|
29
29
|
|
|
30
30
|
// SRPCEchoerClient is the client API for Echoer service.
|
|
31
31
|
class SRPCEchoerClient {
|
|
32
|
-
|
|
32
|
+
public:
|
|
33
33
|
virtual ~SRPCEchoerClient() = default;
|
|
34
34
|
|
|
35
35
|
// SRPCClient returns the underlying SRPC client.
|
|
36
|
-
virtual starpc::Client*
|
|
36
|
+
virtual starpc::Client *SRPCClient() = 0;
|
|
37
37
|
|
|
38
38
|
// Echo
|
|
39
|
-
virtual starpc::Error Echo(const echo::EchoMsg&
|
|
39
|
+
virtual starpc::Error Echo(const echo::EchoMsg &in, echo::EchoMsg *out) = 0;
|
|
40
40
|
// EchoServerStream
|
|
41
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>,
|
|
41
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>,
|
|
42
|
+
starpc::Error>
|
|
43
|
+
EchoServerStream(const echo::EchoMsg &in) = 0;
|
|
42
44
|
// EchoClientStream
|
|
43
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>,
|
|
45
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>,
|
|
46
|
+
starpc::Error>
|
|
47
|
+
EchoClientStream() = 0;
|
|
44
48
|
// EchoBidiStream
|
|
45
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>,
|
|
49
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>,
|
|
50
|
+
starpc::Error>
|
|
51
|
+
EchoBidiStream() = 0;
|
|
46
52
|
// RpcStream
|
|
47
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
53
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
54
|
+
RpcStream() = 0;
|
|
48
55
|
// DoNothing
|
|
49
|
-
virtual starpc::Error DoNothing(const google::protobuf::Empty&
|
|
56
|
+
virtual starpc::Error DoNothing(const google::protobuf::Empty &in,
|
|
57
|
+
google::protobuf::Empty *out) = 0;
|
|
50
58
|
};
|
|
51
59
|
|
|
52
60
|
// SRPCEchoerClientImpl implements SRPCEchoerClient.
|
|
53
61
|
class SRPCEchoerClientImpl : public SRPCEchoerClient {
|
|
54
|
-
|
|
55
|
-
explicit SRPCEchoerClientImpl(starpc::Client*
|
|
56
|
-
|
|
62
|
+
public:
|
|
63
|
+
explicit SRPCEchoerClientImpl(starpc::Client *cc,
|
|
64
|
+
const std::string &service_id = "")
|
|
65
|
+
: cc_(cc),
|
|
66
|
+
service_id_(service_id.empty() ? kSRPCEchoerServiceID : service_id) {}
|
|
57
67
|
|
|
58
|
-
starpc::Client*
|
|
68
|
+
starpc::Client *SRPCClient() override { return cc_; }
|
|
59
69
|
|
|
60
70
|
// Echo
|
|
61
|
-
virtual starpc::Error Echo(const echo::EchoMsg&
|
|
71
|
+
virtual starpc::Error Echo(const echo::EchoMsg &in,
|
|
72
|
+
echo::EchoMsg *out) override;
|
|
62
73
|
// EchoServerStream
|
|
63
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>,
|
|
74
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>,
|
|
75
|
+
starpc::Error>
|
|
76
|
+
EchoServerStream(const echo::EchoMsg &in) override;
|
|
64
77
|
// EchoClientStream
|
|
65
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>,
|
|
78
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>,
|
|
79
|
+
starpc::Error>
|
|
80
|
+
EchoClientStream() override;
|
|
66
81
|
// EchoBidiStream
|
|
67
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>,
|
|
82
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>,
|
|
83
|
+
starpc::Error>
|
|
84
|
+
EchoBidiStream() override;
|
|
68
85
|
// RpcStream
|
|
69
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
86
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
87
|
+
RpcStream() override;
|
|
70
88
|
// DoNothing
|
|
71
|
-
virtual starpc::Error DoNothing(const google::protobuf::Empty&
|
|
89
|
+
virtual starpc::Error DoNothing(const google::protobuf::Empty &in,
|
|
90
|
+
google::protobuf::Empty *out) override;
|
|
72
91
|
|
|
73
|
-
|
|
74
|
-
starpc::Client*
|
|
92
|
+
private:
|
|
93
|
+
starpc::Client *cc_;
|
|
75
94
|
std::string service_id_;
|
|
76
95
|
};
|
|
77
96
|
|
|
78
97
|
// NewSRPCEchoerClient creates a new client.
|
|
79
|
-
inline std::unique_ptr<SRPCEchoerClient>
|
|
98
|
+
inline std::unique_ptr<SRPCEchoerClient>
|
|
99
|
+
NewSRPCEchoerClient(starpc::Client *cc) {
|
|
80
100
|
return std::make_unique<SRPCEchoerClientImpl>(cc);
|
|
81
101
|
}
|
|
82
102
|
|
|
83
103
|
// SRPCEchoerServer is the server API for Echoer service.
|
|
84
104
|
class SRPCEchoerServer {
|
|
85
|
-
|
|
105
|
+
public:
|
|
86
106
|
virtual ~SRPCEchoerServer() = default;
|
|
87
107
|
|
|
88
108
|
// Echo
|
|
89
|
-
virtual starpc::Error Echo(const echo::EchoMsg&
|
|
109
|
+
virtual starpc::Error Echo(const echo::EchoMsg &req, echo::EchoMsg *resp) = 0;
|
|
90
110
|
// EchoServerStream
|
|
91
|
-
virtual starpc::Error
|
|
111
|
+
virtual starpc::Error
|
|
112
|
+
EchoServerStream(const echo::EchoMsg &req,
|
|
113
|
+
SRPCEchoer_EchoServerStreamStream *strm) = 0;
|
|
92
114
|
// EchoClientStream
|
|
93
|
-
virtual starpc::Error
|
|
115
|
+
virtual starpc::Error
|
|
116
|
+
EchoClientStream(SRPCEchoer_EchoClientStreamStream *strm,
|
|
117
|
+
echo::EchoMsg *resp) = 0;
|
|
94
118
|
// EchoBidiStream
|
|
95
|
-
virtual starpc::Error
|
|
119
|
+
virtual starpc::Error
|
|
120
|
+
EchoBidiStream(SRPCEchoer_EchoBidiStreamStream *strm) = 0;
|
|
96
121
|
// RpcStream
|
|
97
|
-
virtual starpc::Error RpcStream(SRPCEchoer_RpcStreamStream*
|
|
122
|
+
virtual starpc::Error RpcStream(SRPCEchoer_RpcStreamStream *strm) = 0;
|
|
98
123
|
// DoNothing
|
|
99
|
-
virtual starpc::Error DoNothing(const google::protobuf::Empty&
|
|
124
|
+
virtual starpc::Error DoNothing(const google::protobuf::Empty &req,
|
|
125
|
+
google::protobuf::Empty *resp) = 0;
|
|
100
126
|
};
|
|
101
127
|
|
|
102
128
|
// SRPCEchoerHandler implements starpc::Handler for Echoer.
|
|
103
129
|
class SRPCEchoerHandler : public starpc::Handler {
|
|
104
|
-
|
|
105
|
-
SRPCEchoerHandler(SRPCEchoerServer*
|
|
106
|
-
: impl_(impl),
|
|
130
|
+
public:
|
|
131
|
+
SRPCEchoerHandler(SRPCEchoerServer *impl, const std::string &service_id = "")
|
|
132
|
+
: impl_(impl),
|
|
133
|
+
service_id_(service_id.empty() ? kSRPCEchoerServiceID : service_id) {}
|
|
107
134
|
|
|
108
|
-
const std::string&
|
|
135
|
+
const std::string &GetServiceID() const override { return service_id_; }
|
|
109
136
|
std::vector<std::string> GetMethodIDs() const override;
|
|
110
|
-
std::pair<bool, starpc::Error> InvokeMethod(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
starpc::Stream* strm) override;
|
|
137
|
+
std::pair<bool, starpc::Error> InvokeMethod(const std::string &service_id,
|
|
138
|
+
const std::string &method_id,
|
|
139
|
+
starpc::Stream *strm) override;
|
|
114
140
|
|
|
115
|
-
|
|
116
|
-
SRPCEchoerServer*
|
|
141
|
+
private:
|
|
142
|
+
SRPCEchoerServer *impl_;
|
|
117
143
|
std::string service_id_;
|
|
118
144
|
};
|
|
119
145
|
|
|
120
146
|
// NewSRPCEchoerHandler creates a new handler for the given implementation.
|
|
121
|
-
inline std::unique_ptr<SRPCEchoerHandler>
|
|
147
|
+
inline std::unique_ptr<SRPCEchoerHandler>
|
|
148
|
+
NewSRPCEchoerHandler(SRPCEchoerServer *impl) {
|
|
122
149
|
return std::make_unique<SRPCEchoerHandler>(impl);
|
|
123
150
|
}
|
|
124
151
|
|
|
125
152
|
// SRPCRegisterEchoer registers the server implementation with the mux.
|
|
126
153
|
// The returned handler must outlive the mux registration.
|
|
127
|
-
inline std::pair<std::unique_ptr<SRPCEchoerHandler>, starpc::Error>
|
|
154
|
+
inline std::pair<std::unique_ptr<SRPCEchoerHandler>, starpc::Error>
|
|
155
|
+
SRPCRegisterEchoer(starpc::Mux *mux, SRPCEchoerServer *impl) {
|
|
128
156
|
auto handler = NewSRPCEchoerHandler(impl);
|
|
129
157
|
starpc::Error err = mux->Register(handler.get());
|
|
130
158
|
if (err != starpc::Error::OK) {
|
|
@@ -135,158 +163,155 @@ inline std::pair<std::unique_ptr<SRPCEchoerHandler>, starpc::Error> SRPCRegister
|
|
|
135
163
|
|
|
136
164
|
// SRPCEchoer_EchoServerStreamClient is the client stream for EchoServerStream.
|
|
137
165
|
class SRPCEchoer_EchoServerStreamClient {
|
|
138
|
-
|
|
139
|
-
explicit SRPCEchoer_EchoServerStreamClient(
|
|
166
|
+
public:
|
|
167
|
+
explicit SRPCEchoer_EchoServerStreamClient(
|
|
168
|
+
std::unique_ptr<starpc::Stream> strm)
|
|
169
|
+
: strm_(std::move(strm)) {}
|
|
140
170
|
|
|
141
|
-
starpc::Error Recv(echo::EchoMsg* msg)
|
|
142
|
-
return strm_->MsgRecv(msg);
|
|
143
|
-
}
|
|
171
|
+
starpc::Error Recv(echo::EchoMsg *msg) { return strm_->MsgRecv(msg); }
|
|
144
172
|
|
|
145
173
|
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
146
174
|
starpc::Error Close() { return strm_->Close(); }
|
|
147
175
|
|
|
148
|
-
|
|
176
|
+
private:
|
|
149
177
|
std::unique_ptr<starpc::Stream> strm_;
|
|
150
178
|
};
|
|
151
179
|
|
|
152
180
|
// SRPCEchoer_EchoServerStreamStream is the server stream for EchoServerStream.
|
|
153
181
|
class SRPCEchoer_EchoServerStreamStream {
|
|
154
|
-
|
|
155
|
-
explicit SRPCEchoer_EchoServerStreamStream(starpc::Stream*
|
|
182
|
+
public:
|
|
183
|
+
explicit SRPCEchoer_EchoServerStreamStream(starpc::Stream *strm)
|
|
184
|
+
: strm_(strm) {}
|
|
156
185
|
|
|
157
|
-
starpc::Error Send(const echo::EchoMsg& msg)
|
|
158
|
-
return strm_->MsgSend(msg);
|
|
159
|
-
}
|
|
186
|
+
starpc::Error Send(const echo::EchoMsg &msg) { return strm_->MsgSend(msg); }
|
|
160
187
|
|
|
161
|
-
starpc::Error SendAndClose(const echo::EchoMsg&
|
|
188
|
+
starpc::Error SendAndClose(const echo::EchoMsg &msg) {
|
|
162
189
|
starpc::Error err = strm_->MsgSend(msg);
|
|
163
|
-
if (err != starpc::Error::OK)
|
|
190
|
+
if (err != starpc::Error::OK)
|
|
191
|
+
return err;
|
|
164
192
|
return strm_->CloseSend();
|
|
165
193
|
}
|
|
166
194
|
|
|
167
|
-
|
|
168
|
-
starpc::Stream*
|
|
195
|
+
private:
|
|
196
|
+
starpc::Stream *strm_;
|
|
169
197
|
};
|
|
170
198
|
|
|
171
199
|
// SRPCEchoer_EchoClientStreamClient is the client stream for EchoClientStream.
|
|
172
200
|
class SRPCEchoer_EchoClientStreamClient {
|
|
173
|
-
|
|
174
|
-
explicit SRPCEchoer_EchoClientStreamClient(
|
|
201
|
+
public:
|
|
202
|
+
explicit SRPCEchoer_EchoClientStreamClient(
|
|
203
|
+
std::unique_ptr<starpc::Stream> strm)
|
|
204
|
+
: strm_(std::move(strm)) {}
|
|
175
205
|
|
|
176
|
-
starpc::Error Send(const echo::EchoMsg& msg)
|
|
177
|
-
return strm_->MsgSend(msg);
|
|
178
|
-
}
|
|
206
|
+
starpc::Error Send(const echo::EchoMsg &msg) { return strm_->MsgSend(msg); }
|
|
179
207
|
|
|
180
|
-
starpc::Error CloseAndRecv(echo::EchoMsg*
|
|
208
|
+
starpc::Error CloseAndRecv(echo::EchoMsg *msg) {
|
|
181
209
|
starpc::Error err = strm_->CloseSend();
|
|
182
|
-
if (err != starpc::Error::OK)
|
|
210
|
+
if (err != starpc::Error::OK)
|
|
211
|
+
return err;
|
|
183
212
|
return strm_->MsgRecv(msg);
|
|
184
213
|
}
|
|
185
214
|
|
|
186
215
|
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
187
216
|
starpc::Error Close() { return strm_->Close(); }
|
|
188
217
|
|
|
189
|
-
|
|
218
|
+
private:
|
|
190
219
|
std::unique_ptr<starpc::Stream> strm_;
|
|
191
220
|
};
|
|
192
221
|
|
|
193
222
|
// SRPCEchoer_EchoClientStreamStream is the server stream for EchoClientStream.
|
|
194
223
|
class SRPCEchoer_EchoClientStreamStream {
|
|
195
|
-
|
|
196
|
-
explicit SRPCEchoer_EchoClientStreamStream(starpc::Stream*
|
|
224
|
+
public:
|
|
225
|
+
explicit SRPCEchoer_EchoClientStreamStream(starpc::Stream *strm)
|
|
226
|
+
: strm_(strm) {}
|
|
197
227
|
|
|
198
|
-
starpc::Error Recv(echo::EchoMsg* msg)
|
|
199
|
-
return strm_->MsgRecv(msg);
|
|
200
|
-
}
|
|
228
|
+
starpc::Error Recv(echo::EchoMsg *msg) { return strm_->MsgRecv(msg); }
|
|
201
229
|
|
|
202
|
-
|
|
203
|
-
starpc::Stream*
|
|
230
|
+
private:
|
|
231
|
+
starpc::Stream *strm_;
|
|
204
232
|
};
|
|
205
233
|
|
|
206
234
|
// SRPCEchoer_EchoBidiStreamClient is the client stream for EchoBidiStream.
|
|
207
235
|
class SRPCEchoer_EchoBidiStreamClient {
|
|
208
|
-
|
|
209
|
-
explicit SRPCEchoer_EchoBidiStreamClient(std::unique_ptr<starpc::Stream> strm)
|
|
236
|
+
public:
|
|
237
|
+
explicit SRPCEchoer_EchoBidiStreamClient(std::unique_ptr<starpc::Stream> strm)
|
|
238
|
+
: strm_(std::move(strm)) {}
|
|
210
239
|
|
|
211
|
-
starpc::Error Send(const echo::EchoMsg& msg)
|
|
212
|
-
return strm_->MsgSend(msg);
|
|
213
|
-
}
|
|
240
|
+
starpc::Error Send(const echo::EchoMsg &msg) { return strm_->MsgSend(msg); }
|
|
214
241
|
|
|
215
|
-
starpc::Error Recv(echo::EchoMsg* msg)
|
|
216
|
-
return strm_->MsgRecv(msg);
|
|
217
|
-
}
|
|
242
|
+
starpc::Error Recv(echo::EchoMsg *msg) { return strm_->MsgRecv(msg); }
|
|
218
243
|
|
|
219
244
|
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
220
245
|
starpc::Error Close() { return strm_->Close(); }
|
|
221
246
|
|
|
222
|
-
|
|
247
|
+
private:
|
|
223
248
|
std::unique_ptr<starpc::Stream> strm_;
|
|
224
249
|
};
|
|
225
250
|
|
|
226
251
|
// SRPCEchoer_EchoBidiStreamStream is the server stream for EchoBidiStream.
|
|
227
252
|
class SRPCEchoer_EchoBidiStreamStream {
|
|
228
|
-
|
|
229
|
-
explicit SRPCEchoer_EchoBidiStreamStream(starpc::Stream*
|
|
253
|
+
public:
|
|
254
|
+
explicit SRPCEchoer_EchoBidiStreamStream(starpc::Stream *strm)
|
|
255
|
+
: strm_(strm) {}
|
|
230
256
|
|
|
231
|
-
starpc::Error Send(const echo::EchoMsg& msg)
|
|
232
|
-
return strm_->MsgSend(msg);
|
|
233
|
-
}
|
|
257
|
+
starpc::Error Send(const echo::EchoMsg &msg) { return strm_->MsgSend(msg); }
|
|
234
258
|
|
|
235
|
-
starpc::Error SendAndClose(const echo::EchoMsg&
|
|
259
|
+
starpc::Error SendAndClose(const echo::EchoMsg &msg) {
|
|
236
260
|
starpc::Error err = strm_->MsgSend(msg);
|
|
237
|
-
if (err != starpc::Error::OK)
|
|
261
|
+
if (err != starpc::Error::OK)
|
|
262
|
+
return err;
|
|
238
263
|
return strm_->CloseSend();
|
|
239
264
|
}
|
|
240
265
|
|
|
241
|
-
starpc::Error Recv(echo::EchoMsg* msg)
|
|
242
|
-
return strm_->MsgRecv(msg);
|
|
243
|
-
}
|
|
266
|
+
starpc::Error Recv(echo::EchoMsg *msg) { return strm_->MsgRecv(msg); }
|
|
244
267
|
|
|
245
|
-
|
|
246
|
-
starpc::Stream*
|
|
268
|
+
private:
|
|
269
|
+
starpc::Stream *strm_;
|
|
247
270
|
};
|
|
248
271
|
|
|
249
272
|
// SRPCEchoer_RpcStreamClient is the client stream for RpcStream.
|
|
250
273
|
class SRPCEchoer_RpcStreamClient {
|
|
251
|
-
|
|
252
|
-
explicit SRPCEchoer_RpcStreamClient(std::unique_ptr<starpc::Stream> strm)
|
|
274
|
+
public:
|
|
275
|
+
explicit SRPCEchoer_RpcStreamClient(std::unique_ptr<starpc::Stream> strm)
|
|
276
|
+
: strm_(std::move(strm)) {}
|
|
253
277
|
|
|
254
|
-
starpc::Error Send(const rpcstream::RpcStreamPacket&
|
|
278
|
+
starpc::Error Send(const rpcstream::RpcStreamPacket &msg) {
|
|
255
279
|
return strm_->MsgSend(msg);
|
|
256
280
|
}
|
|
257
281
|
|
|
258
|
-
starpc::Error Recv(rpcstream::RpcStreamPacket*
|
|
282
|
+
starpc::Error Recv(rpcstream::RpcStreamPacket *msg) {
|
|
259
283
|
return strm_->MsgRecv(msg);
|
|
260
284
|
}
|
|
261
285
|
|
|
262
286
|
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
263
287
|
starpc::Error Close() { return strm_->Close(); }
|
|
264
288
|
|
|
265
|
-
|
|
289
|
+
private:
|
|
266
290
|
std::unique_ptr<starpc::Stream> strm_;
|
|
267
291
|
};
|
|
268
292
|
|
|
269
293
|
// SRPCEchoer_RpcStreamStream is the server stream for RpcStream.
|
|
270
294
|
class SRPCEchoer_RpcStreamStream {
|
|
271
|
-
|
|
272
|
-
explicit SRPCEchoer_RpcStreamStream(starpc::Stream*
|
|
295
|
+
public:
|
|
296
|
+
explicit SRPCEchoer_RpcStreamStream(starpc::Stream *strm) : strm_(strm) {}
|
|
273
297
|
|
|
274
|
-
starpc::Error Send(const rpcstream::RpcStreamPacket&
|
|
298
|
+
starpc::Error Send(const rpcstream::RpcStreamPacket &msg) {
|
|
275
299
|
return strm_->MsgSend(msg);
|
|
276
300
|
}
|
|
277
301
|
|
|
278
|
-
starpc::Error SendAndClose(const rpcstream::RpcStreamPacket&
|
|
302
|
+
starpc::Error SendAndClose(const rpcstream::RpcStreamPacket &msg) {
|
|
279
303
|
starpc::Error err = strm_->MsgSend(msg);
|
|
280
|
-
if (err != starpc::Error::OK)
|
|
304
|
+
if (err != starpc::Error::OK)
|
|
305
|
+
return err;
|
|
281
306
|
return strm_->CloseSend();
|
|
282
307
|
}
|
|
283
308
|
|
|
284
|
-
starpc::Error Recv(rpcstream::RpcStreamPacket*
|
|
309
|
+
starpc::Error Recv(rpcstream::RpcStreamPacket *msg) {
|
|
285
310
|
return strm_->MsgRecv(msg);
|
|
286
311
|
}
|
|
287
312
|
|
|
288
|
-
|
|
289
|
-
starpc::Stream*
|
|
313
|
+
private:
|
|
314
|
+
starpc::Stream *strm_;
|
|
290
315
|
};
|
|
291
316
|
|
|
292
|
-
}
|
|
317
|
+
} // namespace echo
|
package/go.mod
CHANGED
|
@@ -11,7 +11,7 @@ replace (
|
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
require (
|
|
14
|
-
github.com/aperturerobotics/common v0.
|
|
14
|
+
github.com/aperturerobotics/common v0.29.0 // latest
|
|
15
15
|
github.com/aperturerobotics/protobuf-go-lite v0.12.0 // latest
|
|
16
16
|
github.com/aperturerobotics/util v1.32.3 // latest
|
|
17
17
|
)
|
|
@@ -30,7 +30,7 @@ require (
|
|
|
30
30
|
github.com/aperturerobotics/cli v1.1.0 // indirect
|
|
31
31
|
github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260131050911-b5f94b044584 // indirect
|
|
32
32
|
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726 // indirect
|
|
33
|
-
github.com/aperturerobotics/protobuf v0.0.0-
|
|
33
|
+
github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 // wasi
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
require (
|
package/go.sum
CHANGED
|
@@ -2,16 +2,16 @@ github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 h1:3U7
|
|
|
2
2
|
github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017/go.mod h1:lNSJTKECIUFAnfeSqy01kXYTYe1BHubW7198jNX3nEw=
|
|
3
3
|
github.com/aperturerobotics/cli v1.1.0 h1:7a+YRC+EY3npAnTzhHV5gLCiw91KS0Ts3XwLILGOsT8=
|
|
4
4
|
github.com/aperturerobotics/cli v1.1.0/go.mod h1:M7BFP9wow5ytTzMyJQOOO991fGfsUqdTI7gGEsHfTQ8=
|
|
5
|
-
github.com/aperturerobotics/common v0.
|
|
6
|
-
github.com/aperturerobotics/common v0.
|
|
5
|
+
github.com/aperturerobotics/common v0.29.0 h1:zSRERLPqmOD0RNs0I/Jr0YVv2Top0oKoDojEdxJEu38=
|
|
6
|
+
github.com/aperturerobotics/common v0.29.0/go.mod h1:q8ix+7nLZZ0FQ1j5w/EXI5S0FbVUX8k+eJkw83pPTT4=
|
|
7
7
|
github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0 h1:tGwbeDoEeQCrUQL+ClUywldqvz9eRmhcVrGwGxz2xJg=
|
|
8
8
|
github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0/go.mod h1:FJkAtQcP9XxqG1NNLNHKm+wLVIGSCQX2s6CEoD+w97g=
|
|
9
9
|
github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260131050911-b5f94b044584 h1:ER8DYYL71cTg39uZ+Gi699tL/hZoscUWDOw4DbizqhI=
|
|
10
10
|
github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260131050911-b5f94b044584/go.mod h1:vEq8i7EKb32+KXGtIEZjjhNns+BdsL2dUMw4uhy3578=
|
|
11
11
|
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726 h1:4B1F0DzuqPzb6WqgCjWaqDD7JU9RDsevQG5OP0DFBgs=
|
|
12
12
|
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726/go.mod h1:SvGGBv3OVxUyqO0ZxA/nvs6z3cg7NIbZ64TnbV2OISo=
|
|
13
|
-
github.com/aperturerobotics/protobuf v0.0.0-
|
|
14
|
-
github.com/aperturerobotics/protobuf v0.0.0-
|
|
13
|
+
github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 h1:4Dy3BAHh2kgVdHAqtlwcFsgY0kAwUe2m3rfFcaGwGQg=
|
|
14
|
+
github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4/go.mod h1:tMgO7y6SJo/d9ZcvrpNqIQtdYT9de+QmYaHOZ4KnhOg=
|
|
15
15
|
github.com/aperturerobotics/protobuf-go-lite v0.12.0 h1:ZPPokQtm/NPhgGv+vYD9AhInvkrzQal6MDnqcYLWvlg=
|
|
16
16
|
github.com/aperturerobotics/protobuf-go-lite v0.12.0/go.mod h1:lGH3s5ArCTXKI4wJdlNpaybUtwSjfAG0vdWjxOfMcF8=
|
|
17
17
|
github.com/aperturerobotics/util v1.32.3 h1:wBc6L2guYMgLEzFwORH3CLMoMpfEqbV6pDqYervo3S0=
|
package/mock/mock_srpc.pb.cpp
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//go:build deps_only
|
|
1
|
+
// go:build deps_only
|
|
2
2
|
|
|
3
3
|
// Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
|
|
4
4
|
// protoc-gen-starpc-cpp version: v0.43.2-0.20260131104303-1de77bff6409+dirty
|
|
@@ -8,20 +8,21 @@
|
|
|
8
8
|
|
|
9
9
|
namespace e2e::mock {
|
|
10
10
|
|
|
11
|
-
starpc::Error SRPCMockClientImpl::MockRequest(const e2e::mock::MockMsg&
|
|
11
|
+
starpc::Error SRPCMockClientImpl::MockRequest(const e2e::mock::MockMsg &in,
|
|
12
|
+
e2e::mock::MockMsg *out) {
|
|
12
13
|
return cc_->ExecCall(service_id_, "MockRequest", in, out);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
std::vector<std::string> SRPCMockHandler::GetMethodIDs() const {
|
|
16
17
|
return {
|
|
17
|
-
|
|
18
|
+
"MockRequest",
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
std::pair<bool, starpc::Error>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
std::pair<bool, starpc::Error>
|
|
23
|
+
SRPCMockHandler::InvokeMethod(const std::string &service_id,
|
|
24
|
+
const std::string &method_id,
|
|
25
|
+
starpc::Stream *strm) {
|
|
25
26
|
if (!service_id.empty() && service_id != service_id_) {
|
|
26
27
|
return {false, starpc::Error::OK};
|
|
27
28
|
}
|
|
@@ -29,14 +30,16 @@ std::pair<bool, starpc::Error> SRPCMockHandler::InvokeMethod(
|
|
|
29
30
|
if (method_id == "MockRequest") {
|
|
30
31
|
e2e::mock::MockMsg req;
|
|
31
32
|
starpc::Error err = strm->MsgRecv(&req);
|
|
32
|
-
if (err != starpc::Error::OK)
|
|
33
|
+
if (err != starpc::Error::OK)
|
|
34
|
+
return {true, err};
|
|
33
35
|
e2e::mock::MockMsg resp;
|
|
34
36
|
err = impl_->MockRequest(req, &resp);
|
|
35
|
-
if (err != starpc::Error::OK)
|
|
37
|
+
if (err != starpc::Error::OK)
|
|
38
|
+
return {true, err};
|
|
36
39
|
return {true, strm->MsgSend(resp)};
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
return {false, starpc::Error::OK};
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
}
|
|
45
|
+
} // namespace e2e::mock
|