pub struct DNSZoneStatusUpdater { /* private fields */ }Expand description
Centralized status updater for DNSZone resources.
This struct collects all status changes during reconciliation and applies them atomically in a single Kubernetes API call. This prevents the tight reconciliation loop caused by multiple status updates triggering multiple “object updated” events.
Pattern aligns with kube-condition project for future migration.
§Example
use bindy::reconcilers::status::DNSZoneStatusUpdater;
async fn reconcile(client: Client, zone: DNSZone) -> Result<()> {
let mut status_updater = DNSZoneStatusUpdater::new(&zone);
// Collect status changes in memory
status_updater.set_condition("Progressing", "True", "Configuring", "Setting up zone");
status_updater.set_records(vec![/* discovered records */]);
status_updater.set_secondary_ips(vec!["10.0.0.1".to_string()]);
// Single atomic update at the end
status_updater.apply(&client).await?;
Ok(())
}Implementations§
Source§impl DNSZoneStatusUpdater
impl DNSZoneStatusUpdater
Sourcepub fn new(dnszone: &DNSZone) -> Self
pub fn new(dnszone: &DNSZone) -> Self
Create a new status updater for a DNSZone.
Initializes with the current status from the zone, or creates a new empty status.
Sourcepub fn set_condition(
&mut self,
condition_type: &str,
status: &str,
reason: &str,
message: &str,
)
pub fn set_condition( &mut self, condition_type: &str, status: &str, reason: &str, message: &str, )
Update or add a condition (in-memory only, no API call).
Marks the status as changed if the condition differs from the current state.
Sourcepub fn set_records(&mut self, records: Vec<RecordReference>)
pub fn set_records(&mut self, records: Vec<RecordReference>)
Set the discovered DNS records list (in-memory only, no API call).
Sourcepub fn set_secondary_ips(&mut self, ips: Vec<String>)
pub fn set_secondary_ips(&mut self, ips: Vec<String>)
Set the secondary server IPs (in-memory only, no API call).
Sourcepub fn set_observed_generation(&mut self, generation: Option<i64>)
pub fn set_observed_generation(&mut self, generation: Option<i64>)
Set the observed generation to match the current generation.
Sourcepub fn has_changes(&self) -> bool
pub fn has_changes(&self) -> bool
Check if the status has actually changed compared to the current status.
Returns true if there are semantic changes that warrant an API update.
Sourcepub async fn apply(&self, client: &Client) -> Result<()>
pub async fn apply(&self, client: &Client) -> Result<()>
Apply the collected status changes to Kubernetes (single atomic API call).
Only makes the API call if there are actual changes. Skips the update if the status is semantically unchanged, preventing unnecessary reconciliation loops.
§Errors
Returns an error if the Kubernetes API call fails.
Auto Trait Implementations§
impl Freeze for DNSZoneStatusUpdater
impl RefUnwindSafe for DNSZoneStatusUpdater
impl Send for DNSZoneStatusUpdater
impl Sync for DNSZoneStatusUpdater
impl Unpin for DNSZoneStatusUpdater
impl UnwindSafe for DNSZoneStatusUpdater
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more