From f29d8edb89e3f05e0bd9c3b0eccc0587882a3ed3 Mon Sep 17 00:00:00 2001 From: Stanislav Chzhen Date: Mon, 14 Oct 2024 15:03:08 +0300 Subject: [PATCH] client: imp docs --- internal/client/storage.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/client/storage.go b/internal/client/storage.go index d20a47dc..c3820cd8 100644 --- a/internal/client/storage.go +++ b/internal/client/storage.go @@ -85,7 +85,8 @@ type HostsContainer interface { // StorageConfig is the client storage configuration structure. type StorageConfig struct { - // Logger is used for logging the operation of the client storage. + // Logger is used for logging the operation of the client storage. It must + // not be nil. Logger *slog.Logger // DHCP is used to match IPs against MACs of persistent clients and update @@ -113,7 +114,8 @@ type StorageConfig struct { // Storage contains information about persistent and runtime clients. type Storage struct { - // logger is used for logging the operation of the client storage. + // logger is used for logging the operation of the client storage. It must + // not be nil. logger *slog.Logger // mu protects indexes of persistent and runtime clients. @@ -205,7 +207,7 @@ func (s *Storage) Shutdown(_ context.Context) (err error) { // periodicARPUpdate periodically reloads runtime clients from ARP. It is // intended to be used as a goroutine. func (s *Storage) periodicARPUpdate(ctx context.Context) { - slogutil.RecoverAndLog(ctx, s.logger) + defer slogutil.RecoverAndLog(ctx, s.logger) t := time.NewTicker(s.arpClientsUpdatePeriod) @@ -270,7 +272,7 @@ func (s *Storage) handleHostsUpdates(ctx context.Context) { return } - slogutil.RecoverAndLog(ctx, s.logger) + defer slogutil.RecoverAndLog(ctx, s.logger) for { select {