仓库初始化
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
namespace Hyperf\Engine\Contract;
|
||||
|
||||
if (PHP_VERSION_ID > 80000 && SWOOLE_VERSION_ID >= 50000) {
|
||||
interface ChannelInterface
|
||||
{
|
||||
/**
|
||||
* @param float|int $timeout [optional] = -1
|
||||
*/
|
||||
public function push(mixed $data, float $timeout = -1): bool;
|
||||
|
||||
/**
|
||||
* @param float $timeout seconds [optional] = -1
|
||||
* @return mixed when pop failed, return false
|
||||
*/
|
||||
public function pop(float $timeout = -1): mixed;
|
||||
|
||||
/**
|
||||
* Swow: When the channel is closed, all the data in it will be destroyed.
|
||||
* Swoole: When the channel is closed, the data in it can still be popped out, but push behavior will no longer succeed.
|
||||
*/
|
||||
public function close(): bool;
|
||||
|
||||
public function getCapacity(): int;
|
||||
|
||||
public function getLength(): int;
|
||||
|
||||
public function isAvailable(): bool;
|
||||
|
||||
public function hasProducers(): bool;
|
||||
|
||||
public function hasConsumers(): bool;
|
||||
|
||||
public function isEmpty(): bool;
|
||||
|
||||
public function isFull(): bool;
|
||||
|
||||
public function isReadable(): bool;
|
||||
|
||||
public function isWritable(): bool;
|
||||
|
||||
public function isClosing(): bool;
|
||||
|
||||
public function isTimeout(): bool;
|
||||
}
|
||||
} else {
|
||||
interface ChannelInterface
|
||||
{
|
||||
/**
|
||||
* @param mixed $data [required]
|
||||
* @param float|int $timeout [optional] = -1
|
||||
* @return bool
|
||||
*/
|
||||
public function push($data, $timeout = -1);
|
||||
|
||||
/**
|
||||
* @param float $timeout seconds [optional] = -1
|
||||
* @return mixed when pop failed, return false
|
||||
*/
|
||||
public function pop($timeout = -1);
|
||||
|
||||
/**
|
||||
* Swow: When the channel is closed, all the data in it will be destroyed.
|
||||
* Swoole: When the channel is closed, the data in it can still be popped out, but push behavior will no longer succeed.
|
||||
* @return mixed
|
||||
*/
|
||||
public function close(): bool;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCapacity();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLength();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAvailable();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasProducers();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasConsumers();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isFull();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isReadable();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isWritable();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isClosing();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isTimeout();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
namespace Hyperf\Engine\Contract;
|
||||
|
||||
use Hyperf\Engine\Exception\CoroutineDestroyedException;
|
||||
use Hyperf\Engine\Exception\RunningInNonCoroutineException;
|
||||
|
||||
interface CoroutineInterface
|
||||
{
|
||||
/**
|
||||
* @param callable $callable [required]
|
||||
*/
|
||||
public function __construct(callable $callable);
|
||||
|
||||
/**
|
||||
* @param mixed ...$data
|
||||
* @return $this
|
||||
*/
|
||||
public function execute(...$data);
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param callable $callable [required]
|
||||
* @param mixed ...$data
|
||||
* @return $this
|
||||
*/
|
||||
public static function create(callable $callable, ...$data);
|
||||
|
||||
/**
|
||||
* @return int returns coroutine id from current coroutine, -1 in non coroutine environment
|
||||
*/
|
||||
public static function id();
|
||||
|
||||
/**
|
||||
* Returns the parent coroutine ID.
|
||||
* Returns 0 when running in the top level coroutine.
|
||||
* @throws RunningInNonCoroutineException when running in non-coroutine context
|
||||
* @throws CoroutineDestroyedException when the coroutine has been destroyed
|
||||
*/
|
||||
public static function pid(?int $id = null);
|
||||
|
||||
/**
|
||||
* Set config to coroutine.
|
||||
*/
|
||||
public static function set(array $config);
|
||||
|
||||
/**
|
||||
* @param null|int $id coroutine id
|
||||
* @return null|\ArrayObject
|
||||
*/
|
||||
public static function getContextFor(?int $id = null);
|
||||
|
||||
/**
|
||||
* Execute callback when coroutine destruct.
|
||||
*/
|
||||
public static function defer(callable $callable);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
namespace Hyperf\Engine\Contract\Http;
|
||||
|
||||
use Hyperf\Engine\Http\RawResponse;
|
||||
|
||||
interface ClientInterface
|
||||
{
|
||||
public function set(array $settings): bool;
|
||||
|
||||
/**
|
||||
* @param string[][] $headers
|
||||
*/
|
||||
public function request(string $method = 'GET', string $path = '/', array $headers = [], string $contents = '', string $version = '1.1'): RawResponse;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
namespace Hyperf\Engine\Contract\WebSocket;
|
||||
|
||||
interface WebSocketInterface
|
||||
{
|
||||
public const ON_MESSAGE = 'message';
|
||||
|
||||
public const ON_CLOSE = 'close';
|
||||
|
||||
public function on(string $event, callable $callback): void;
|
||||
|
||||
public function start(): void;
|
||||
}
|
||||
Reference in New Issue
Block a user