mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-23 03:17:43 +00:00
util/eventbus: track additional event context in publish queue
Updates #15160 Signed-off-by: David Anderson <dave@tailscale.com>
This commit is contained in:

committed by
Dave Anderson

parent
bf40bc4fa0
commit
a1192dd686
@@ -5,8 +5,15 @@ package eventbus
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type publishedEvent struct {
|
||||
Event any
|
||||
From *Client
|
||||
Published time.Time
|
||||
}
|
||||
|
||||
// publisher is a uniformly typed wrapper around Publisher[T], so that
|
||||
// debugging facilities can look at active publishers.
|
||||
type publisher interface {
|
||||
@@ -52,8 +59,14 @@ func (p *Publisher[T]) Publish(v T) {
|
||||
default:
|
||||
}
|
||||
|
||||
evt := publishedEvent{
|
||||
Event: v,
|
||||
From: p.client,
|
||||
Published: time.Now(),
|
||||
}
|
||||
|
||||
select {
|
||||
case p.client.publish() <- v:
|
||||
case p.client.publish() <- evt:
|
||||
case <-p.stop.Done():
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user