Skip to content

Commit

Permalink
Merge pull request #111 from DNikolaevAtRocket/bugfix/nil-chan
Browse files Browse the repository at this point in the history
Fix uninitialized channel
  • Loading branch information
DNikolaevAtRocket authored Nov 27, 2024
2 parents c092437 + ca7eaed commit c60eaac
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions grafana/rmf-app/pkg/plugin/dds/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Client struct {
headerMap *HeaderMap

stopChan chan struct{}
closeOnce sync.Once
waitGroup sync.WaitGroup
rwMutex sync.RWMutex
}
Expand All @@ -72,6 +73,7 @@ func NewClient(baseUrl string, username string, password string, timeout int, tl
},
},
},
stopChan: make(chan struct{}),
}
client.waitGroup.Add(1)
go client.sync()
Expand Down Expand Up @@ -99,9 +101,11 @@ func (c *Client) sync() {
}

func (c *Client) Close() {
close(c.stopChan)
c.waitGroup.Wait()
c.httpClient.CloseIdleConnections()
c.closeOnce.Do(func() {
close(c.stopChan)
c.waitGroup.Wait()
c.httpClient.CloseIdleConnections()
})
}

func (c *Client) Get(ctx context.Context, path string, params ...string) (*Response, error) {
Expand Down

0 comments on commit c60eaac

Please sign in to comment.