pub struct Context {
pub client: Client,
pub config: Arc<OperatorConfig>,
pub registry: SharedRegistry,
pub admin_clients: Arc<Mutex<HashMap<String, AdminClientHandle>>>,
pub rebalancer_clients: Arc<Mutex<HashMap<String, RebalancerClientHandle>>>,
}Expand description
Shared per-reconciler context. Cheap to clone (all fields Arc / shared via interior mutability).
Fields§
§client: Client§config: Arc<OperatorConfig>§registry: SharedRegistry§admin_clients: Arc<Mutex<HashMap<String, AdminClientHandle>>>Per-cluster admin-client cache. Keyed by Kafka resource name.
Broken connections are replaced lazily on next use.
rebalancer_clients: Arc<Mutex<HashMap<String, RebalancerClientHandle>>>Per-endpoint rebalancer-client cache. Keyed by the resolved Connect base URL. Dropped + re-created lazily on transport failure.
Implementations§
Source§impl Context
impl Context
pub fn new( client: Client, config: OperatorConfig, registry: SharedRegistry, ) -> Self
Sourcepub async fn admin_client_for(
&self,
cluster: &str,
bootstrap: &str,
) -> Result<AdminClientHandle, AdminError>
pub async fn admin_client_for( &self, cluster: &str, bootstrap: &str, ) -> Result<AdminClientHandle, AdminError>
Look up or open an AdminClient for the named cluster.
bootstrap is the inter-broker listener’s bootstrap_servers
string, e.g. demo-broker-headless.default.svc.cluster.local:9092.
Sourcepub async fn drop_admin_client(&self, cluster: &str)
pub async fn drop_admin_client(&self, cluster: &str)
Drop the cached admin client for cluster (used by reconcile when
a Transport error indicates the connection died — next call will
reopen).
Sourcepub async fn insert_admin_client_for_test(
&self,
cluster: &str,
admin: AdminClientHandle,
)
pub async fn insert_admin_client_for_test( &self, cluster: &str, admin: AdminClientHandle, )
Test-only: pre-populate the admin-client cache with a caller-supplied
handle. The AdminClientLike trait abstracts over the real client
and per-test fakes, so reconcile tests can drive the trait methods
without opening a TCP connection.
Not cfg-gated: the function exists in the public API but is harmless (and unused) in production — keeping it un-gated avoids a parallel test-only build profile.
Sourcepub async fn rebalancer_client_for(
&self,
endpoint: &str,
) -> RebalancerClientHandle
pub async fn rebalancer_client_for( &self, endpoint: &str, ) -> RebalancerClientHandle
Look up or build a rebalancer client for endpoint (a Connect base
URL like http://host:9300). Construction is infallible (no
connection is opened until the first RPC), so this returns the
handle directly.
Sourcepub async fn drop_rebalancer_client(&self, endpoint: &str)
pub async fn drop_rebalancer_client(&self, endpoint: &str)
Drop the cached rebalancer client for endpoint (used by reconcile
after a transport error — the next call rebuilds it).
Sourcepub async fn insert_rebalancer_client_for_test(
&self,
endpoint: &str,
client: RebalancerClientHandle,
)
pub async fn insert_rebalancer_client_for_test( &self, endpoint: &str, client: RebalancerClientHandle, )
Test-only: pre-populate the rebalancer-client cache with a fake.
Mirrors Self::insert_admin_client_for_test.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Context
impl !UnwindSafe for Context
impl Freeze for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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