Skip to main content

Controller

Struct Controller 

Source
pub struct Controller<K>
where K: Resource<DynamicType = ()> + Clone + Debug + 'static,
{ /* private fields */ }
Available on crate feature k8s only.
Expand description

One controller: a kind, what it owns, how it reconciles. See the module docs.

Implementations§

Source§

impl<K> Controller<K>
where K: Resource<DynamicType = ()> + Clone + DeserializeOwned + Serialize + Debug + Send + Sync + 'static, <K as Resource>::Scope: Scope,

Source

pub fn new(api: Api<K>) -> Controller<K>

Watch api’s objects (Api::all or Api::namespaced).

Source

pub fn watching(self, config: Config) -> Controller<K>

Only the objects config selects (labels, fields).

Source

pub fn owns<C>(self, api: Api<C>) -> Controller<K>
where C: Resource<DynamicType = ()> + Clone + DeserializeOwned + Debug + Send + Sync + 'static,

Also reconcile an object when a C it owns (an owner reference) changes — the Deployment of a custom resource, say.

Source

pub fn reconcile<F, Fut>(self, f: F) -> Controller<K>
where F: Fn(Arc<K>, Arc<Context>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Action, Error>> + Send + 'static,

The reconcile function: make the world match the object, answer when to look again.

Source

pub fn finalizer<F, Fut>(self, name: &str, cleanup: F) -> Controller<K>
where F: Fn(Arc<K>, Arc<Context>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<(), Error>> + Send + 'static,

Add the finalizer name to every object and run cleanup when one is deleted; the finalizer is removed (letting the deletion finish) once cleanup succeeds.

Source

pub fn on_error(self, first_delay: Duration) -> Controller<K>

The first delay before retrying a failed reconcile (doubling per failure of the same object, up to 5 min). Default 5 s.

Source

pub fn rule(self, rule: Rule) -> Controller<K>

Extra RBAC rules the reconcile needs (reading Secrets, say).

Trait Implementations§

Source§

impl<K> Runnable for Controller<K>
where K: Resource<DynamicType = ()> + Clone + DeserializeOwned + Serialize + Debug + Send + Sync + 'static, <K as Resource>::Scope: Scope,

Source§

fn kind(&self) -> String

Source§

fn rules(&self) -> Vec<Rule>

Source§

fn start( self: Box<Controller<K>>, client: Client, ctx: Arc<Context>, ) -> Pin<Box<dyn Future<Output = ()> + Send>>

Auto Trait Implementations§

§

impl<K> !RefUnwindSafe for Controller<K>

§

impl<K> !Sync for Controller<K>

§

impl<K> !UnwindSafe for Controller<K>

§

impl<K> Forget for Controller<K>

§

impl<K> Freeze for Controller<K>
where Api<K>: Freeze, Vec<Box<dyn FnOnce(Controller<K>, &Client) -> Controller<K> + Send>>: Freeze, Option<Arc<dyn Fn(Arc<K>, Arc<Context>) -> Pin<Box<dyn Future<Output = Result<Action, Error>> + Send>> + Send + Sync>>: Freeze, Option<(String, Arc<dyn Fn(Arc<K>, Arc<Context>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> + Send + Sync>)>: Freeze,

§

impl<K> Move for Controller<K>

§

impl<K> Send for Controller<K>
where Api<K>: Send, Vec<Box<dyn FnOnce(Controller<K>, &Client) -> Controller<K> + Send>>: Send, Option<Arc<dyn Fn(Arc<K>, Arc<Context>) -> Pin<Box<dyn Future<Output = Result<Action, Error>> + Send>> + Send + Sync>>: Send, Option<(String, Arc<dyn Fn(Arc<K>, Arc<Context>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> + Send + Sync>)>: Send,

§

impl<K> Unpin for Controller<K>
where Api<K>: Unpin, Vec<Box<dyn FnOnce(Controller<K>, &Client) -> Controller<K> + Send>>: Unpin, Option<Arc<dyn Fn(Arc<K>, Arc<Context>) -> Pin<Box<dyn Future<Output = Result<Action, Error>> + Send>> + Send + Sync>>: Unpin, Option<(String, Arc<dyn Fn(Arc<K>, Arc<Context>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> + Send + Sync>)>: Unpin,

§

impl<K> UnsafeUnpin for Controller<K>
where Api<K>: UnsafeUnpin, Vec<Box<dyn FnOnce(Controller<K>, &Client) -> Controller<K> + Send>>: UnsafeUnpin, Option<Arc<dyn Fn(Arc<K>, Arc<Context>) -> Pin<Box<dyn Future<Output = Result<Action, Error>> + Send>> + Send + Sync>>: UnsafeUnpin, Option<(String, Arc<dyn Fn(Arc<K>, Arc<Context>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> + Send + Sync>)>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ServiceExt for T

Source§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Available on crate feature map-response-body only.
Apply a transformation to the response body. Read more
Source§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

Available on crate feature trace only.
High level tracing that classifies responses using HTTP status codes. Read more
Source§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

Available on crate feature trace only.
High level tracing that classifies responses using gRPC headers. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more