types.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. AddProcess(containerID, processFriendlyName string, process Process) error
  33. Resize(containerID, processFriendlyName string, width, height int) error
  34. Pause(containerID string) error
  35. Resume(containerID string) error
  36. Restore(containerID string, options ...CreateOption) error
  37. Stats(containerID string) (*Stats, error)
  38. GetPidsForContainer(containerID string) ([]int, error)
  39. Summary(containerID string) ([]Summary, error)
  40. UpdateResources(containerID string, resources Resources) error
  41. }
  42. // CreateOption allows to configure parameters of container creation.
  43. type CreateOption interface {
  44. Apply(interface{}) error
  45. }
  46. // IOPipe contains the stdio streams.
  47. type IOPipe struct {
  48. Stdin io.WriteCloser
  49. Stdout io.Reader
  50. Stderr io.Reader
  51. Terminal bool // Whether stderr is connected on Windows
  52. }