Skip to content

Commit 111182a

Browse files
committed
lint fix
1 parent e0e6fd5 commit 111182a

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ linters:
5353
# - wsl
5454

5555
linters-settings:
56+
depguard:
57+
rules:
58+
main:
59+
allow:
60+
- $gostd
61+
- github.com/databricks/databricks-sql-go
5662
gosec:
5763
exclude-generated: true
5864
severity: "low"

telemetry/circuitbreaker.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,6 @@ func (cb *circuitBreaker) getFailureRate() int {
255255
return (cb.failureCount * 100) / windowSize
256256
}
257257

258-
// getTotalCalls returns the total number of recorded calls (for testing).
259-
func (cb *circuitBreaker) getTotalCalls() int {
260-
cb.mu.RLock()
261-
defer cb.mu.RUnlock()
262-
return cb.totalCalls
263-
}
264-
265258
// circuitBreakerManager manages circuit breakers per host.
266259
// Each host gets its own circuit breaker to provide isolation.
267260
type circuitBreakerManager struct {

telemetry/circuitbreaker_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ func TestCircuitBreaker_ClosedToOpen_FailureRate(t *testing.T) {
3737

3838
// Execute 10 calls: 6 failures (60% failure rate) should open circuit
3939
for i := 0; i < 6; i++ {
40-
cb.execute(ctx, failFunc)
40+
_ = cb.execute(ctx, failFunc)
4141
}
4242
for i := 0; i < 4; i++ {
43-
cb.execute(ctx, successFunc)
43+
_ = cb.execute(ctx, successFunc)
4444
}
4545

4646
// Circuit should be open (60% > 50% threshold)
@@ -66,7 +66,7 @@ func TestCircuitBreaker_MinimumCallsRequired(t *testing.T) {
6666

6767
// Execute 10 failures (less than minimum)
6868
for i := 0; i < 10; i++ {
69-
cb.execute(ctx, failFunc)
69+
_ = cb.execute(ctx, failFunc)
7070
}
7171

7272
// Circuit should still be closed (not enough calls)
@@ -76,7 +76,7 @@ func TestCircuitBreaker_MinimumCallsRequired(t *testing.T) {
7676

7777
// Execute 10 more failures (now 20 total, 100% failure rate)
7878
for i := 0; i < 10; i++ {
79-
cb.execute(ctx, failFunc)
79+
_ = cb.execute(ctx, failFunc)
8080
}
8181

8282
// Now circuit should be open
@@ -105,7 +105,7 @@ func TestCircuitBreaker_SlidingWindow(t *testing.T) {
105105

106106
// Fill window with 10 failures (100% failure rate)
107107
for i := 0; i < 10; i++ {
108-
cb.execute(ctx, failFunc)
108+
_ = cb.execute(ctx, failFunc)
109109
}
110110

111111
if cb.getState() != stateOpen {
@@ -116,22 +116,22 @@ func TestCircuitBreaker_SlidingWindow(t *testing.T) {
116116
time.Sleep(cfg.waitDurationInOpenState + 50*time.Millisecond)
117117

118118
// Successful call to move to half-open
119-
cb.execute(ctx, successFunc)
119+
_ = cb.execute(ctx, successFunc)
120120

121121
if cb.getState() != stateHalfOpen {
122122
t.Fatalf("Expected state to be HalfOpen, got %v", cb.getState())
123123
}
124124

125125
// One more success should close it (2 successes needed)
126-
cb.execute(ctx, successFunc)
126+
_ = cb.execute(ctx, successFunc)
127127

128128
if cb.getState() != stateClosed {
129129
t.Errorf("Expected state to be Closed after half-open successes, got %v", cb.getState())
130130
}
131131

132132
// Window should be reset - now add 10 successes
133133
for i := 0; i < 10; i++ {
134-
cb.execute(ctx, successFunc)
134+
_ = cb.execute(ctx, successFunc)
135135
}
136136

137137
// Should remain closed (0% failure rate)
@@ -157,7 +157,7 @@ func TestCircuitBreaker_OpenRejectsRequests(t *testing.T) {
157157

158158
// Open the circuit (10 failures = 100% failure rate)
159159
for i := 0; i < 10; i++ {
160-
cb.execute(ctx, failFunc)
160+
_ = cb.execute(ctx, failFunc)
161161
}
162162

163163
if cb.getState() != stateOpen {
@@ -192,7 +192,7 @@ func TestCircuitBreaker_OpenToHalfOpen(t *testing.T) {
192192

193193
// Open the circuit
194194
for i := 0; i < 10; i++ {
195-
cb.execute(ctx, failFunc)
195+
_ = cb.execute(ctx, failFunc)
196196
}
197197

198198
if cb.getState() != stateOpen {
@@ -237,7 +237,7 @@ func TestCircuitBreaker_HalfOpenToClosed(t *testing.T) {
237237

238238
// Open the circuit
239239
for i := 0; i < 10; i++ {
240-
cb.execute(ctx, failFunc)
240+
_ = cb.execute(ctx, failFunc)
241241
}
242242

243243
// Wait for wait duration
@@ -274,7 +274,7 @@ func TestCircuitBreaker_HalfOpenToOpen(t *testing.T) {
274274

275275
// Open the circuit
276276
for i := 0; i < 10; i++ {
277-
cb.execute(ctx, failFunc)
277+
_ = cb.execute(ctx, failFunc)
278278
}
279279

280280
// Wait for wait duration
@@ -338,7 +338,7 @@ func TestCircuitBreaker_ConcurrentAccess(t *testing.T) {
338338
wg.Add(1)
339339
go func() {
340340
defer wg.Done()
341-
cb.execute(ctx, func() error {
341+
_ = cb.execute(ctx, func() error {
342342
return errors.New("test error")
343343
})
344344
}()
@@ -441,11 +441,11 @@ func TestCircuitBreaker_FailureRateCalculation(t *testing.T) {
441441
// Execute 30 calls: 15 failures, 15 successes (50% failure rate)
442442
for i := 0; i < 30; i++ {
443443
if i%2 == 0 {
444-
cb.execute(ctx, func() error {
444+
_ = cb.execute(ctx, func() error {
445445
return errors.New("test error")
446446
})
447447
} else {
448-
cb.execute(ctx, func() error {
448+
_ = cb.execute(ctx, func() error {
449449
return nil
450450
})
451451
}

telemetry/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (m *clientManager) getOrCreateClient(host string, httpClient *http.Client,
5454
client := newTelemetryClient(host, httpClient, cfg)
5555
if err := client.start(); err != nil {
5656
// Failed to start client, don't add to map
57-
logger.Logger.Warn().Str("host", host).Err(err).Msg("failed to start telemetry client")
57+
logger.Logger.Debug().Str("host", host).Err(err).Msg("failed to start telemetry client")
5858
return nil
5959
}
6060
holder = &clientHolder{
@@ -100,7 +100,7 @@ func (m *clientManager) shutdown() error {
100100
var lastErr error
101101
for host, holder := range m.clients {
102102
if err := holder.client.close(); err != nil {
103-
logger.Logger.Warn().Str("host", host).Err(err).Msg("error closing telemetry client during shutdown")
103+
logger.Logger.Debug().Str("host", host).Err(err).Msg("error closing telemetry client during shutdown")
104104
lastErr = err
105105
}
106106
}

0 commit comments

Comments
 (0)