summaryrefslogtreecommitdiff
path: root/oldCluster.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-24 21:54:13 -0500
committerJeff Carr <[email protected]>2025-03-24 21:54:13 -0500
commite4345c8ad6584f4fc5393c7844bb1967d6564d63 (patch)
treeb145c2e11edd3650ea0a3ea1954838ae00b8b818 /oldCluster.go
parent276c5cec2f28ef265a615d31cf27d25e72b29cf8 (diff)
moving to a cluster.proto config filev0.2.33
Diffstat (limited to 'oldCluster.go')
-rw-r--r--oldCluster.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/oldCluster.go b/oldCluster.go
new file mode 100644
index 0000000..c6d6fd9
--- /dev/null
+++ b/oldCluster.go
@@ -0,0 +1,48 @@
+package virtpb
+
+import (
+ sync "sync"
+
+ durationpb "google.golang.org/protobuf/types/known/durationpb"
+ "google.golang.org/protobuf/types/known/timestamppb"
+)
+
+type OldCluster struct {
+ sync.RWMutex
+
+ Dirs []string
+ d *Droplets
+ H *Hypervisors
+ e *Events
+ Unstable *timestamppb.Timestamp
+ UnstableTimeout *durationpb.Duration
+}
+
+func (c *OldCluster) GetDropletsPB() *Droplets {
+ return c.d
+}
+
+func (c *OldCluster) GetHypervisorsPB() *Hypervisors {
+ return c.H
+}
+
+func (c *OldCluster) GetEventsPB() *Events {
+ return c.e
+}
+
+// adds a new droplet. enforce unique hostnames
+func (c *OldCluster) 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
+}