summaryrefslogtreecommitdiff
path: root/cluster.go
diff options
context:
space:
mode:
Diffstat (limited to 'cluster.go')
-rw-r--r--cluster.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/cluster.go b/cluster.go
index 97da63a..a2c2391 100644
--- a/cluster.go
+++ b/cluster.go
@@ -17,3 +17,20 @@ type Cluster struct {
Unstable *timestamppb.Timestamp
UnstableTimeout *durationpb.Duration
}
+
+// adds a new droplet. enforce unique hostnames
+func (c *Cluster) AddDroplet(newd *Droplet) bool {
+ c.Lock()
+ defer c.Unlock()
+
+ for _, d := range c.d.Droplets {
+ if newd.Hostname == d.Hostname {
+ // boo. that one is already here
+ return false
+ }
+ }
+
+ // everything is ok, this hostname is new
+ c.d.Droplets = append(c.d.Droplets, newd)
+ return true
+}