github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/types/message.go (about)

     1  package types
     2  
     3  import (
     4  	"bytes"
     5  
     6  	resourcetypes "github.com/projecteru2/core/resource/types"
     7  )
     8  
     9  // RemoveWorkloadMessage for remove message
    10  type RemoveWorkloadMessage struct {
    11  	WorkloadID string
    12  	Success    bool
    13  	Hook       []*bytes.Buffer
    14  }
    15  
    16  // DissociateWorkloadMessage for dissociate workload message
    17  type DissociateWorkloadMessage struct {
    18  	WorkloadID string
    19  	Error      error
    20  }
    21  
    22  // BuildImageMessage for build image ops message
    23  type BuildImageMessage struct {
    24  	ID          string      `json:"id,omitempty"`
    25  	Status      string      `json:"status,omitempty"`
    26  	Progress    string      `json:"progress,omitempty"`
    27  	Error       string      `json:"error,omitempty"`
    28  	Stream      string      `json:"stream,omitempty"`
    29  	ErrorDetail errorDetail `json:"errorDetail,omitempty"`
    30  }
    31  
    32  // CopyMessage for copy message
    33  type CopyMessage struct {
    34  	ID        string `json:"id,omitempty"`
    35  	Path      string `json:"path,omitempty"`
    36  	Error     error  `json:"error,omitempty"`
    37  	LinuxFile `json:"-"`
    38  }
    39  
    40  // SendMessage for send message
    41  type SendMessage struct {
    42  	ID    string `json:"id,omitempty"`
    43  	Path  string `json:"path,omitempty"`
    44  	Error error  `json:"error,omitempty"`
    45  }
    46  
    47  // CacheImageMessage for cache image on pod
    48  type CacheImageMessage struct {
    49  	Image    string
    50  	Success  bool
    51  	Nodename string
    52  	Message  string
    53  }
    54  
    55  // RemoveImageMessage for remove image message
    56  type RemoveImageMessage struct {
    57  	Image    string
    58  	Success  bool
    59  	Messages []string
    60  }
    61  
    62  // Image .
    63  type Image struct {
    64  	ID   string
    65  	Tags []string
    66  }
    67  
    68  // ListImageMessage for list image
    69  type ListImageMessage struct {
    70  	Images   []*Image
    71  	Nodename string
    72  	Error    error
    73  }
    74  
    75  // ControlWorkloadMessage for workload control message
    76  type ControlWorkloadMessage struct {
    77  	WorkloadID string
    78  	Error      error
    79  	Hook       []*bytes.Buffer
    80  }
    81  
    82  // CreateWorkloadMessage for create message
    83  type CreateWorkloadMessage struct {
    84  	EngineParams resourcetypes.Resources
    85  	Resources    resourcetypes.Resources
    86  	Podname      string
    87  	Nodename     string
    88  	WorkloadID   string
    89  	WorkloadName string
    90  	Error        error
    91  	Publish      map[string][]string
    92  	Hook         []*bytes.Buffer
    93  }
    94  
    95  // ReplaceWorkloadMessage for replace method
    96  type ReplaceWorkloadMessage struct {
    97  	Create *CreateWorkloadMessage
    98  	Remove *RemoveWorkloadMessage
    99  	Error  error
   100  }
   101  
   102  // StdStreamType shows stdout / stderr
   103  type StdStreamType int
   104  
   105  const (
   106  	// EruError means this message is carrying some error from eru
   107  	// not from user program
   108  	EruError StdStreamType = -1
   109  	// Stdout means this message is carrying stdout from user program
   110  	Stdout StdStreamType = 0
   111  	// Stderr means this message is carrying stderr from user program
   112  	Stderr StdStreamType = 1
   113  	// TypeWorkloadID means this is the workload id
   114  	TypeWorkloadID StdStreamType = 6
   115  )
   116  
   117  // AttachWorkloadMessage for run and wait
   118  type AttachWorkloadMessage struct {
   119  	WorkloadID string
   120  	Data       []byte
   121  	StdStreamType
   122  }
   123  
   124  // PullImageMessage for cache image
   125  type PullImageMessage struct {
   126  	BuildImageMessage
   127  }
   128  
   129  // ReallocResourceMessage for realloc resource
   130  type ReallocResourceMessage struct {
   131  	WorkloadID string
   132  }
   133  
   134  // StdStreamMessage embodies bytes and std type
   135  type StdStreamMessage struct {
   136  	Data []byte
   137  	StdStreamType
   138  }
   139  
   140  // LogStreamMessage for log stream
   141  type LogStreamMessage struct {
   142  	ID    string
   143  	Error error
   144  	Data  []byte
   145  	StdStreamType
   146  }
   147  
   148  // CapacityMessage for CalculateCapacity API output
   149  type CapacityMessage struct {
   150  	Total          int
   151  	NodeCapacities map[string]int
   152  }
   153  
   154  type errorDetail struct {
   155  	Code    int    `json:"code,omitempty"`
   156  	Message string `json:"message,omitempty"`
   157  }
   158  
   159  type RawEngineMessage struct {
   160  	ID   string `json:"id,omitempty"`
   161  	Data []byte `json:"data,omitempty"`
   162  }