summaryrefslogtreecommitdiff
path: root/pkg/backend/gatewaychecker.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/backend/gatewaychecker.go')
-rw-r--r--pkg/backend/gatewaychecker.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/backend/gatewaychecker.go b/pkg/backend/gatewaychecker.go
new file mode 100644
index 0000000..f10e47e
--- /dev/null
+++ b/pkg/backend/gatewaychecker.go
@@ -0,0 +1,32 @@
+package backend
+
+import (
+ "time"
+)
+
+// The gateway selector gets populated asynchronously, so this spawns a goroutine that
+// checks whether they've been fetched to update status.
+func (c connectionCtx) delayCheckForGateways() {
+ go func() {
+ cnt := 0
+ for {
+ if cnt > 60*2 {
+ break
+ }
+ time.Sleep(time.Second * 5)
+ transport := c.bm.GetTransport()
+ locs := c.bm.ListLocationFullness(transport)
+ if len(locs) != 0 {
+ c.Locations = locs
+ updateStatusForGateways()
+ break
+ }
+ }
+ }()
+}
+
+func updateStatusForGateways() {
+ statusMutex.Lock()
+ defer statusMutex.Unlock()
+ go trigger(OnStatusChanged)
+}