Skip to content

Expose Priority #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 5, 2025
Merged
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
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ trim_trailing_whitespace = true
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 2

[*.yaml]
indent_size = 2

[*.json]
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
"psr/log": "^2.0 || ^3.0.2",
"ramsey/uuid": "^4.7.6",
"react/promise": "^2.11",
"roadrunner-php/roadrunner-api-dto": "^1.10.0",
"roadrunner-php/roadrunner-api-dto": "^1.12.0",
"roadrunner-php/version-checker": "^1.0.1",
"spiral/attributes": "^3.1.8",
"spiral/roadrunner": "^2024.3.3 || ^2025.1.1",
"spiral/roadrunner": "^2025.1.0",
"spiral/roadrunner-cli": "^2.6",
"spiral/roadrunner-kv": "^4.3",
"spiral/roadrunner-worker": "^3.6.1",
"spiral/roadrunner-kv": "^4.3.1",
"spiral/roadrunner-worker": "^3.6.2",
"symfony/filesystem": "^5.4.45 || ^6.4.13 || ^7.0",
"symfony/http-client": "^5.4.49 || ^6.4.17 || ^7.0",
"symfony/polyfill-php83": "^1.31.0",
Expand All @@ -56,7 +56,7 @@
"composer/composer": "^2.8.4",
"dereuromark/composer-prefer-lowest": "^0.1.10",
"doctrine/annotations": "^1.14.4 || ^2.0.2",
"internal/dload": "^1.1.0",
"internal/dload": "^1.2.0",
"jetbrains/phpstorm-attributes": "dev-master",
"laminas/laminas-code": "^4.16",
"phpunit/phpunit": "10.5.45",
Expand Down
4 changes: 2 additions & 2 deletions dload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
temp-dir="./runtime"
>
<actions>
<download software="rr" version="^2024.3.3"/>
<download software="temporal"/>
<download software="rr" version="^2025.1.0"/>
<download software="temporal" version="^1.3-priority"/>
<download software="temporal-tests-server"/>
</actions>
<registry>
Expand Down
11 changes: 11 additions & 0 deletions src/Activity/ActivityInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use JetBrains\PhpStorm\Immutable;
use Temporal\Activity;
use Temporal\Client\ActivityCompletionClientInterface;
use Temporal\Common\Priority;
use Temporal\Common\Uuid;
use Temporal\Internal\Marshaller\Meta\Marshal;
use Temporal\Internal\Marshaller\Type\DateIntervalType;
Expand Down Expand Up @@ -99,6 +100,14 @@ final class ActivityInfo
#[Marshal(name: 'Attempt')]
public int $attempt = 1;

/**
* Return the priority of the activity task.
*
* @internal Experimental API
*/
#[Marshal(name: 'Priority')]
public Priority $priority;

/**
* ActivityInfo constructor.
*/
Expand All @@ -112,5 +121,7 @@ public function __construct()
$this->scheduledTime = CarbonImmutable::now();
$this->startedTime = CarbonImmutable::now();
$this->deadline = CarbonImmutable::now();

$this->priority = Priority::new();
}
}
29 changes: 29 additions & 0 deletions src/Activity/ActivityOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Carbon\CarbonInterval;
use JetBrains\PhpStorm\Pure;
use Temporal\Common\MethodRetry;
use Temporal\Common\Priority;
use Temporal\Common\RetryOptions;
use Temporal\Internal\Marshaller\Meta\Marshal;
use Temporal\Internal\Marshaller\Type\ActivityCancellationType as ActivityCancellationMarshallerType;
Expand Down Expand Up @@ -109,6 +110,15 @@ class ActivityOptions extends Options implements ActivityOptionsInterface
#[Marshal(name: 'RetryPolicy', type: NullableType::class, of: RetryOptions::class)]
public ?RetryOptions $retryOptions = null;

/**
* Optional priority settings that control relative ordering of task processing when tasks are
* backed up in a queue.
*
* Defaults to inheriting priority from the workflow that scheduled the activity.
*/
#[Marshal(name: 'Priority')]
public Priority $priority;

/**
* ActivityOptions constructor.
*/
Expand All @@ -118,6 +128,7 @@ public function __construct()
$this->scheduleToCloseTimeout = CarbonInterval::seconds(0);
$this->startToCloseTimeout = CarbonInterval::seconds(0);
$this->heartbeatTimeout = CarbonInterval::seconds(0);
$this->priority = Priority::new();

parent::__construct();
}
Expand Down Expand Up @@ -291,4 +302,22 @@ public function withRetryOptions(?RetryOptions $options): self

return $self;
}

/**
* Optional priority settings that control relative ordering of task processing when tasks are
* backed up in a queue.
*
* Defaults to inheriting priority from the workflow that scheduled the activity.
*
* @return $this
*
* @internal Experimental
*/
#[Pure]
public function withPriority(Priority $priority): self
{
$self = clone $this;
$self->priority = $priority;
return $self;
}
}
Loading
Loading