feat: make table.Watch() func blocking
This commit is contained in:
parent
1cc263ca8b
commit
34fa420040
11
arp/table.go
11
arp/table.go
|
@ -55,17 +55,18 @@ func (t *Table) Watch(ctx context.Context, config WatchConfig) error {
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
if err := h.ListenAndServe(ctx); err != nil {
|
defer cancel()
|
||||||
panic(errors.WithStack(err))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
notifications := make(chan arp.MACEntry)
|
notifications := make(chan arp.MACEntry)
|
||||||
h.AddNotificationChannel(notifications)
|
h.AddNotificationChannel(notifications)
|
||||||
|
|
||||||
go t.handleNotifications(ctx, notifications)
|
go t.handleNotifications(ctx, notifications)
|
||||||
|
|
||||||
|
if err := h.ListenAndServe(ctx); err != nil {
|
||||||
|
return errors.WithStack(err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue