types.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package libcontainerd
  2. import "io"
  3. // State constants used in state change reporting.
  4. const (
  5. StateStart = "start-container"
  6. StatePause = "pause"
  7. StateResume = "resume"
  8. StateExit = "exit"
  9. StateRestart = "restart"
  10. StateRestore = "restore"
  11. StateStartProcess = "start-process"
  12. StateExitProcess = "exit-process"
  13. StateOOM = "oom" // fake state
  14. stateLive = "live"
  15. )
  16. // CommonStateInfo contains the state info common to all platforms.
  17. type CommonStateInfo struct { // FIXME: event?
  18. State string
  19. Pid uint32
  20. ExitCode uint32
  21. ProcessID string
  22. }
  23. // Backend defines callbacks that the client of the library needs to implement.
  24. type Backend interface {
  25. StateChanged(containerID string, state StateInfo) error
  26. AttachStreams(processFriendlyName string, io IOPipe) error
  27. }
  28. // Client provides access to containerd features.
  29. type Client interface {
  30. Create(containerID string, spec Spec, options ...CreateOption) error
  31. Signal(containerID string, sig int) error
  32. SignalProcess(containerID string, processFriendlyName string, sig int) error
  33. AddProcess(containerID, processFriendlyName string, process Process) error
  34. Resize(containerID, processFriendlyName string, width, height int) error
  35. Pause(containerID string) error
  36. Resume(containerID string) error
  37. Restore(containerID string, options ...CreateOption) error
  38. Stats(containerID string) (*Stats, error)
  39. GetPidsForContainer(containerID string) ([]int, error)
  40. Summary(containerID string) ([]Summary, error)
  41. UpdateResources(containerID string, resources Resources) error
  42. }
  43. // CreateOption allows to configure parameters of container creation.
  44. type CreateOption interface {
  45. Apply(interface{}) error
  46. }
  47. // IOPipe contains the stdio streams.
  48. type IOPipe struct {
  49. Stdin io.WriteCloser
  50. Stdout io.Reader
  51. Stderr io.Reader
  52. Terminal bool // Whether stderr is connected on Windows
  53. }