starpc 0.45.0 → 0.46.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/Cargo.toml +0 -4
- package/echo/echo.pb.go +1 -1
- package/echo/echo.pb.rs +9 -0
- package/echo/echo.pb.ts +1 -1
- package/echo/echo_e2e_test.cpp +1 -1
- package/echo/echo_srpc.pb.cpp +29 -41
- package/echo/echo_srpc.pb.go +1 -1
- package/echo/echo_srpc.pb.hpp +109 -132
- package/echo/echo_srpc.pb.rs +312 -0
- package/echo/gen/mod.rs +15 -2
- package/echo/main.rs +9 -0
- package/go.mod +3 -2
- package/go.sum +6 -4
- package/mock/mock.pb.go +1 -1
- package/mock/mock.pb.rs +9 -0
- package/mock/mock.pb.ts +1 -1
- package/mock/mock_srpc.pb.cpp +11 -14
- package/mock/mock_srpc.pb.go +1 -1
- package/mock/mock_srpc.pb.hpp +31 -35
- package/mock/mock_srpc.pb.rs +103 -0
- package/package.json +1 -1
- package/srpc/Cargo.toml +1 -2
- package/srpc/client-rpc.cpp +1 -1
- package/srpc/client.cpp +1 -1
- package/srpc/common-rpc.cpp +1 -1
- package/srpc/lib.rs +1 -0
- package/srpc/mux.cpp +1 -1
- package/srpc/packet.cpp +1 -1
- package/srpc/proto.rs +5 -0
- package/srpc/rpcproto.pb.go +1 -1
- package/srpc/rpcproto.pb.rs +62 -0
- package/srpc/rpcproto.pb.ts +1 -1
- package/srpc/rpcstream/mod.rs +38 -0
- package/srpc/rpcstream/proto.rs +286 -0
- package/srpc/rpcstream/stream.rs +517 -0
- package/srpc/rpcstream/writer.rs +150 -0
- package/srpc/server-rpc.cpp +1 -1
- package/echo/build.rs +0 -15
- package/srpc/build.rs +0 -15
- package/srpc/proto/mod.rs +0 -10
package/dist/echo/echo.pb.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-lite unknown with parameter "ts_nocheck=false
|
|
1
|
+
// @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/echo/echo.proto (package echo, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
import { createMessageType, ScalarType } from '@aptre/protobuf-es-lite';
|
package/dist/mock/mock.pb.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-lite unknown with parameter "ts_nocheck=false
|
|
1
|
+
// @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/mock/mock.proto (package e2e.mock, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
import { createMessageType, ScalarType } from '@aptre/protobuf-es-lite';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-lite unknown with parameter "ts_nocheck=false
|
|
1
|
+
// @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/rpcstream/rpcstream.proto (package rpcstream, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
import { createMessageType, ScalarType } from '@aptre/protobuf-es-lite';
|
package/dist/srpc/rpcproto.pb.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-lite unknown with parameter "ts_nocheck=false
|
|
1
|
+
// @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/srpc/rpcproto.proto (package srpc, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
import { createMessageType, ScalarType } from '@aptre/protobuf-es-lite';
|
package/echo/Cargo.toml
CHANGED
package/echo/echo.pb.go
CHANGED
package/echo/echo.pb.rs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @generated
|
|
2
|
+
// This file is @generated by prost-build.
|
|
3
|
+
/// EchoMsg is the message body for Echo.
|
|
4
|
+
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
|
5
|
+
pub struct EchoMsg {
|
|
6
|
+
#[prost(string, tag="1")]
|
|
7
|
+
pub body: ::prost::alloc::string::String,
|
|
8
|
+
}
|
|
9
|
+
// @@protoc_insertion_point(module)
|
package/echo/echo.pb.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-lite unknown with parameter "ts_nocheck=false
|
|
1
|
+
// @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/echo/echo.proto (package echo, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
package/echo/echo_e2e_test.cpp
CHANGED
package/echo/echo_srpc.pb.cpp
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
//
|
|
1
|
+
//go:build deps_only
|
|
2
2
|
|
|
3
3
|
// Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
|
|
4
|
-
// protoc-gen-starpc-cpp version: v0.
|
|
4
|
+
// protoc-gen-starpc-cpp version: v0.45.1-0.20260203090429-3e915608d4e8
|
|
5
5
|
// source: github.com/aperturerobotics/starpc/echo/echo.proto
|
|
6
6
|
|
|
7
7
|
#include "echo_srpc.pb.hpp"
|
|
8
8
|
|
|
9
9
|
namespace echo {
|
|
10
10
|
|
|
11
|
-
starpc::Error SRPCEchoerClientImpl::Echo(const echo::EchoMsg
|
|
12
|
-
echo::EchoMsg *out) {
|
|
11
|
+
starpc::Error SRPCEchoerClientImpl::Echo(const echo::EchoMsg& in, echo::EchoMsg* out) {
|
|
13
12
|
return cc_->ExecCall(service_id_, "Echo", in, out);
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error>
|
|
17
|
-
SRPCEchoerClientImpl::EchoServerStream(const echo::EchoMsg &in) {
|
|
15
|
+
std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error> SRPCEchoerClientImpl::EchoServerStream(const echo::EchoMsg& in) {
|
|
18
16
|
auto [strm, err] = cc_->NewStream(service_id_, "EchoServerStream", &in);
|
|
19
17
|
if (err != starpc::Error::OK) {
|
|
20
18
|
return {nullptr, err};
|
|
@@ -23,56 +21,52 @@ SRPCEchoerClientImpl::EchoServerStream(const echo::EchoMsg &in) {
|
|
|
23
21
|
if (err != starpc::Error::OK) {
|
|
24
22
|
return {nullptr, err};
|
|
25
23
|
}
|
|
26
|
-
return {std::make_unique<SRPCEchoer_EchoServerStreamClient>(std::move(strm)),
|
|
27
|
-
starpc::Error::OK};
|
|
24
|
+
return {std::make_unique<SRPCEchoer_EchoServerStreamClient>(std::move(strm)), starpc::Error::OK};
|
|
28
25
|
}
|
|
29
26
|
|
|
30
|
-
std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>, starpc::Error>
|
|
31
|
-
SRPCEchoerClientImpl::EchoClientStream() {
|
|
27
|
+
std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>, starpc::Error> SRPCEchoerClientImpl::EchoClientStream() {
|
|
32
28
|
auto [strm, err] = cc_->NewStream(service_id_, "EchoClientStream", nullptr);
|
|
33
29
|
if (err != starpc::Error::OK) {
|
|
34
30
|
return {nullptr, err};
|
|
35
31
|
}
|
|
36
|
-
return {std::make_unique<SRPCEchoer_EchoClientStreamClient>(std::move(strm)),
|
|
37
|
-
starpc::Error::OK};
|
|
32
|
+
return {std::make_unique<SRPCEchoer_EchoClientStreamClient>(std::move(strm)), starpc::Error::OK};
|
|
38
33
|
}
|
|
39
34
|
|
|
40
|
-
std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>, starpc::Error>
|
|
41
|
-
SRPCEchoerClientImpl::EchoBidiStream() {
|
|
35
|
+
std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>, starpc::Error> SRPCEchoerClientImpl::EchoBidiStream() {
|
|
42
36
|
auto [strm, err] = cc_->NewStream(service_id_, "EchoBidiStream", nullptr);
|
|
43
37
|
if (err != starpc::Error::OK) {
|
|
44
38
|
return {nullptr, err};
|
|
45
39
|
}
|
|
46
|
-
return {std::make_unique<SRPCEchoer_EchoBidiStreamClient>(std::move(strm)),
|
|
47
|
-
starpc::Error::OK};
|
|
40
|
+
return {std::make_unique<SRPCEchoer_EchoBidiStreamClient>(std::move(strm)), starpc::Error::OK};
|
|
48
41
|
}
|
|
49
42
|
|
|
50
|
-
std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
51
|
-
SRPCEchoerClientImpl::RpcStream() {
|
|
43
|
+
std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error> SRPCEchoerClientImpl::RpcStream() {
|
|
52
44
|
auto [strm, err] = cc_->NewStream(service_id_, "RpcStream", nullptr);
|
|
53
45
|
if (err != starpc::Error::OK) {
|
|
54
46
|
return {nullptr, err};
|
|
55
47
|
}
|
|
56
|
-
return {std::make_unique<SRPCEchoer_RpcStreamClient>(std::move(strm)),
|
|
57
|
-
starpc::Error::OK};
|
|
48
|
+
return {std::make_unique<SRPCEchoer_RpcStreamClient>(std::move(strm)), starpc::Error::OK};
|
|
58
49
|
}
|
|
59
50
|
|
|
60
|
-
starpc::Error SRPCEchoerClientImpl::DoNothing(const google::protobuf::Empty
|
|
61
|
-
google::protobuf::Empty *out) {
|
|
51
|
+
starpc::Error SRPCEchoerClientImpl::DoNothing(const google::protobuf::Empty& in, google::protobuf::Empty* out) {
|
|
62
52
|
return cc_->ExecCall(service_id_, "DoNothing", in, out);
|
|
63
53
|
}
|
|
64
54
|
|
|
65
55
|
std::vector<std::string> SRPCEchoerHandler::GetMethodIDs() const {
|
|
66
56
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
"Echo",
|
|
58
|
+
"EchoServerStream",
|
|
59
|
+
"EchoClientStream",
|
|
60
|
+
"EchoBidiStream",
|
|
61
|
+
"RpcStream",
|
|
62
|
+
"DoNothing",
|
|
69
63
|
};
|
|
70
64
|
}
|
|
71
65
|
|
|
72
|
-
std::pair<bool, starpc::Error>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
std::pair<bool, starpc::Error> SRPCEchoerHandler::InvokeMethod(
|
|
67
|
+
const std::string& service_id,
|
|
68
|
+
const std::string& method_id,
|
|
69
|
+
starpc::Stream* strm) {
|
|
76
70
|
if (!service_id.empty() && service_id != service_id_) {
|
|
77
71
|
return {false, starpc::Error::OK};
|
|
78
72
|
}
|
|
@@ -80,26 +74,22 @@ SRPCEchoerHandler::InvokeMethod(const std::string &service_id,
|
|
|
80
74
|
if (method_id == "Echo") {
|
|
81
75
|
echo::EchoMsg req;
|
|
82
76
|
starpc::Error err = strm->MsgRecv(&req);
|
|
83
|
-
if (err != starpc::Error::OK)
|
|
84
|
-
return {true, err};
|
|
77
|
+
if (err != starpc::Error::OK) return {true, err};
|
|
85
78
|
echo::EchoMsg resp;
|
|
86
79
|
err = impl_->Echo(req, &resp);
|
|
87
|
-
if (err != starpc::Error::OK)
|
|
88
|
-
return {true, err};
|
|
80
|
+
if (err != starpc::Error::OK) return {true, err};
|
|
89
81
|
return {true, strm->MsgSend(resp)};
|
|
90
82
|
} else if (method_id == "EchoServerStream") {
|
|
91
83
|
echo::EchoMsg req;
|
|
92
84
|
starpc::Error err = strm->MsgRecv(&req);
|
|
93
|
-
if (err != starpc::Error::OK)
|
|
94
|
-
return {true, err};
|
|
85
|
+
if (err != starpc::Error::OK) return {true, err};
|
|
95
86
|
SRPCEchoer_EchoServerStreamStream serverStrm(strm);
|
|
96
87
|
return {true, impl_->EchoServerStream(req, &serverStrm)};
|
|
97
88
|
} else if (method_id == "EchoClientStream") {
|
|
98
89
|
SRPCEchoer_EchoClientStreamStream clientStrm(strm);
|
|
99
90
|
echo::EchoMsg resp;
|
|
100
91
|
starpc::Error err = impl_->EchoClientStream(&clientStrm, &resp);
|
|
101
|
-
if (err != starpc::Error::OK)
|
|
102
|
-
return {true, err};
|
|
92
|
+
if (err != starpc::Error::OK) return {true, err};
|
|
103
93
|
return {true, strm->MsgSend(resp)};
|
|
104
94
|
} else if (method_id == "EchoBidiStream") {
|
|
105
95
|
SRPCEchoer_EchoBidiStreamStream bidiStrm(strm);
|
|
@@ -110,16 +100,14 @@ SRPCEchoerHandler::InvokeMethod(const std::string &service_id,
|
|
|
110
100
|
} else if (method_id == "DoNothing") {
|
|
111
101
|
google::protobuf::Empty req;
|
|
112
102
|
starpc::Error err = strm->MsgRecv(&req);
|
|
113
|
-
if (err != starpc::Error::OK)
|
|
114
|
-
return {true, err};
|
|
103
|
+
if (err != starpc::Error::OK) return {true, err};
|
|
115
104
|
google::protobuf::Empty resp;
|
|
116
105
|
err = impl_->DoNothing(req, &resp);
|
|
117
|
-
if (err != starpc::Error::OK)
|
|
118
|
-
return {true, err};
|
|
106
|
+
if (err != starpc::Error::OK) return {true, err};
|
|
119
107
|
return {true, strm->MsgSend(resp)};
|
|
120
108
|
}
|
|
121
109
|
|
|
122
110
|
return {false, starpc::Error::OK};
|
|
123
111
|
}
|
|
124
112
|
|
|
125
|
-
}
|
|
113
|
+
} // namespace echo
|
package/echo/echo_srpc.pb.go
CHANGED
package/echo/echo_srpc.pb.hpp
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
//go:build deps_only && cgo
|
|
2
|
+
|
|
1
3
|
// Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
|
|
2
|
-
// protoc-gen-starpc-cpp version: v0.
|
|
4
|
+
// protoc-gen-starpc-cpp version: v0.45.1-0.20260203090429-3e915608d4e8
|
|
3
5
|
// source: github.com/aperturerobotics/starpc/echo/echo.proto
|
|
4
6
|
|
|
5
7
|
#pragma once
|
|
@@ -16,7 +18,7 @@
|
|
|
16
18
|
namespace echo {
|
|
17
19
|
|
|
18
20
|
// Service ID for Echoer
|
|
19
|
-
constexpr const char
|
|
21
|
+
constexpr const char* kSRPCEchoerServiceID = "echo.Echoer";
|
|
20
22
|
|
|
21
23
|
class SRPCEchoer_EchoServerStreamClient;
|
|
22
24
|
class SRPCEchoer_EchoServerStreamStream;
|
|
@@ -29,130 +31,102 @@ class SRPCEchoer_RpcStreamStream;
|
|
|
29
31
|
|
|
30
32
|
// SRPCEchoerClient is the client API for Echoer service.
|
|
31
33
|
class SRPCEchoerClient {
|
|
32
|
-
public:
|
|
34
|
+
public:
|
|
33
35
|
virtual ~SRPCEchoerClient() = default;
|
|
34
36
|
|
|
35
37
|
// SRPCClient returns the underlying SRPC client.
|
|
36
|
-
virtual starpc::Client
|
|
38
|
+
virtual starpc::Client* SRPCClient() = 0;
|
|
37
39
|
|
|
38
40
|
// Echo
|
|
39
|
-
virtual starpc::Error Echo(const echo::EchoMsg
|
|
41
|
+
virtual starpc::Error Echo(const echo::EchoMsg& in, echo::EchoMsg* out) = 0;
|
|
40
42
|
// EchoServerStream
|
|
41
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>,
|
|
42
|
-
starpc::Error>
|
|
43
|
-
EchoServerStream(const echo::EchoMsg &in) = 0;
|
|
43
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error> EchoServerStream(const echo::EchoMsg& in) = 0;
|
|
44
44
|
// EchoClientStream
|
|
45
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>,
|
|
46
|
-
starpc::Error>
|
|
47
|
-
EchoClientStream() = 0;
|
|
45
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>, starpc::Error> EchoClientStream() = 0;
|
|
48
46
|
// EchoBidiStream
|
|
49
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>,
|
|
50
|
-
starpc::Error>
|
|
51
|
-
EchoBidiStream() = 0;
|
|
47
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>, starpc::Error> EchoBidiStream() = 0;
|
|
52
48
|
// RpcStream
|
|
53
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
54
|
-
RpcStream() = 0;
|
|
49
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error> RpcStream() = 0;
|
|
55
50
|
// DoNothing
|
|
56
|
-
virtual starpc::Error DoNothing(const google::protobuf::Empty
|
|
57
|
-
google::protobuf::Empty *out) = 0;
|
|
51
|
+
virtual starpc::Error DoNothing(const google::protobuf::Empty& in, google::protobuf::Empty* out) = 0;
|
|
58
52
|
};
|
|
59
53
|
|
|
60
54
|
// SRPCEchoerClientImpl implements SRPCEchoerClient.
|
|
61
55
|
class SRPCEchoerClientImpl : public SRPCEchoerClient {
|
|
62
|
-
public:
|
|
63
|
-
explicit SRPCEchoerClientImpl(starpc::Client
|
|
64
|
-
|
|
65
|
-
: cc_(cc),
|
|
66
|
-
service_id_(service_id.empty() ? kSRPCEchoerServiceID : service_id) {}
|
|
56
|
+
public:
|
|
57
|
+
explicit SRPCEchoerClientImpl(starpc::Client* cc, const std::string& service_id = "")
|
|
58
|
+
: cc_(cc), service_id_(service_id.empty() ? kSRPCEchoerServiceID : service_id) {}
|
|
67
59
|
|
|
68
|
-
starpc::Client
|
|
60
|
+
starpc::Client* SRPCClient() override { return cc_; }
|
|
69
61
|
|
|
70
62
|
// Echo
|
|
71
|
-
virtual starpc::Error Echo(const echo::EchoMsg
|
|
72
|
-
echo::EchoMsg *out) override;
|
|
63
|
+
virtual starpc::Error Echo(const echo::EchoMsg& in, echo::EchoMsg* out) override;
|
|
73
64
|
// EchoServerStream
|
|
74
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>,
|
|
75
|
-
starpc::Error>
|
|
76
|
-
EchoServerStream(const echo::EchoMsg &in) override;
|
|
65
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoServerStreamClient>, starpc::Error> EchoServerStream(const echo::EchoMsg& in) override;
|
|
77
66
|
// EchoClientStream
|
|
78
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>,
|
|
79
|
-
starpc::Error>
|
|
80
|
-
EchoClientStream() override;
|
|
67
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoClientStreamClient>, starpc::Error> EchoClientStream() override;
|
|
81
68
|
// EchoBidiStream
|
|
82
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>,
|
|
83
|
-
starpc::Error>
|
|
84
|
-
EchoBidiStream() override;
|
|
69
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_EchoBidiStreamClient>, starpc::Error> EchoBidiStream() override;
|
|
85
70
|
// RpcStream
|
|
86
|
-
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error>
|
|
87
|
-
RpcStream() override;
|
|
71
|
+
virtual std::pair<std::unique_ptr<SRPCEchoer_RpcStreamClient>, starpc::Error> RpcStream() override;
|
|
88
72
|
// DoNothing
|
|
89
|
-
virtual starpc::Error DoNothing(const google::protobuf::Empty
|
|
90
|
-
google::protobuf::Empty *out) override;
|
|
73
|
+
virtual starpc::Error DoNothing(const google::protobuf::Empty& in, google::protobuf::Empty* out) override;
|
|
91
74
|
|
|
92
|
-
private:
|
|
93
|
-
starpc::Client
|
|
75
|
+
private:
|
|
76
|
+
starpc::Client* cc_;
|
|
94
77
|
std::string service_id_;
|
|
95
78
|
};
|
|
96
79
|
|
|
97
80
|
// NewSRPCEchoerClient creates a new client.
|
|
98
|
-
inline std::unique_ptr<SRPCEchoerClient>
|
|
99
|
-
NewSRPCEchoerClient(starpc::Client *cc) {
|
|
81
|
+
inline std::unique_ptr<SRPCEchoerClient> NewSRPCEchoerClient(starpc::Client* cc) {
|
|
100
82
|
return std::make_unique<SRPCEchoerClientImpl>(cc);
|
|
101
83
|
}
|
|
102
84
|
|
|
103
85
|
// SRPCEchoerServer is the server API for Echoer service.
|
|
104
86
|
class SRPCEchoerServer {
|
|
105
|
-
public:
|
|
87
|
+
public:
|
|
106
88
|
virtual ~SRPCEchoerServer() = default;
|
|
107
89
|
|
|
108
90
|
// Echo
|
|
109
|
-
virtual starpc::Error Echo(const echo::EchoMsg
|
|
91
|
+
virtual starpc::Error Echo(const echo::EchoMsg& req, echo::EchoMsg* resp) = 0;
|
|
110
92
|
// EchoServerStream
|
|
111
|
-
virtual starpc::Error
|
|
112
|
-
EchoServerStream(const echo::EchoMsg &req,
|
|
113
|
-
SRPCEchoer_EchoServerStreamStream *strm) = 0;
|
|
93
|
+
virtual starpc::Error EchoServerStream(const echo::EchoMsg& req, SRPCEchoer_EchoServerStreamStream* strm) = 0;
|
|
114
94
|
// EchoClientStream
|
|
115
|
-
virtual starpc::Error
|
|
116
|
-
EchoClientStream(SRPCEchoer_EchoClientStreamStream *strm,
|
|
117
|
-
echo::EchoMsg *resp) = 0;
|
|
95
|
+
virtual starpc::Error EchoClientStream(SRPCEchoer_EchoClientStreamStream* strm, echo::EchoMsg* resp) = 0;
|
|
118
96
|
// EchoBidiStream
|
|
119
|
-
virtual starpc::Error
|
|
120
|
-
EchoBidiStream(SRPCEchoer_EchoBidiStreamStream *strm) = 0;
|
|
97
|
+
virtual starpc::Error EchoBidiStream(SRPCEchoer_EchoBidiStreamStream* strm) = 0;
|
|
121
98
|
// RpcStream
|
|
122
|
-
virtual starpc::Error RpcStream(SRPCEchoer_RpcStreamStream
|
|
99
|
+
virtual starpc::Error RpcStream(SRPCEchoer_RpcStreamStream* strm) = 0;
|
|
123
100
|
// DoNothing
|
|
124
|
-
virtual starpc::Error DoNothing(const google::protobuf::Empty
|
|
125
|
-
google::protobuf::Empty *resp) = 0;
|
|
101
|
+
virtual starpc::Error DoNothing(const google::protobuf::Empty& req, google::protobuf::Empty* resp) = 0;
|
|
126
102
|
};
|
|
127
103
|
|
|
128
104
|
// SRPCEchoerHandler implements starpc::Handler for Echoer.
|
|
129
105
|
class SRPCEchoerHandler : public starpc::Handler {
|
|
130
|
-
public:
|
|
131
|
-
SRPCEchoerHandler(SRPCEchoerServer
|
|
132
|
-
: impl_(impl),
|
|
133
|
-
service_id_(service_id.empty() ? kSRPCEchoerServiceID : service_id) {}
|
|
106
|
+
public:
|
|
107
|
+
SRPCEchoerHandler(SRPCEchoerServer* impl, const std::string& service_id = "")
|
|
108
|
+
: impl_(impl), service_id_(service_id.empty() ? kSRPCEchoerServiceID : service_id) {}
|
|
134
109
|
|
|
135
|
-
const std::string
|
|
110
|
+
const std::string& GetServiceID() const override { return service_id_; }
|
|
136
111
|
std::vector<std::string> GetMethodIDs() const override;
|
|
137
|
-
std::pair<bool, starpc::Error> InvokeMethod(
|
|
138
|
-
|
|
139
|
-
|
|
112
|
+
std::pair<bool, starpc::Error> InvokeMethod(
|
|
113
|
+
const std::string& service_id,
|
|
114
|
+
const std::string& method_id,
|
|
115
|
+
starpc::Stream* strm) override;
|
|
140
116
|
|
|
141
|
-
private:
|
|
142
|
-
SRPCEchoerServer
|
|
117
|
+
private:
|
|
118
|
+
SRPCEchoerServer* impl_;
|
|
143
119
|
std::string service_id_;
|
|
144
120
|
};
|
|
145
121
|
|
|
146
122
|
// NewSRPCEchoerHandler creates a new handler for the given implementation.
|
|
147
|
-
inline std::unique_ptr<SRPCEchoerHandler>
|
|
148
|
-
NewSRPCEchoerHandler(SRPCEchoerServer *impl) {
|
|
123
|
+
inline std::unique_ptr<SRPCEchoerHandler> NewSRPCEchoerHandler(SRPCEchoerServer* impl) {
|
|
149
124
|
return std::make_unique<SRPCEchoerHandler>(impl);
|
|
150
125
|
}
|
|
151
126
|
|
|
152
127
|
// SRPCRegisterEchoer registers the server implementation with the mux.
|
|
153
128
|
// 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) {
|
|
129
|
+
inline std::pair<std::unique_ptr<SRPCEchoerHandler>, starpc::Error> SRPCRegisterEchoer(starpc::Mux* mux, SRPCEchoerServer* impl) {
|
|
156
130
|
auto handler = NewSRPCEchoerHandler(impl);
|
|
157
131
|
starpc::Error err = mux->Register(handler.get());
|
|
158
132
|
if (err != starpc::Error::OK) {
|
|
@@ -163,155 +137,158 @@ SRPCRegisterEchoer(starpc::Mux *mux, SRPCEchoerServer *impl) {
|
|
|
163
137
|
|
|
164
138
|
// SRPCEchoer_EchoServerStreamClient is the client stream for EchoServerStream.
|
|
165
139
|
class SRPCEchoer_EchoServerStreamClient {
|
|
166
|
-
public:
|
|
167
|
-
explicit SRPCEchoer_EchoServerStreamClient(
|
|
168
|
-
std::unique_ptr<starpc::Stream> strm)
|
|
169
|
-
: strm_(std::move(strm)) {}
|
|
140
|
+
public:
|
|
141
|
+
explicit SRPCEchoer_EchoServerStreamClient(std::unique_ptr<starpc::Stream> strm) : strm_(std::move(strm)) {}
|
|
170
142
|
|
|
171
|
-
starpc::Error Recv(echo::EchoMsg
|
|
143
|
+
starpc::Error Recv(echo::EchoMsg* msg) {
|
|
144
|
+
return strm_->MsgRecv(msg);
|
|
145
|
+
}
|
|
172
146
|
|
|
173
147
|
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
174
148
|
starpc::Error Close() { return strm_->Close(); }
|
|
175
149
|
|
|
176
|
-
private:
|
|
150
|
+
private:
|
|
177
151
|
std::unique_ptr<starpc::Stream> strm_;
|
|
178
152
|
};
|
|
179
153
|
|
|
180
154
|
// SRPCEchoer_EchoServerStreamStream is the server stream for EchoServerStream.
|
|
181
155
|
class SRPCEchoer_EchoServerStreamStream {
|
|
182
|
-
public:
|
|
183
|
-
explicit SRPCEchoer_EchoServerStreamStream(starpc::Stream
|
|
184
|
-
: strm_(strm) {}
|
|
156
|
+
public:
|
|
157
|
+
explicit SRPCEchoer_EchoServerStreamStream(starpc::Stream* strm) : strm_(strm) {}
|
|
185
158
|
|
|
186
|
-
starpc::Error Send(const echo::EchoMsg
|
|
159
|
+
starpc::Error Send(const echo::EchoMsg& msg) {
|
|
160
|
+
return strm_->MsgSend(msg);
|
|
161
|
+
}
|
|
187
162
|
|
|
188
|
-
starpc::Error SendAndClose(const echo::EchoMsg
|
|
163
|
+
starpc::Error SendAndClose(const echo::EchoMsg& msg) {
|
|
189
164
|
starpc::Error err = strm_->MsgSend(msg);
|
|
190
|
-
if (err != starpc::Error::OK)
|
|
191
|
-
return err;
|
|
165
|
+
if (err != starpc::Error::OK) return err;
|
|
192
166
|
return strm_->CloseSend();
|
|
193
167
|
}
|
|
194
168
|
|
|
195
|
-
private:
|
|
196
|
-
starpc::Stream
|
|
169
|
+
private:
|
|
170
|
+
starpc::Stream* strm_;
|
|
197
171
|
};
|
|
198
172
|
|
|
199
173
|
// SRPCEchoer_EchoClientStreamClient is the client stream for EchoClientStream.
|
|
200
174
|
class SRPCEchoer_EchoClientStreamClient {
|
|
201
|
-
public:
|
|
202
|
-
explicit SRPCEchoer_EchoClientStreamClient(
|
|
203
|
-
std::unique_ptr<starpc::Stream> strm)
|
|
204
|
-
: strm_(std::move(strm)) {}
|
|
175
|
+
public:
|
|
176
|
+
explicit SRPCEchoer_EchoClientStreamClient(std::unique_ptr<starpc::Stream> strm) : strm_(std::move(strm)) {}
|
|
205
177
|
|
|
206
|
-
starpc::Error Send(const echo::EchoMsg
|
|
178
|
+
starpc::Error Send(const echo::EchoMsg& msg) {
|
|
179
|
+
return strm_->MsgSend(msg);
|
|
180
|
+
}
|
|
207
181
|
|
|
208
|
-
starpc::Error CloseAndRecv(echo::EchoMsg
|
|
182
|
+
starpc::Error CloseAndRecv(echo::EchoMsg* msg) {
|
|
209
183
|
starpc::Error err = strm_->CloseSend();
|
|
210
|
-
if (err != starpc::Error::OK)
|
|
211
|
-
return err;
|
|
184
|
+
if (err != starpc::Error::OK) return err;
|
|
212
185
|
return strm_->MsgRecv(msg);
|
|
213
186
|
}
|
|
214
187
|
|
|
215
188
|
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
216
189
|
starpc::Error Close() { return strm_->Close(); }
|
|
217
190
|
|
|
218
|
-
private:
|
|
191
|
+
private:
|
|
219
192
|
std::unique_ptr<starpc::Stream> strm_;
|
|
220
193
|
};
|
|
221
194
|
|
|
222
195
|
// SRPCEchoer_EchoClientStreamStream is the server stream for EchoClientStream.
|
|
223
196
|
class SRPCEchoer_EchoClientStreamStream {
|
|
224
|
-
public:
|
|
225
|
-
explicit SRPCEchoer_EchoClientStreamStream(starpc::Stream
|
|
226
|
-
: strm_(strm) {}
|
|
197
|
+
public:
|
|
198
|
+
explicit SRPCEchoer_EchoClientStreamStream(starpc::Stream* strm) : strm_(strm) {}
|
|
227
199
|
|
|
228
|
-
starpc::Error Recv(echo::EchoMsg
|
|
200
|
+
starpc::Error Recv(echo::EchoMsg* msg) {
|
|
201
|
+
return strm_->MsgRecv(msg);
|
|
202
|
+
}
|
|
229
203
|
|
|
230
|
-
private:
|
|
231
|
-
starpc::Stream
|
|
204
|
+
private:
|
|
205
|
+
starpc::Stream* strm_;
|
|
232
206
|
};
|
|
233
207
|
|
|
234
208
|
// SRPCEchoer_EchoBidiStreamClient is the client stream for EchoBidiStream.
|
|
235
209
|
class SRPCEchoer_EchoBidiStreamClient {
|
|
236
|
-
public:
|
|
237
|
-
explicit SRPCEchoer_EchoBidiStreamClient(std::unique_ptr<starpc::Stream> strm)
|
|
238
|
-
: strm_(std::move(strm)) {}
|
|
210
|
+
public:
|
|
211
|
+
explicit SRPCEchoer_EchoBidiStreamClient(std::unique_ptr<starpc::Stream> strm) : strm_(std::move(strm)) {}
|
|
239
212
|
|
|
240
|
-
starpc::Error Send(const echo::EchoMsg
|
|
213
|
+
starpc::Error Send(const echo::EchoMsg& msg) {
|
|
214
|
+
return strm_->MsgSend(msg);
|
|
215
|
+
}
|
|
241
216
|
|
|
242
|
-
starpc::Error Recv(echo::EchoMsg
|
|
217
|
+
starpc::Error Recv(echo::EchoMsg* msg) {
|
|
218
|
+
return strm_->MsgRecv(msg);
|
|
219
|
+
}
|
|
243
220
|
|
|
244
221
|
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
245
222
|
starpc::Error Close() { return strm_->Close(); }
|
|
246
223
|
|
|
247
|
-
private:
|
|
224
|
+
private:
|
|
248
225
|
std::unique_ptr<starpc::Stream> strm_;
|
|
249
226
|
};
|
|
250
227
|
|
|
251
228
|
// SRPCEchoer_EchoBidiStreamStream is the server stream for EchoBidiStream.
|
|
252
229
|
class SRPCEchoer_EchoBidiStreamStream {
|
|
253
|
-
public:
|
|
254
|
-
explicit SRPCEchoer_EchoBidiStreamStream(starpc::Stream
|
|
255
|
-
: strm_(strm) {}
|
|
230
|
+
public:
|
|
231
|
+
explicit SRPCEchoer_EchoBidiStreamStream(starpc::Stream* strm) : strm_(strm) {}
|
|
256
232
|
|
|
257
|
-
starpc::Error Send(const echo::EchoMsg
|
|
233
|
+
starpc::Error Send(const echo::EchoMsg& msg) {
|
|
234
|
+
return strm_->MsgSend(msg);
|
|
235
|
+
}
|
|
258
236
|
|
|
259
|
-
starpc::Error SendAndClose(const echo::EchoMsg
|
|
237
|
+
starpc::Error SendAndClose(const echo::EchoMsg& msg) {
|
|
260
238
|
starpc::Error err = strm_->MsgSend(msg);
|
|
261
|
-
if (err != starpc::Error::OK)
|
|
262
|
-
return err;
|
|
239
|
+
if (err != starpc::Error::OK) return err;
|
|
263
240
|
return strm_->CloseSend();
|
|
264
241
|
}
|
|
265
242
|
|
|
266
|
-
starpc::Error Recv(echo::EchoMsg
|
|
243
|
+
starpc::Error Recv(echo::EchoMsg* msg) {
|
|
244
|
+
return strm_->MsgRecv(msg);
|
|
245
|
+
}
|
|
267
246
|
|
|
268
|
-
private:
|
|
269
|
-
starpc::Stream
|
|
247
|
+
private:
|
|
248
|
+
starpc::Stream* strm_;
|
|
270
249
|
};
|
|
271
250
|
|
|
272
251
|
// SRPCEchoer_RpcStreamClient is the client stream for RpcStream.
|
|
273
252
|
class SRPCEchoer_RpcStreamClient {
|
|
274
|
-
public:
|
|
275
|
-
explicit SRPCEchoer_RpcStreamClient(std::unique_ptr<starpc::Stream> strm)
|
|
276
|
-
: strm_(std::move(strm)) {}
|
|
253
|
+
public:
|
|
254
|
+
explicit SRPCEchoer_RpcStreamClient(std::unique_ptr<starpc::Stream> strm) : strm_(std::move(strm)) {}
|
|
277
255
|
|
|
278
|
-
starpc::Error Send(const rpcstream::RpcStreamPacket
|
|
256
|
+
starpc::Error Send(const rpcstream::RpcStreamPacket& msg) {
|
|
279
257
|
return strm_->MsgSend(msg);
|
|
280
258
|
}
|
|
281
259
|
|
|
282
|
-
starpc::Error Recv(rpcstream::RpcStreamPacket
|
|
260
|
+
starpc::Error Recv(rpcstream::RpcStreamPacket* msg) {
|
|
283
261
|
return strm_->MsgRecv(msg);
|
|
284
262
|
}
|
|
285
263
|
|
|
286
264
|
starpc::Error CloseSend() { return strm_->CloseSend(); }
|
|
287
265
|
starpc::Error Close() { return strm_->Close(); }
|
|
288
266
|
|
|
289
|
-
private:
|
|
267
|
+
private:
|
|
290
268
|
std::unique_ptr<starpc::Stream> strm_;
|
|
291
269
|
};
|
|
292
270
|
|
|
293
271
|
// SRPCEchoer_RpcStreamStream is the server stream for RpcStream.
|
|
294
272
|
class SRPCEchoer_RpcStreamStream {
|
|
295
|
-
public:
|
|
296
|
-
explicit SRPCEchoer_RpcStreamStream(starpc::Stream
|
|
273
|
+
public:
|
|
274
|
+
explicit SRPCEchoer_RpcStreamStream(starpc::Stream* strm) : strm_(strm) {}
|
|
297
275
|
|
|
298
|
-
starpc::Error Send(const rpcstream::RpcStreamPacket
|
|
276
|
+
starpc::Error Send(const rpcstream::RpcStreamPacket& msg) {
|
|
299
277
|
return strm_->MsgSend(msg);
|
|
300
278
|
}
|
|
301
279
|
|
|
302
|
-
starpc::Error SendAndClose(const rpcstream::RpcStreamPacket
|
|
280
|
+
starpc::Error SendAndClose(const rpcstream::RpcStreamPacket& msg) {
|
|
303
281
|
starpc::Error err = strm_->MsgSend(msg);
|
|
304
|
-
if (err != starpc::Error::OK)
|
|
305
|
-
return err;
|
|
282
|
+
if (err != starpc::Error::OK) return err;
|
|
306
283
|
return strm_->CloseSend();
|
|
307
284
|
}
|
|
308
285
|
|
|
309
|
-
starpc::Error Recv(rpcstream::RpcStreamPacket
|
|
286
|
+
starpc::Error Recv(rpcstream::RpcStreamPacket* msg) {
|
|
310
287
|
return strm_->MsgRecv(msg);
|
|
311
288
|
}
|
|
312
289
|
|
|
313
|
-
private:
|
|
314
|
-
starpc::Stream
|
|
290
|
+
private:
|
|
291
|
+
starpc::Stream* strm_;
|
|
315
292
|
};
|
|
316
293
|
|
|
317
|
-
}
|
|
294
|
+
} // namespace echo
|