Skip to content

Commit 6979290

Browse files
authored
Merge branch 'main' into andystaples-add-purge-timeout
2 parents 700cd8b + 903d8dc commit 6979290

7 files changed

Lines changed: 52 additions & 2 deletions

File tree

‎.github/workflows/codeql.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767

6868
# Initializes the CodeQL tools for scanning.
6969
- name: Initialize CodeQL
70-
uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
70+
uses: github/codeql-action/init@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7
7171
with:
7272
languages: ${{ matrix.language }}
7373
build-mode: ${{ matrix.build-mode }}
@@ -96,6 +96,6 @@ jobs:
9696
exit 1
9797
9898
- name: Perform CodeQL Analysis
99-
uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
99+
uses: github/codeql-action/analyze@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7
100100
with:
101101
category: "/language:${{matrix.language}}"

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ADDED
1212
- Added an optional timeout to filtered orchestration purges. Callers can now
1313
limit a purge operation's duration and inspect `PurgeInstancesResult.is_complete`
1414
for completed, partial, or backend-unknown completion status.
15+
- Added `OrchestrationQuery.instance_id_prefix` to retrieve orchestration
16+
instances whose IDs begin with a specified prefix.
1517
- Added optional `reason` parameters to `TaskHubGrpcClient` and
1618
`AsyncTaskHubGrpcClient` suspend and resume operations. The reason is now sent
1719
to the backend with the lifecycle request.

‎azure-functions-durable/CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ ADDED
1111

1212
- Added an optional timeout to filtered orchestration purges through
1313
`DurableFunctionsClient` and `SyncDurableFunctionsClient`.
14+
- Added inherited `OrchestrationQuery.instance_id_prefix` support to retrieve
15+
orchestration instances whose IDs begin with a specified prefix.
1416
> [!NOTE]
1517
> Release this change only in coordination with a new `durabletask` release
1618
> that contains the suspend/resume reason APIs. Publish `durabletask` first,

‎durabletask-azuremanaged/CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ ADDED
1111

1212
- Added an optional timeout to filtered orchestration purges through
1313
`DurableTaskSchedulerClient` and `AsyncDurableTaskSchedulerClient`.
14+
- Added inherited `OrchestrationQuery.instance_id_prefix` support to retrieve
15+
orchestration instances whose IDs begin with a specified prefix.
1416
- Added optional `reason` parameters to suspend and resume operations inherited
1517
from `TaskHubGrpcClient` and `AsyncTaskHubGrpcClient`.
1618

‎durabletask/client.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class OrchestrationQuery:
196196
# results instead.
197197
max_instance_count: int | None = (1 << 31) - 1
198198
fetch_inputs_and_outputs: bool = False
199+
instance_id_prefix: str | None = None
199200

200201

201202
@dataclass

‎durabletask/internal/client_helpers.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def build_query_instances_req(
103103
runtimeStatus=[status.value for status in orchestration_query.runtime_status] if orchestration_query.runtime_status else None,
104104
createdTimeFrom=helpers.new_timestamp(orchestration_query.created_time_from) if orchestration_query.created_time_from else None,
105105
createdTimeTo=helpers.new_timestamp(orchestration_query.created_time_to) if orchestration_query.created_time_to else None,
106+
instanceIdPrefix=helpers.get_string_value(orchestration_query.instance_id_prefix),
106107
maxInstanceCount=orchestration_query.max_instance_count,
107108
fetchInputsAndOutputs=orchestration_query.fetch_inputs_and_outputs,
108109
continuationToken=continuation_token

‎tests/durabletask/test_batch_actions.py‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pytest
1313
from durabletask import client, entities, task
1414
from durabletask.client import TaskHubGrpcClient
15+
from durabletask.internal.client_helpers import build_query_instances_req
1516
from durabletask.testing import create_test_backend
1617
from durabletask.worker import TaskHubGrpcWorker
1718

@@ -163,6 +164,47 @@ def test_get_orchestration_state_by_time_range(backend):
163164
assert len([o for o in orchestrations_outside_range if o.instance_id == id]) == 0
164165

165166

167+
def test_get_orchestration_state_by_instance_id_prefix(backend):
168+
worker = TaskHubGrpcWorker(host_address=HOST)
169+
170+
worker.add_orchestrator(empty_orchestrator)
171+
worker.start()
172+
173+
try:
174+
with TaskHubGrpcClient(host_address=HOST) as c:
175+
matching_id = "prefix-match"
176+
non_matching_id = "other-instance"
177+
c.schedule_new_orchestration(empty_orchestrator, instance_id=matching_id)
178+
c.schedule_new_orchestration(empty_orchestrator, instance_id=non_matching_id)
179+
c.wait_for_orchestration_completion(matching_id, timeout=30)
180+
c.wait_for_orchestration_completion(non_matching_id, timeout=30)
181+
182+
query = client.OrchestrationQuery(instance_id_prefix="prefix-")
183+
orchestrations = c.get_all_orchestration_states(query)
184+
finally:
185+
worker.stop()
186+
187+
assert [orchestration.instance_id for orchestration in orchestrations] == [matching_id]
188+
189+
190+
def test_orchestration_query_serializes_instance_id_prefix():
191+
request = build_query_instances_req(
192+
client.OrchestrationQuery(instance_id_prefix="prefix-"),
193+
continuation_token=None,
194+
)
195+
196+
assert request.query.HasField("instanceIdPrefix")
197+
assert request.query.instanceIdPrefix.value == "prefix-"
198+
199+
200+
def test_orchestration_query_preserves_positional_argument_order():
201+
query = client.OrchestrationQuery(None, None, None, None, True)
202+
203+
assert query.max_instance_count is None
204+
assert query.fetch_inputs_and_outputs is True
205+
assert query.instance_id_prefix is None
206+
207+
166208
def test_get_orchestration_state_pagination_succeeds(backend):
167209
# Create a custom handler to capture log messages
168210
log_records = []

0 commit comments

Comments
 (0)