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

     1  package swarm
     2  
     3  import "time"
     4  
     5  // ClusterInfo represents info about the cluster for outputing in "info"
     6  // it contains the same information as "Swarm", but without the JoinTokens
     7  type ClusterInfo struct {
     8  	ID string
     9  	Meta
    10  	Spec Spec
    11  }
    12  
    13  // Swarm represents a swarm.
    14  type Swarm struct {
    15  	ClusterInfo
    16  	JoinTokens JoinTokens
    17  }
    18  
    19  // JoinTokens contains the tokens workers and managers need to join the swarm.
    20  type JoinTokens struct {
    21  	// Worker is the join token workers may use to join the swarm.
    22  	Worker string
    23  	// Manager is the join token managers may use to join the swarm.
    24  	Manager string
    25  }
    26  
    27  // Spec represents the spec of a swarm.
    28  type Spec struct {
    29  	Annotations
    30  
    31  	Orchestration OrchestrationConfig `json:",omitempty"`
    32  	Raft          RaftConfig          `json:",omitempty"`
    33  	Dispatcher    DispatcherConfig    `json:",omitempty"`
    34  	CAConfig      CAConfig            `json:",omitempty"`
    35  	TaskDefaults  TaskDefaults        `json:",omitempty"`
    36  }
    37  
    38  // OrchestrationConfig represents orchestration configuration.
    39  type OrchestrationConfig struct {
    40  	// TaskHistoryRetentionLimit is the number of historic tasks to keep per instance or
    41  	// node. If negative, never remove completed or failed tasks.
    42  	TaskHistoryRetentionLimit *int64 `json:",omitempty"`
    43  }
    44  
    45  // TaskDefaults parameterizes cluster-level task creation with default values.
    46  type TaskDefaults struct {
    47  	// LogDriver selects the log driver to use for tasks created in the
    48  	// orchestrator if unspecified by a service.
    49  	//
    50  	// Updating this value will only have an affect on new tasks. Old tasks
    51  	// will continue use their previously configured log driver until
    52  	// recreated.
    53  	LogDriver *Driver `json:",omitempty"`
    54  }
    55  
    56  // RaftConfig represents raft configuration.
    57  type RaftConfig struct {
    58  	// SnapshotInterval is the number of log entries between snapshots.
    59  	SnapshotInterval uint64 `json:",omitempty"`
    60  
    61  	// KeepOldSnapshots is the number of snapshots to keep beyond the
    62  	// current snapshot.
    63  	KeepOldSnapshots uint64 `json:",omitempty"`
    64  
    65  	// LogEntriesForSlowFollowers is the number of log entries to keep
    66  	// around to sync up slow followers after a snapshot is created.
    67  	LogEntriesForSlowFollowers uint64 `json:",omitempty"`
    68  
    69  	// ElectionTick is the number of ticks that a follower will wait for a message
    70  	// from the leader before becoming a candidate and starting an election.
    71  	// ElectionTick must be greater than HeartbeatTick.
    72  	//
    73  	// A tick currently defaults to one second, so these translate directly to
    74  	// seconds currently, but this is NOT guaranteed.
    75  	ElectionTick int
    76  
    77  	// HeartbeatTick is the number of ticks between heartbeats. Every
    78  	// HeartbeatTick ticks, the leader will send a heartbeat to the
    79  	// followers.
    80  	//
    81  	// A tick currently defaults to one second, so these translate directly to
    82  	// seconds currently, but this is NOT guaranteed.
    83  	HeartbeatTick int
    84  }
    85  
    86  // DispatcherConfig represents dispatcher configuration.
    87  type DispatcherConfig struct {
    88  	// HeartbeatPeriod defines how often agent should send heartbeats to
    89  	// dispatcher.
    90  	HeartbeatPeriod time.Duration `json:",omitempty"`
    91  }
    92  
    93  // CAConfig represents CA configuration.
    94  type CAConfig struct {
    95  	// NodeCertExpiry is the duration certificates should be issued for
    96  	NodeCertExpiry time.Duration `json:",omitempty"`
    97  
    98  	// ExternalCAs is a list of CAs to which a manager node will make
    99  	// certificate signing requests for node certificates.
   100  	ExternalCAs []*ExternalCA `json:",omitempty"`
   101  }
   102  
   103  // ExternalCAProtocol represents type of external CA.
   104  type ExternalCAProtocol string
   105  
   106  // ExternalCAProtocolCFSSL CFSSL
   107  const ExternalCAProtocolCFSSL ExternalCAProtocol = "cfssl"
   108  
   109  // ExternalCA defines external CA to be used by the cluster.
   110  type ExternalCA struct {
   111  	// Protocol is the protocol used by this external CA.
   112  	Protocol ExternalCAProtocol
   113  
   114  	// URL is the URL where the external CA can be reached.
   115  	URL string
   116  
   117  	// Options is a set of additional key/value pairs whose interpretation
   118  	// depends on the specified CA type.
   119  	Options map[string]string `json:",omitempty"`
   120  }
   121  
   122  // InitRequest is the request used to init a swarm.
   123  type InitRequest struct {
   124  	ListenAddr      string
   125  	AdvertiseAddr   string
   126  	ForceNewCluster bool
   127  	Spec            Spec
   128  }
   129  
   130  // JoinRequest is the request used to join a swarm.
   131  type JoinRequest struct {
   132  	ListenAddr    string
   133  	AdvertiseAddr string
   134  	RemoteAddrs   []string
   135  	JoinToken     string // accept by secret
   136  }
   137  
   138  // LocalNodeState represents the state of the local node.
   139  type LocalNodeState string
   140  
   141  const (
   142  	// LocalNodeStateInactive INACTIVE
   143  	LocalNodeStateInactive LocalNodeState = "inactive"
   144  	// LocalNodeStatePending PENDING
   145  	LocalNodeStatePending LocalNodeState = "pending"
   146  	// LocalNodeStateActive ACTIVE
   147  	LocalNodeStateActive LocalNodeState = "active"
   148  	// LocalNodeStateError ERROR
   149  	LocalNodeStateError LocalNodeState = "error"
   150  )
   151  
   152  // Info represents generic information about swarm.
   153  type Info struct {
   154  	NodeID   string
   155  	NodeAddr string
   156  
   157  	LocalNodeState   LocalNodeState
   158  	ControlAvailable bool
   159  	Error            string
   160  
   161  	RemoteManagers []Peer
   162  	Nodes          int
   163  	Managers       int
   164  
   165  	Cluster ClusterInfo
   166  }
   167  
   168  // Peer represents a peer.
   169  type Peer struct {
   170  	NodeID string
   171  	Addr   string
   172  }
   173  
   174  // UpdateFlags contains flags for SwarmUpdate.
   175  type UpdateFlags struct {
   176  	RotateWorkerToken  bool
   177  	RotateManagerToken bool
   178  }