diff --git a/src/core/src/Redis/RedisProxy.php b/src/core/src/Redis/RedisProxy.php deleted file mode 100644 index 718cc2e6..00000000 --- a/src/core/src/Redis/RedisProxy.php +++ /dev/null @@ -1,32 +0,0 @@ - $callback($message, $channel); - - parent::subscribe(Arr::wrap($channels), $callback); - } - - /** - * Subscribe to a set of given channels with wildcards. - */ - public function psubscribe(array|string $channels, Closure $callback): void - { - $callback = fn ($redis, $pattern, $channel, $message) => $callback($message, $channel); - - parent::psubscribe(Arr::wrap($channels), $callback); - } -} diff --git a/src/redis/src/RedisConnection.php b/src/redis/src/RedisConnection.php index efdba500..9570e7b0 100644 --- a/src/redis/src/RedisConnection.php +++ b/src/redis/src/RedisConnection.php @@ -5,6 +5,7 @@ namespace Hypervel\Redis; use Hyperf\Redis\RedisConnection as HyperfRedisConnection; +use Hypervel\Support\Arr; use Hypervel\Support\Collection; use Redis; use Throwable; @@ -157,7 +158,7 @@ * @method static \Redis|bool pfmerge(string $dst, array $srckeys) * @method static \Redis|string|bool ping(string|null $message = null) * @method static \Redis|bool psetex(string $key, int $expire, mixed $value) - * @method static bool psubscribe(array $patterns, callable $cb) + * @method static void psubscribe(array|string $channels, \Closure $callback) * @method static \Redis|int|false pttl(string $key) * @method static \Redis|int|false publish(string $channel, string $message) * @method static mixed pubsub(string $command, mixed $arg = null) @@ -202,7 +203,7 @@ * @method static \Redis|int|false srem(string $key, mixed $value, mixed ...$other_values) * @method static bool ssubscribe(array $channels, callable $cb) * @method static \Redis|int|false strlen(string $key) - * @method static bool subscribe(array $channels, callable $cb) + * @method static void subscribe(array|string $channels, \Closure $callback) * @method static \Redis|array|bool sunsubscribe(array $channels) * @method static \Redis|bool swapdb(int $src, int $dst) * @method static \Redis|array time() @@ -683,11 +684,31 @@ protected function callSubscribe(string $name, array $arguments): mixed $this->connection->setOption(Redis::OPT_READ_TIMEOUT, -1); try { - return $this->connection->{$name}(...$arguments); + return $this->connection->{$name}( + ...$this->getSubscribeArguments($name, $arguments) + ); } finally { // Restore the read timeout to the original value before // returning to the connection pool. $this->connection->setOption(Redis::OPT_READ_TIMEOUT, $timeout); } } + + protected function getSubscribeArguments(string $name, array $arguments): array + { + $channels = Arr::wrap($arguments[0]); + $callback = $arguments[1]; + + if ($name === 'subscribe') { + return [ + $channels, + fn ($redis, $channel, $message) => $callback($message, $channel), + ]; + } + + return [ + $channels, + $callback = fn ($redis, $pattern, $channel, $message) => $callback($message, $channel), + ]; + } } diff --git a/src/support/src/Facades/Queue.php b/src/support/src/Facades/Queue.php index d29f7054..b3c22d71 100644 --- a/src/support/src/Facades/Queue.php +++ b/src/support/src/Facades/Queue.php @@ -34,6 +34,10 @@ * @method static array getPoolables() * @method static \Hypervel\Queue\QueueManager setPoolables(array $poolables) * @method static int size(string|null $queue = null) + * @method static int pendingSize(string|null $queue = null) + * @method static int delayedSize(string|null $queue = null) + * @method static int reservedSize(string|null $queue = null) + * @method static int|null creationTimeOfOldestPendingJob(string|null $queue = null) * @method static mixed push(object|string $job, mixed $data = '', string|null $queue = null) * @method static mixed pushOn(string|null $queue, object|string $job, mixed $data = '') * @method static mixed pushRaw(string $payload, string|null $queue = null, array $options = []) @@ -47,6 +51,8 @@ * @method static mixed getJobBackoff(mixed $job) * @method static mixed getJobExpiration(mixed $job) * @method static void createPayloadUsing(callable|null $callback) + * @method static array getConfig() + * @method static \Hypervel\Queue\Queue setConfig(array $config) * @method static \Psr\Container\ContainerInterface getContainer() * @method static \Hypervel\Queue\Queue setContainer(\Psr\Container\ContainerInterface $container) * @method static \Hypervel\Support\Testing\Fakes\QueueFake except(array|string $jobsToBeQueued) diff --git a/src/support/src/Facades/Redis.php b/src/support/src/Facades/Redis.php index b07d1e49..ed557cb6 100644 --- a/src/support/src/Facades/Redis.php +++ b/src/support/src/Facades/Redis.php @@ -171,7 +171,7 @@ * @method static \Redis|bool pfmerge(string $dst, array $srckeys) * @method static \Redis|string|bool ping(string|null $message = null) * @method static \Redis|bool psetex(string $key, int $expire, mixed $value) - * @method static bool psubscribe(array $patterns, callable $cb) + * @method static void psubscribe(array|string $channels, \Closure $callback) * @method static \Redis|int|false pttl(string $key) * @method static \Redis|int|false publish(string $channel, string $message) * @method static mixed pubsub(string $command, mixed $arg = null) @@ -216,7 +216,7 @@ * @method static \Redis|int|false srem(string $key, mixed $value, mixed ...$other_values) * @method static bool ssubscribe(array $channels, callable $cb) * @method static \Redis|int|false strlen(string $key) - * @method static bool subscribe(array $channels, callable $cb) + * @method static void subscribe(array|string $channels, \Closure $callback) * @method static \Redis|array|bool sunsubscribe(array $channels) * @method static \Redis|bool swapdb(int $src, int $dst) * @method static \Redis|array time()