async fn handle_event(
        &self,
        event: WatchEvent<Pod>,
        config: Configuration,
    ) -> Result<(), failure::Error> {
        // TODO: Is there value in keeping one client and cloning it?
        let client = APIClient::new(config);
        //let provider = self.provider.clone(); // Arc +1
        match event {
            WatchEvent::Added(p) => {
                // Step 1: Is this legit?
                // Step 2: Can the provider handle this?
                if !self.can_schedule(&p) {
                    debug!(
                        "Provider cannot schedule {}",
                        p.metadata.unwrap_or_default().name.unwrap_or_default()
                    );
                    return Ok(());
                };
                // Step 3: DO IT!
                self.add(p, client).await
            }
            WatchEvent::Modified(p) => {
                // Step 1: Can the provider handle this? (This should be the faster function,
                // so we can weed out negatives quickly.)
                if !self.can_schedule(&p) {
                    debug!(
                        "Provider cannot schedule {}",
                        p.metadata.unwrap_or_default().name.unwrap_or_default()
                    );
                    return Ok(());
                };
                // Step 2: Is this a real modification, or just status?
                // Step 3: DO IT!
                self.modify(p, client).await
            }
            WatchEvent::Deleted(p) => {
                // Step 1: Can the provider handle this?
                if !self.can_schedule(&p) {
                    debug!(
                        "Provider cannot schedule {}",
                        p.metadata.unwrap_or_default().name.unwrap_or_default()
                    );
                    return Ok(());
                };
                // Step 2: DO IT!
                self.delete(p, client).await
            }
            WatchEvent::Error(e) => {
                error!("Event error: {}", e);
                Err(e.into())
            }
        }
    }
/// Determine what to do when a new event comes in.
///
/// In most cases, this should not be overridden. It is exposed for rare cases when
/// the underlying event handling needs to change.
Determine what to do when a new event comes in.
In most cases, this should not be overridden. It is exposed for rare cases when
the underlying event handling needs to change.
Determine what to do when a new event comes in . In most cases this should not be overridden . It is exposed for rare cases when the underlying event handling needs to change .
async fn handle_event(
        &self,
        event: WatchEvent<Pod>,
        config: Configuration,
    ) -> Result<(), failure::Error> {
        // TODO: Is there value in keeping one client and cloning it?
        let client = APIClient::new(config);
        //let provider = self.provider.clone(); // Arc +1
        match event {
            WatchEvent::Added(p) => {
                // Step 1: Is this legit?
                // Step 2: Can the provider handle this?
                if !self.can_schedule(&p) {
                    debug!(
                        "Provider cannot schedule {}",
                        p.metadata.unwrap_or_default().name.unwrap_or_default()
                    );
                    return Ok(());
                };
                // Step 3: DO IT!
                self.add(p, client).await
            }
            WatchEvent::Modified(p) => {
                // Step 1: Can the provider handle this? (This should be the faster function,
                // so we can weed out negatives quickly.)
                if !self.can_schedule(&p) {
                    debug!(
                        "Provider cannot schedule {}",
                        p.metadata.unwrap_or_default().name.unwrap_or_default()
                    );
                    return Ok(());
                };
                // Step 2: Is this a real modification, or just status?
                // Step 3: DO IT!
                self.modify(p, client).await
            }
            WatchEvent::Deleted(p) => {
                // Step 1: Can the provider handle this?
                if !self.can_schedule(&p) {
                    debug!(
                        "Provider cannot schedule {}",
                        p.metadata.unwrap_or_default().name.unwrap_or_default()
                    );
                    return Ok(());
                };
                // Step 2: DO IT!
                self.delete(p, client).await
            }
            WatchEvent::Error(e) => {
                error!("Event error: {}", e);
                Err(e.into())
            }
        }
    }
async fn handle_event ( & self , event : WatchEvent < Pod > , config : Configuration , ) -> Result < ( ) , failure :: Error > { // TODO: Is there value in keeping one client and cloning it? let client = APIClient :: new ( config ) ; //let provider = self.provider.clone(); // Arc +1 match event { WatchEvent :: Added ( p ) => { // Step 1: Is this legit? // Step 2: Can the provider handle this? if ! self . can_schedule ( & p ) { debug ! ( " " p metadata unwrap_or_default ( ) name unwrap_or_default ( ) ) ; return Ok ( ( ) ) ; } ; // Step 3: DO IT! self . add ( p , client ) . await } WatchEvent :: Modified ( p ) => { // Step 1: Can the provider handle this? (This should be the faster function, // so we can weed out negatives quickly.) if ! self . can_schedule ( & p ) { debug ! ( " " p metadata unwrap_or_default ( ) name unwrap_or_default ( ) ) ; return Ok ( ( ) ) ; } ; // Step 2: Is this a real modification, or just status? // Step 3: DO IT! self . modify ( p , client ) . await } WatchEvent :: Deleted ( p ) => { // Step 1: Can the provider handle this? if ! self . can_schedule ( & p ) { debug ! ( " " p metadata unwrap_or_default ( ) name unwrap_or_default ( ) ) ; return Ok ( ( ) ) ; } ; // Step 2: DO IT! self . delete ( p , client ) . await } WatchEvent :: Error ( e ) => { error ! ( " " e ) ; Err ( e . into ( ) ) } } }
Determine what to do when a new event comes in.
Determine what to do when a new event comes in .
&self
event
WatchEvent<Pod>
config
Configuration
&self
event
WatchEvent<Pod>
config
Configuration