starpc 0.43.1 → 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/dist/echo/echo.pb.js +1 -1
- package/dist/mock/mock.pb.js +1 -1
- package/dist/rpcstream/rpcstream.pb.js +1 -1
- package/dist/srpc/rpcproto.pb.js +1 -1
- package/echo/echo.pb.ts +1 -1
- package/echo/echo_e2e_test.cpp +1048 -0
- package/echo/echo_srpc.pb.cpp +125 -0
- package/echo/echo_srpc.pb.hpp +317 -0
- package/go.mod +7 -7
- package/go.sum +14 -14
- package/mock/mock.pb.ts +1 -1
- package/mock/mock_srpc.pb.cpp +45 -0
- package/mock/mock_srpc.pb.hpp +104 -0
- package/package.json +6 -5
- package/srpc/CMakeLists.txt +59 -0
- package/srpc/client-rpc.cpp +106 -0
- package/srpc/client-rpc.hpp +68 -0
- package/srpc/client.cpp +101 -0
- package/srpc/client.hpp +66 -0
- package/srpc/common-rpc.cpp +182 -0
- package/srpc/common-rpc.hpp +109 -0
- package/srpc/errors.hpp +71 -0
- package/srpc/handler.hpp +23 -0
- package/srpc/invoker.hpp +91 -0
- package/srpc/message.hpp +28 -0
- package/srpc/msg-stream.hpp +86 -0
- package/srpc/mux.cpp +109 -0
- package/srpc/mux.hpp +64 -0
- package/srpc/packet.cpp +83 -0
- package/srpc/packet.hpp +56 -0
- package/srpc/rpcproto.pb.ts +1 -1
- package/srpc/server-rpc.cpp +97 -0
- package/srpc/server-rpc.hpp +63 -0
- package/srpc/starpc.hpp +18 -0
- package/srpc/stream.hpp +61 -0
- package/srpc/writer.hpp +60 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// go:build deps_only
|
|
2
|
+
|
|
3
|
+
// Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
|
|
4
|
+
// protoc-gen-starpc-cpp version: v0.43.2-0.20260131104303-1de77bff6409+dirty
|
|
5
|
+
// source: github.com/aperturerobotics/starpc/echo/echo.proto
|
|
6
|
+
|
|
7
|
+
#include "echo_srpc.pb.hpp"
|
|
8
|
+
|
|
9
|
+
namespace echo {
|
|
10
|
+
|
|
11
|
+
starpc::Error SRPCEchoerClientImpl::Echo(const echo::EchoMsg &in,
|
|
12
|
+
echo::EchoMsg *out) {
|
|
13
|
+
return cc_->ExecCall(service_id_, "Echo", in, out);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error>
|
|
17
|
+
SRPCEchoerClientImpl::EchoServerStream(const echo::EchoMsg &in) {
|
|
18
|
+
auto [strm, err] = cc_->NewStream(service_id_, "EchoServerStream", &in);
|
|
19
|
+
if (err != starpc::Error::OK) {
|
|
20
|
+
return {nullptr, err};
|
|
21
|
+
}
|
|
22
|
+
err = strm->CloseSend();
|
|
23
|
+
if (err != starpc::Error::OK) {
|
|
24
|
+
return {nullptr, err};
|
|
25
|
+
}
|
|
26
|
+
return {std::make_unique<SRPCEchoer_EchoServerStreamClient>(std::move(strm)),
|
|
27
|
+
starpc::Error::OK};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>, starpc::Error>
|
|
31
|
+
SRPCEchoerClientImpl::EchoClientStream() {
|
|
32
|
+
auto [strm, err] = cc_->NewStream(service_id_, "EchoClientStream", nullptr);
|
|
33
|
+
if (err != starpc::Error::OK) {
|
|
34
|
+
return {nullptr, err};
|
|
35
|
+
}
|
|
36
|
+
return {std::make_unique<SRPCEchoer_EchoClientStreamClient>(std::move(strm)),
|
|
37
|
+
starpc::Error::OK};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>, starpc::Error>
|
|
41
|
+
SRPCEchoerClientImpl::EchoBidiStream() {
|
|
42
|
+
auto [strm, err] = cc_->NewStream(service_id_, "EchoBidiStream", nullptr);
|
|
43
|
+
if (err != starpc::Error::OK) {
|
|
44
|
+
return {nullptr, err};
|
|
45
|
+
}
|
|
46
|
+
return {std::make_unique<SRPCEchoer_EchoBidiStreamClient>(std::move(strm)),
|
|
47
|
+
starpc::Error::OK};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
51
|
+
SRPCEchoerClientImpl::RpcStream() {
|
|
52
|
+
auto [strm, err] = cc_->NewStream(service_id_, "RpcStream", nullptr);
|
|
53
|
+
if (err != starpc::Error::OK) {
|
|
54
|
+
return {nullptr, err};
|
|
55
|
+
}
|
|
56
|
+
return {std::make_unique<SRPCEchoer_RpcStreamClient>(std::move(strm)),
|
|
57
|
+
starpc::Error::OK};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
starpc::Error SRPCEchoerClientImpl::DoNothing(const google::protobuf::Empty &in,
|
|
61
|
+
google::protobuf::Empty *out) {
|
|
62
|
+
return cc_->ExecCall(service_id_, "DoNothing", in, out);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
std::vector<std::string> SRPCEchoerHandler::GetMethodIDs() const {
|
|
66
|
+
return {
|
|
67
|
+
"Echo", "EchoServerStream", "EchoClientStream",
|
|
68
|
+
"EchoBidiStream", "RpcStream", "DoNothing",
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
std::pair<bool, starpc::Error>
|
|
73
|
+
SRPCEchoerHandler::InvokeMethod(const std::string &service_id,
|
|
74
|
+
const std::string &method_id,
|
|
75
|
+
starpc::Stream *strm) {
|
|
76
|
+
if (!service_id.empty() && service_id != service_id_) {
|
|
77
|
+
return {false, starpc::Error::OK};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (method_id == "Echo") {
|
|
81
|
+
echo::EchoMsg req;
|
|
82
|
+
starpc::Error err = strm->MsgRecv(&req);
|
|
83
|
+
if (err != starpc::Error::OK)
|
|
84
|
+
return {true, err};
|
|
85
|
+
echo::EchoMsg resp;
|
|
86
|
+
err = impl_->Echo(req, &resp);
|
|
87
|
+
if (err != starpc::Error::OK)
|
|
88
|
+
return {true, err};
|
|
89
|
+
return {true, strm->MsgSend(resp)};
|
|
90
|
+
} else if (method_id == "EchoServerStream") {
|
|
91
|
+
echo::EchoMsg req;
|
|
92
|
+
starpc::Error err = strm->MsgRecv(&req);
|
|
93
|
+
if (err != starpc::Error::OK)
|
|
94
|
+
return {true, err};
|
|
95
|
+
SRPCEchoer_EchoServerStreamStream serverStrm(strm);
|
|
96
|
+
return {true, impl_->EchoServerStream(req, &serverStrm)};
|
|
97
|
+
} else if (method_id == "EchoClientStream") {
|
|
98
|
+
SRPCEchoer_EchoClientStreamStream clientStrm(strm);
|
|
99
|
+
echo::EchoMsg resp;
|
|
100
|
+
starpc::Error err = impl_->EchoClientStream(&clientStrm, &resp);
|
|
101
|
+
if (err != starpc::Error::OK)
|
|
102
|
+
return {true, err};
|
|
103
|
+
return {true, strm->MsgSend(resp)};
|
|
104
|
+
} else if (method_id == "EchoBidiStream") {
|
|
105
|
+
SRPCEchoer_EchoBidiStreamStream bidiStrm(strm);
|
|
106
|
+
return {true, impl_->EchoBidiStream(&bidiStrm)};
|
|
107
|
+
} else if (method_id == "RpcStream") {
|
|
108
|
+
SRPCEchoer_RpcStreamStream bidiStrm(strm);
|
|
109
|
+
return {true, impl_->RpcStream(&bidiStrm)};
|
|
110
|
+
} else if (method_id == "DoNothing") {
|
|
111
|
+
google::protobuf::Empty req;
|
|
112
|
+
starpc::Error err = strm->MsgRecv(&req);
|
|
113
|
+
if (err != starpc::Error::OK)
|
|
114
|
+
return {true, err};
|
|
115
|
+
google::protobuf::Empty resp;
|
|
116
|
+
err = impl_->DoNothing(req, &resp);
|
|
117
|
+
if (err != starpc::Error::OK)
|
|
118
|
+
return {true, err};
|
|
119
|
+
return {true, strm->MsgSend(resp)};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {false, starpc::Error::OK};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
} // namespace echo
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
|
|
2
|
+
// protoc-gen-starpc-cpp version: v0.43.2-0.20260131104303-1de77bff6409+dirty
|
|
3
|
+
// source: github.com/aperturerobotics/starpc/echo/echo.proto
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <functional>
|
|
8
|
+
#include <memory>
|
|
9
|
+
#include <string>
|
|
10
|
+
#include <utility>
|
|
11
|
+
|
|
12
|
+
#include "srpc/starpc.hpp"
|
|
13
|
+
|
|
14
|
+
#include "echo.pb.h"
|
|
15
|
+
|
|
16
|
+
namespace echo {
|
|
17
|
+
|
|
18
|
+
// Service ID for Echoer
|
|
19
|
+
constexpr const char *kSRPCEchoerServiceID = "echo.Echoer";
|
|
20
|
+
|
|
21
|
+
class SRPCEchoer_EchoServerStreamClient;
|
|
22
|
+
class SRPCEchoer_EchoServerStreamStream;
|
|
23
|
+
class SRPCEchoer_EchoClientStreamClient;
|
|
24
|
+
class SRPCEchoer_EchoClientStreamStream;
|
|
25
|
+
class SRPCEchoer_EchoBidiStreamClient;
|
|
26
|
+
class SRPCEchoer_EchoBidiStreamStream;
|
|
27
|
+
class SRPCEchoer_RpcStreamClient;
|
|
28
|
+
class SRPCEchoer_RpcStreamStream;
|
|
29
|
+
|
|
30
|
+
// SRPCEchoerClient is the client API for Echoer service.
|
|
31
|
+
class SRPCEchoerClient {
|
|
32
|
+
public:
|
|
33
|
+
virtual ~SRPCEchoerClient() = default;
|
|
34
|
+
|
|
35
|
+
// SRPCClient returns the underlying SRPC client.
|
|
36
|
+
virtual starpc::Client *SRPCClient() = 0;
|
|
37
|
+
|
|
38
|
+
// Echo
|
|
39
|
+
virtual starpc::Error Echo(const echo::EchoMsg &in, echo::EchoMsg *out) = 0;
|
|
40
|
+
// EchoServerStream
|
|
41
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>,
|
|
42
|
+
starpc::Error>
|
|
43
|
+
EchoServerStream(const echo::EchoMsg &in) = 0;
|
|
44
|
+
// EchoClientStream
|
|
45
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>,
|
|
46
|
+
starpc::Error>
|
|
47
|
+
EchoClientStream() = 0;
|
|
48
|
+
// EchoBidiStream
|
|
49
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>,
|
|
50
|
+
starpc::Error>
|
|
51
|
+
EchoBidiStream() = 0;
|
|
52
|
+
// RpcStream
|
|
53
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
54
|
+
RpcStream() = 0;
|
|
55
|
+
// DoNothing
|
|
56
|
+
virtual starpc::Error DoNothing(const google::protobuf::Empty &in,
|
|
57
|
+
google::protobuf::Empty *out) = 0;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// SRPCEchoerClientImpl implements SRPCEchoerClient.
|
|
61
|
+
class SRPCEchoerClientImpl : public SRPCEchoerClient {
|
|
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) {}
|
|
67
|
+
|
|
68
|
+
starpc::Client *SRPCClient() override { return cc_; }
|
|
69
|
+
|
|
70
|
+
// Echo
|
|
71
|
+
virtual starpc::Error Echo(const echo::EchoMsg &in,
|
|
72
|
+
echo::EchoMsg *out) override;
|
|
73
|
+
// EchoServerStream
|
|
74
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>,
|
|
75
|
+
starpc::Error>
|
|
76
|
+
EchoServerStream(const echo::EchoMsg &in) override;
|
|
77
|
+
// EchoClientStream
|
|
78
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>,
|
|
79
|
+
starpc::Error>
|
|
80
|
+
EchoClientStream() override;
|
|
81
|
+
// EchoBidiStream
|
|
82
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>,
|
|
83
|
+
starpc::Error>
|
|
84
|
+
EchoBidiStream() override;
|
|
85
|
+
// RpcStream
|
|
86
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
87
|
+
RpcStream() override;
|
|
88
|
+
// DoNothing
|
|
89
|
+
virtual starpc::Error DoNothing(const google::protobuf::Empty &in,
|
|
90
|
+
google::protobuf::Empty *out) override;
|
|
91
|
+
|
|
92
|
+
private:
|
|
93
|
+
starpc::Client *cc_;
|
|
94
|
+
std::string service_id_;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// NewSRPCEchoerClient creates a new client.
|
|
98
|
+
inline std::unique_ptr<SRPCEchoerClient>
|
|
99
|
+
NewSRPCEchoerClient(starpc::Client *cc) {
|
|
100
|
+
return std::make_unique<SRPCEchoerClientImpl>(cc);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// SRPCEchoerServer is the server API for Echoer service.
|
|
104
|
+
class SRPCEchoerServer {
|
|
105
|
+
public:
|
|
106
|
+
virtual ~SRPCEchoerServer() = default;
|
|
107
|
+
|
|
108
|
+
// Echo
|
|
109
|
+
virtual starpc::Error Echo(const echo::EchoMsg &req, echo::EchoMsg *resp) = 0;
|
|
110
|
+
// EchoServerStream
|
|
111
|
+
virtual starpc::Error
|
|
112
|
+
EchoServerStream(const echo::EchoMsg &req,
|
|
113
|
+
SRPCEchoer_EchoServerStreamStream *strm) = 0;
|
|
114
|
+
// EchoClientStream
|
|
115
|
+
virtual starpc::Error
|
|
116
|
+
EchoClientStream(SRPCEchoer_EchoClientStreamStream *strm,
|
|
117
|
+
echo::EchoMsg *resp) = 0;
|
|
118
|
+
// EchoBidiStream
|
|
119
|
+
virtual starpc::Error
|
|
120
|
+
EchoBidiStream(SRPCEchoer_EchoBidiStreamStream *strm) = 0;
|
|
121
|
+
// RpcStream
|
|
122
|
+
virtual starpc::Error RpcStream(SRPCEchoer_RpcStreamStream *strm) = 0;
|
|
123
|
+
// DoNothing
|
|
124
|
+
virtual starpc::Error DoNothing(const google::protobuf::Empty &req,
|
|
125
|
+
google::protobuf::Empty *resp) = 0;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// SRPCEchoerHandler implements starpc::Handler for Echoer.
|
|
129
|
+
class SRPCEchoerHandler : public starpc::Handler {
|
|
130
|
+
public:
|
|
131
|
+
SRPCEchoerHandler(SRPCEchoerServer *impl, const std::string &service_id = "")
|
|
132
|
+
: impl_(impl),
|
|
133
|
+
service_id_(service_id.empty() ? kSRPCEchoerServiceID : service_id) {}
|
|
134
|
+
|
|
135
|
+
const std::string &GetServiceID() const override { return service_id_; }
|
|
136
|
+
std::vector<std::string> GetMethodIDs() const override;
|
|
137
|
+
std::pair<bool, starpc::Error> InvokeMethod(const std::string &service_id,
|
|
138
|
+
const std::string &method_id,
|
|
139
|
+
starpc::Stream *strm) override;
|
|
140
|
+
|
|
141
|
+
private:
|
|
142
|
+
SRPCEchoerServer *impl_;
|
|
143
|
+
std::string service_id_;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// NewSRPCEchoerHandler creates a new handler for the given implementation.
|
|
147
|
+
inline std::unique_ptr<SRPCEchoerHandler>
|
|
148
|
+
NewSRPCEchoerHandler(SRPCEchoerServer *impl) {
|
|
149
|
+
return std::make_unique<SRPCEchoerHandler>(impl);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// SRPCRegisterEchoer registers the server implementation with the mux.
|
|
153
|
+
// The returned handler must outlive the mux registration.
|
|
154
|
+
inline std::pair<std::unique_ptr<SRPCEchoerHandler>, starpc::Error>
|
|
155
|
+
SRPCRegisterEchoer(starpc::Mux *mux, SRPCEchoerServer *impl) {
|
|
156
|
+
auto handler = NewSRPCEchoerHandler(impl);
|
|
157
|
+
starpc::Error err = mux->Register(handler.get());
|
|
158
|
+
if (err != starpc::Error::OK) {
|
|
159
|
+
return {nullptr, err};
|
|
160
|
+
}
|
|
161
|
+
return {std::move(handler), starpc::Error::OK};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// SRPCEchoer_EchoServerStreamClient is the client stream for EchoServerStream.
|
|
165
|
+
class SRPCEchoer_EchoServerStreamClient {
|
|
166
|
+
public:
|
|
167
|
+
explicit SRPCEchoer_EchoServerStreamClient(
|
|
168
|
+
std::unique_ptr<starpc::Stream> strm)
|
|
169
|
+
: strm_(std::move(strm)) {}
|
|
170
|
+
|
|
171
|
+
starpc::Error Recv(echo::EchoMsg *msg) { return strm_->MsgRecv(msg); }
|
|
172
|
+
|
|
173
|
+
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
174
|
+
starpc::Error Close() { return strm_->Close(); }
|
|
175
|
+
|
|
176
|
+
private:
|
|
177
|
+
std::unique_ptr<starpc::Stream> strm_;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// SRPCEchoer_EchoServerStreamStream is the server stream for EchoServerStream.
|
|
181
|
+
class SRPCEchoer_EchoServerStreamStream {
|
|
182
|
+
public:
|
|
183
|
+
explicit SRPCEchoer_EchoServerStreamStream(starpc::Stream *strm)
|
|
184
|
+
: strm_(strm) {}
|
|
185
|
+
|
|
186
|
+
starpc::Error Send(const echo::EchoMsg &msg) { return strm_->MsgSend(msg); }
|
|
187
|
+
|
|
188
|
+
starpc::Error SendAndClose(const echo::EchoMsg &msg) {
|
|
189
|
+
starpc::Error err = strm_->MsgSend(msg);
|
|
190
|
+
if (err != starpc::Error::OK)
|
|
191
|
+
return err;
|
|
192
|
+
return strm_->CloseSend();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private:
|
|
196
|
+
starpc::Stream *strm_;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// SRPCEchoer_EchoClientStreamClient is the client stream for EchoClientStream.
|
|
200
|
+
class SRPCEchoer_EchoClientStreamClient {
|
|
201
|
+
public:
|
|
202
|
+
explicit SRPCEchoer_EchoClientStreamClient(
|
|
203
|
+
std::unique_ptr<starpc::Stream> strm)
|
|
204
|
+
: strm_(std::move(strm)) {}
|
|
205
|
+
|
|
206
|
+
starpc::Error Send(const echo::EchoMsg &msg) { return strm_->MsgSend(msg); }
|
|
207
|
+
|
|
208
|
+
starpc::Error CloseAndRecv(echo::EchoMsg *msg) {
|
|
209
|
+
starpc::Error err = strm_->CloseSend();
|
|
210
|
+
if (err != starpc::Error::OK)
|
|
211
|
+
return err;
|
|
212
|
+
return strm_->MsgRecv(msg);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
216
|
+
starpc::Error Close() { return strm_->Close(); }
|
|
217
|
+
|
|
218
|
+
private:
|
|
219
|
+
std::unique_ptr<starpc::Stream> strm_;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// SRPCEchoer_EchoClientStreamStream is the server stream for EchoClientStream.
|
|
223
|
+
class SRPCEchoer_EchoClientStreamStream {
|
|
224
|
+
public:
|
|
225
|
+
explicit SRPCEchoer_EchoClientStreamStream(starpc::Stream *strm)
|
|
226
|
+
: strm_(strm) {}
|
|
227
|
+
|
|
228
|
+
starpc::Error Recv(echo::EchoMsg *msg) { return strm_->MsgRecv(msg); }
|
|
229
|
+
|
|
230
|
+
private:
|
|
231
|
+
starpc::Stream *strm_;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// SRPCEchoer_EchoBidiStreamClient is the client stream for EchoBidiStream.
|
|
235
|
+
class SRPCEchoer_EchoBidiStreamClient {
|
|
236
|
+
public:
|
|
237
|
+
explicit SRPCEchoer_EchoBidiStreamClient(std::unique_ptr<starpc::Stream> strm)
|
|
238
|
+
: strm_(std::move(strm)) {}
|
|
239
|
+
|
|
240
|
+
starpc::Error Send(const echo::EchoMsg &msg) { return strm_->MsgSend(msg); }
|
|
241
|
+
|
|
242
|
+
starpc::Error Recv(echo::EchoMsg *msg) { return strm_->MsgRecv(msg); }
|
|
243
|
+
|
|
244
|
+
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
245
|
+
starpc::Error Close() { return strm_->Close(); }
|
|
246
|
+
|
|
247
|
+
private:
|
|
248
|
+
std::unique_ptr<starpc::Stream> strm_;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// SRPCEchoer_EchoBidiStreamStream is the server stream for EchoBidiStream.
|
|
252
|
+
class SRPCEchoer_EchoBidiStreamStream {
|
|
253
|
+
public:
|
|
254
|
+
explicit SRPCEchoer_EchoBidiStreamStream(starpc::Stream *strm)
|
|
255
|
+
: strm_(strm) {}
|
|
256
|
+
|
|
257
|
+
starpc::Error Send(const echo::EchoMsg &msg) { return strm_->MsgSend(msg); }
|
|
258
|
+
|
|
259
|
+
starpc::Error SendAndClose(const echo::EchoMsg &msg) {
|
|
260
|
+
starpc::Error err = strm_->MsgSend(msg);
|
|
261
|
+
if (err != starpc::Error::OK)
|
|
262
|
+
return err;
|
|
263
|
+
return strm_->CloseSend();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
starpc::Error Recv(echo::EchoMsg *msg) { return strm_->MsgRecv(msg); }
|
|
267
|
+
|
|
268
|
+
private:
|
|
269
|
+
starpc::Stream *strm_;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// SRPCEchoer_RpcStreamClient is the client stream for RpcStream.
|
|
273
|
+
class SRPCEchoer_RpcStreamClient {
|
|
274
|
+
public:
|
|
275
|
+
explicit SRPCEchoer_RpcStreamClient(std::unique_ptr<starpc::Stream> strm)
|
|
276
|
+
: strm_(std::move(strm)) {}
|
|
277
|
+
|
|
278
|
+
starpc::Error Send(const rpcstream::RpcStreamPacket &msg) {
|
|
279
|
+
return strm_->MsgSend(msg);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
starpc::Error Recv(rpcstream::RpcStreamPacket *msg) {
|
|
283
|
+
return strm_->MsgRecv(msg);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
287
|
+
starpc::Error Close() { return strm_->Close(); }
|
|
288
|
+
|
|
289
|
+
private:
|
|
290
|
+
std::unique_ptr<starpc::Stream> strm_;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// SRPCEchoer_RpcStreamStream is the server stream for RpcStream.
|
|
294
|
+
class SRPCEchoer_RpcStreamStream {
|
|
295
|
+
public:
|
|
296
|
+
explicit SRPCEchoer_RpcStreamStream(starpc::Stream *strm) : strm_(strm) {}
|
|
297
|
+
|
|
298
|
+
starpc::Error Send(const rpcstream::RpcStreamPacket &msg) {
|
|
299
|
+
return strm_->MsgSend(msg);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
starpc::Error SendAndClose(const rpcstream::RpcStreamPacket &msg) {
|
|
303
|
+
starpc::Error err = strm_->MsgSend(msg);
|
|
304
|
+
if (err != starpc::Error::OK)
|
|
305
|
+
return err;
|
|
306
|
+
return strm_->CloseSend();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
starpc::Error Recv(rpcstream::RpcStreamPacket *msg) {
|
|
310
|
+
return strm_->MsgRecv(msg);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private:
|
|
314
|
+
starpc::Stream *strm_;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
} // namespace echo
|
package/go.mod
CHANGED
|
@@ -11,9 +11,9 @@ 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
|
-
github.com/aperturerobotics/util v1.32.
|
|
16
|
+
github.com/aperturerobotics/util v1.32.3 // latest
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
require (
|
|
@@ -26,11 +26,11 @@ require (
|
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
require (
|
|
29
|
-
github.com/aperturerobotics/abseil-cpp v0.0.0-
|
|
29
|
+
github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 // aperture-2
|
|
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
|
-
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.
|
|
33
|
-
github.com/aperturerobotics/protobuf v0.0.0-
|
|
32
|
+
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726 // indirect
|
|
33
|
+
github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 // wasi
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
require (
|
|
@@ -49,9 +49,9 @@ require (
|
|
|
49
49
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
|
50
50
|
github.com/tetratelabs/wazero v1.11.0 // indirect
|
|
51
51
|
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
|
|
52
|
-
golang.org/x/crypto v0.
|
|
52
|
+
golang.org/x/crypto v0.45.0 // indirect
|
|
53
53
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
|
|
54
54
|
golang.org/x/mod v0.32.0 // indirect
|
|
55
|
-
golang.org/x/sys v0.
|
|
55
|
+
golang.org/x/sys v0.40.0 // indirect
|
|
56
56
|
lukechampine.com/blake3 v1.3.0 // indirect
|
|
57
57
|
)
|
package/go.sum
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
github.com/aperturerobotics/abseil-cpp v0.0.0-
|
|
2
|
-
github.com/aperturerobotics/abseil-cpp v0.0.0-
|
|
1
|
+
github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 h1:3U7v3ba/ZxaGkbvM//GWvZV7WM2gy3vRgagPFAm0NCk=
|
|
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
|
-
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.
|
|
12
|
-
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.
|
|
13
|
-
github.com/aperturerobotics/protobuf v0.0.0-
|
|
14
|
-
github.com/aperturerobotics/protobuf v0.0.0-
|
|
11
|
+
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726 h1:4B1F0DzuqPzb6WqgCjWaqDD7JU9RDsevQG5OP0DFBgs=
|
|
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-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
|
-
github.com/aperturerobotics/util v1.32.
|
|
18
|
-
github.com/aperturerobotics/util v1.32.
|
|
17
|
+
github.com/aperturerobotics/util v1.32.3 h1:wBc6L2guYMgLEzFwORH3CLMoMpfEqbV6pDqYervo3S0=
|
|
18
|
+
github.com/aperturerobotics/util v1.32.3/go.mod h1:qfRZZUDn0sEfc43JRA6rKP8bwFxliqGqJZX+p1jeOnQ=
|
|
19
19
|
github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
|
|
20
20
|
github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
|
|
21
21
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
@@ -64,15 +64,15 @@ github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbw
|
|
|
64
64
|
github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=
|
|
65
65
|
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg=
|
|
66
66
|
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
|
67
|
-
golang.org/x/crypto v0.
|
|
68
|
-
golang.org/x/crypto v0.
|
|
67
|
+
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
|
68
|
+
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
|
69
69
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
|
|
70
70
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
|
|
71
71
|
golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
|
|
72
72
|
golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
|
|
73
73
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
74
|
-
golang.org/x/sys v0.
|
|
75
|
-
golang.org/x/sys v0.
|
|
74
|
+
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
|
|
75
|
+
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
|
76
76
|
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
|
77
77
|
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
|
78
78
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
package/mock/mock.pb.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-lite unknown with parameter "target=ts
|
|
1
|
+
// @generated by protoc-gen-es-lite unknown with parameter "ts_nocheck=false,target=ts"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/mock/mock.proto (package e2e.mock, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// go:build deps_only
|
|
2
|
+
|
|
3
|
+
// Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
|
|
4
|
+
// protoc-gen-starpc-cpp version: v0.43.2-0.20260131104303-1de77bff6409+dirty
|
|
5
|
+
// source: github.com/aperturerobotics/starpc/mock/mock.proto
|
|
6
|
+
|
|
7
|
+
#include "mock_srpc.pb.hpp"
|
|
8
|
+
|
|
9
|
+
namespace e2e::mock {
|
|
10
|
+
|
|
11
|
+
starpc::Error SRPCMockClientImpl::MockRequest(const e2e::mock::MockMsg &in,
|
|
12
|
+
e2e::mock::MockMsg *out) {
|
|
13
|
+
return cc_->ExecCall(service_id_, "MockRequest", in, out);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
std::vector<std::string> SRPCMockHandler::GetMethodIDs() const {
|
|
17
|
+
return {
|
|
18
|
+
"MockRequest",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
std::pair<bool, starpc::Error>
|
|
23
|
+
SRPCMockHandler::InvokeMethod(const std::string &service_id,
|
|
24
|
+
const std::string &method_id,
|
|
25
|
+
starpc::Stream *strm) {
|
|
26
|
+
if (!service_id.empty() && service_id != service_id_) {
|
|
27
|
+
return {false, starpc::Error::OK};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (method_id == "MockRequest") {
|
|
31
|
+
e2e::mock::MockMsg req;
|
|
32
|
+
starpc::Error err = strm->MsgRecv(&req);
|
|
33
|
+
if (err != starpc::Error::OK)
|
|
34
|
+
return {true, err};
|
|
35
|
+
e2e::mock::MockMsg resp;
|
|
36
|
+
err = impl_->MockRequest(req, &resp);
|
|
37
|
+
if (err != starpc::Error::OK)
|
|
38
|
+
return {true, err};
|
|
39
|
+
return {true, strm->MsgSend(resp)};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {false, starpc::Error::OK};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
} // namespace e2e::mock
|