diff options
Diffstat (limited to 'cluster.go')
| -rw-r--r-- | cluster.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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 +} |
