22
33namespace Enqueue \Fs ;
44
5+ use Interop \Queue \DeliveryDelayNotSupportedException ;
56use Interop \Queue \InvalidDestinationException ;
67use Interop \Queue \InvalidMessageException ;
8+ use Interop \Queue \PriorityNotSupportedException ;
79use Interop \Queue \PsrDestination ;
810use Interop \Queue \PsrMessage ;
911use Interop \Queue \PsrProducer ;
1012use Makasim \File \TempFile ;
1113
1214class FsProducer implements PsrProducer
1315{
16+ /**
17+ * @var float|int|null
18+ */
19+ private $ timeToLive ;
20+
1421 /**
1522 * @var FsContext
1623 */
@@ -41,6 +48,10 @@ public function send(PsrDestination $destination, PsrMessage $message)
4148 return ;
4249 }
4350
51+ if (null !== $ this ->timeToLive ) {
52+ $ message ->setHeader ('x-expire-at ' , microtime (true ) + ($ this ->timeToLive / 1000 ));
53+ }
54+
4455 $ rawMessage = '| ' .json_encode ($ message );
4556
4657 if (JSON_ERROR_NONE !== json_last_error ()) {
@@ -62,7 +73,7 @@ public function send(PsrDestination $destination, PsrMessage $message)
6273 */
6374 public function setDeliveryDelay ($ deliveryDelay )
6475 {
65- throw new \ LogicException ( ' Not implemented ' );
76+ throw DeliveryDelayNotSupportedException :: providerDoestNotSupportIt ( );
6677 }
6778
6879 /**
@@ -78,7 +89,7 @@ public function getDeliveryDelay()
7889 */
7990 public function setPriority ($ priority )
8091 {
81- throw new \ LogicException ( ' Not implemented ' );
92+ throw PriorityNotSupportedException :: providerDoestNotSupportIt ( );
8293 }
8394
8495 /**
@@ -94,7 +105,7 @@ public function getPriority()
94105 */
95106 public function setTimeToLive ($ timeToLive )
96107 {
97- throw new \ LogicException ( ' Not implemented ' ) ;
108+ $ this -> timeToLive = $ timeToLive ;
98109 }
99110
100111 /**
0 commit comments