From 9c4985368aee638d982f30ea7bc5c7ee71ae3ab3 Mon Sep 17 00:00:00 2001 From: Jeroen Wijenbergh Date: Tue, 6 May 2025 12:35:21 +0200 Subject: All: Fix staticcheck errors --- internal/discovery/manager.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'internal/discovery/manager.go') diff --git a/internal/discovery/manager.go b/internal/discovery/manager.go index e71f13a..6a78486 100644 --- a/internal/discovery/manager.go +++ b/internal/discovery/manager.go @@ -7,6 +7,8 @@ import ( "codeberg.org/eduVPN/eduvpn-common/internal/log" ) +// Manager is the discovery struct that is cached +// with some bookkeeping to avoid race conditions type Manager struct { disco *Discovery @@ -15,6 +17,7 @@ type Manager struct { wait sync.WaitGroup } +// NewManager creates a new Discovery manager func NewManager(disco *Discovery) *Manager { return &Manager{disco: disco} } @@ -35,6 +38,8 @@ func (m *Manager) unlock(write bool) { m.mu.RUnlock() } +// Discovery gets the cached discovery +// `write` is true if discovery will be written to func (m *Manager) Discovery(write bool) (*Discovery, func()) { if write { m.wait.Wait() @@ -45,6 +50,7 @@ func (m *Manager) Discovery(write bool) (*Discovery, func()) { } } +// Cancel aborts the running discovery startup process func (m *Manager) Cancel() { if m.cancel != nil { m.cancel() @@ -52,6 +58,8 @@ func (m *Manager) Cancel() { m.wait.Wait() } +// Startup handles the discovery process in the background +// It's called Startup because it's called when the lib is initialised func (m *Manager) Startup(ctx context.Context, cb func()) { ctx, cancel := context.WithCancel(ctx) m.cancel = cancel -- cgit v1.2.3