⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
toner-aktuell.de
/
vendor
/
enqueue
/
redis
/
Edit File: RedisProducer.php
<?php declare(strict_types=1); namespace Enqueue\Redis; use Interop\Queue\Destination; use Interop\Queue\Exception\InvalidDestinationException; use Interop\Queue\Exception\InvalidMessageException; use Interop\Queue\Exception\PriorityNotSupportedException; use Interop\Queue\Message; use Interop\Queue\Producer; use Ramsey\Uuid\Uuid; class RedisProducer implements Producer { /** * @var RedisContext */ private $context; /** * @var int|null */ private $timeToLive; /** * @var int */ private $deliveryDelay; /** * @param RedisContext $context */ public function __construct(RedisContext $context) { $this->context = $context; } /** * @param RedisDestination $destination * @param RedisMessage $message */ public function send(Destination $destination, Message $message): void { InvalidDestinationException::assertDestinationInstanceOf($destination, RedisDestination::class); InvalidMessageException::assertMessageInstanceOf($message, RedisMessage::class); $message->setMessageId(Uuid::uuid4()->toString()); $message->setHeader('attempts', 0); if (null !== $this->timeToLive && null === $message->getTimeToLive()) { $message->setTimeToLive($this->timeToLive); } if (null !== $this->deliveryDelay && null === $message->getDeliveryDelay()) { $message->setDeliveryDelay($this->deliveryDelay); } if ($message->getTimeToLive()) { $message->setHeader('expires_at', time() + $message->getTimeToLive()); } $payload = $this->context->getSerializer()->toString($message); if ($message->getDeliveryDelay()) { $deliveryAt = time() + $message->getDeliveryDelay() / 1000; $this->context->getRedis()->zadd($destination->getName().':delayed', $payload, $deliveryAt); } else { $this->context->getRedis()->lpush($destination->getName(), $payload); } } /** * @return self */ public function setDeliveryDelay(int $deliveryDelay = null): Producer { $this->deliveryDelay = $deliveryDelay; return $this; } public function getDeliveryDelay(): ?int { return $this->deliveryDelay; } /** * @return RedisProducer */ public function setPriority(int $priority = null): Producer { if (null === $priority) { return $this; } throw PriorityNotSupportedException::providerDoestNotSupportIt(); } public function getPriority(): ?int { return null; } /** * @return self */ public function setTimeToLive(int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; return $this; } public function getTimeToLive(): ?int { return $this->timeToLive; } }
Simpan