github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/api/types/swarm/service.go (about)

     1  package swarm
     2  
     3  import "time"
     4  
     5  // Service represents a service.
     6  type Service struct {
     7  	ID string
     8  	Meta
     9  	Spec         ServiceSpec  `json:",omitempty"`
    10  	Endpoint     Endpoint     `json:",omitempty"`
    11  	UpdateStatus UpdateStatus `json:",omitempty"`
    12  }
    13  
    14  // ServiceSpec represents the spec of a service.
    15  type ServiceSpec struct {
    16  	Annotations
    17  
    18  	// TaskTemplate defines how the service should construct new tasks when
    19  	// orchestrating this service.
    20  	TaskTemplate TaskSpec      `json:",omitempty"`
    21  	Mode         ServiceMode   `json:",omitempty"`
    22  	UpdateConfig *UpdateConfig `json:",omitempty"`
    23  
    24  	// Networks field in ServiceSpec is deprecated. The
    25  	// same field in TaskSpec should be used instead.
    26  	// This field will be removed in a future release.
    27  	Networks     []NetworkAttachmentConfig `json:",omitempty"`
    28  	EndpointSpec *EndpointSpec             `json:",omitempty"`
    29  }
    30  
    31  // ServiceMode represents the mode of a service.
    32  type ServiceMode struct {
    33  	Replicated *ReplicatedService `json:",omitempty"`
    34  	Global     *GlobalService     `json:",omitempty"`
    35  }
    36  
    37  // UpdateState is the state of a service update.
    38  type UpdateState string
    39  
    40  const (
    41  	// UpdateStateUpdating is the updating state.
    42  	UpdateStateUpdating UpdateState = "updating"
    43  	// UpdateStatePaused is the paused state.
    44  	UpdateStatePaused UpdateState = "paused"
    45  	// UpdateStateCompleted is the completed state.
    46  	UpdateStateCompleted UpdateState = "completed"
    47  )
    48  
    49  // UpdateStatus reports the status of a service update.
    50  type UpdateStatus struct {
    51  	State       UpdateState `json:",omitempty"`
    52  	StartedAt   time.Time   `json:",omitempty"`
    53  	CompletedAt time.Time   `json:",omitempty"`
    54  	Message     string      `json:",omitempty"`
    55  }
    56  
    57  // ReplicatedService is a kind of ServiceMode.
    58  type ReplicatedService struct {
    59  	Replicas *uint64 `json:",omitempty"`
    60  }
    61  
    62  // GlobalService is a kind of ServiceMode.
    63  type GlobalService struct{}
    64  
    65  const (
    66  	// UpdateFailureActionPause PAUSE
    67  	UpdateFailureActionPause = "pause"
    68  	// UpdateFailureActionContinue CONTINUE
    69  	UpdateFailureActionContinue = "continue"
    70  )
    71  
    72  // UpdateConfig represents the update configuration.
    73  type UpdateConfig struct {
    74  	Parallelism   uint64        `json:",omitempty"`
    75  	Delay         time.Duration `json:",omitempty"`
    76  	FailureAction string        `json:",omitempty"`
    77  }