watcher.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. // Package container defines types for sub-container events and also
  15. // defines an interface for container operation handlers.
  16. package watcher
  17. // SubcontainerEventType indicates an addition or deletion event.
  18. type ContainerEventType int
  19. const (
  20. ContainerAdd ContainerEventType = iota
  21. ContainerDelete
  22. )
  23. type ContainerWatchSource int
  24. const (
  25. Raw ContainerWatchSource = iota
  26. Rkt
  27. )
  28. // ContainerEvent represents a
  29. type ContainerEvent struct {
  30. // The type of event that occurred.
  31. EventType ContainerEventType
  32. // The full container name of the container where the event occurred.
  33. Name string
  34. // The watcher that detected this change event
  35. WatchSource ContainerWatchSource
  36. }
  37. type ContainerWatcher interface {
  38. // Registers a channel to listen for events affecting subcontainers (recursively).
  39. Start(events chan ContainerEvent) error
  40. // Stops watching for subcontainer changes.
  41. Stop() error
  42. }