func (pl *ProfileLoader) listen() {
	pl.wg.Add(1)
	var event model.ProbeEvent
	var ok bool
	for {
		select {
		case <-pl.stop:
			pl.wg.Done()
			return
		case event, ok = <-pl.EventChan:
			if !ok {
				pl.wg.Done()
				return
			}
			switch event.GetEventType() {
			case model.ContainerRunningEventType:
				if err := pl.handleContainerRunning(event.(*model.ContainerEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			case model.ContainerExitedEventType:
				if err := pl.handleContainerExited(event.(*model.ContainerEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			case model.SecurityProfileUpdatedType:
				if err := pl.handleSecurityProfileUpdate(event.(*model.SecurityProfileUpdatedEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			case model.SecurityProfileCreatedType:
				if err := pl.handleSecurityProfileCreation(event.(*model.SecurityProfileCreatedEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			case model.SecurityProfileDeletedType:
				if err := pl.handleSecurityProfileDeletion(event.(*model.SecurityProfileDeletedEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			}
		}
	}
}
// listen - Wait for events and print them
Wait for events and print them
// listen - Wait for events and print them
func (pl *ProfileLoader) listen() {
	pl.wg.Add(1)
	var event model.ProbeEvent
	var ok bool
	for {
		select {
		case <-pl.stop:
			pl.wg.Done()
			return
		case event, ok = <-pl.EventChan:
			if !ok {
				pl.wg.Done()
				return
			}
			switch event.GetEventType() {
			case model.ContainerRunningEventType:
				if err := pl.handleContainerRunning(event.(*model.ContainerEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			case model.ContainerExitedEventType:
				if err := pl.handleContainerExited(event.(*model.ContainerEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			case model.SecurityProfileUpdatedType:
				if err := pl.handleSecurityProfileUpdate(event.(*model.SecurityProfileUpdatedEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			case model.SecurityProfileCreatedType:
				if err := pl.handleSecurityProfileCreation(event.(*model.SecurityProfileCreatedEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			case model.SecurityProfileDeletedType:
				if err := pl.handleSecurityProfileDeletion(event.(*model.SecurityProfileDeletedEvent)); err != nil {
					profileLoaderLogger.Warn(err)
				}
				break
			}
		}
	}
}
func ( pl * ProfileLoader ) listen ( ) { pl . wg . Add ( 1 ) var event model . ProbeEvent var ok bool for { select { case <- pl . stop : pl . wg . Done ( ) return case event , ok = <- pl . EventChan : if ! ok { pl . wg . Done ( ) return } switch event . GetEventType ( ) { case model . ContainerRunningEventType : if err := pl . handleContainerRunning ( event . ( * model . ContainerEvent ) ) ; err != nil { profileLoaderLogger . Warn ( err ) } break case model . ContainerExitedEventType : if err := pl . handleContainerExited ( event . ( * model . ContainerEvent ) ) ; err != nil { profileLoaderLogger . Warn ( err ) } break case model . SecurityProfileUpdatedType : if err := pl . handleSecurityProfileUpdate ( event . ( * model . SecurityProfileUpdatedEvent ) ) ; err != nil { profileLoaderLogger . Warn ( err ) } break case model . SecurityProfileCreatedType : if err := pl . handleSecurityProfileCreation ( event . ( * model . SecurityProfileCreatedEvent ) ) ; err != nil { profileLoaderLogger . Warn ( err ) } break case model . SecurityProfileDeletedType : if err := pl . handleSecurityProfileDeletion ( event . ( * model . SecurityProfileDeletedEvent ) ) ; err != nil { profileLoaderLogger . Warn ( err ) } break } } } }
Wait for events and print them
Wait for events and print them