github.com/google/cadvisor@v0.49.1/watcher/watcher.go (about) 1 // Copyright 2016 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package container defines types for sub-container events and also 16 // defines an interface for container operation handlers. 17 package watcher 18 19 // SubcontainerEventType indicates an addition or deletion event. 20 type ContainerEventType int 21 22 const ( 23 ContainerAdd ContainerEventType = iota 24 ContainerDelete 25 ) 26 27 type ContainerWatchSource int 28 29 const ( 30 Raw ContainerWatchSource = iota 31 ) 32 33 // ContainerEvent represents a 34 type ContainerEvent struct { 35 // The type of event that occurred. 36 EventType ContainerEventType 37 38 // The full container name of the container where the event occurred. 39 Name string 40 41 // The watcher that detected this change event 42 WatchSource ContainerWatchSource 43 } 44 45 type ContainerWatcher interface { 46 // Registers a channel to listen for events affecting subcontainers (recursively). 47 Start(events chan ContainerEvent) error 48 49 // Stops watching for subcontainer changes. 50 Stop() error 51 }