java微服务可以php模块吗_java/php微服务架构(php服务端)

1、服务端:php

项目服务使用lumen5.8+Swoole做为运行环境,.env配置文件中须要定义每一个服务端服务id,方便调试和作特殊的逻辑处理java

如:服务器

SERVICE_ID=10001

一、composer中引入composer

"cecd/thrift": "dev-master"

并执行composer updatesocket

二、建立启动脚本ui

namespace Cecd\Sdk\Rpc;

use Thrift\CeCd\Sdk\Core\TSwooleServerTransport;

use Thrift\CeCd\Sdk\RpcServiceProcessor;

use Thrift\Factory\TTransportFactory;

use Thrift\Factory\TBinaryProtocolFactory;

/**

* Class Command.

*/

class Command extends \Thrift\CeCd\Sdk\Core\Command\Command

{

/**

* Run up the server.

*

* @param string $argv

*

* @throws \Exception

*/

public function run($host, $port)

{

require ROOT_PATH .'vendor/autoload.php';

$this->serverOptions['pid_file'] = '/var/tmp/server_rpc.pid';

if (file_exists($this->serverOptions['pid_file'])) {

$pid = file_get_contents($this->serverOptions['pid_file']);

if (posix_getpgid($pid)) {

echo "server is running\n";

return;

} else {

//意外退出后再次启动

unlink($this->serverOptions['pid_file']);

}

}

$this->serverOptions['worker_num'] = 4;

$handler = new RpcServiceHandle();

$processor = new RpcServiceProcessor($handler);

$socket_tranport = new TSwooleServerTransport();

$out_factory = $in_factory = new TTransportFactory();

$out_protocol = $in_protocol = new TBinaryProtocolFactory();

$server = new SwooleServer($processor, $socket_tranport, $in_factory, $out_factory, $in_protocol, $out_protocol);

$server->options($this->serverOptions);

$server->setServer($host, $port);

$server->serve();

}

}

以上仅为示例代码,启动脚本须要继承 \Thrift\CeCd\Sdk\Core\Command\Command 类this

三、实现本身的服务器处理接口spa

问题:调试

今天写java通讯php的rpc,遇到个很尴尬的问题,java方法参数是强类型,参数若是是map list set,php只能传arraycode

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值