diff --git a/pkg/icingadb/delta_test.go b/pkg/icingadb/delta_test.go index 62de7fc6..6c627caa 100644 --- a/pkg/icingadb/delta_test.go +++ b/pkg/icingadb/delta_test.go @@ -135,11 +135,9 @@ func TestDelta(t *testing.T) { // Log ID mapping to allow easier debugging in case of failures. t.Logf("ID=%d(%s) Test=%s SendOrder=%s", id, testDeltaMakeIdOrChecksum(id).String(), test.Name, sendOrder.Name) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { sendOrder.Send(id, test, chActual, chDesired) - }() + }) if test.Create != 0 { expectedCreate[id] = test.Create diff --git a/pkg/icingadb/history/sla.go b/pkg/icingadb/history/sla.go index 3ed32a22..ef8b5f06 100644 --- a/pkg/icingadb/history/sla.go +++ b/pkg/icingadb/history/sla.go @@ -11,7 +11,7 @@ import ( ) var slaStateStructify = structify.MakeMapStructifier( - reflect.TypeOf((*history.SlaHistoryState)(nil)).Elem(), + reflect.TypeFor[history.SlaHistoryState](), "json", contracts.SafeInit) diff --git a/pkg/icingadb/history/sync.go b/pkg/icingadb/history/sync.go index 6c547815..ba459e91 100644 --- a/pkg/icingadb/history/sync.go +++ b/pkg/icingadb/history/sync.go @@ -331,7 +331,7 @@ func userNotificationStage(ctx context.Context, s Sync, key string, in <-chan re } structifier := structify.MakeMapStructifier( - reflect.TypeOf((*NotificationHistory)(nil)).Elem(), + reflect.TypeFor[NotificationHistory](), "structify", contracts.SafeInit) diff --git a/pkg/icingaredis/utils_test.go b/pkg/icingaredis/utils_test.go index b92aefa0..0b34055c 100644 --- a/pkg/icingaredis/utils_test.go +++ b/pkg/icingaredis/utils_test.go @@ -240,8 +240,7 @@ func TestSetChecksums(t *testing.T) { t.Run(fmt.Sprint(concurrency), func(t *testing.T) { for _, l := range latencies { t.Run(l.name, func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() input := make(chan database.Entity, 1) go func() { @@ -311,8 +310,7 @@ func TestSetChecksums(t *testing.T) { for _, concurrency := range []int{0, -1, -2, -30} { t.Run(fmt.Sprint(concurrency), func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() input := make(chan database.Entity, 1) input <- nil diff --git a/pkg/notifications/notifications.go b/pkg/notifications/notifications.go index d79ee8bc..2cbd9c43 100644 --- a/pkg/notifications/notifications.go +++ b/pkg/notifications/notifications.go @@ -430,7 +430,7 @@ func (client *Client) Submit(entity database.Entity) bool { // This loop allows resubmitting an event if the rules have changed. The first try would be the rule update, the // second try would be the resubmit, and the third try would be for bad luck, e.g., when a second rule update just // crept in between. If there are three subsequent rule updates, something is wrong. - for try := 0; try < 3; try++ { + for range 3 { eventRuleIds, err := client.evaluateRulesForObject( client.ctx, metaHistory.HostId, @@ -484,7 +484,7 @@ func (client *Client) SyncExtraStages() map[string]history.StageFunc { } sorterCallbackFn := func(msg redis.XMessage, key string) bool { - makeEntity := func(key string, values map[string]interface{}) (database.Entity, error) { + makeEntity := func(key string, values map[string]any) (database.Entity, error) { structPtr, ok := syncKeyStructPtrs[key] if !ok { return nil, fmt.Errorf("key is not part of keyStructPtrs")