Skip to content

Commit

Permalink
Merge pull request #107 from josephschorr/exp-rel-count-changes
Browse files Browse the repository at this point in the history
Changes to the relationships counter API after discussion
  • Loading branch information
josephschorr authored May 22, 2024
2 parents 81d767d + 7776139 commit c80c505
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
16 changes: 8 additions & 8 deletions authzed/api/v1/error_reason.proto
Original file line number Diff line number Diff line change
Expand Up @@ -365,25 +365,25 @@ enum ErrorReason {
// }
ERROR_REASON_EMPTY_PRECONDITION = 25;

// The request failed because the filter was already registered.
// The request failed because the counter was already registered.
//
// Example of an ErrorInfo:
//
// {
// "reason": "ERROR_REASON_FILTER_ALREADY_REGISTERED",
// "reason": "ERROR_REASON_COUNTER_ALREADY_REGISTERED",
// "domain": "authzed.com",
// "metadata": { ... filter fields ... }
// "metadata": { "counter_name": "name" }
// }
ERROR_REASON_FILTER_ALREADY_REGISTERED = 26;
ERROR_REASON_COUNTER_ALREADY_REGISTERED = 26;

// The request failed because the filter was not registered.
// The request failed because the counter was not registered.
//
// Example of an ErrorInfo:
//
// {
// "reason": "ERROR_REASON_FILTER_NOT_REGISTERED",
// "reason": "ERROR_REASON_COUNTER_NOT_REGISTERED",
// "domain": "authzed.com",
// "metadata": { ... filter fields ... }
// "metadata": { "counter_name": "name" }
// }
ERROR_REASON_FILTER_NOT_REGISTERED = 27;
ERROR_REASON_COUNTER_NOT_REGISTERED = 27;
}
47 changes: 31 additions & 16 deletions authzed/api/v1/experimental_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -129,37 +129,52 @@ service ExperimentalService {
}

message ExperimentalRegisterRelationshipCounterRequest {
// name is the name of the counter being registered.
string name = 1[ (validate.rules).string = {
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$",
max_bytes : 64,
} ];

// relationship_filter defines the filter to be applied to the relationships
// to be counted.
RelationshipFilter relationship_filter = 1
RelationshipFilter relationship_filter = 2
[ (validate.rules).message.required = true ];
}

message ExperimentalRegisterRelationshipCounterResponse {}

message ExperimentalCountRelationshipsRequest {
// consistency defines the consistency level for the count operation. If the
// requested consistency is fully consistent or represents a zedtoken that is
// not stored in the system, the count will be performed synchronously, which
// can be *quite slow* for large datasets.
Consistency consistency = 1;

// relationship_filter defines the filter to be applied to the relationships
// to be counted.
RelationshipFilter relationship_filter = 2
[ (validate.rules).message.required = true ];
// name is the name of the counter whose count is being requested.
string name = 1[ (validate.rules).string = {
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$",
max_bytes : 64,
} ];
}

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

uint64 relationship_count = 2;
// read_counter_value is the value of the counter at the time of the read.
ReadCounterValue read_counter_value = 2;
}
}

message ReadCounterValue {
// relationship_count is the count of relationships that match the filter.
uint64 relationship_count = 1;

// read_at is the ZedToken at which the relationship count applies.
ZedToken read_at = 2 [ (validate.rules).message.required = true ];
}

message ExperimentalUnregisterRelationshipCounterRequest {
RelationshipFilter relationship_filter = 1
[ (validate.rules).message.required = true ];
// name is the name of the counter being unregistered.
string name = 1[ (validate.rules).string = {
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$",
max_bytes : 64,
} ];
}

message ExperimentalUnregisterRelationshipCounterResponse {}
Expand Down

0 comments on commit c80c505

Please sign in to comment.