MCPcopy Index your code
hub / github.com/coder/coder / encodeForStream

Method encodeForStream

aibridge/intercept/messages/streaming.go:672–682  ·  view source on GitHub ↗
(payload []byte, typ string)

Source from the content-addressed store, hash-verified

670}
671
672func (*StreamingInterception) encodeForStream(payload []byte, typ string) []byte {
673 // bytes.Buffer writes to in-memory storage and never return errors.
674 var buf bytes.Buffer
675 _, _ = buf.WriteString("event: ")
676 _, _ = buf.WriteString(typ)
677 _, _ = buf.WriteString("\n")
678 _, _ = buf.WriteString("data: ")
679 _, _ = buf.Write(payload)
680 _, _ = buf.WriteString("\n\n")
681 return buf.Bytes()
682}
683
684// newStream traces svc.NewStreaming() call.
685func (i *StreamingInterception) newStream(ctx context.Context, svc anthropic.MessageService, extraOpts ...option.RequestOption) *ssestream.Stream[anthropic.MessageStreamEventUnion] {

Callers 3

marshalEventMethod · 0.95
marshalMethod · 0.95
pingPayloadMethod · 0.95

Calls 3

WriteStringMethod · 0.80
WriteMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected