paulobezerr/soap_threads
Composer 安装命令:
composer require paulobezerr/soap_threads
包简介
Simple code to make SOAP requests with thread
README 文档
README
This is a very simple library that facilitates the SOAP threaded requests.
The code can be used as an example of pthread usage or a real implementation of SOAP requests in separated threads.
Requirements
- PHP7+
- Pthreads 3.1.6
Examples
With pimple and Pool
<?php $pimple = new Pimple\Container(); $pimple->register(new Soap\Provider); // Configure and get instance of Pool. $pimple['soap_pool_threads'] = 2; $pimple['soap_pool_url'] = 'http://SOAP_URL?wsdl'; $soapPool = $pimple['soap_pool_factory']; $elements = array( array( 'SOAP_FUNCTION' => 'soap_fuction_name', 'SOAP_PARAMS' => array('soap', 'function', 'params') ), array( 'SOAP_FUNCTION' => 'soap_fuction_name', 'SOAP_PARAMS' => array('soap', 'function', 'params') ) ); foreach ($elements as $item) { $soapThreadFunc = $pimple['soap_thread_factory']; $soapPool->submit( $soapThreadFunc($item['SOAP_FUNCTION'], $item['SOAP_PARAMS']) ); } $workerCount = count($elements); // Here we collect all soap results and put in array $soapResults = array(); while ($soapPool->collect(function(Soap\Thread $thread) use (&$soapResults) { if ($thread->isGarbage()) { $soapResults[] = $thread->soapResult; } return $thread->isGarbage(); }) || count($soapResults) < $workerCount) { continue; }; $soapPool->shutdown(); var_dump($soapResults);
Without pimple with Pool
<?php use Soap; use Pool; $numberOfThreads = 2; $workerParams = array( 'http://SOAP_URL?wsdl', array('trace' => false, 'exceptions' => false) // Or anything that you need ); $elements = array( array( 'SOAP_FUNCTION' => 'soap_fuction_name', 'SOAP_PARAMS' => array('soap', 'function', 'params') ), array( 'SOAP_FUNCTION' => 'soap_fuction_name', 'SOAP_PARAMS' => array('soap', 'function', 'params') ) ); $pool = new Pool($numberOfThreads, Worker::class, $workerParams); foreach ($elements as $item) { $pool->submit(new Thread( $item['SOAP_FUNCTION'], $item['SOAP_PARAMS'] )); } $workerCount = count($elements); // Here we collect all soap results and put in array $soapResults = array(); while ($pool->collect(function($thread) use (&$soapResults) { if ($thread->isGarbage()) { $soapResults[] = $thread->soapResult; } return $thread->isGarbage(); }) || count($soapResults) < $workerCount) { continue; }; $pool->shutdown(); var_dump($soapResults);
paulobezerr/soap_threads 适用场景与选型建议
paulobezerr/soap_threads 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 693 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 paulobezerr/soap_threads 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 paulobezerr/soap_threads 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 693
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2017-01-25