mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-27 20:08:40 +00:00
control/controlclient: introduce eventbus messages instead of callbacks (#16956)
This is a small introduction of the eventbus into controlclient that communicates with mainly ipnlocal. While ipnlocal is a complicated part of the codebase, the subscribers here are from the perspective of ipnlocal already called async. Updates #15160 Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
12
tsd/tsd.go
12
tsd/tsd.go
@@ -80,9 +80,17 @@ type System struct {
|
||||
|
||||
// NewSystem constructs a new otherwise-empty [System] with a
|
||||
// freshly-constructed event bus populated.
|
||||
func NewSystem() *System {
|
||||
func NewSystem() *System { return NewSystemWithBus(eventbus.New()) }
|
||||
|
||||
// NewSystemWithBus constructs a new otherwise-empty [System] with an
|
||||
// eventbus provided by the caller. The provided bus must not be nil.
|
||||
// This is mainly intended for testing; for production use call [NewBus].
|
||||
func NewSystemWithBus(bus *eventbus.Bus) *System {
|
||||
if bus == nil {
|
||||
panic("nil eventbus")
|
||||
}
|
||||
sys := new(System)
|
||||
sys.Set(eventbus.New())
|
||||
sys.Set(bus)
|
||||
return sys
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user