Skip to content

Commit e5ebc0e

Browse files
scraper: remove dead Context/SetContext interface methods
Context() and SetContext() on SNMPScraper have zero call sites — they were re-introduced by a previous fix subagent after commit 5a347df had already removed them cleanly. Drop them from the interface and their implementations in GoSNMPWrapper and mockSNMPScraper; also remove the now-unused "context" import from scraper.go and mock.go. go build ./... and go test ./... -race both pass. Signed-off-by: Alex Muntean <amuntean@godaddy.com> Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 678df05 commit e5ebc0e

3 files changed

Lines changed: 0 additions & 28 deletions

File tree

scraper/gosnmp.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,6 @@ func (g *GoSNMPWrapper) Clone() SNMPScraper {
147147
return &GoSNMPWrapper{c: clone, logger: g.logger}
148148
}
149149

150-
// Context returns the context associated with this scraper.
151-
// Falls back to context.Background() if none has been set.
152-
func (g *GoSNMPWrapper) Context() context.Context {
153-
if g.c.Context != nil {
154-
return g.c.Context
155-
}
156-
return context.Background()
157-
}
158-
159-
// SetContext sets the context on the underlying GoSNMP client,
160-
// enabling cancellation of in-flight SNMP operations.
161-
func (g *GoSNMPWrapper) SetContext(ctx context.Context) {
162-
g.c.Context = ctx
163-
}
164-
165150
func (g *GoSNMPWrapper) Get(oids []string) (*gosnmp.SnmpPacket, error) {
166151
g.logger.Debug("Getting OIDs", "oids", oids)
167152
st := time.Now()

scraper/mock.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
package scraper
1515

1616
import (
17-
"context"
18-
1917
"github.com/gosnmp/gosnmp"
2018
)
2119

@@ -96,8 +94,3 @@ func (m *mockSNMPScraper) Clone() SNMPScraper {
9694
}
9795
}
9896

99-
func (m *mockSNMPScraper) Context() context.Context {
100-
return context.Background()
101-
}
102-
103-
func (m *mockSNMPScraper) SetContext(_ context.Context) {}

scraper/scraper.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
package scraper
1515

1616
import (
17-
"context"
18-
1917
"github.com/gosnmp/gosnmp"
2018
)
2119

@@ -28,8 +26,4 @@ type SNMPScraper interface {
2826
// Clone returns a new unconnected scraper with the same transport/auth settings.
2927
// Used to create per-goroutine connections for parallel OID walks.
3028
Clone() SNMPScraper
31-
// Context returns the context associated with this scraper.
32-
Context() context.Context
33-
// SetContext sets the context on this scraper, enabling cancellation.
34-
SetContext(context.Context)
3529
}

0 commit comments

Comments
 (0)