Skip to content

Commit

Permalink
Add Controller::for_stream + Controller::watches_stream (#1187)
Browse files Browse the repository at this point in the history
* Add `Controller::for_stream`

This adds a stream interface analogue for `Controller::new`,
that allows the user to create the root `watcher` and `reflector`,
outside, and pass in the reader + flattened stream.

We originally discussed this name as `from_stream`, but given that we
need to also pass along the `reader`, it is no longer a `From` equivalent.
So have instead named it along the lines of `Controller::for` and highlighted
the terminology. Note that `Controller::For` is the [controller-runtime equivalent](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/builder#Builder.For).

Also fixes up bad doc setups and ensures unstable features are highlighted,
even though they appear in the middle of a trait.

The owns-stream unstable flagged is moved to `unstable-runtime-stream-share`
which now also contains this new method.

Signed-off-by: clux <sszynrae@gmail.com>

* fix extraneous import of `StreamExt` in watcher docs

closes #1186

Tried to cherry-pick, but would have had to do a rebase
on the two commits in there, so just re-did it.

Thanks @suryapandian.

Signed-off-by: clux <sszynrae@gmail.com>

* forgotten sentence save

Signed-off-by: clux <sszynrae@gmail.com>

* Add `Controller::watches_stream`

Signed-off-by: clux <sszynrae@gmail.com>

* cleanup dynamic type bounds for watches

Signed-off-by: clux <sszynrae@gmail.com>

* rename feature to stream-control

since it doesn't work with stream subscribe yet

Signed-off-by: clux <sszynrae@gmail.com>

* remove leftover arc when testing

Signed-off-by: clux <sszynrae@gmail.com>

* factor out `trigger_others` from Controller::watches* bodies

Signed-off-by: clux <sszynrae@gmail.com>

* use david's smarter trigger_owners

Signed-off-by: clux <sszynrae@gmail.com>

---------

Signed-off-by: clux <sszynrae@gmail.com>
  • Loading branch information
clux committed Apr 7, 2023
1 parent 2968e3e commit 740111f
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 69 deletions.
4 changes: 2 additions & 2 deletions kube-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ rust-version = "1.63.0"
edition = "2021"

[features]
unstable-runtime = ["unstable-runtime-subscribe", "unstable-runtime-predicates", "unstable-runtime-owns-stream"]
unstable-runtime = ["unstable-runtime-subscribe", "unstable-runtime-predicates", "unstable-runtime-stream-control"]
unstable-runtime-subscribe = []
unstable-runtime-predicates = []
unstable-runtime-owns-stream = []
unstable-runtime-stream-control = []

[package.metadata.docs.rs]
features = ["k8s-openapi/v1_26", "unstable-runtime"]
Expand Down
Loading

0 comments on commit 740111f

Please sign in to comment.