Closed jon-whit closed 2 years ago
It has been decided to allow for an empty list of ObjectTypes
which will allow the client to watch for all changes to any object type. So, for example, the following code:
stream, err := client.Watch(context.TODO(), &v1.WatchRequest{
ObjectTypes: []string{}, // watch for 'all' changes
Operations: []v1.RelationshipUpdate_Operation{
v1.RelationshipUpdate_OPERATION_CREATE,
v1.RelationshipUpdate_OPERATION_DELETE,
},
OptionalStartCursor: GetOptionalStartCursor(),
})
if err != nil {
// handle error
}
would start watching for relationship updates that are CREATE or DELETE operations for any object type.
This was discussed in the Discord development channel.
https://discord.com/channels/844600078504951838/900405749405089812/906247932490158082 https://discord.com/channels/844600078504951838/900405749405089812/906274500004438036
These changes were introduced in https://github.com/authzed/api/pull/13.
As a client watching for changes, I'd like to be able to subscribe to changes for any resource type in a single API request.
For example,
This work is also a prerequisite to supporting issue #207 as its implementation will demand an easy way to watch for changes to all resources beginning at some optional start cursor. Also, we should consider adding an operation filter to the Watch API so that a client can filter based on a specific operation (CREATE, DELETE, TOUCH). This way the client doesn't have to filter client side.
The LookupWatch API implementation proposed in #207 will make use of both of these features by watching for changes to all resources for any operation CREATE or DELETE.