Skip to content

Commit 1dd587b

Browse files
committed
cetty-protobuf: update
1 parent b51b5d5 commit 1dd587b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3347
-846
lines changed

cetty-core/build/cetty/cetty.vcxproj

+4
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@
349349
<ClInclude Include="..\..\..\include\cetty\handler\execution\ServicePoolExecutor.h" />
350350
<ClInclude Include="..\..\..\include\cetty\logging\LoggerHelper.h" />
351351
<ClInclude Include="..\..\..\include\cetty\logging\LoggerHelperPrivate.h" />
352+
<ClInclude Include="..\..\..\include\cetty\service\ClientService.h" />
353+
<ClInclude Include="..\..\..\include\cetty\service\DownCastServiceFuture.h" />
354+
<ClInclude Include="..\..\..\include\cetty\service\Service.h" />
355+
<ClInclude Include="..\..\..\include\cetty\service\ServiceFuture.h" />
352356
<ClInclude Include="..\..\..\include\cetty\util\NameValueCollection.h" />
353357
<ClInclude Include="..\..\..\include\cetty\util\NestedDiagnosticContext.h" />
354358
<ClInclude Include="..\..\..\include\cetty\util\SimpleString.h" />

cetty-core/build/cetty/cetty.vcxproj.filters

+35-20
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
<Filter Include="handler\execution">
7373
<UniqueIdentifier>{f585ecef-9b88-405b-8473-ec0c8cfded58}</UniqueIdentifier>
7474
</Filter>
75+
<Filter Include="service">
76+
<UniqueIdentifier>{393eaf8f-a722-4a93-bb42-034b3379b32d}</UniqueIdentifier>
77+
</Filter>
7578
</ItemGroup>
7679
<ItemGroup>
7780
<ClCompile Include="..\..\src\cetty\channel\AbstractChannel.cpp">
@@ -1045,41 +1048,53 @@
10451048
<ClInclude Include="..\..\..\include\cetty\handler\execution\ServicePoolExecutor.h">
10461049
<Filter>handler\execution</Filter>
10471050
</ClInclude>
1048-
<ClInclude Include="..\..\..\include\cetty\channel\AbstractChannel.h">
1049-
<Filter>buffer</Filter>
1050-
</ClInclude>
1051-
<ClInclude Include="..\..\..\include\cetty\channel\AbstractChannelSink.h">
1052-
<Filter>buffer</Filter>
1053-
</ClInclude>
1054-
<ClInclude Include="..\..\..\include\cetty\channel\AbstractServerChannel.h">
1055-
<Filter>buffer</Filter>
1056-
</ClInclude>
1057-
<ClInclude Include="..\..\..\include\cetty\channel\Channel.h">
1058-
<Filter>buffer</Filter>
1051+
<ClInclude Include="..\..\..\include\cetty\channel\ChannelFutureProgressListener.h">
1052+
<Filter>channel</Filter>
10591053
</ClInclude>
10601054
<ClInclude Include="..\..\..\include\cetty\channel\ChannelConfig.h">
1061-
<Filter>buffer</Filter>
1055+
<Filter>channel</Filter>
10621056
</ClInclude>
10631057
<ClInclude Include="..\..\..\include\cetty\channel\ChannelDownstreamHandler.h">
1064-
<Filter>buffer</Filter>
1058+
<Filter>channel</Filter>
10651059
</ClInclude>
10661060
<ClInclude Include="..\..\..\include\cetty\channel\ChannelEvent.h">
1067-
<Filter>buffer</Filter>
1061+
<Filter>channel</Filter>
10681062
</ClInclude>
10691063
<ClInclude Include="..\..\..\include\cetty\channel\ChannelException.h">
1070-
<Filter>buffer</Filter>
1064+
<Filter>channel</Filter>
10711065
</ClInclude>
10721066
<ClInclude Include="..\..\..\include\cetty\channel\ChannelFactory.h">
1073-
<Filter>buffer</Filter>
1067+
<Filter>channel</Filter>
10741068
</ClInclude>
10751069
<ClInclude Include="..\..\..\include\cetty\channel\ChannelFuture.h">
1076-
<Filter>buffer</Filter>
1070+
<Filter>channel</Filter>
10771071
</ClInclude>
10781072
<ClInclude Include="..\..\..\include\cetty\channel\ChannelFutureListener.h">
1079-
<Filter>buffer</Filter>
1073+
<Filter>channel</Filter>
10801074
</ClInclude>
1081-
<ClInclude Include="..\..\..\include\cetty\channel\ChannelFutureProgressListener.h">
1082-
<Filter>buffer</Filter>
1075+
<ClInclude Include="..\..\..\include\cetty\channel\Channel.h">
1076+
<Filter>channel</Filter>
1077+
</ClInclude>
1078+
<ClInclude Include="..\..\..\include\cetty\channel\AbstractChannel.h">
1079+
<Filter>channel</Filter>
1080+
</ClInclude>
1081+
<ClInclude Include="..\..\..\include\cetty\channel\AbstractChannelSink.h">
1082+
<Filter>channel</Filter>
1083+
</ClInclude>
1084+
<ClInclude Include="..\..\..\include\cetty\channel\AbstractServerChannel.h">
1085+
<Filter>channel</Filter>
1086+
</ClInclude>
1087+
<ClInclude Include="..\..\..\include\cetty\service\ClientService.h">
1088+
<Filter>service</Filter>
1089+
</ClInclude>
1090+
<ClInclude Include="..\..\..\include\cetty\service\DownCastServiceFuture.h">
1091+
<Filter>service</Filter>
1092+
</ClInclude>
1093+
<ClInclude Include="..\..\..\include\cetty\service\Service.h">
1094+
<Filter>service</Filter>
1095+
</ClInclude>
1096+
<ClInclude Include="..\..\..\include\cetty\service\ServiceFuture.h">
1097+
<Filter>service</Filter>
10831098
</ClInclude>
10841099
</ItemGroup>
10851100
</Project>

