-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix codedump and replace return zval* to return zval
- Loading branch information
1 parent
a6f8b20
commit 6fd67d8
Showing
30 changed files
with
1,506 additions
and
325 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,75 +1,49 @@ | ||
# How to build | ||
|
||
## 前期准备 | ||
### 构建 Polaris-CPP | ||
## Preparation | ||
### Build Polaris-CPP | ||
|
||
将`polaris-cpp`项目`clone`到你本地的一个目录中 | ||
Put the `polaris-cpp` project `clone` to a directory on your local | ||
|
||
```shell | ||
cd {你的一个目录} | ||
# 下载 | ||
cd {One of your directories} | ||
|
||
# run git clone | ||
git clone [email protected]:polarismesh/polaris-cpp.git | ||
|
||
# 执行编译构建 | ||
# run compile build | ||
|
||
make && make package | ||
``` | ||
|
||
执行make package后会在当前目录下生成一个polaris_cpp_sdk.tar.gz压缩文件。该文件的内容如下: | ||
After executing make package, a polaris_cpp_sdk.tar.gz compressed file will be generated in the current directory. The content of the file is as follows: | ||
|
||
``` | ||
|-- include/polaris # 头文件 | ||
|-- include/polaris # head File | ||
| |-- consumer.h provider.h limit.h config.h context.h log.h defs.h ... | ||
|-- dlib # 动态库 | ||
|-- dlib # Dynamic library | ||
| |-- libpolaris_api.so | ||
`-- slib # 静态库 | ||
`-- slib # Static library | ||
|-- libpolaris_api.a libprotobuf.a | ||
``` | ||
|
||
对文件`polaris_cpp_sdk.tar.gz`进行解压,将`slib`目录下的`libpolaris_api.a`以及`libprotobuf.a`拷贝到本项目(`polaris-php`)的`lib`目录下 | ||
|
||
```shell | ||
cd {你的一个目录}/polaris-cpp | ||
``` | ||
|
||
最终的目录结构如下 | ||
Unzip the file `polaris_cpp_sdk.tar.gz`, copy `libpolaris_api.a` and `libprotobuf.a` in the `slib` directory to the `lib` directory of this project (`polaris-php`) | ||
|
||
```shell | ||
. | ||
├── doc | ||
│ ├── ApiDoc.md | ||
│ └── HowToBuild.md | ||
├── example | ||
│ ├── polaris_consumer.php | ||
│ ├── polaris_limit.php | ||
│ └── polaris_provider.php | ||
├── include | ||
│ ├── polaris | ||
│ └── utils.hpp | ||
├── lib | ||
│ ├── libpolaris_api.a | ||
│ └── libprotobuf.a | ||
├── php | ||
│ └── php-5.6.40 | ||
├── polaris | ||
├── polaris.yaml | ||
├── polaris.yaml.template | ||
└── README.md | ||
cd {One of your directories}/polaris-cpp | ||
``` | ||
### Build Polaris PHP | ||
|
||
### 构建 Polaris PHP | ||
|
||
确保本地默认的`php`版本为`5.6.x`或者为`7.4.x`版本 | ||
Make sure that the local default `php` version is `5.6.x` or `7.4.x` | ||
|
||
```shell | ||
|
||
cd ./polaris | ||
# clean last build info | ||
|
||
phpize --clean | ||
|
||
phpize | ||
|
||
./configure --with-php-config=${php-config 文件的全路径信息} --with-polaris_provider | ||
./configure --with-php-config=${php-config Full path information of the file} --with-polaris_provider | ||
|
||
make && make install | ||
``` |
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,48 @@ | ||
# How to build | ||
|
||
## 前期准备 | ||
### 构建 Polaris-CPP | ||
|
||
将`polaris-cpp`项目`clone`到你本地的一个目录中 | ||
|
||
```shell | ||
cd {你的一个目录} | ||
# 下载 | ||
git clone [email protected]:polarismesh/polaris-cpp.git | ||
|
||
# 执行编译构建 | ||
|
||
make && make package | ||
``` | ||
|
||
执行make package后会在当前目录下生成一个polaris_cpp_sdk.tar.gz压缩文件。该文件的内容如下: | ||
|
||
``` | ||
|-- include/polaris # 头文件 | ||
| |-- consumer.h provider.h limit.h config.h context.h log.h defs.h ... | ||
|-- dlib # 动态库 | ||
| |-- libpolaris_api.so | ||
`-- slib # 静态库 | ||
|-- libpolaris_api.a libprotobuf.a | ||
``` | ||
|
||
对文件`polaris_cpp_sdk.tar.gz`进行解压,将`slib`目录下的`libpolaris_api.a`以及`libprotobuf.a`拷贝到本项目(`polaris-php`)的`lib`目录下 | ||
|
||
```shell | ||
cd {你的一个目录}/polaris-cpp | ||
``` | ||
### 构建 Polaris PHP | ||
|
||
确保本地默认的`php`版本为`5.6.40`或者为`7.4.x` | ||
|
||
```shell | ||
cd ./polaris | ||
|
||
phpize --clean | ||
|
||
phpize | ||
|
||
./configure --with-php-config=${php-config 文件的全路径信息} --with-polaris_provider | ||
|
||
make && make install | ||
``` |
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,51 @@ | ||
# CircuitBreaker Example | ||
|
||
Based on a simple polaris-php usage example, demonstrate how a php application can quickly use Polaris' service CircuitBreaker. | ||
|
||
## How to build | ||
|
||
- Build the corresponding polaris-php plugin [Build documentation](../../doc/HowToBuild.md) | ||
|
||
## How to Use | ||
|
||
### Create Service | ||
|
||
- Create the corresponding service through the Polaris console in advance. If it is installed through a local one-click installation package, open the console directly in the browser through 127.0.0.1:8091. | ||
- Create a service provider | ||
- ![create_provider_service](./image/create-php-provider.png) | ||
- Create service provider instance | ||
- ![create_provider_instance](./image/create-php-provider-instance.png) | ||
|
||
|
||
### Execute program | ||
|
||
```shell | ||
php circuitbreaker.php | ||
``` | ||
|
||
Observe the output | ||
|
||
- Output expected value | ||
|
||
``` | ||
array(3) { | ||
[0]=> | ||
array(19) { | ||
["host"]=> string(9) "127.0.0.2" | ||
["port"]=> int(8080) | ||
... | ||
} | ||
[1]=> | ||
array(19) { | ||
["host"]=> string(9) "127.0.0.1" | ||
["port"]=> int(8080) | ||
... | ||
} | ||
[2]=> | ||
array(19) { | ||
["host"]=> string(9) "127.0.0.4" | ||
["port"]=> int(8080) | ||
... | ||
} | ||
} | ||
``` |
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,51 @@ | ||
# CircuitBreaker Example | ||
|
||
根据简单的 polaris-php 使用示例,演示 php 应用如何快速使用北极星的服务熔断功能。 | ||
|
||
## 如何构建 | ||
|
||
- 构建对应的 polaris-php 插件, [构建文档](../../doc/HowToBuild_ZH.md) | ||
|
||
## 如何使用 | ||
|
||
### 创建服务 | ||
|
||
- 预先通过北极星控制台创建对应的服务,如果是通过本地一键安装包的方式安装,直接在浏览器通过127.0.0.1:8091打开控制台。 | ||
- 创建服务提供者 | ||
- ![create_provider_service](./image/create-php-provider.png) | ||
- 创建服务提供这实例 | ||
- ![create_provider_instance](./image/create-php-provider-instance.png) | ||
|
||
|
||
### 执行程序 | ||
|
||
```shell | ||
php circuitbreaker.php | ||
``` | ||
|
||
观察输出结果 | ||
|
||
- 输出期望值 | ||
|
||
``` | ||
array(3) { | ||
[0]=> | ||
array(19) { | ||
["host"]=> string(9) "127.0.0.2" | ||
["port"]=> int(8080) | ||
... | ||
} | ||
[1]=> | ||
array(19) { | ||
["host"]=> string(9) "127.0.0.1" | ||
["port"]=> int(8080) | ||
... | ||
} | ||
[2]=> | ||
array(19) { | ||
["host"]=> string(9) "127.0.0.4" | ||
["port"]=> int(8080) | ||
... | ||
} | ||
} | ||
``` |
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,43 @@ | ||
<?php | ||
$br = (php_sapi_name() == "cli")? "":"<br>"; | ||
|
||
if(!extension_loaded('polaris')) { | ||
dl('polaris.' . PHP_SHLIB_SUFFIX); | ||
} | ||
|
||
// 创建一个 polaris-provider 实例 | ||
$polaris = new PolarisClient(array( | ||
"config_path" => "./polaris.yaml", | ||
"log_dir" => "./" | ||
)); | ||
$client_req = array( | ||
"namespace" => "default", | ||
"service" => "polaris-php-provider", | ||
); | ||
|
||
$polaris->InitConsumer(); | ||
|
||
$res = $polaris->GetInstances($client_req, 5000, 1); | ||
var_dump($res); | ||
|
||
for ($i=1; $i<=10; $i++) | ||
{ | ||
$call_service_result = array( | ||
"namespace" => "default", | ||
"service" => "polaris-php-provider", | ||
"host" => "127.0.0.3", | ||
"port" => "8080", | ||
"ret_status" => "error", | ||
); | ||
|
||
$timeout = 500; | ||
$flow_id = 123456; | ||
$res = $polaris->UpdateServiceCallResult($call_service_result, $timeout, $flow_id); | ||
var_dump($res); | ||
sleep(1); | ||
} | ||
|
||
$res = $polaris->GetInstances($client_req, 5000, 1); | ||
$instances = $res["response"]["instances"]; | ||
var_dump($instances); | ||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,4 @@ | ||
global: | ||
serverConnector: | ||
addresses: | ||
- 127.0.0.1:8091 |
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,42 @@ | ||
# QuickStart | ||
|
||
根据简单的 php socket 应用示例,演示 php 应用如何快速接入北极星。[English document](./README.md) | ||
|
||
## 目录介绍 | ||
|
||
> consumer | ||
php-client 端示例,负责发起 socket 请求。启动时先从北极星拉取一个对应 php-server 的服务地址并发起调用 | ||
|
||
> provider | ||
php-server 端示例,负责处理 socket 请求。启动时进程1负责处理socket请求,进程2则进行服务实例的注册,并发送心跳维持 | ||
实例的健康状态 | ||
|
||
## 如何构建 | ||
|
||
- 构建对应的 polaris-php 插件, [构建文档](../../doc/HowToBuild_ZH.md) | ||
|
||
## 如何使用 | ||
|
||
### 创建服务 | ||
|
||
预先通过北极星控制台创建对应的服务,如果是通过本地一键安装包的方式安装,直接在浏览器通过127.0.0.1:8091打开控制台。 | ||
|
||
![create_service](./image/create_php_service.png) | ||
|
||
### 执行程序 | ||
|
||
运行 php-server | ||
|
||
```shell | ||
cd provider | ||
php provider.php | ||
``` | ||
|
||
运行 php-client | ||
|
||
```shell | ||
cd consumer | ||
php consumer.php | ||
``` |
Oops, something went wrong.