MCPcopy Create free account
hub / github.com/coder/aibridge / encodeForStream

Method encodeForStream

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

Source from the content-addressed store, hash-verified

573}
574
575func (*StreamingInterception) encodeForStream(payload []byte, typ string) []byte {
576 // bytes.Buffer writes to in-memory storage and never return errors.
577 var buf bytes.Buffer
578 _, _ = buf.WriteString("event: ")
579 _, _ = buf.WriteString(typ)
580 _, _ = buf.WriteString("\n")
581 _, _ = buf.WriteString("data: ")
582 _, _ = buf.Write(payload)
583 _, _ = buf.WriteString("\n\n")
584 return buf.Bytes()
585}
586
587// newStream traces svc.NewStreaming() call.
588func (i *StreamingInterception) newStream(ctx context.Context, svc anthropic.MessageService) *ssestream.Stream[anthropic.MessageStreamEventUnion] {

Callers 3

marshalEventMethod · 0.95
marshalMethod · 0.95
pingPayloadMethod · 0.95

Calls 1

WriteMethod · 0.45

Tested by

no test coverage detected