Skip to content
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

broker: List RPC is now server-streaming and supports long-lived watches #389

Closed
wants to merge 2 commits into from

Conversation

jgraettinger
Copy link
Contributor

@jgraettinger jgraettinger commented Jun 22, 2024

The List RPC was originally a unary API, which has two issues:

  • In large deployments, unary responses bump against gRPC maximum messages sizes.
  • Unary responses can't represent a long-lived watch of changes.

Often callers want to react to changes in journals, such as reading a
newly created journal or spreading appended messages across the current
set of journals.

client.NewPolledList somewhat enabled this functionality, but is
inefficient and requires selection of a polling interval.

To address both issues, List is updated to become a server-streaming API
while retaining backward comatibility with MOST clients expecting a
unary response, so long as the response size is under one thousand
journals.

The List RPC is also extended with a Watch mode. When enabled, brokers
will continue to stream real-time updates upon every change to the set
of journals which match the selector. This lets clients react instantly
to changes in journal topology.

client.NewPolledList becomes client.NewWatchedList, with a nearly
identical API (the polling interval is removed).

The shard List RPC is not modified by this change, but could follow a
similar path in the future.


This change is Reviewable

In uses of Gazette, labels often encode a hierarchical namespace
such as "foo/bar/baz", and for such labels it's desireable to be able to
create a LabelSelector that includes or excludes an entire sub-hierarchy
of potential label values, such as including or excluding any label
that begins with "foo/bar/".

Extend Label to have a Prefix field which may only be set in the context
of a LabelSelector (and is a Validate() error otherwise).

In a LabelSelector context, Prefix instructs selector matching to match
any label value which is prefixed by the given selector label.

Introduce a convention of "my-label:prefix" as a special suffix which
indicates that prefix matching is desired, and update LabelSelector
parsing to round-trip such ":prefix" suffixes.

Update the implementation of the special meta-label "prefix" to be in
terms of a "name:prefix" selector label, and back out the bespoke
implementation that has until-now been used for journal name prefix
matching.
The List RPC was originally a unary API, which has two issues:
* In large deployments, unary responses bump against gRPC maximum messages sizes.
* Unary responses can't represent a long-lived watch of changes.

Often callers want to react to changes in journals, such as reading a
newly created journal or spreading appended messages across the current
set of journals.

client.NewPolledList _somewhat_ enabled this functionality, but is
inefficient and requires selection of a polling interval.

To address both issues, List is updated to become a server-streaming API
while retaining backward comatibility with MOST clients expecting a
unary response, so long as the response size is under one thousand
journals.

The List RPC is also extended with a Watch mode. When enabled, brokers
will continue to stream real-time updates upon every change to the set
of journals which match the selector. This lets clients react instantly
to changes in journal topology.

client.NewPolledList becomes client.NewWatchedList, with a nearly
identical API (the polling interval is removed).

The shard List RPC is not modified by this change, but could follow a
similar path in the future.
@jgraettinger jgraettinger deleted the johnny/list-watch branch August 29, 2024 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant