Skip to content

Commit ecc2373

Browse files
committed
Add docs on ProbeBuilder
1 parent 92ffe03 commit ecc2373

File tree

1 file changed

+31
-0
lines changed
  • crates/stackable-operator/src/builder/pod

1 file changed

+31
-0
lines changed

crates/stackable-operator/src/builder/pod/probe.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,37 @@ pub enum Error {
2323
PeriodIsZero {},
2424
}
2525

26+
/// Kubernetes [`Probe`] builder.
27+
///
28+
/// The upstream [`Probe`] struct does not prevent invalid probe configurations
29+
/// which leads to surprises at runtime which can be deeply hidden.
30+
/// You need to specify at least an action and interval (in this order).
31+
///
32+
/// ### Usage example
33+
///
34+
/// ```
35+
/// use stackable_operator::{
36+
/// builder::pod::probe::ProbeBuilder,
37+
/// time::Duration,
38+
/// };
39+
/// # use k8s_openapi::api::core::v1::HTTPGetAction;
40+
/// # use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString;
41+
///
42+
/// let probe = ProbeBuilder::default()
43+
/// .with_http_get_action_helper(8080, None, None)
44+
/// .with_period(Duration::from_secs(10))
45+
/// .build()
46+
/// .expect("failed to build probe");
47+
///
48+
/// assert_eq!(
49+
/// probe.http_get,
50+
/// Some(HTTPGetAction {
51+
/// port: IntOrString::Int(8080),
52+
/// ..Default::default()
53+
/// })
54+
/// );
55+
/// assert_eq!(probe.period_seconds, Some(10));
56+
/// ```
2657
#[derive(Debug)]
2758
pub struct ProbeBuilder<Action, Period> {
2859
// Mandatory field

0 commit comments

Comments
 (0)