Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
7d4b3c05
Commit
7d4b3c05
authored
Aug 07, 2018
by
root
Committed by
caidaojin
Aug 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync with master
parent
1f2b637a
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
157 additions
and
50 deletions
+157
-50
BUILD
BUILD
+134
-9
CMakeLists.txt
CMakeLists.txt
+14
-11
channel.h
src/brpc/channel.h
+0
-1
controller.h
src/brpc/controller.h
+1
-27
memcache.cpp
src/brpc/memcache.cpp
+2
-0
memcache.h
src/brpc/memcache.h
+3
-2
couchbase_authenticator.h
src/brpc/policy/couchbase_authenticator.h
+3
-0
No files found.
BUILD
View file @
7d4b3c05
...
...
@@ -10,11 +10,29 @@ config_setting(
visibility = ["//visibility:public"],
)
config_setting(
name = "with_thrift",
define_values = {"with_thrift": "true"},
visibility = ["//visibility:public"],
)
config_setting(
name = "unittest",
define_values = {"unittest": "true"},
)
config_setting(
name = "darwin",
values = {"cpu": "darwin"},
visibility = ["//visibility:public"],
)
config_setting(
name = "linux",
values = {"cpu": "linux"},
visibility = ["//visibility:public"],
)
COPTS = [
"-DBTHREAD_USE_FAST_PTHREAD_MUTEX",
"-D__const__=",
...
...
@@ -28,16 +46,40 @@ COPTS = [
] + select({
":with_glog": ["-DBRPC_WITH_GLOG=1"],
"//conditions:default": ["-DBRPC_WITH_GLOG=0"],
}) + select({
":with_thrift": ["-DENABLE_THRIFT_FRAMED_PROTOCOL=1"],
"//conditions:default": [""],
})
LINKOPTS = [
"-lpthread",
"-lrt",
"-lssl",
"-lcrypto",
"-ldl",
"-lz",
]
"-lssl",
"-lcrypto",
] + select({
":darwin": [
"-framework CoreFoundation",
"-framework CoreGraphics",
"-framework CoreData",
"-framework CoreText",
"-framework Security",
"-framework Foundation",
"-Wl,-U,_MallocExtension_ReleaseFreeMemory",
"-Wl,-U,_ProfilerStart",
"-Wl,-U,_ProfilerStop",
"-Wl,-U,_RegisterThriftProtocol",
],
"//conditions:default": [
"-lrt",
],
}) + select({
":with_thrift": [
"-lthriftnb",
"-levent",
"-lthrift"],
"//conditions:default": [],
})
genrule(
name = "config_h",
...
...
@@ -107,7 +149,6 @@ BUTIL_SRCS = [
"src/butil/files/scoped_file.cc",
"src/butil/files/scoped_temp_dir.cc",
"src/butil/file_util.cc",
"src/butil/file_util_linux.cc",
"src/butil/file_util_posix.cc",
"src/butil/guid.cc",
"src/butil/guid_posix.cc",
...
...
@@ -122,6 +163,7 @@ BUTIL_SRCS = [
"src/butil/memory/weak_ptr.cc",
"src/butil/posix/file_descriptor_shuffle.cc",
"src/butil/posix/global_descriptors.cc",
"src/butil/process_util.cc",
"src/butil/rand_util.cc",
"src/butil/rand_util_posix.cc",
"src/butil/fast_rand.cpp",
...
...
@@ -137,7 +179,6 @@ BUTIL_SRCS = [
"src/butil/strings/string_util.cc",
"src/butil/strings/string_util_constants.cc",
"src/butil/strings/stringprintf.cc",
"src/butil/strings/sys_string_conversions_posix.cc",
"src/butil/strings/utf_offset_string_conversions.cc",
"src/butil/strings/utf_string_conversion_utils.cc",
"src/butil/strings/utf_string_conversions.cc",
...
...
@@ -145,7 +186,6 @@ BUTIL_SRCS = [
"src/butil/synchronization/condition_variable_posix.cc",
"src/butil/synchronization/waitable_event_posix.cc",
"src/butil/threading/non_thread_safe_impl.cc",
"src/butil/threading/platform_thread_linux.cc",
"src/butil/threading/platform_thread_posix.cc",
"src/butil/threading/simple_thread.cc",
"src/butil/threading/thread_checker_impl.cc",
...
...
@@ -181,8 +221,82 @@ BUTIL_SRCS = [
"src/butil/containers/case_ignored_flat_map.cpp",
"src/butil/iobuf.cpp",
"src/butil/popen.cpp",
]
] + select({
":darwin": [
"src/butil/time/time_mac.cc",
"src/butil/mac/scoped_mach_port.cc",
],
"//conditions:default": [
"src/butil/file_util_linux.cc",
"src/butil/threading/platform_thread_linux.cc",
"src/butil/strings/sys_string_conversions_posix.cc",
],
})
objc_library(
name = "macos_lib",
hdrs = [":config_h",
"src/butil/atomicops.h",
"src/butil/atomicops_internals_atomicword_compat.h",
"src/butil/atomicops_internals_mac.h",
"src/butil/base_export.h",
"src/butil/basictypes.h",
"src/butil/build_config.h",
"src/butil/compat.h",
"src/butil/compiler_specific.h",
"src/butil/containers/hash_tables.h",
"src/butil/debug/debugger.h",
"src/butil/debug/leak_annotations.h",
"src/butil/file_util.h",
"src/butil/file_descriptor_posix.h",
"src/butil/files/file_path.h",
"src/butil/files/file.h",
"src/butil/files/scoped_file.h",
"src/butil/lazy_instance.h",
"src/butil/logging.h",
"src/butil/mac/bundle_locations.h",
"src/butil/mac/foundation_util.h",
"src/butil/mac/scoped_cftyperef.h",
"src/butil/mac/scoped_typeref.h",
"src/butil/macros.h",
"src/butil/memory/aligned_memory.h",
"src/butil/memory/scoped_policy.h",
"src/butil/memory/scoped_ptr.h",
"src/butil/move.h",
"src/butil/port.h",
"src/butil/posix/eintr_wrapper.h",
"src/butil/scoped_generic.h",
"src/butil/strings/string16.h",
"src/butil/strings/string_piece.h",
"src/butil/strings/string_util.h",
"src/butil/strings/string_util_posix.h",
"src/butil/strings/sys_string_conversions.h",
"src/butil/synchronization/lock.h",
"src/butil/time/time.h",
"src/butil/time.h",
"src/butil/third_party/dynamic_annotations/dynamic_annotations.h",
"src/butil/threading/platform_thread.h",
"src/butil/threading/thread_restrictions.h",
"src/butil/threading/thread_id_name_manager.h",
"src/butil/type_traits.h",
],
non_arc_srcs = [
"src/butil/mac/bundle_locations.mm",
"src/butil/mac/foundation_util.mm",
"src/butil/file_util_mac.mm",
"src/butil/threading/platform_thread_mac.mm",
"src/butil/strings/sys_string_conversions_mac.mm",
],
deps = [
"@com_github_gflags_gflags//:gflags",
] + select({
":with_glog": ["@com_github_google_glog//:glog"],
"//conditions:default": [],
}),
includes = ["src/"],
enable_modules = True,
tags = ["manual"],
)
cc_library(
name = "butil",
...
...
@@ -203,6 +317,7 @@ cc_library(
"@com_github_gflags_gflags//:gflags",
] + select({
":with_glog": ["@com_github_google_glog//:glog"],
":darwin": [":macos_lib"],
"//conditions:default": [],
}),
includes = [
...
...
@@ -347,7 +462,17 @@ cc_library(
srcs = glob([
"src/brpc/*.cpp",
"src/brpc/**/*.cpp",
]),
],
exclude = [
"src/brpc/thrift_service.cpp",
"src/brpc/thrift_message.cpp",
"src/brpc/policy/thrift_protocol.cpp",
]) + select({
":with_thrift" : glob([
"src/brpc/thrift*.cpp",
"src/brpc/**/thrift*.cpp"]),
"//conditions:default" : [],
}),
hdrs = glob([
"src/brpc/*.h",
"src/brpc/**/*.h"
...
...
CMakeLists.txt
View file @
7d4b3c05
...
...
@@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 2.8.10)
project
(
brpc C CXX
)
# Enable MACOSX_RPATH. Run "cmake --help-policy CMP0042" for policy details.
cmake_policy
(
SET CMP0042 NEW
)
if
(
POLICY CMP0042
)
cmake_policy
(
SET CMP0042 NEW
)
endif
()
set
(
BRPC_VERSION 0.9.0
)
...
...
@@ -20,14 +22,14 @@ else()
message
(
WARNING
"You are using an unsupported compiler! Compilation has only been tested with Clang and GCC."
)
endif
()
option
(
BRPC_
WITH_GLOG
"With glog"
OFF
)
option
(
WITH_GLOG
"With glog"
OFF
)
option
(
DEBUG
"Print debug logs"
OFF
)
option
(
WITH_DEBUG_SYMBOLS
"With debug symbols"
ON
)
option
(
BRPC_
WITH_THRIFT
"With thrift framed protocol supported"
OFF
)
option
(
WITH_THRIFT
"With thrift framed protocol supported"
OFF
)
option
(
BUILD_UNIT_TESTS
"Whether to build unit tests"
OFF
)
set
(
WITH_GLOG_VAL
"0"
)
if
(
BRPC_
WITH_GLOG
)
if
(
WITH_GLOG
)
set
(
WITH_GLOG_VAL
"1"
)
endif
()
...
...
@@ -35,10 +37,10 @@ if(WITH_DEBUG_SYMBOLS)
set
(
DEBUG_SYMBOL
"-g"
)
endif
()
if
(
BRPC_
WITH_THRIFT
)
if
(
WITH_THRIFT
)
set
(
THRIFT_CPP_FLAG
"-DENABLE_THRIFT_FRAMED_PROTOCOL"
)
set
(
THRIFT_LIB
"thriftnb"
)
message
(
"Enable thrift framed procotol
"
)
set
(
THRIFT
NB
_LIB
"thriftnb"
)
set
(
THRIFT_LIB
"thrift
"
)
endif
()
include
(
GNUInstallDirs
)
...
...
@@ -119,7 +121,7 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
message
(
FATAL_ERROR
"Fail to find leveldb"
)
endif
()
if
(
BRPC_
WITH_GLOG
)
if
(
WITH_GLOG
)
find_path
(
GLOG_INCLUDE_PATH NAMES glog/logging.h
)
find_library
(
GLOG_LIB NAMES glog
)
if
((
NOT GLOG_INCLUDE_PATH
)
OR
(
NOT GLOG_LIB
))
...
...
@@ -155,6 +157,7 @@ set(DYNAMIC_LIB
${
PROTOC_LIB
}
${
CMAKE_THREAD_LIBS_INIT
}
${
THRIFT_LIB
}
${
THRIFTNB_LIB
}
${
OPENSSL_LIBRARIES
}
${
OPENSSL_CRYPTO_LIBRARY
}
dl
...
...
@@ -162,7 +165,7 @@ set(DYNAMIC_LIB
)
set
(
BRPC_PRIVATE_LIBS
"-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz"
)
if
(
BRPC_
WITH_GLOG
)
if
(
WITH_GLOG
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
${
GLOG_LIB
}
)
set
(
BRPC_PRIVATE_LIBS
"
${
BRPC_PRIVATE_LIBS
}
-lglog"
)
endif
()
...
...
@@ -181,8 +184,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
"-Wl,-U,_RegisterThriftProtocol"
)
"-Wl,-U,_ProfilerStop"
)
endif
()
# for *.so
...
...
@@ -381,6 +383,7 @@ set(SOURCES
${
JSON2PB_SOURCES
}
${
MCPACK2PB_SOURCES
}
${
BRPC_SOURCES
}
${
THRIFT_SOURCES
}
)
add_subdirectory
(
src
)
...
...
src/brpc/channel.h
View file @
7d4b3c05
...
...
@@ -124,7 +124,6 @@ struct ChannelOptions {
class
Channel
:
public
ChannelBase
{
friend
class
Controller
;
friend
class
SelectiveChannel
;
friend
class
CouchbaseChannel
;
public
:
Channel
(
ProfilerLinker
=
ProfilerLinker
());
~
Channel
();
...
...
src/brpc/controller.h
View file @
7d4b3c05
...
...
@@ -147,15 +147,6 @@ public:
void
set_timeout_ms
(
int64_t
timeout_ms
);
int64_t
timeout_ms
()
const
{
return
_timeout_ms
;
}
// Set timeout of the request trace deadline (in milliseconds)
void
set_request_trace_timeout_ms
(
int64_t
timeout_ms
);
// Set the request trace deadline. We suggest you to use
// set_request_trace_timeout_ms for root request.
void
set_request_trace_deadline
(
int64_t
request_trace_deadline
)
{
_request_trace_deadline
=
request_trace_deadline
;
}
// Set/get the delay to send backup request in milliseconds. Use
// ChannelOptions.backup_request_ms on unset.
void
set_backup_request_ms
(
int64_t
timeout_ms
);
...
...
@@ -384,11 +375,6 @@ public:
// Get the data attached to a mongo session(practically a socket).
MongoContext
*
mongo_session_data
()
{
return
_mongo_session_data
.
get
();
}
// Get a request trace deadline timestamp.
int64_t
request_trace_deadline
()
const
;
// Get remain milliseconds to the request trace deadline.
int64_t
get_request_trace_remain_ms
()
const
;
// -------------------------------------------------------------------
// Both-side methods.
// Following methods can be called from both client and server. But they
...
...
@@ -470,14 +456,7 @@ public:
void
set_idl_result
(
int64_t
result
)
{
_idl_result
=
result
;
}
int64_t
idl_result
()
const
{
return
_idl_result
;
}
bool
has_request_trace_deadline
()
const
{
return
_request_trace_deadline
!=
UNSET_MAGIC_NUM
;
}
void
set_thrift_method_name
(
const
std
::
string
&
method_name
)
{
_thrift_method_name
=
method_name
;
}
std
::
string
thrift_method_name
()
{
return
_thrift_method_name
;
}
const
std
::
string
&
thrift_method_name
()
{
return
_thrift_method_name
;
}
private
:
struct
CompletionInfo
{
...
...
@@ -651,10 +630,6 @@ private:
int32_t
_timeout_ms
;
int32_t
_connect_timeout_ms
;
int32_t
_backup_request_ms
;
// Deadline of this rpc trace(since the Epoch in microseconds),
// set by root request of the rpc trace, and each child node of trace
// can judge root rpc request timed out or not according to the value.
int64_t
_request_trace_deadline
;
// Deadline of this RPC (since the Epoch in microseconds).
int64_t
_abstime_us
;
// Timer registered to trigger RPC timeout event
...
...
@@ -716,7 +691,6 @@ private:
// Thrift method name, only used when thrift protocol enabled
std
::
string
_thrift_method_name
;
uint32_t
_thrift_seq_id
;
};
// Advises the RPC system that the caller desires that the RPC call be
...
...
src/brpc/memcache.cpp
View file @
7d4b3c05
...
...
@@ -451,6 +451,8 @@ const char* MemcacheResponse::status_str(Status st) {
return
"Not stored"
;
case
STATUS_DELTA_BADVAL
:
return
"Bad delta"
;
case
STATUS_NOT_MY_VBUCKET
:
return
"Not my vbucket"
;
case
STATUS_AUTH_ERROR
:
return
"authentication error"
;
case
STATUS_AUTH_CONTINUE
:
...
...
src/brpc/memcache.h
View file @
7d4b3c05
...
...
@@ -111,7 +111,7 @@ public:
butil
::
IOBuf
&
raw_buffer
()
{
return
_buf
;
}
const
butil
::
IOBuf
&
raw_buffer
()
const
{
return
_buf
;
}
pr
ivate
:
pr
otected
:
bool
GetOrDelete
(
uint8_t
command
,
const
butil
::
StringPiece
&
key
);
bool
Counter
(
uint8_t
command
,
const
butil
::
StringPiece
&
key
,
uint64_t
delta
,
uint64_t
initial_value
,
uint32_t
exptime
);
...
...
@@ -172,6 +172,7 @@ public:
STATUS_EINVAL
=
0x04
,
STATUS_NOT_STORED
=
0x05
,
STATUS_DELTA_BADVAL
=
0x06
,
STATUS_NOT_MY_VBUCKET
=
0x07
,
STATUS_AUTH_ERROR
=
0x20
,
STATUS_AUTH_CONTINUE
=
0x21
,
STATUS_UNKNOWN_COMMAND
=
0x81
,
...
...
@@ -230,7 +231,7 @@ public:
static
const
char
*
status_str
(
Status
);
pr
ivate
:
pr
otected
:
bool
PopCounter
(
uint8_t
command
,
uint64_t
*
new_value
,
uint64_t
*
cas_value
);
bool
PopStore
(
uint8_t
command
,
uint64_t
*
cas_value
);
...
...
src/brpc/policy/couchbase_authenticator.h
View file @
7d4b3c05
...
...
@@ -39,6 +39,9 @@ class CouchbaseAuthenticator : public Authenticator {
return
0
;
}
const
std
::
string
&
bucket_name
()
const
{
return
bucket_name_
;
}
const
std
::
string
&
bucket_password
()
const
{
return
bucket_password_
;
}
private
:
const
std
::
string
bucket_name_
;
const
std
::
string
bucket_password_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment