-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation about ZedTokens/Zookies and consistency #174
Conversation
574f86b
to
5c95054
Compare
docs/consistency-options.md
Outdated
Consistency is provided via the [Consistency block] on API calls. | ||
|
||
[V1 API]: https://buf.build/authzed/api/tree/main/authzed/api/v1 | ||
[Consistency block]: https://buf.build/authzed/api/file/main/authzed/api/v1/permission_service.proto#L50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That URL is guaranteed to change, you probably meant this one: https://buf.build/authzed/api/docs/main/authzed.api.v1#authzed.api.v1.Consistency
@@ -0,0 +1,187 @@ | |||
# ZedTokens and Zookies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than the focus of this being documenting zed tokens / zookies, could we make this focused on "consistency and availability of spicedb" in general? Then we can answer questions like
- where does SpiceDB fit into the CAP theorem?
- what knobs for consistency are available to application developers?
- what happens if SpiceDB is unavailable?
and also cover zed tokens/zookies in a way that people will discover them when they aren't familiar with the terms or how they relate to the system in general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO most people will not care initially about reading about the CAP theorem, but rather how to effectively use the system. The consistency knobs are described in the other consistency document.
If we want a section on CAP guarantees, we can add that, but it is likely too technical for people trying to integrate effectively initially.
d84b79b
to
63820a9
Compare
I think this needs a rebase now that we have CI linting markdown. |
63820a9
to
47ba4a8
Compare
Rebased. Will fix lint issues as they appear. |
6a53838
to
a91c78e
Compare
Updated |
Was reading this PR to understand Zookies, found it very useful. I notice that the recommendations around storing/using zookies only covered the Read/Write endpoints. Was curious which Zookie do you use for Expand/Lookup endpoints? eg. if you have a relationship between a User and their Notes, and you are using Expand, since you store a zookie against each Note resource, do you just pick one? Or always using the strongest consistency? Did I miss something? |
Generally, you always use the ZedToken for the resource on which you're performing the call. So if you previously issued a fully_consistent Check for that resource (and stored a ZedToken), you'd use the same ZedToken in For |
docs/consistency-options.md
Outdated
@@ -0,0 +1,70 @@ | |||
# Consistency Options | |||
|
|||
SpiceDB's [V1 API] provides the ability to specify the *consistency* level at which API calls are made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use lowercase v
everywhere else. This whole document needs to be updated for that.
docs/consistency-options.md
Outdated
|
||
SpiceDB's [V1 API] provides the ability to specify the *consistency* level at which API calls are made. | ||
|
||
Consistency is provided via the [Consistency block] on API calls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/block/message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... on {adjective} API calls.
supported?
available?
docs/consistency-options.md
Outdated
[V1 API]: https://buf.build/authzed/api/tree/main/authzed/api/v1 | ||
[Consistency block]: https://buf.build/authzed/api/docs/main/authzed.api.v1#authzed.api.v1.Consistency | ||
|
||
## Default Consistency: minimize_latency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant we should just change this section title to be "Defaults" since it not only talks about minimize_latency, but also the fully consistent APIs like the schema APIs and write/delete.
docs/consistency-options.md
Outdated
|
||
## Default Consistency: minimize_latency | ||
|
||
The default consistency level for all V1 API calls (except `WriteRelationships` and `DeleteRelationships`, which are always fully consistent) is `minimize_latency`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schema operations are also fully consistent
docs/consistency-options.md
Outdated
|
||
Note that the snapshot used will be loaded at the beginning of the API call, and that new data written *after* the API starts executing will be ignored. | ||
|
||
**WARNING:** Use of `fully_consistent` means little caching will be available, which means performance will suffer. Only use if a [ZedToken/Zookie] is not available or absolutely latest information is required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one sentence per line
docs/consistency-options.md
Outdated
|
||
**WARNING:** Use of `fully_consistent` means little caching will be available, which means performance will suffer. Only use if a [ZedToken/Zookie] is not available or absolutely latest information is required. | ||
|
||
[ZedToken/Zookie]:zedtokens-and-zookies.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between :
and zedtokens-and-zookies.md
docs/zedtokens-and-zookies.md
Outdated
|
||
### What is a ZedToken or Zookie? | ||
|
||
In simplest terms a `ZedToken` (or `Zookie`) is a token representing a **point-in-time** of the SpiceDB datastore, encoded for easy storage and transmission. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ZedToken (v1) or Zookie (v0)" or maybe even link to the buf docs for each
docs/zedtokens-and-zookies.md
Outdated
[V1 API]: https://buf.build/authzed/api/tree/main/authzed/api/v1 | ||
[Consistency]: consistency-options.md | ||
|
||
#### v0 API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should de-emphasize v0 somehow. Either put it in a <details>
or just get rid of it all together.
docs/zedtokens-and-zookies.md
Outdated
|
||
In V1, you can pass the `ZedToken` as `at_exact_snapshot` in the [Consistency] options to ensure the API result is computed at that exact point. | ||
|
||
**WARNING:** SpiceDB will expire garbage and collect it over time. The above API call *can fail with a "Snapshot Expired" error*. This window is determined by the `--datastore-gc-window` when running SpiceDB. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one sentence per line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this probably needs one more sentence describing how you should basically only use this if you're paginating something over a very short amount of time and nothing else.
docs/zedtokens-and-zookies.md
Outdated
V1Zookie deprecated_v1_zookie = 2; | ||
V1ZedToken v1 = 3; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid of these codeblocks rotting. Maybe we should just link to the proto files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
a91c78e
to
43528b1
Compare
Updated |
55f0248
to
7e9e3b5
Compare
Fixes #13 Signed-off-by: Joseph Schorr <josephschorr@users.noreply.github.com>
7e9e3b5
to
51ef755
Compare
Fixes #13