Skip to content

Commit b537ad8

Browse files
Introduce CountSchedules operation (#696)
**What changed?** - Added a new CountSchedules API, symmetric to the other Count* operations. **Why?** - Although it isn't documented as public API, the temporal UI makes use of `ListWorkflowExecutions` to display the total count of schedules. This operation will not return data for CHASM-based schedules. Therefore, I'm introducing a public CountSchedules operation that the UI (and customers) can make use of. **Breaking changes** - The technique of using `ListWorkflowExecutions` to query schedules was always unsupported, so we aren't interested in supporting it for CHASM schedules. - `CountSchedules` will be implemented for both V1 and V2 schedules. **Server**: - [Server implementation PR](temporalio/temporal#9046)
1 parent f8b2e39 commit b537ad8

File tree

4 files changed

+231
-0
lines changed

4 files changed

+231
-0
lines changed

openapi/openapiv2.json

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,44 @@
14341434
]
14351435
}
14361436
},
1437+
"/api/v1/namespaces/{namespace}/schedule-count": {
1438+
"get": {
1439+
"summary": "CountSchedules is a visibility API to count schedules in a specific namespace.",
1440+
"operationId": "CountSchedules2",
1441+
"responses": {
1442+
"200": {
1443+
"description": "A successful response.",
1444+
"schema": {
1445+
"$ref": "#/definitions/v1CountSchedulesResponse"
1446+
}
1447+
},
1448+
"default": {
1449+
"description": "An unexpected error response.",
1450+
"schema": {
1451+
"$ref": "#/definitions/rpcStatus"
1452+
}
1453+
}
1454+
},
1455+
"parameters": [
1456+
{
1457+
"name": "namespace",
1458+
"in": "path",
1459+
"required": true,
1460+
"type": "string"
1461+
},
1462+
{
1463+
"name": "query",
1464+
"description": "Visibility query, see https://docs.temporal.io/list-filter for the syntax.",
1465+
"in": "query",
1466+
"required": false,
1467+
"type": "string"
1468+
}
1469+
],
1470+
"tags": [
1471+
"WorkflowService"
1472+
]
1473+
}
1474+
},
14371475
"/api/v1/namespaces/{namespace}/schedules": {
14381476
"get": {
14391477
"summary": "List all schedules in a namespace.",
@@ -5668,6 +5706,44 @@
56685706
]
56695707
}
56705708
},
5709+
"/namespaces/{namespace}/schedule-count": {
5710+
"get": {
5711+
"summary": "CountSchedules is a visibility API to count schedules in a specific namespace.",
5712+
"operationId": "CountSchedules",
5713+
"responses": {
5714+
"200": {
5715+
"description": "A successful response.",
5716+
"schema": {
5717+
"$ref": "#/definitions/v1CountSchedulesResponse"
5718+
}
5719+
},
5720+
"default": {
5721+
"description": "An unexpected error response.",
5722+
"schema": {
5723+
"$ref": "#/definitions/rpcStatus"
5724+
}
5725+
}
5726+
},
5727+
"parameters": [
5728+
{
5729+
"name": "namespace",
5730+
"in": "path",
5731+
"required": true,
5732+
"type": "string"
5733+
},
5734+
{
5735+
"name": "query",
5736+
"description": "Visibility query, see https://docs.temporal.io/list-filter for the syntax.",
5737+
"in": "query",
5738+
"required": false,
5739+
"type": "string"
5740+
}
5741+
],
5742+
"tags": [
5743+
"WorkflowService"
5744+
]
5745+
}
5746+
},
56715747
"/namespaces/{namespace}/schedules": {
56725748
"get": {
56735749
"summary": "List all schedules in a namespace.",
@@ -11411,6 +11487,40 @@
1141111487
}
1141211488
}
1141311489
},
11490+
"v1CountSchedulesResponse": {
11491+
"type": "object",
11492+
"properties": {
11493+
"count": {
11494+
"type": "string",
11495+
"format": "int64",
11496+
"description": "If `query` is not grouping by any field, the count is an approximate number\nof schedules that match the query.\nIf `query` is grouping by a field, the count is simply the sum of the counts\nof the groups returned in the response. This number can be smaller than the\ntotal number of schedules matching the query."
11497+
},
11498+
"groups": {
11499+
"type": "array",
11500+
"items": {
11501+
"type": "object",
11502+
"$ref": "#/definitions/v1CountSchedulesResponseAggregationGroup"
11503+
},
11504+
"description": "Contains the groups if the request is grouping by a field.\nThe list might not be complete, and the counts of each group is approximate."
11505+
}
11506+
}
11507+
},
11508+
"v1CountSchedulesResponseAggregationGroup": {
11509+
"type": "object",
11510+
"properties": {
11511+
"groupValues": {
11512+
"type": "array",
11513+
"items": {
11514+
"type": "object",
11515+
"$ref": "#/definitions/v1Payload"
11516+
}
11517+
},
11518+
"count": {
11519+
"type": "string",
11520+
"format": "int64"
11521+
}
11522+
}
11523+
},
1141411524
"v1CountWorkflowExecutionsResponse": {
1141511525
"type": "object",
1141611526
"properties": {

openapi/openapiv3.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,36 @@ paths:
13191319
application/json:
13201320
schema:
13211321
$ref: '#/components/schemas/Status'
1322+
/api/v1/namespaces/{namespace}/schedule-count:
1323+
get:
1324+
tags:
1325+
- WorkflowService
1326+
description: CountSchedules is a visibility API to count schedules in a specific namespace.
1327+
operationId: CountSchedules
1328+
parameters:
1329+
- name: namespace
1330+
in: path
1331+
required: true
1332+
schema:
1333+
type: string
1334+
- name: query
1335+
in: query
1336+
description: Visibility query, see https://docs.temporal.io/list-filter for the syntax.
1337+
schema:
1338+
type: string
1339+
responses:
1340+
"200":
1341+
description: OK
1342+
content:
1343+
application/json:
1344+
schema:
1345+
$ref: '#/components/schemas/CountSchedulesResponse'
1346+
default:
1347+
description: Default error response
1348+
content:
1349+
application/json:
1350+
schema:
1351+
$ref: '#/components/schemas/Status'
13221352
/api/v1/namespaces/{namespace}/schedules:
13231353
get:
13241354
tags:
@@ -5113,6 +5143,36 @@ paths:
51135143
application/json:
51145144
schema:
51155145
$ref: '#/components/schemas/Status'
5146+
/namespaces/{namespace}/schedule-count:
5147+
get:
5148+
tags:
5149+
- WorkflowService
5150+
description: CountSchedules is a visibility API to count schedules in a specific namespace.
5151+
operationId: CountSchedules
5152+
parameters:
5153+
- name: namespace
5154+
in: path
5155+
required: true
5156+
schema:
5157+
type: string
5158+
- name: query
5159+
in: query
5160+
description: Visibility query, see https://docs.temporal.io/list-filter for the syntax.
5161+
schema:
5162+
type: string
5163+
responses:
5164+
"200":
5165+
description: OK
5166+
content:
5167+
application/json:
5168+
schema:
5169+
$ref: '#/components/schemas/CountSchedulesResponse'
5170+
default:
5171+
description: Default error response
5172+
content:
5173+
application/json:
5174+
schema:
5175+
$ref: '#/components/schemas/Status'
51165176
/namespaces/{namespace}/schedules:
51175177
get:
51185178
tags:
@@ -8568,6 +8628,33 @@ components:
85688628
$ref: '#/components/schemas/Payload'
85698629
count:
85708630
type: string
8631+
CountSchedulesResponse:
8632+
type: object
8633+
properties:
8634+
count:
8635+
type: string
8636+
description: |-
8637+
If `query` is not grouping by any field, the count is an approximate number
8638+
of schedules that match the query.
8639+
If `query` is grouping by a field, the count is simply the sum of the counts
8640+
of the groups returned in the response. This number can be smaller than the
8641+
total number of schedules matching the query.
8642+
groups:
8643+
type: array
8644+
items:
8645+
$ref: '#/components/schemas/CountSchedulesResponse_AggregationGroup'
8646+
description: |-
8647+
Contains the groups if the request is grouping by a field.
8648+
The list might not be complete, and the counts of each group is approximate.
8649+
CountSchedulesResponse_AggregationGroup:
8650+
type: object
8651+
properties:
8652+
groupValues:
8653+
type: array
8654+
items:
8655+
$ref: '#/components/schemas/Payload'
8656+
count:
8657+
type: string
85718658
CountWorkflowExecutionsResponse:
85728659
type: object
85738660
properties:

temporal/api/workflowservice/v1/request_response.proto

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,30 @@ message ListSchedulesResponse {
13891389
bytes next_page_token = 2;
13901390
}
13911391

1392+
message CountSchedulesRequest {
1393+
string namespace = 1;
1394+
// Visibility query, see https://docs.temporal.io/list-filter for the syntax.
1395+
string query = 2;
1396+
}
1397+
1398+
message CountSchedulesResponse {
1399+
// If `query` is not grouping by any field, the count is an approximate number
1400+
// of schedules that match the query.
1401+
// If `query` is grouping by a field, the count is simply the sum of the counts
1402+
// of the groups returned in the response. This number can be smaller than the
1403+
// total number of schedules matching the query.
1404+
int64 count = 1;
1405+
1406+
// Contains the groups if the request is grouping by a field.
1407+
// The list might not be complete, and the counts of each group is approximate.
1408+
repeated AggregationGroup groups = 2;
1409+
1410+
message AggregationGroup {
1411+
repeated temporal.api.common.v1.Payload group_values = 1;
1412+
int64 count = 2;
1413+
}
1414+
}
1415+
13921416
// [cleanup-wv-pre-release]
13931417
message UpdateWorkerBuildIdCompatibilityRequest {
13941418
message AddNewCompatibleVersion {

temporal/api/workflowservice/v1/service.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,16 @@ service WorkflowService {
670670
};
671671
}
672672

673+
// CountSchedules is a visibility API to count schedules in a specific namespace.
674+
rpc CountSchedules (CountSchedulesRequest) returns (CountSchedulesResponse) {
675+
option (google.api.http) = {
676+
get: "/namespaces/{namespace}/schedule-count"
677+
additional_bindings {
678+
get: "/api/v1/namespaces/{namespace}/schedule-count"
679+
}
680+
};
681+
}
682+
673683
// Deprecated. Use `UpdateWorkerVersioningRules`.
674684
//
675685
// Allows users to specify sets of worker build id versions on a per task queue basis. Versions

0 commit comments

Comments
 (0)