Skip to content

Commit

Permalink
fix lint issues (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored and cedric-cordenier committed Oct 4, 2024
1 parent a156b08 commit 4fa1cca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ func Test_Capabilities(t *testing.T) {
expectedRequest)
require.NotNil(t, err)
assert.Equal(t, "bang", err.Error())

})

t.Run("fetching an action capability, and closing it", func(t *testing.T) {
Expand All @@ -494,7 +493,6 @@ func Test_Capabilities(t *testing.T) {
ctx,
expectedRequest)
require.NoError(t, err)

})

t.Run("calling execute should be synchronous", func(t *testing.T) {
Expand Down
36 changes: 18 additions & 18 deletions pkg/monitoring/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ type managerImpl struct {
currentDataMu sync.Mutex
}

func (m *managerImpl) Run(backgroundCtx context.Context, managed ...ManagedFunc) {
var localCtx context.Context
var localCtxCancel context.CancelFunc
func (m *managerImpl) Run(ctx context.Context, managed ...ManagedFunc) {
var cancel context.CancelFunc
var localSubs *utils.Subprocesses
for {
select {
Expand All @@ -68,23 +67,24 @@ func (m *managerImpl) Run(backgroundCtx context.Context, managed ...ManagedFunc)
}
m.log.Infow("change in feeds configuration detected", "feeds", fmt.Sprintf("%#v", updatedData))
// Terminate previous managed function if not the first run.
if localCtxCancel != nil && localSubs != nil {
localCtxCancel()
if cancel != nil && localSubs != nil {
cancel()
localSubs.Wait()
}
// Start new managed function
localCtx, localCtxCancel = context.WithCancel(backgroundCtx)
localSubs = &utils.Subprocesses{}
m.log.Infow("starting managed funcs", "count", len(managed))
for i := range managed {
i := i // copy i to prevent race
localSubs.Go(func() {
managed[i](localCtx, updatedData)
})
}
case <-backgroundCtx.Done():
if localCtxCancel != nil {
localCtxCancel()
func(ctx context.Context) {
ctx, cancel = context.WithCancel(ctx)
localSubs = &utils.Subprocesses{}
m.log.Infow("starting managed funcs", "count", len(managed))
for i := range managed {
i := i // copy i to prevent race
localSubs.Go(func() {
managed[i](ctx, updatedData)
})
}
}(ctx)
case <-ctx.Done():
if cancel != nil {
cancel()
}
if localSubs != nil {
localSubs.Wait()
Expand Down

0 comments on commit 4fa1cca

Please sign in to comment.