xwp/wait-for 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xwp/wait-for

最新稳定版本:0.0.2

Composer 安装命令:

composer require xwp/wait-for

包简介

无描述信息

README 文档

README

Wait for TCP connections to services with a timeout. Useful when waiting for services on Docker containers that take a while to start such as MySQL.

Usage

Require this library as a development dependency for your project:

composer require --dev xwp/wait-for

Use it in your project to wait for a TCP response from localhost:3306:

// Include the Composer autoloader.
require_once __DIR__ . '/vendor/autoload.php';

$connection = new XWP\Wait_For\Tcp_Connection( 'localhost', 3306 );

try {
	$connection->connect( 30 );
} catch ( Exception $e ) {
	trigger_error( $e->getMessage(), E_USER_ERROR );
}

where locahost is the hostname, 3306 is the port number and 30 is the timeout in seconds.

Design Decisions

  • Use PHP exceptions on connection errors to ensure that applications relying on process return codes are made aware of the connection error.

Examples

Use the included helpers to create your own waiting logic:

use XWP\Wait_For\With_Retry;

$runner = new With_Retry(
	function() {
		// Do something here.
		return false;
	}
);

if ( ! $runner->run( 10 ) ) {
	trigger_error( 'Failed to connect!' );
}

统计信息

  • 总下载量: 90.45k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 未知