Skip to content

Commit

Permalink
Merge pull request #18 from MaterializeInc/doy-concurrency
Browse files Browse the repository at this point in the history
set the concurrency during instantiation rather than during definition
  • Loading branch information
doy-materialize authored Mar 1, 2024
2 parents a0ac4e9 + feb6db0 commit 37572e3
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ where
let controller = kube_runtime::controller::Controller::new(
Api::<Ctx::Resource>::namespaced(client.clone(), namespace),
wc,
)
.with_config(
kube_runtime::Config::default()
.concurrency(Ctx::MAX_CONCURRENT_RECILIATIONS.to_owned()),
);
Self {
client,
Expand Down Expand Up @@ -95,10 +91,6 @@ where
let controller = kube_runtime::controller::Controller::new(
Api::<Ctx::Resource>::all(client.clone()),
wc,
)
.with_config(
kube_runtime::Config::default()
.concurrency(Ctx::MAX_CONCURRENT_RECILIATIONS.to_owned()),
);
Self {
client,
Expand All @@ -125,10 +117,6 @@ where
let controller = kube_runtime::controller::Controller::new(
Api::<Ctx::Resource>::all(client.clone()),
wc,
)
.with_config(
kube_runtime::Config::default()
.concurrency(Ctx::MAX_CONCURRENT_RECILIATIONS.to_owned()),
);
Self {
client,
Expand Down Expand Up @@ -203,6 +191,13 @@ where
})
.await
}

pub fn with_concurrency(mut self, concurrency: u16) -> Self {
self.controller = self
.controller
.with_config(kube_runtime::Config::default().concurrency(concurrency));
self
}
}

/// The [`Context`] trait should be implemented in order to provide callbacks
Expand All @@ -221,12 +216,6 @@ pub trait Context {
/// run against the same resource, unexpected behavior can occur.
const FINALIZER_NAME: &'static str;

/// Max objects to reconcile concurrently.
/// Set to 0 for unbound concurrency.
/// Regardless of this attribute a given object
/// will not be reconciled twice at the same time.
const MAX_CONCURRENT_RECILIATIONS: &'static u16 = &0u16;

/// This method is called when a watched resource is created or updated.
/// The [`Client`] used by the controller is passed in to allow making
/// additional API requests, as is the resource which triggered this
Expand Down

0 comments on commit 37572e3

Please sign in to comment.