Browse code

add swarm type comments and fix nits

Signed-off-by: allencloud <allen.sun@daocloud.io>

allencloud authored on 2016/09/25 00:17:18
Showing 6 changed files
... ...
@@ -84,7 +84,7 @@ type CopyToContainerOptions struct {
84 84
 	AllowOverwriteDirWithFile bool
85 85
 }
86 86
 
87
-// EventsOptions hold parameters to filter events with.
87
+// EventsOptions holds parameters to filter events with.
88 88
 type EventsOptions struct {
89 89
 	Since   string
90 90
 	Until   string
... ...
@@ -9,7 +9,7 @@ func (i Isolation) IsValid() bool {
9 9
 	return i.IsDefault()
10 10
 }
11 11
 
12
-// IsPrivate indicates whether container uses it's private network stack.
12
+// IsPrivate indicates whether container uses its private network stack.
13 13
 func (n NetworkMode) IsPrivate() bool {
14 14
 	return !(n.IsHost() || n.IsContainer())
15 15
 }
... ...
@@ -2,12 +2,12 @@ package swarm
2 2
 
3 3
 import "time"
4 4
 
5
-// Version represent the internal object version.
5
+// Version represents the internal object version.
6 6
 type Version struct {
7 7
 	Index uint64 `json:",omitempty"`
8 8
 }
9 9
 
10
-// Meta is  base object inherited by most of the other once.
10
+// Meta is a base object inherited by most of the other once.
11 11
 type Meta struct {
12 12
 	Version   Version   `json:",omitempty"`
13 13
 	CreatedAt time.Time `json:",omitempty"`
... ...
@@ -4,11 +4,17 @@ package swarm
4 4
 type Node struct {
5 5
 	ID string
6 6
 	Meta
7
-
8
-	Spec          NodeSpec        `json:",omitempty"`
9
-	Description   NodeDescription `json:",omitempty"`
10
-	Status        NodeStatus      `json:",omitempty"`
11
-	ManagerStatus *ManagerStatus  `json:",omitempty"`
7
+	// Spec defines the desired state of the node as specified by the user.
8
+	// The system will honor this and will *never* modify it.
9
+	Spec NodeSpec `json:",omitempty"`
10
+	// Description encapsulates the properties of the Node as reported by the
11
+	// agent.
12
+	Description NodeDescription `json:",omitempty"`
13
+	// Status provides the current status of the node, as seen by the manager.
14
+	Status NodeStatus `json:",omitempty"`
15
+	// ManagerStatus provides the current status of the node's manager
16
+	// component, if the node is a manager.
17
+	ManagerStatus *ManagerStatus `json:",omitempty"`
12 18
 }
13 19
 
14 20
 // NodeSpec represents the spec of a node.
... ...
@@ -18,7 +18,9 @@ type Swarm struct {
18 18
 
19 19
 // JoinTokens contains the tokens workers and managers need to join the swarm.
20 20
 type JoinTokens struct {
21
-	Worker  string
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.
22 24
 	Manager string
23 25
 }
24 26
 
... ...
@@ -35,6 +37,8 @@ type Spec struct {
35 35
 
36 36
 // OrchestrationConfig represents orchestration configuration.
37 37
 type OrchestrationConfig struct {
38
+	// TaskHistoryRetentionLimit is the number of historic tasks to keep per instance or
39
+	// node. If negative, never remove completed or failed tasks.
38 40
 	TaskHistoryRetentionLimit int64 `json:",omitempty"`
39 41
 }
40 42
 
... ...
@@ -51,8 +55,15 @@ type TaskDefaults struct {
51 51
 
52 52
 // RaftConfig represents raft configuration.
53 53
 type RaftConfig struct {
54
-	SnapshotInterval           uint64 `json:",omitempty"`
55
-	KeepOldSnapshots           uint64 `json:",omitempty"`
54
+	// SnapshotInterval is the number of log entries between snapshots.
55
+	SnapshotInterval uint64 `json:",omitempty"`
56
+
57
+	// KeepOldSnapshots is the number of snapshots to keep beyond the
58
+	// current snapshot.
59
+	KeepOldSnapshots uint64 `json:",omitempty"`
60
+
61
+	// LogEntriesForSlowFollowers is the number of log entries to keep
62
+	// around to sync up slow followers after a snapshot is created.
56 63
 	LogEntriesForSlowFollowers uint64 `json:",omitempty"`
57 64
 
58 65
 	// ElectionTick is the number of ticks that a follower will wait for a message
... ...
@@ -74,13 +85,19 @@ type RaftConfig struct {
74 74
 
75 75
 // DispatcherConfig represents dispatcher configuration.
76 76
 type DispatcherConfig struct {
77
+	// HeartbeatPeriod defines how often agent should send heartbeats to
78
+	// dispatcher.
77 79
 	HeartbeatPeriod time.Duration `json:",omitempty"`
78 80
 }
79 81
 
80 82
 // CAConfig represents CA configuration.
81 83
 type CAConfig struct {
84
+	// NodeCertExpiry is the duration certificates should be issued for
82 85
 	NodeCertExpiry time.Duration `json:",omitempty"`
83
-	ExternalCAs    []*ExternalCA `json:",omitempty"`
86
+
87
+	// ExternalCAs is a list of CAs to which a manager node will make
88
+	// certificate signing requests for node certificates.
89
+	ExternalCAs []*ExternalCA `json:",omitempty"`
84 90
 }
85 91
 
86 92
 // ExternalCAProtocol represents type of external CA.
... ...
@@ -91,9 +108,15 @@ const ExternalCAProtocolCFSSL ExternalCAProtocol = "cfssl"
91 91
 
92 92
 // ExternalCA defines external CA to be used by the cluster.
93 93
 type ExternalCA struct {
94
+	// Protocol is the protocol used by this external CA.
94 95
 	Protocol ExternalCAProtocol
95
-	URL      string
96
-	Options  map[string]string `json:",omitempty"`
96
+
97
+	// URL is the URL where the external CA can be reached.
98
+	URL string
99
+
100
+	// Options is a set of additional key/value pairs whose interpretation
101
+	// depends on the specified CA type.
102
+	Options map[string]string `json:",omitempty"`
97 103
 }
98 104
 
99 105
 // InitRequest is the request used to init a swarm.
... ...
@@ -183,7 +183,7 @@ type ContainerPathStat struct {
183 183
 	LinkTarget string      `json:"linkTarget"`
184 184
 }
185 185
 
186
-// ContainerStats contains resonse of Remote API:
186
+// ContainerStats contains response of Remote API:
187 187
 // GET "/stats"
188 188
 type ContainerStats struct {
189 189
 	Body   io.ReadCloser `json:"body"`
... ...
@@ -446,7 +446,7 @@ type VolumesListResponse struct {
446 446
 	Warnings []string  // Warnings is a list of warnings that occurred when getting the list from the volume drivers
447 447
 }
448 448
 
449
-// VolumeCreateRequest contains the response for the remote API:
449
+// VolumeCreateRequest contains the request for the remote API:
450 450
 // POST "/volumes/create"
451 451
 type VolumeCreateRequest struct {
452 452
 	Name       string            // Name is the requested name of the volume