Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Messaging/MessageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private static function asTaskVersion2(
'exchange' => '',
'routing_key' => $si->getQueue(),
],
'priority' => 0,
'priority' => $si->getPriority(),
'delivery_tag' => Functions::uuid4(),
];

Expand Down
27 changes: 27 additions & 0 deletions src/TaskSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class TaskSignature {
*/
protected ?int $retries = null;

/**
* Set the priority, 0 to 9, 0 is highest priority
*/
protected ?int $priority = null;

/** Expiry time (UTC) of the task, if set. */
protected ?string $expiration = null;

Expand All @@ -66,6 +71,7 @@ public function __construct(
?array $args = null,
?array $kwargs = null,
?int $retries = null,
?int $priority = null,
?int $countdown = null,
null|string|\DateTimeInterface $eta = null,
null|string|\DateTimeInterface $expiration = null,
Expand All @@ -80,6 +86,7 @@ public function __construct(
$args !== null && $this->rawSetArgs($args);
$kwargs !== null && $this->rawSetKwargs($kwargs);
$retries !== null && $this->rawSetRetries($retries);
$priority !== null && $this->rawSetPriority($priority);
$countdown !== null && $this->rawSetCountdown($countdown);
$eta !== null && $this->rawSetEta($eta);
$expiration !== null && $this->rawSetExpiration($expiration);
Expand Down Expand Up @@ -113,6 +120,10 @@ public function getRetries(): ?int {
return $this->retries;
}

public function getPriority(): ?int {
return $this->priority;
}

public function getEta(): ?string {
return $this->eta;
}
Expand Down Expand Up @@ -166,6 +177,15 @@ public function setRetries(?int $retries): self {
return $self;
}

/**
* Set the priority, 0 to 9, 0 is highest priority
*/
public function setPriority(?int $priority): self {
$self = clone $this;
$self->rawSetPriority($priority);
return $self;
}

/**
* Countdown is a shortcut to set ETA by seconds into the future.
* See method TaskSignature::setEta().
Expand Down Expand Up @@ -250,6 +270,13 @@ private function rawSetRetries(?int $retries): void {
$this->retries = $retries;
}

/**
* Set the priority, 0 to 9, 0 is highest priority
*/
private function rawSetPriority(?int $priority): void {
$this->priority = $priority;
}

/**
* Countdown is a shortcut to set ETA by seconds into the future.
* See method TaskSignature::setEta().
Expand Down