pub struct OperatorContext {
pub kube_client: Client,
pub event_recorder: Recorder,
pub observability: OperatorObservability,
/* private fields */
}Expand description
Shared state for the operator, passed to every reconciliation.
Fields§
§kube_client: ClientKubernetes client for API calls.
event_recorder: RecorderKubernetes Event recorder for transition-based policy Events.
observability: OperatorObservabilityShared health/metrics state.
Implementations§
Source§impl OperatorContext
impl OperatorContext
Sourcepub fn new(
kube_client: Client,
observability: OperatorObservability,
event_recorder: Recorder,
) -> Self
pub fn new( kube_client: Client, observability: OperatorObservability, event_recorder: Recorder, ) -> Self
Create a new operator context with an empty pool cache.
Sourcepub async fn try_lock_database(
&self,
database_identity: &str,
) -> Option<DatabaseLockGuard>
pub async fn try_lock_database( &self, database_identity: &str, ) -> Option<DatabaseLockGuard>
Try to acquire the in-process lock for the given database identity.
Returns Some(guard) if no other reconcile is in progress for this
database, None if one is already running. The lock is released when
the guard is dropped.
Sourcepub async fn get_or_create_pool(
&self,
namespace: &str,
secret_name: &str,
secret_key: &str,
) -> Result<PgPool, ContextError>
pub async fn get_or_create_pool( &self, namespace: &str, secret_name: &str, secret_key: &str, ) -> Result<PgPool, ContextError>
Get or create a PgPool for the given secret reference.
Reads the DATABASE_URL (or custom key) from the referenced Secret,
and caches the resulting pool for reuse.
Sourcepub async fn fetch_secret_value(
&self,
namespace: &str,
secret_name: &str,
secret_key: &str,
) -> Result<String, ContextError>
pub async fn fetch_secret_value( &self, namespace: &str, secret_name: &str, secret_key: &str, ) -> Result<String, ContextError>
Fetch a single string value from a Kubernetes Secret.
Used to resolve role passwords from Secret references at reconcile time.
Sourcepub async fn evict_pool(
&self,
namespace: &str,
secret_name: &str,
secret_key: &str,
)
pub async fn evict_pool( &self, namespace: &str, secret_name: &str, secret_key: &str, )
Remove a cached pool (e.g. when secret changes or CR is deleted).
Trait Implementations§
Source§impl Clone for OperatorContext
impl Clone for OperatorContext
Source§fn clone(&self) -> OperatorContext
fn clone(&self) -> OperatorContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for OperatorContext
impl !RefUnwindSafe for OperatorContext
impl Send for OperatorContext
impl Sync for OperatorContext
impl Unpin for OperatorContext
impl UnsafeUnpin for OperatorContext
impl !UnwindSafe for OperatorContext
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request