TUN-6301: Allow to update logger used by UDP session manager
This commit is contained in:
parent
baed5f4eea
commit
b8ba5b444c
|
@ -29,6 +29,8 @@ type Manager interface {
|
||||||
RegisterSession(ctx context.Context, sessionID uuid.UUID, dstConn io.ReadWriteCloser) (*Session, error)
|
RegisterSession(ctx context.Context, sessionID uuid.UUID, dstConn io.ReadWriteCloser) (*Session, error)
|
||||||
// UnregisterSession stops tracking the session and terminates it
|
// UnregisterSession stops tracking the session and terminates it
|
||||||
UnregisterSession(ctx context.Context, sessionID uuid.UUID, message string, byRemote bool) error
|
UnregisterSession(ctx context.Context, sessionID uuid.UUID, message string, byRemote bool) error
|
||||||
|
// UpdateLogger updates the logger used by the Manager
|
||||||
|
UpdateLogger(log *zerolog.Logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
type manager struct {
|
type manager struct {
|
||||||
|
@ -57,6 +59,11 @@ func NewManager(transport transport, log *zerolog.Logger) *manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *manager) UpdateLogger(log *zerolog.Logger) {
|
||||||
|
// Benign data race, no problem if the old pointer is read or not concurrently.
|
||||||
|
m.log = log
|
||||||
|
}
|
||||||
|
|
||||||
func (m *manager) Serve(ctx context.Context) error {
|
func (m *manager) Serve(ctx context.Context) error {
|
||||||
errGroup, ctx := errgroup.WithContext(ctx)
|
errGroup, ctx := errgroup.WithContext(ctx)
|
||||||
errGroup.Go(func() error {
|
errGroup.Go(func() error {
|
||||||
|
|
Loading…
Reference in New Issue