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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
//! qorb is a connection pooling crate.
//!
//! qorb offers a flexible interface for managing connections.
//!
//! It uses the following terminology:
//! * Services are named entities providing the same interface.
//! * Backends are specific instantiations of a program, providing
//! a service. In the case of, e.g., a distributed database, a single
//! service would be provided by multiple backends.
//!
//! # Usage
//!
//! * The main interface for this crate is [pool::Pool].
//! * To construct a pool, you must supply a [resolver::Resolver] and
//! a [backend::Connector]. These are interfaces which specify "how to find
//! backends" and "how to create connections to a backend", respectively.
//!
//! # DTrace probes
//!
//! qorb contains a number of DTrace USDT probes, which fire as the qorb pool
//! manages its connections. These probes provide visibility into when qorb
//! initiates connections; checks health; and vends out claims from a pool. The
//! full list of probes is:
//!
//! - `claim-start`: Fires before attempting to make take a claim from the pool.
//! - `claim-done`: Fires before returning a successful claim to the client.
//! - `claim-failed`: Fires on failure to take a claim from the pool.
//! - `connect-start`: Fires before attempting a connection to a backend.
//! - `connect-done`: Fires after successfully connecting to a backend.
//! - `connect-failed`: Fires after failing to connect to a backend.
//! - `pool-claim-start`: Fires when a pool tries to make a claim, on behalf of
//! a user-requested claim-start.
//! - `pool-claim-done`: Fires when a pool successfully makes a claim.
//! - `pool-claim-failed`: Fires when a pool cannot make a claim.
//! - `slot-set-claim-start`: Fires when a claim has been made to a backend.
//! - `slot-set-claim-done`: Fires when a backend returns a claim.
//! - `slot-set-claim-failed`: Fires when a backend cannot return a claim.
//! - `slot-set-online`: Fires when a backend becomes online.
//! - `slot-set-offline`: Fires when a backend becomes offline.
//! - `slot-state-change`: Fires when a slot has a state change, and emits
//! stats for the backend.
//! - `handle-claimed`: Fires after claiming a handle from the pool, before
//! returning it to the client.
//! - `handle-returned`: Fires when a handle is returned to the pool, after it
//! is dropped.
//! - `health-check-start`: Fires when a health check for a backend starts.
//! - `health-check-done`: Fires when a health check for a backend completes
//! successfully.
//! - `health-check-failed`: Fires when a health check for a backend fails.
//! - `recycle-start`: Fires before attempting to recycle a connection.
//! - `recycle-done`: Fires after successsfully recycling a connection.
//! - `recycle-failed`: Fires when failing to recycle a connection.
//! - `rebalance-start`: Fires when rebalancing the connection pool.
//! - `rebalance-done`: Fires when the connection pool is done rebalancing.
//!
//! The existence of the probes is behind the `"probes"` feature, which is
//! enabled by default. Probes are zero-cost unless they are explicitly enabled,
//! by tracing the program with the `dtrace(1)` command-line tool.
//!
//! On most systems, the USDT probes must be registered with the DTrace kernel
//! module. This process is technically fallible, although extremely unlikely to
//! fail in practice. To account for this, the `pool::Pool::new` constructor is
//! fallible, returning an `Err` if registration fails. However, it's very
//! context-dependent what one wants to do with this failure -- some
//! applications may choose to panic, while others would rather have a pool that
//! can't be instrumented rather than no pool at all.
//!
//! To support both of these cases, the `Result` returned from `pool::Pool::new`
//! gives access to the pool itself in both the `Ok` or `Err` variant. Some
//! applications may just `unwrap()` or propagate an error, while others may
//! choose to extract the pool in either case. (This is similar to the
//! `std::sync::PoisonError`.)
// Public API
// Necessary for implementation
// mod codel;
// Default implementations of generic interfaces
/// Uniquely identifies a claim for probes
pub ;
pub ;
/// USDT probes for tracing how qorb makes pools and hands out claims.