pub struct EventRecorder { /* private fields */ }Expand description
Publishes Kubernetes events on resources on behalf of one controller, aggregating repeats as described in the module documentation.
Share a recorder (via Arc) between a Controller
and whatever else publishes events on that controller’s behalf, but not
between controllers.
Implementations§
Source§impl EventRecorder
impl EventRecorder
Sourcepub fn new(client: Client, reporter: Reporter) -> Self
pub fn new(client: Client, reporter: Reporter) -> Self
Creates a recorder that publishes events as reporter, with the
default timeout.
Reporter::controller becomes each event’s reportingController,
shown by kubectl describe as where the event came from. It should
name the individual controller, and must be a qualified name (for
instance "my-operator.example.com/widgets"), or the API server
rejects the event. Reporter::instance becomes each event’s
reportingInstance, and should identify the replica, for which the
pod name is a good choice; if it is None, the controller name is
used instead.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets how long publishing an event may take, including any wait for
a concurrent publish of the same event, before giving up with
PublishError::Timeout.
Sourcepub async fn publish<K>(
&self,
resource: &K,
event: &Event,
) -> Result<(), PublishError>
pub async fn publish<K>( &self, resource: &K, event: &Event, ) -> Result<(), PublishError>
Publishes event about resource.
A note longer than MAX_NOTE_BYTES is truncated to fit rather than
having the whole event rejected.
Events are informational, so callers should usually log a failure to publish one rather than let it change what they do next.
Sourcepub fn forget<K: Resource>(&self, resource: &K)
pub fn forget<K: Resource>(&self, resource: &K)
Forgets every event published about resource, so that the next
event published about it creates a new event object even if it is
identical to the last one.
This is useful when an event reports a state that the resource can leave and later re-enter, and each entry should be reported as a distinct occurrence.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EventRecorder
impl !RefUnwindSafe for EventRecorder
impl !UnwindSafe for EventRecorder
impl Send for EventRecorder
impl Sync for EventRecorder
impl Unpin for EventRecorder
impl UnsafeUnpin for EventRecorder
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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