1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! Kubernetes "watch" stream reader.
//!
//! Turns a `?watch=true` streaming response into a low-latency "something
//! changed" signal that triggers a full re-list, rather than
//! incrementally applying `ADDED`/`MODIFIED`/`DELETED` events to an
//! in-memory per-object cache.
//!
//! A fully correct watch client tracks a `resourceVersion` bookmark,
//! applies each event as a delta, and re-lists from scratch on a
//! `410 Gone` (the bookmark expired). That's meaningfully more surface
//! area to get subtly wrong (missed deletes, duplicate or stale entries,
//! resourceVersion bookkeeping across reconnects) than this crate's
//! existing polling loop ever had to handle. Reading every event line as
//! a plain trigger for [`super::KubernetesIngressWatcher::poll`] still
//! delivers both benefits the gap this closes named: a quiet cluster
//! leaves this thread blocked on a read with no polling work at all, and
//! a real change unblocks that read — and triggers a re-list — as soon as
//! the API server sends it, instead of waiting up to `poll_interval_secs`.
//! The existing interval-based resync loop keeps running unchanged
//! alongside this as a safety net (and as the sole mechanism if the watch
//! connection can't be established at all, e.g. the API server doesn't
//! support it for some reason).
use Read;
/// Read a `Transfer-Encoding: chunked` HTTP response from `read` — first
/// consuming the status line + headers (returning an error for a non-2xx
/// status), then decoding the chunked body into newline-delimited lines,
/// calling `on_line` for each non-empty one.
///
/// Returns `Ok(())` once the stream ends cleanly (last chunk or EOF) —
/// the caller is expected to reconnect after a backoff. Blocks on `read`
/// according to whatever timeout the caller configured on the underlying
/// stream; a timeout surfaces as an `Err` like any other I/O error.
pub