cetty-core/src/cetty/channel/socket/asio/AsioClientSocketPipelineSink.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void AsioClientSocketPipelineSink::writeRequested(
6868
const ChannelPipeline& pipeline,
6969
const MessageEvent& e) {
7070
const ChannelPtr& channel = e.getChannel();
71-
(static_cast<AsioSocketChannel*>(channel))->innerWrite(e);
71+
(static_cast<AsioSocketChannel*>(channel))->internalWrite(e);
7272

7373
LOG_INFO(logger, "has written the msg to the address.");
7474
}
@@ -89,13 +89,13 @@ void AsioClientSocketPipelineSink::handleStateChange(const ChannelStateEvent& ev
8989

9090
if (state == ChannelState::OPEN) {
9191
if (value.empty()) {
92-
asioSocketChannel->innerClose(future);
92+
asioSocketChannel->internalClose(future);
9393
LOG_INFO(logger, "received a close channel event, so closed the channel.");
9494
}
9595
}
9696
else if (state == ChannelState::BOUND) {
9797
if (value.empty()) {
98-
asioSocketChannel->innerClose(future);
98+
asioSocketChannel->internalClose(future);
9999
LOG_INFO(logger, "received an unbound channel event, so closed the channel.");
100100
}
101101
else {
@@ -115,14 +115,14 @@ void AsioClientSocketPipelineSink::handleStateChange(const ChannelStateEvent& ev
115115
}
116116
}
117117
else {
118-
asioSocketChannel->innerClose(future);
118+
asioSocketChannel->internalClose(future);
119119
LOG_INFO(logger, "received an disconnect channel event, so closed the channel.");
120120
}
121121
}
122122
else if (state == ChannelState::INTEREST_OPS) {
123123
if (!value.empty()) {
124124
int v = ConversionUtil::toInt(value);
125-
asioSocketChannel->innerSetInterestOps(future, v);
125+
asioSocketChannel->internalSetInterestOps(future, v);
126126
LOG_INFO(logger, "received an interestOps (%s) event.", Channel::getInterestOpsString(v));
127127
}
128128
else {
@@ -151,7 +151,7 @@ void AsioClientSocketPipelineSink::connect(const ChannelPtr& channel,
151151
cf->setFailure(exception);
152152
Channels::fireExceptionCaught(channel, exception);
153153

154-
socketChannel->innerClose(channel->getCloseFuture());
154+
socketChannel->internalClose(channel->getCloseFuture());
155155
return;
156156
}
157157

@@ -180,7 +180,7 @@ void AsioClientSocketPipelineSink::connect(const ChannelPtr& channel,
180180
ChannelException e("the boost asio service can not be started.");
181181
cf->setFailure(e);
182182
Channels::fireExceptionCaught(channel, e);
183-
socketChannel->innerClose(channel->getCloseFuture());
183+
socketChannel->internalClose(channel->getCloseFuture());
184184

185185
//TODO: should terminate the program
186186
std::terminate();

cetty-core/src/cetty/channel/socket/asio/AsioServerSocketPipelineSink.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void AsioServerSocketPipelineSink::writeRequested(
6565
const ChannelPipeline& pipeline,
6666
const MessageEvent& e) {
6767
const ChannelPtr& channel = e.getChannel();
68-
(static_cast<AsioSocketChannel*>(channel))->innerWrite(e);
68+
(static_cast<AsioSocketChannel*>(channel))->internalWrite(e);
6969
}
7070

7171
void AsioServerSocketPipelineSink::stateChangeRequested(
@@ -120,7 +120,7 @@ void AsioServerSocketPipelineSink::handleAcceptChannelStateChange(
120120
if (ChannelState::INTEREST_OPS == state) {
121121
AsioSocketChannel* socketChannel = static_cast<AsioSocketChannel*>(channel);
122122
int v = ConversionUtil::toInt(value);
123-
socketChannel->innerSetInterestOps(future, v);
123+
socketChannel->internalSetInterestOps(future, v);
124124
}
125125
else {
126126
// when AsioAcceptedSocketChannel started, it has connected. So it will has
@@ -303,7 +303,7 @@ void AsioServerSocketPipelineSink::closeAcceptChannel(
303303
const ChannelFuturePtr& future) {
304304

305305
AsioSocketChannel* c = static_cast<AsioSocketChannel*>(channel);
306-
c->innerClose(future);
306+
c->internalClose(future);
307307

308308
//TODO should make sure thread safe, post to accept servicePtr
309309
//delete the channel.

cetty-core/src/cetty/channel/socket/asio/AsioSocketChannel.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ ChannelFuturePtr AsioSocketChannel::write(const ChannelMessage& message) {
199199
return future;
200200
}
201201

202-
void AsioSocketChannel::innerWrite(const MessageEvent& evt) {
202+
void AsioSocketChannel::internalWrite(const MessageEvent& evt) {
203203
const ChannelFuturePtr& f = evt.getFuture();
204204

205205
if (!isConnected()) {
@@ -292,7 +292,7 @@ cetty::channel::ChannelFuturePtr AsioSocketChannel::close() {
292292
return closeFuture;
293293
}
294294

295-
void AsioSocketChannel::innerClose(const ChannelFuturePtr& future) {
295+
void AsioSocketChannel::internalClose(const ChannelFuturePtr& future) {
296296
if (!isOpen() || !tcpSocket.is_open() || getCloseFuture()->isDone()) {
297297
LOG_INFO(logger, "close the socket channel, but the channel already closed.");
298298
return;
@@ -392,7 +392,7 @@ cetty::channel::ChannelFuturePtr AsioSocketChannel::setInterestOps(int interestO
392392
return future;
393393
}
394394

395-
void AsioSocketChannel::innerSetInterestOps(const ChannelFuturePtr& future, int interestOps) {
395+
void AsioSocketChannel::internalSetInterestOps(const ChannelFuturePtr& future, int interestOps) {
396396
bool isOrgReadable = isReadable();
397397

398398
// Override OP_WRITE flag - a user cannot change this flag.
@@ -513,7 +513,7 @@ void AsioSocketChannel::handleConnect(const boost::system::error_code& error,
513513
}
514514
else {
515515
cf->setFailure(ChannelException("failed to connect to remote server", error.value()));
516-
innerClose(cf);
516+
internalClose(cf);
517517
}
518518
}
519519

cetty-core/src/cetty/channel/socket/asio/AsioSocketChannel.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ class AsioSocketChannel : public cetty::channel::socket::SocketChannel {
113113

114114
virtual bool setClosed();
115115

116-
void innerWrite(const MessageEvent& evt);
117-
void innerClose(const ChannelFuturePtr& future);
118-
void innerSetInterestOps(const ChannelFuturePtr& future, int interestOps);
116+
void internalWrite(const MessageEvent& evt);
117+
void internalClose(const ChannelFuturePtr& future);
118+
void internalSetInterestOps(const ChannelFuturePtr& future, int interestOps);
119119
void cleanUpWriteBuffer();
120120

121121
void handleRead(const boost::system::error_code& error, size_t bytes_transferred);

cetty-protobuf/build/protobufrpc/protobufrpc.vcxproj

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,23 @@
1111
</ProjectConfiguration>
1212
</ItemGroup>
1313
<ItemGroup>
14+
<ClInclude Include="..\..\..\include\cetty\protobuf\DownCastServiceFuture.h" />
1415
<ClInclude Include="..\..\..\include\cetty\protobuf\handler\ProtobufRpcDecoder.h" />
1516
<ClInclude Include="..\..\..\include\cetty\protobuf\handler\ProtobufRpcEncoder.h" />
17+
<ClInclude Include="..\..\..\include\cetty\protobuf\handler\ProtobufRpcMessage.h" />
1618
<ClInclude Include="..\..\..\include\cetty\protobuf\handler\ProtobufRpcMessageHandler.h" />
17-
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufRpcClientChannel.h" />
19+
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufRpcClient.h" />
20+
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufService.h" />
21+
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufServiceFuture.h" />
1822
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufServicePtr.h" />
1923
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufServiceRegister.h" />
20-
<ClInclude Include="..\..\..\include\cetty\protobuf\Service.h" />
24+
<ClInclude Include="..\..\..\include\cetty\protobuf\ServiceFuture.h" />
2125
</ItemGroup>
2226
<ItemGroup>
27+
<ClCompile Include="..\..\src\cetty\protobuf\handler\ProtobufRpcDecoder.cpp" />
28+
<ClCompile Include="..\..\src\cetty\protobuf\handler\ProtobufRpcEncoder.cpp" />
2329
<ClCompile Include="..\..\src\cetty\protobuf\handler\ProtobufRpcMessageHandler.cpp" />
24-
<ClCompile Include="..\..\src\cetty\protobuf\ProtobufRpcClientChannel.cpp" />
30+
<ClCompile Include="..\..\src\cetty\protobuf\ProtobufRpcClient.cpp" />
2531
<ClCompile Include="..\..\src\cetty\protobuf\ProtobufServiceRegister.cpp" />
2632
</ItemGroup>
2733
<PropertyGroup Label="Globals">

cetty-protobuf/build/protobufrpc/protobufrpc.vcxproj.filters

+24-6
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,45 @@
2121
<ClInclude Include="..\..\..\include\cetty\protobuf\handler\ProtobufRpcMessageHandler.h">
2222
<Filter>protobuf\handler</Filter>
2323
</ClInclude>
24-
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufRpcClientChannel.h">
25-
<Filter>protobuf</Filter>
26-
</ClInclude>
2724
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufServicePtr.h">
2825
<Filter>protobuf</Filter>
2926
</ClInclude>
3027
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufServiceRegister.h">
3128
<Filter>protobuf</Filter>
3229
</ClInclude>
33-
<ClInclude Include="..\..\..\include\cetty\protobuf\Service.h">
30+
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufService.h">
31+
<Filter>protobuf</Filter>
32+
</ClInclude>
33+
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufServiceFuture.h">
34+
<Filter>protobuf</Filter>
35+
</ClInclude>
36+
<ClInclude Include="..\..\..\include\cetty\protobuf\ServiceFuture.h">
37+
<Filter>protobuf</Filter>
38+
</ClInclude>
39+
<ClInclude Include="..\..\..\include\cetty\protobuf\ProtobufRpcClient.h">
40+
<Filter>protobuf</Filter>
41+
</ClInclude>
42+
<ClInclude Include="..\..\..\include\cetty\protobuf\DownCastServiceFuture.h">
3443
<Filter>protobuf</Filter>
3544
</ClInclude>
45+
<ClInclude Include="..\..\..\include\cetty\protobuf\handler\ProtobufRpcMessage.h">
46+
<Filter>protobuf\handler</Filter>
47+
</ClInclude>
3648
</ItemGroup>
3749
<ItemGroup>
3850
<ClCompile Include="..\..\src\cetty\protobuf\ProtobufServiceRegister.cpp">
3951
<Filter>protobuf</Filter>
4052
</ClCompile>
41-
<ClCompile Include="..\..\src\cetty\protobuf\ProtobufRpcClientChannel.cpp">
53+
<ClCompile Include="..\..\src\cetty\protobuf\handler\ProtobufRpcMessageHandler.cpp">
54+
<Filter>protobuf\handler</Filter>
55+
</ClCompile>
56+
<ClCompile Include="..\..\src\cetty\protobuf\ProtobufRpcClient.cpp">
4257
<Filter>protobuf</Filter>
4358
</ClCompile>
44-
<ClCompile Include="..\..\src\cetty\protobuf\handler\ProtobufRpcMessageHandler.cpp">
59+
<ClCompile Include="..\..\src\cetty\protobuf\handler\ProtobufRpcDecoder.cpp">
60+
<Filter>protobuf\handler</Filter>
61+
</ClCompile>
62+
<ClCompile Include="..\..\src\cetty\protobuf\handler\ProtobufRpcEncoder.cpp">
4563
<Filter>protobuf\handler</Filter>
4664
</ClCompile>
4765
</ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11

22

3-
#include <cetty/protobuf/ProtobufRpcChannel.h>
3+
#include <cetty/protobuf/ProtobufClientServiceAdaptor.h>
44

55
#include <boost/bind.hpp>
66
#include <google/protobuf/descriptor.h>
77

8-
#include <cetty/protobuf/service.h>
8+
#include <cetty/protobuf/ProtobufService.h>
99
#include <cetty/protobuf/rpc.pb.h>
1010

1111
// Call the given method of the remote service. The signature of this
1212
// procedure looks the same as Service::CallMethod(), but the requirements
1313
// are less strict in one important way: the request and response objects
1414
// need not be of any specific class as long as their descriptors are
1515
// method->input_type() and method->output_type().
16-
void ProtobufRpcClientChannel::CallMethod(const ::google::protobuf::MethodDescriptor* method,
17-
const ::google::protobuf::Message* request,
18-
const ::google::protobuf::Message* response,
19-
const DoneCallback& done) {
16+
void ProtobufClientServiceAdaptor::CallMethod(const ::google::protobuf::MethodDescriptor* method,
17+
const ::google::protobuf::Message* request,
18+
const ProtobufServiceFuturePtr& future) {
2019

20+
#if 0
2121
if (!channel) { // the channel has not connected yet.
2222
if (done) {
2323
done->Run();
2424
}
2525

2626
return;
2727
}
28+
#endif
2829

2930
proto::RpcMessage* message = new proto::RpcMessage;
3031
message->set_type(proto::REQUEST);
31-
3232
message->set_service(method->service()->full_name());
3333
message->set_method(method->name());
3434

3535

36-
channel->write(ChannelMessage((MessageLite*)message));
36+
//channel->write(ChannelMessage((MessageLite*)message));
3737
}
3838

0 commit comments

Comments
 (0)