Skip to content
Permalink
Browse files
update getting_start and json2pb docs (#73)
* adding security and committer guide docs

* remove .DS_Store files

* bugfix committer docs

* update brpc users page

* fix all docs link-jump problems

* update getting_start and json2pb docs

Co-authored-by: XiguoHu <huxiguo@baidu.com>
  • Loading branch information
Huixxi and XiguoHu committed Jun 13, 2022
1 parent a31ce10 commit b6b734ea718b3e1e0480b1ef945f6228413126b4
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 36 deletions.
@@ -42,6 +42,23 @@ repeated int32 numbers = 1;
{"numbers" : [12, 17, 1, 24] }
```

特别的,针对仅有一个 `repeated` 类型成员的 `message`,序列化为 `json` 时支持直接序列化为数组,以简化包体。

```protobuf
// protobuf
message Foo {
required int32 numbers = 1;
}
// rapidjson
[12, 17, 1, 24]
```

该特性默认为关闭状态,客户端在发送请求时,或服务端在发送回复时,可手动开启:
```c++
brpc::Controller cntl;
cntl.set_pb_single_repeated_to_array(true);
```

## map

满足如下条件的repeated MSG被视作json map :
@@ -26,7 +26,7 @@ brpc depends on following packages:
## Ubuntu/LinuxMint/WSL
### Prepare deps

Install common deps, [gflags](https://github.com/gflags/gflags), [protobuf](https://github.com/google/protobuf), [leveldb](https://github.com/google/leveldb):
Install dependencies:
```shell
sudo apt-get install -y git g++ make libssl-dev libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev
```
@@ -118,14 +118,9 @@ CentOS needs to install EPEL generally otherwise many packages are not available
sudo yum install epel-release
```

Install common deps:
Install dependencies:
```shell
sudo yum install git gcc-c++ make openssl-devel
```

Install [gflags](https://github.com/gflags/gflags), [protobuf](https://github.com/google/protobuf), [leveldb](https://github.com/google/leveldb):
```shell
sudo yum install gflags-devel protobuf-devel protobuf-compiler leveldb-devel
sudo yum install git gcc-c++ make openssl-devel gflags-devel protobuf-devel protobuf-compiler leveldb-devel
```

If you need to enable cpu/heap profilers in examples:
@@ -221,37 +216,51 @@ Same with [here](#compile-brpc-with-cmake)

## MacOS

Note: In the same running environment, the performance of the current Mac version is about 2.5 times worse than the Linux version. If your service is performance-critical, do not use MacOS as your production environment.
Note: With same environment, the performance of the MacOS version is worse than the Linux version. If your service is performance-critical, do not use MacOS as your production environment.

### Prepare deps
### Apple Silicon

Install common deps:
```shell
brew install openssl git gnu-getopt coreutils
```
The code at master HEAD already supports M1 series chips. M2 series are not tested yet. Please feel free to report remaining warnings/errors to us by issues.

### Prepare deps

Install [gflags](https://github.com/gflags/gflags), [protobuf](https://github.com/google/protobuf), [leveldb](https://github.com/google/leveldb):
Install dependencies:
```shell
brew install gflags protobuf leveldb
brew install openssl git gnu-getopt coreutils gflags protobuf leveldb
```

If you need to enable cpu/heap profilers in examples:
```shell
brew install gperftools
```

If you need to run tests, download and compile googletest (which is not compiled yet):
If you need to run tests, googletest is required. Run `brew install googletest` first to see if it works. If not (old homebrew does not have googletest), you can download and compile googletest by your own:
```shell
git clone https://github.com/google/googletest -b release-1.10.0 && cd googletest/googletest && mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make
```
After the compilation, copy include/ and lib/ into /usr/local/include and /usr/local/lib respectively to expose gtest to all apps
After the compilation, copy `include/` and `lib/` into `/usr/local/include` and `/usr/local/lib` respectively to expose gtest to all apps

### OpenSSL

openssl installed in Monterey may not be found at `/usr/local/opt/openssl`, instead it's probably put under `/opt/homebrew/Cellar`. If the compiler cannot find openssl:

* Run `brew link openssl --force` first and check if `/user/local/opt/openssl` appears.
* If above command does not work, consider making a soft link using `sudo ln -s /opt/homebrew/Cellar/openssl@3/3.0.3 /usr/local/opt/openssl`. Note that the installed openssl in above command may be put in different places in different environments, which could be revealed by running `brew info openssl`.

### Compile brpc with config_brpc.sh
git clone brpc, cd into the repo and run
```shell
$ sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib --cc=clang --cxx=clang++
$ make
```

The homebrew in Monterey may install software at different directories from before. If path related errors are reported, try setting headers/libs like below:

```shell
$ sh config_brpc.sh --headers=/opt/homebrew/include --libs=/opt/homebrew/lib --cc=clang --cxx=clang++
$ make
```

To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.

To use brpc with glog, add `--with-glog`.
@@ -42,6 +42,23 @@ repeated int32 numbers = 1;
{"numbers" : [12, 17, 1, 24] }
```

特别的,针对仅有一个 `repeated` 类型成员的 `message`,序列化为 `json` 时支持直接序列化为数组,以简化包体。

```protobuf
// protobuf
message Foo {
required int32 numbers = 1;
}
// rapidjson
[12, 17, 1, 24]
```

该特性默认为关闭状态,客户端在发送请求时,或服务端在发送回复时,可手动开启:
```c++
brpc::Controller cntl;
cntl.set_pb_single_repeated_to_array(true);
```

## map

满足如下条件的repeated MSG被视作json map :
@@ -26,7 +26,7 @@ brpc有如下依赖:
## Ubuntu/LinuxMint/WSL
### 依赖准备

安装通用依赖,[gflags](https://github.com/gflags/gflags), [protobuf](https://github.com/google/protobuf), [leveldb](https://github.com/google/leveldb):
安装依赖:
```shell
sudo apt-get install -y git g++ make libssl-dev libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev
```
@@ -119,14 +119,9 @@ CentOS一般需要安装EPEL,否则很多包都默认不可用。
sudo yum install epel-release
```

安装通用依赖
安装依赖
```shell
sudo yum install git gcc-c++ make openssl-devel
```

安装 [gflags](https://github.com/gflags/gflags), [protobuf](https://github.com/google/protobuf), [leveldb](https://github.com/google/leveldb):
```shell
sudo yum install gflags-devel protobuf-devel protobuf-compiler leveldb-devel
sudo yum install git gcc-c++ make openssl-devel gflags-devel protobuf-devel protobuf-compiler leveldb-devel
```

如果你要在样例中启用cpu/heap的profiler:
@@ -222,37 +217,49 @@ $ make

## MacOS

注意:在相同运行环境下,当前Mac版brpc的性能比Linux版差2.5倍。如果你的服务是性能敏感的,请不要使用MacOs作为你的生产环境
注意:在相同硬件条件下,MacOS版brpc的性能可能明显差于Linux版。如果你的服务是性能敏感的,请不要使用MacOS作为你的生产环境

### 依赖准备
### Apple Silicon

安装通用依赖:
```shell
brew install openssl git gnu-getopt coreutils
```
master HEAD已支持M1系列芯片,M2还未测试。欢迎通过issues向我们报告遗留的warning/error。

### 依赖准备

安装[gflags](https://github.com/gflags/gflags),[protobuf](https://github.com/google/protobuf),[leveldb](https://github.com/google/leveldb)
安装依赖
```shell
brew install gflags protobuf leveldb
brew install openssl git gnu-getopt coreutils gflags protobuf leveldb
```

如果你要在样例中启用cpu/heap的profiler:
```shell
brew install gperftools
```

如果你要运行测试,那么要安装并编译googletest(它没有被默认编译)
如果你要运行测试,需安装gtest。先运行`brew install googletest`看看homebrew是否支持(老版本没有),没有的话请下载和编译googletest
```shell
git clone https://github.com/google/googletest -b release-1.10.0 && cd googletest/googletest && mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make
```
在编译完成后,复制include/和lib/目录到/usr/local/include和/usr/local/lib目录中,以便于让所有应用都能使用gtest。
在编译完成后,复制`include/``lib/`目录到`/usr/local/include``/usr/local/lib`目录中,以便于让所有应用都能使用gtest。

### OpenSSL
Monterey中openssl的安装位置可能不再位于`/usr/local/opt/openssl`,很可能会在`/opt/homebrew/Cellar`目录下,如果编译时报告找不到openssl:

* 先运行`brew link openssl --force`看看`/user/local/opt/openssl`是否出现了
* 没有的话可以自行设置软链:`sudo ln -s /opt/homebrew/Cellar/openssl@3/3.0.3 /usr/local/opt/openssl`。请注意此命令中openssl的目录可能随环境变化而变化,可通过`brew info openssl`查看。

### 使用config_brpc.sh编译brpc
git克隆brpc,进入到项目目录然后运行:
```shell
$ sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib --cc=clang --cxx=clang++
$ make
```
MacOS Monterey下的brew安装路径可能改变,如有路径相关的错误,可考虑设置如下:

```shell
$ sh config_brpc.sh --headers=/opt/homebrew/include --libs=/opt/homebrew/lib --cc=clang --cxx=clang++
$ make
```

不想链接调试符号,添加选项`--nodebugsymbols`,然后编译将会得到更轻量的二进制文件。

使用glog版的brpc,添加选项`--with-glog`

0 comments on commit b6b734e

Please sign in to comment.