zwwl2016 / cluster
This package's canonical repository appears to be gone and the package has been frozen as a result.
1.5.4
2020-05-03 15:31 UTC
Requires
- php: >=5.5.9
- ext-json: *
- corneltek/class-template: ^3.0
This package is auto-updated.
Last update: 2021-01-09 08:36:49 UTC
README
安装教程
composer require zwwl2016/cluster
phalcon初始化服务
composer exec -vvv phalconcluster
加载服务
use Zwwl2016\Cluster\Cluster;
$url='http://test.apiserver.com:30080/execute';//your cluster url
Cluster::Instance($url)->scaffold()->syncClusterServices();
使用说明
简单服务执行
$url='http://test.apiserver.com:30080/execute';//your cluster url
$serviceKey=DefaultServiceKeys.HelloWorld;//your service key from library/services
$result=Cluster::Instance($url)
->service($serviceKey)
->async()
->start()
->response();
一般参数
use Zwwl2016\Cluster\ClusterParameters;
where方式
$clusterParameters = ClusterParameters::Instance()->where("mytable.mycolumn=myvalue);
$clusterParameters = ClusterParameters::Instance()->where("mycolumn=myvalue);
Builder方式
$clusterParameters = ClusterParameters::Instance()
->table("a")->b("c")
->table()->d("e")
->build();
参数使用
Cluster::Instance($url)
->service($serviceKey)
->setParameters($clusterParameters)
->start()
->response();
CronTask参数
use Zwwl2016\Cluster\ClusterCronTaskParameters;
use Zwwl2016\Cluster\ClusterCronTaskParameterPair;
use Zwwl2016\Cluster\ClusterParameters;
一般方式
cronTask参数由cron时间参数与ClusterParameters的键值对组成。
$clusterParameters = ClusterParameters::Instance()
->where("a.b=c")
->where("d=e");
$cron="* 5 9 * * *";
$clusterCronTaskParameterPair=ClusterCronTaskParameterPair::Instance()
->setCronString($cron)
->setClusterParameters($clusterParameters);
$clusterCronTaskParameter =ClusterCronTaskParameters::Instance()
->add($clusterCronTaskParameterPair);
Builder方式
$clusterCronTaskParameters=ClusterCronTaskParameters::Instance()
->cron("* 2 1 * * *")
->where("h.b=ggg")
->where("d=1")
->cron("* 5 9 * * *")
->table()
->b("c")
->d(1)
->table("e")
->f("g")
->h("l")
->build();
参数使用
Cluster::Instance($url)
->service($serviceKey)
->setParameters($clusterParameters)
->bindClusterCronTasks($clusterCronTaskParameters)
->response();