Skip to content

Commit c80c505

Browse files
authored
Merge pull request #107 from josephschorr/exp-rel-count-changes
Changes to the relationships counter API after discussion
2 parents 81d767d + 7776139 commit c80c505

2 files changed

Lines changed: 39 additions & 24 deletions

File tree

authzed/api/v1/error_reason.proto

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,25 +365,25 @@ enum ErrorReason {
365365
// }
366366
ERROR_REASON_EMPTY_PRECONDITION = 25;
367367

368-
// The request failed because the filter was already registered.
368+
// The request failed because the counter was already registered.
369369
//
370370
// Example of an ErrorInfo:
371371
//
372372
// {
373-
// "reason": "ERROR_REASON_FILTER_ALREADY_REGISTERED",
373+
// "reason": "ERROR_REASON_COUNTER_ALREADY_REGISTERED",
374374
// "domain": "authzed.com",
375-
// "metadata": { ... filter fields ... }
375+
// "metadata": { "counter_name": "name" }
376376
// }
377-
ERROR_REASON_FILTER_ALREADY_REGISTERED = 26;
377+
ERROR_REASON_COUNTER_ALREADY_REGISTERED = 26;
378378

379-
// The request failed because the filter was not registered.
379+
// The request failed because the counter was not registered.
380380
//
381381
// Example of an ErrorInfo:
382382
//
383383
// {
384-
// "reason": "ERROR_REASON_FILTER_NOT_REGISTERED",
384+
// "reason": "ERROR_REASON_COUNTER_NOT_REGISTERED",
385385
// "domain": "authzed.com",
386-
// "metadata": { ... filter fields ... }
386+
// "metadata": { "counter_name": "name" }
387387
// }
388-
ERROR_REASON_FILTER_NOT_REGISTERED = 27;
388+
ERROR_REASON_COUNTER_NOT_REGISTERED = 27;
389389
}

authzed/api/v1/experimental_service.proto

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,37 +129,52 @@ service ExperimentalService {
129129
}
130130

131131
message ExperimentalRegisterRelationshipCounterRequest {
132+
// name is the name of the counter being registered.
133+
string name = 1[ (validate.rules).string = {
134+
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$",
135+
max_bytes : 64,
136+
} ];
137+
132138
// relationship_filter defines the filter to be applied to the relationships
133139
// to be counted.
134-
RelationshipFilter relationship_filter = 1
140+
RelationshipFilter relationship_filter = 2
135141
[ (validate.rules).message.required = true ];
136142
}
137143

138144
message ExperimentalRegisterRelationshipCounterResponse {}
139145

140146
message ExperimentalCountRelationshipsRequest {
141-
// consistency defines the consistency level for the count operation. If the
142-
// requested consistency is fully consistent or represents a zedtoken that is
143-
// not stored in the system, the count will be performed synchronously, which
144-
// can be *quite slow* for large datasets.
145-
Consistency consistency = 1;
146-
147-
// relationship_filter defines the filter to be applied to the relationships
148-
// to be counted.
149-
RelationshipFilter relationship_filter = 2
150-
[ (validate.rules).message.required = true ];
147+
// name is the name of the counter whose count is being requested.
148+
string name = 1[ (validate.rules).string = {
149+
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$",
150+
max_bytes : 64,
151+
} ];
151152
}
152153

153154
message ExperimentalCountRelationshipsResponse {
154-
// read_at is the ZedToken at which the relationship count was performed
155-
ZedToken read_at = 1 [ (validate.rules).message.required = true ];
155+
oneof counter_result {
156+
// counter_still_calculating is true if the counter is still calculating the count.
157+
bool counter_still_calculating = 1;
156158

157-
uint64 relationship_count = 2;
159+
// read_counter_value is the value of the counter at the time of the read.
160+
ReadCounterValue read_counter_value = 2;
161+
}
162+
}
163+
164+
message ReadCounterValue {
165+
// relationship_count is the count of relationships that match the filter.
166+
uint64 relationship_count = 1;
167+
168+
// read_at is the ZedToken at which the relationship count applies.
169+
ZedToken read_at = 2 [ (validate.rules).message.required = true ];
158170
}
159171

160172
message ExperimentalUnregisterRelationshipCounterRequest {
161-
RelationshipFilter relationship_filter = 1
162-
[ (validate.rules).message.required = true ];
173+
// name is the name of the counter being unregistered.
174+
string name = 1[ (validate.rules).string = {
175+
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$",
176+
max_bytes : 64,
177+
} ];
163178
}
164179

165180
message ExperimentalUnregisterRelationshipCounterResponse {}

0 commit comments

Comments
 (0)