-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
3,897 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.pb.* | ||
*Assets.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
resource_library( | ||
name = 'static_resource', | ||
srcs = [ | ||
'./assets/forms.html', | ||
'./assets/forms.js', | ||
'./assets/methods.html' | ||
] | ||
) | ||
|
||
cc_binary( | ||
name='protoc-gen-rpc', | ||
srcs=['./generator/protoc-gen-rpc.cc'], | ||
deps=['//thirdparty/protobuf:protobuf', '//thirdparty/protobuf:protoc', '#pthread'], | ||
dynamic_link=True | ||
) | ||
|
||
gen_rule( | ||
name = 'gen-rpc-proto', | ||
srcs = ['rpcmessage.proto', 'builtin_service.proto'], | ||
cmd = 'sh -x claire/protorpc/gen-rpc.sh $BUILD_DIR', | ||
outs = ['builtin_service.pb.h', 'builtin_service.pb.cc', 'rpcmessage.pb.h', 'rpcmessage.pb.cc'], | ||
deps = ['//thirdparty/protobuf-2.6.1/src:protoc.bin', ':protoc-gen-rpc'] | ||
) | ||
|
||
cc_library( | ||
name = 'claire_protorpc', | ||
srcs = [ | ||
'BuiltinService.cc', | ||
'RpcChannel.cc', | ||
'RpcCodec.cc', | ||
'RpcController.cc', | ||
'RpcServer.cc', | ||
'RpcUtil.cc', | ||
'builtin_service.pb.cc', | ||
'rpcmessage.pb.cc' | ||
], | ||
deps = [ | ||
'//claire/common:claire_common', | ||
'//claire/netty:claire_netty', | ||
':static_resource', | ||
':gen-rpc-proto', | ||
'//thirdparty/protobuf-2.6.1/src:protobuf' | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) 2013 The claire-protorpc Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. See the AUTHORS file for names of contributors. | ||
|
||
#include <claire/protorpc/BuiltinService.h> | ||
|
||
#include "thirdparty/gflags/gflags.h" | ||
|
||
namespace claire { | ||
namespace protorpc { | ||
|
||
static bool g_protorpc_healthy = true; | ||
|
||
void BuiltinServiceImpl::HeartBeat(RpcControllerPtr& controller, | ||
const HeartBeatRequestPtr& request, | ||
const HeartBeatResponse* response_prototype, | ||
const RpcDoneCallback& done) | ||
{ | ||
HeartBeatResponse response; | ||
if (g_protorpc_healthy) | ||
{ | ||
response.set_status("Ok"); | ||
} | ||
else | ||
{ | ||
response.set_status("Bad"); | ||
} | ||
done(controller, &response); | ||
} | ||
|
||
void BuiltinServiceImpl::Services(RpcControllerPtr& controller, | ||
const ServicesRequestPtr& request, | ||
const ServicesResponse* response_prototype, | ||
const RpcDoneCallback& done) | ||
{ | ||
ServicesResponse response; | ||
for (auto it = services_.cbegin(); it != services_.cend(); ++it) | ||
{ | ||
if (it->second == this) | ||
{ | ||
continue; | ||
} | ||
response.add_services()->set_name(it->second->GetDescriptor()->full_name()); | ||
} | ||
done(controller, &response); | ||
} | ||
|
||
void BuiltinServiceImpl::GetFileSet(RpcControllerPtr& controller, | ||
const GetFileSetRequestPtr& request, | ||
const GetFileSetResponse* response_prototype, | ||
const RpcDoneCallback& done) | ||
{ | ||
GetFileSetResponse response; | ||
for (int i = 0; i < request->names_size(); i++) | ||
{ | ||
auto it = services_.find(request->names(i)); | ||
if (it != services_.end()) | ||
{ | ||
auto file = response.mutable_file_set()->add_file(); | ||
it->second->GetDescriptor()->file()->CopyTo(file); | ||
} | ||
} | ||
done(controller, &response); | ||
} | ||
|
||
} // namespace protorpc | ||
} // namespace claire |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2013 The claire-protorpc Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. See the AUTHORS file for names of contributors. | ||
|
||
#pragma once | ||
|
||
#include <map> | ||
#include <string> | ||
|
||
#include <claire/protorpc/builtin_service.pb.h> // generate by protoc | ||
|
||
namespace claire { | ||
namespace protorpc { | ||
|
||
class BuiltinServiceImpl : public BuiltinService { | ||
public: | ||
typedef std::map<std::string, Service*> ServiceMap; | ||
|
||
void set_services(const ServiceMap& services) | ||
{ | ||
services_ = services; | ||
} | ||
|
||
virtual void HeartBeat(RpcControllerPtr& controller, | ||
const HeartBeatRequestPtr& request, | ||
const HeartBeatResponse* response_prototype, | ||
const RpcDoneCallback& done); | ||
|
||
virtual void Services(RpcControllerPtr& controller, | ||
const ServicesRequestPtr& request, | ||
const ServicesResponse* response_prototype, | ||
const RpcDoneCallback& done); | ||
|
||
virtual void GetFileSet(RpcControllerPtr& controller, | ||
const GetFileSetRequestPtr& request, | ||
const GetFileSetResponse* response_prototype, | ||
const RpcDoneCallback& done); | ||
|
||
private: | ||
ServiceMap services_; | ||
}; | ||
|
||
} // namespace protorpc | ||
} // namespace claire |
Oops, something went wrong.