Skip to content

Commit

Permalink
update readme as well
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Apr 6, 2020
1 parent 6cf5a30 commit 3dceef4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ A basic event watcher that presents a stream of api events on a resource with a
An Informer updates the last received `resourceVersion` internally on every event, before shipping the event to the app. If your controller restarts, you will receive one event for every active object at startup, before entering a normal watch.

```rust
let r = Resource::all::<Pod>();
let inf = Informer::new(client, r);
let pods: Api<Pod> = Api::namespaced(client, "default");
let inform = Informer::new(pods, pods);
```

The main feature of `Informer<K>` is being able to subscribe to events while having a streaming `.poll()` open:

```rust
let pods = inf.poll().await?.boxed(); // starts a watch and returns a stream
let pods = inform.poll().await?.boxed(); // starts a watch and returns a stream

while let Some(event) = pods.try_next().await? { // await next event
handle(event).await?; // pass the WatchEvent to a handler
Expand Down Expand Up @@ -133,10 +133,10 @@ A cache for `K` that keeps itself up to date. It does not expose events, but you


```rust
let r = Resource::namespaced::<Node>(&namespace);
let nodes: Api<Node> = Api::namespaced(client, &namespace);
let lp = ListParams::default()
.labels("beta.kubernetes.io/instance-type=m4.2xlarge");
let rf = Reflector::new(client, lp, r);
let rf = Reflector::new(nodes, lp);
```

then you should `poll()` the reflector, and `state()` to get the current cached state:
Expand Down

0 comments on commit 3dceef4

Please sign in to comment.