Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. package cell
  2.  
  3. import "io"
  4.  
  5. type Client interface {
  6. Query(QueryRequest) (QueryResponse, error)
  7. Allocate(AllocationRequest) (AllocationResponse, error)
  8. Run(RunRequest) (RunResponse, error)
  9. Stop(StopRequest) (StopResponse, error)
  10. Delete(DeleteRequest) (DeleteResponse, error)
  11. Events(EventRequest) (EventStream, error)
  12. File(FileRequest) (io.ReadCloser, error)
  13. }
  14.  
  15. type EventStream interface {
  16. Next() (Event, error)
  17. Close() error
  18. }
  19.  
  20. type AllocationCommand struct {
  21. Guid string
  22. Resources ContainerResources
  23. Tags Tags
  24. }
  25.  
  26. type AllocationRequest struct {
  27. Allocate []AllocationCommand
  28. }
  29.  
  30. type AllocationResponse struct {
  31. AllocationFailures []CommandFailure
  32. }
  33.  
  34. type CellInfo struct {
  35. Guid string
  36. Zone string
  37. State CellState
  38. Resources CellResources
  39. }
  40.  
  41. type CellResources struct {
  42. AvailableMemoryMB int
  43. MaxMemoryMB int
  44. AvailableDiskMB int
  45. MaxDiskMB int
  46. AvailableContainers int
  47. MaxContainers int
  48. VolumeDrivers []string
  49. RootFS []string
  50. }
  51.  
  52. type CellState string
  53.  
  54. const (
  55. CellStateStarting CellState = "starting"
  56. CellStateRunning CellState = "running"
  57. CellStateEvacuating CellState = "evacuating"
  58. )
  59.  
  60. type CommandFailure struct {
  61. ContainerGuid string
  62. Error string
  63. }
  64.  
  65. type ContainerInfo struct {
  66. Guid string
  67. State ContainerState
  68. Resources ContainerResources
  69. ExternalIP string
  70. Stopped bool
  71. Failed bool
  72. FailureReason string
  73. Tags Tags
  74. }
  75.  
  76. type ContainerResources struct {
  77. MemoryLimitMB int
  78. DiskLimitMB int
  79. RootFS string
  80. VolumeDrivers []string
  81. }
  82.  
  83. type ContainerState string
  84.  
  85. const (
  86. ContainerStateReserved ContainerState = "reserved"
  87. ContainerStateInitializing ContainerState = "initializing"
  88. ContainerStateCreated ContainerState = "created"
  89. ContainerStateRunning ContainerState = "running"
  90. ContainerStateCompleted ContainerState = "completed"
  91. )
  92.  
  93. type DeleteRequest struct {
  94. Delete []DeleteCommand
  95. }
  96.  
  97. type DeleteCommand struct {
  98. Guid string
  99. }
  100.  
  101. type DeleteResponse struct {
  102. DeletionFailures []CommandFailure
  103. }
  104.  
  105. type EventRequest struct {
  106. ContainerInfo bool
  107. ContainerTags []string
  108. }
  109.  
  110. type Event struct {
  111. Guid string
  112. State ContainerState
  113. }
  114.  
  115. type FileRequest struct {
  116. Guid string
  117. Path string
  118. }
  119.  
  120. type QueryRequest struct {
  121. CellInfo bool
  122. Containers bool
  123. ContainerGuids []string
  124. ContainerTags []string
  125. }
  126.  
  127. type QueryResponse struct {
  128. CellInfo CellInfo
  129. Containers []ContainerInfo
  130. }
  131.  
  132. type RunRequest struct {
  133. Run []RunCommand
  134. }
  135.  
  136. type RunResponse struct {
  137. RunFailures []CommandFailure
  138. }
  139.  
  140. type StopRequest struct {
  141. Stop []StopCommand
  142. }
  143.  
  144. type StopCommand struct {
  145. Guid string
  146. }
  147.  
  148. type StopResponse struct {
  149. StopFailures []CommandFailure
  150. }
  151.  
  152. type Tags map[string]string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement