Skip to content

Commit 484f365

Browse files
committed
chore: lint fixes part 3
1 parent 3f49be8 commit 484f365

File tree

22 files changed

+75
-76
lines changed

22 files changed

+75
-76
lines changed

intercept/apidump/apidump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (d *dumper) dumpResponse(resp *http.Response) error {
154154
// for deterministic output.
155155
// `sensitive` and `overrides` must both supply keys in canoncialized form.
156156
// See [textproto.MIMEHeader].
157-
func (d *dumper) writeRedactedHeaders(w io.Writer, headers http.Header, sensitive map[string]struct{}, overrides map[string]string) error {
157+
func (*dumper) writeRedactedHeaders(w io.Writer, headers http.Header, sensitive map[string]struct{}, overrides map[string]string) error {
158158
// Collect all header keys including overrides.
159159
headerKeys := make([]string, 0, len(headers)+len(overrides))
160160
seen := make(map[string]struct{}, len(headers)+len(overrides))

intercept/chatcompletions/base.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ func (i *interceptionBase) CorrelatingToolCallID() *string {
9999
return &msg.OfTool.ToolCallID
100100
}
101101

102-
func (s *interceptionBase) baseTraceAttributes(r *http.Request, streaming bool) []attribute.KeyValue {
102+
func (i *interceptionBase) baseTraceAttributes(r *http.Request, streaming bool) []attribute.KeyValue {
103103
return []attribute.KeyValue{
104104
attribute.String(tracing.RequestPath, r.URL.Path),
105-
attribute.String(tracing.InterceptionID, s.id.String()),
105+
attribute.String(tracing.InterceptionID, i.id.String()),
106106
attribute.String(tracing.InitiatorID, aibcontext.ActorIDFromContext(r.Context())),
107-
attribute.String(tracing.Provider, s.providerName),
108-
attribute.String(tracing.Model, s.Model()),
107+
attribute.String(tracing.Provider, i.providerName),
108+
attribute.String(tracing.Model, i.Model()),
109109
attribute.Bool(tracing.Streaming, streaming),
110110
}
111111
}
@@ -118,7 +118,7 @@ func (i *interceptionBase) Model() string {
118118
return i.req.Model
119119
}
120120

121-
func (i *interceptionBase) newErrorResponse(err error) map[string]any {
121+
func (*interceptionBase) newErrorResponse(err error) map[string]any {
122122
return map[string]any{
123123
"error": true,
124124
"message": err.Error(),

intercept/chatcompletions/blocking.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ func NewBlockingInterceptor(
5151
}}
5252
}
5353

54-
func (s *BlockingInterception) Setup(logger slog.Logger, recorder recorder.Recorder, mcpProxy mcp.ServerProxier) {
55-
s.interceptionBase.Setup(logger.Named("blocking"), recorder, mcpProxy)
54+
func (i *BlockingInterception) Setup(logger slog.Logger, recorder recorder.Recorder, mcpProxy mcp.ServerProxier) {
55+
i.interceptionBase.Setup(logger.Named("blocking"), recorder, mcpProxy)
5656
}
5757

58-
func (s *BlockingInterception) Streaming() bool {
58+
func (*BlockingInterception) Streaming() bool {
5959
return false
6060
}
6161

62-
func (s *BlockingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue {
63-
return s.interceptionBase.baseTraceAttributes(r, false)
62+
func (i *BlockingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue {
63+
return i.interceptionBase.baseTraceAttributes(r, false)
6464
}
6565

6666
func (i *BlockingInterception) ProcessRequest(w http.ResponseWriter, r *http.Request) (outErr error) {

intercept/chatcompletions/streaming.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ func (i *StreamingInterception) Setup(logger slog.Logger, recorder recorder.Reco
5959
i.interceptionBase.Setup(logger.Named("streaming"), recorder, mcpProxy)
6060
}
6161

62-
func (i *StreamingInterception) Streaming() bool {
62+
func (*StreamingInterception) Streaming() bool {
6363
return true
6464
}
6565

66-
func (s *StreamingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue {
67-
return s.interceptionBase.baseTraceAttributes(r, true)
66+
func (i *StreamingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue {
67+
return i.interceptionBase.baseTraceAttributes(r, true)
6868
}
6969

7070
// ProcessRequest handles a request to /v1/chat/completions.
@@ -389,7 +389,7 @@ func (i *StreamingInterception) marshalErr(err error) ([]byte, error) {
389389
return i.encodeForStream(data), nil
390390
}
391391

392-
func (i *StreamingInterception) encodeForStream(payload []byte) []byte {
392+
func (*StreamingInterception) encodeForStream(payload []byte) []byte {
393393
var buf bytes.Buffer
394394
buf.WriteString("data: ")
395395
buf.Write(payload)

intercept/eventstream/eventstream.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ type EventStream struct {
3232
initiated atomic.Bool
3333
initiateOnce sync.Once
3434

35-
closeOnce sync.Once
3635
shutdownOnce sync.Once
3736
eventsCh chan event
3837

intercept/messages/base.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ func (i *interceptionBase) Model() string {
118118
return i.reqPayload.model()
119119
}
120120

121-
func (s *interceptionBase) baseTraceAttributes(r *http.Request, streaming bool) []attribute.KeyValue {
121+
func (i *interceptionBase) baseTraceAttributes(r *http.Request, streaming bool) []attribute.KeyValue {
122122
return []attribute.KeyValue{
123123
attribute.String(tracing.RequestPath, r.URL.Path),
124-
attribute.String(tracing.InterceptionID, s.id.String()),
124+
attribute.String(tracing.InterceptionID, i.id.String()),
125125
attribute.String(tracing.InitiatorID, aibcontext.ActorIDFromContext(r.Context())),
126-
attribute.String(tracing.Provider, s.providerName),
127-
attribute.String(tracing.Model, s.Model()),
126+
attribute.String(tracing.Provider, i.providerName),
127+
attribute.String(tracing.Model, i.Model()),
128128
attribute.Bool(tracing.Streaming, streaming),
129-
attribute.Bool(tracing.IsBedrock, s.bedrockCfg != nil),
129+
attribute.Bool(tracing.IsBedrock, i.bedrockCfg != nil),
130130
}
131131
}
132132

@@ -176,7 +176,7 @@ func (i *interceptionBase) disableParallelToolCalls() {
176176
}
177177

178178
// extractModelThoughts returns any thinking blocks that were returned in the response.
179-
func (i *interceptionBase) extractModelThoughts(msg *anthropic.Message) []*recorder.ModelThoughtRecord {
179+
func (*interceptionBase) extractModelThoughts(msg *anthropic.Message) []*recorder.ModelThoughtRecord {
180180
if msg == nil {
181181
return nil
182182
}
@@ -264,7 +264,7 @@ func (i *interceptionBase) withBody() option.RequestOption {
264264
return option.WithRequestBody("application/json", []byte(i.reqPayload))
265265
}
266266

267-
func (i *interceptionBase) withAWSBedrockOptions(ctx context.Context, cfg *aibconfig.AWSBedrock) ([]option.RequestOption, error) {
267+
func (*interceptionBase) withAWSBedrockOptions(ctx context.Context, cfg *aibconfig.AWSBedrock) ([]option.RequestOption, error) {
268268
if cfg == nil {
269269
return nil, xerrors.New("nil config given")
270270
}

intercept/messages/base_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,11 @@ type mockServerProxier struct {
777777
tools []*mcp.Tool
778778
}
779779

780-
func (m *mockServerProxier) Init(context.Context) error {
780+
func (*mockServerProxier) Init(context.Context) error {
781781
return nil
782782
}
783783

784-
func (m *mockServerProxier) Shutdown(context.Context) error {
784+
func (*mockServerProxier) Shutdown(context.Context) error {
785785
return nil
786786
}
787787

@@ -798,7 +798,7 @@ func (m *mockServerProxier) GetTool(id string) *mcp.Tool {
798798
return nil
799799
}
800800

801-
func (m *mockServerProxier) CallTool(context.Context, string, any) (*mcpgo.CallToolResult, error) {
801+
func (*mockServerProxier) CallTool(context.Context, string, any) (*mcpgo.CallToolResult, error) {
802802
return nil, nil
803803
}
804804

intercept/messages/blocking.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (i *BlockingInterception) TraceAttributes(r *http.Request) []attribute.KeyV
6262
return i.interceptionBase.baseTraceAttributes(r, false)
6363
}
6464

65-
func (s *BlockingInterception) Streaming() bool {
65+
func (*BlockingInterception) Streaming() bool {
6666
return false
6767
}
6868

intercept/messages/reqpayload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func (p MessagesRequestPayload) tools() ([]json.RawMessage, error) {
313313
return p.resultToRawMessage(tools.Array()), nil
314314
}
315315

316-
func (p MessagesRequestPayload) resultToRawMessage(items []gjson.Result) []json.RawMessage {
316+
func (MessagesRequestPayload) resultToRawMessage(items []gjson.Result) []json.RawMessage {
317317
// gjson.Result conversion to json.RawMessage is needed because
318318
// gjson.Result does not implement json.Marshaler — would
319319
// serialize its struct fields instead of the raw JSON it represents.

intercept/messages/streaming.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ func NewStreamingInterceptor(
5959
}}
6060
}
6161

62-
func (s *StreamingInterception) Setup(logger slog.Logger, recorder recorder.Recorder, mcpProxy mcp.ServerProxier) {
63-
s.interceptionBase.Setup(logger.Named("streaming"), recorder, mcpProxy)
62+
func (i *StreamingInterception) Setup(logger slog.Logger, recorder recorder.Recorder, mcpProxy mcp.ServerProxier) {
63+
i.interceptionBase.Setup(logger.Named("streaming"), recorder, mcpProxy)
6464
}
6565

66-
func (s *StreamingInterception) Streaming() bool {
66+
func (*StreamingInterception) Streaming() bool {
6767
return true
6868
}
6969

70-
func (s *StreamingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue {
71-
return s.interceptionBase.baseTraceAttributes(r, true)
70+
func (i *StreamingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue {
71+
return i.interceptionBase.baseTraceAttributes(r, true)
7272
}
7373

7474
// ProcessRequest handles a request to /v1/messages.
@@ -534,8 +534,8 @@ newStream:
534534
return interceptionErr
535535
}
536536

537-
func (s *StreamingInterception) marshalEvent(event anthropic.MessageStreamEventUnion) ([]byte, error) {
538-
sj, err := sjson.Set(event.RawJSON(), "message.id", s.ID().String())
537+
func (i *StreamingInterception) marshalEvent(event anthropic.MessageStreamEventUnion) ([]byte, error) {
538+
sj, err := sjson.Set(event.RawJSON(), "message.id", i.ID().String())
539539
if err != nil {
540540
return nil, xerrors.Errorf("marshal event id failed: %w", err)
541541
}
@@ -545,10 +545,10 @@ func (s *StreamingInterception) marshalEvent(event anthropic.MessageStreamEventU
545545
return nil, xerrors.Errorf("marshal event usage failed: %w", err)
546546
}
547547

548-
return s.encodeForStream([]byte(sj), event.Type), nil
548+
return i.encodeForStream([]byte(sj), event.Type), nil
549549
}
550550

551-
func (s *StreamingInterception) marshal(payload any) ([]byte, error) {
551+
func (i *StreamingInterception) marshal(payload any) ([]byte, error) {
552552
data, err := json.Marshal(payload)
553553
if err != nil {
554554
return nil, xerrors.Errorf("marshal payload: %w", err)
@@ -564,15 +564,15 @@ func (s *StreamingInterception) marshal(payload any) ([]byte, error) {
564564
return nil, xerrors.Errorf("could not determine type from payload %q", data)
565565
}
566566

567-
return s.encodeForStream(data, eventType), nil
567+
return i.encodeForStream(data, eventType), nil
568568
}
569569

570570
// https://docs.anthropic.com/en/docs/build-with-claude/streaming#basic-streaming-request
571-
func (s *StreamingInterception) pingPayload() []byte {
572-
return s.encodeForStream([]byte(`{"type": "ping"}`), "ping")
571+
func (i *StreamingInterception) pingPayload() []byte {
572+
return i.encodeForStream([]byte(`{"type": "ping"}`), "ping")
573573
}
574574

575-
func (s *StreamingInterception) encodeForStream(payload []byte, typ string) []byte {
575+
func (*StreamingInterception) encodeForStream(payload []byte, typ string) []byte {
576576
var buf bytes.Buffer
577577
buf.WriteString("event: ")
578578
buf.WriteString(typ)
@@ -584,9 +584,9 @@ func (s *StreamingInterception) encodeForStream(payload []byte, typ string) []by
584584
}
585585

586586
// newStream traces svc.NewStreaming() call.
587-
func (s *StreamingInterception) newStream(ctx context.Context, svc anthropic.MessageService) *ssestream.Stream[anthropic.MessageStreamEventUnion] {
588-
_, span := s.tracer.Start(ctx, "Intercept.ProcessRequest.Upstream", trace.WithAttributes(tracing.InterceptionAttributesFromContext(ctx)...))
587+
func (i *StreamingInterception) newStream(ctx context.Context, svc anthropic.MessageService) *ssestream.Stream[anthropic.MessageStreamEventUnion] {
588+
_, span := i.tracer.Start(ctx, "Intercept.ProcessRequest.Upstream", trace.WithAttributes(tracing.InterceptionAttributesFromContext(ctx)...))
589589
defer span.End()
590590

591-
return svc.NewStreaming(ctx, anthropic.MessageNewParams{}, s.withBody())
591+
return svc.NewStreaming(ctx, anthropic.MessageNewParams{}, i.withBody())
592592
}

0 commit comments

Comments
 (0)