@@ -396,8 +396,8 @@ func (t *StreamableServerTransport) Connect(ctx context.Context) (Connection, er
396396 jsonResponse : t .jsonResponse ,
397397 incoming : make (chan jsonrpc.Message , 10 ),
398398 done : make (chan struct {}),
399- streams : make (map [StreamID ]* stream ),
400- requestStreams : make (map [jsonrpc.ID ]StreamID ),
399+ streams : make (map [string ]* stream ),
400+ requestStreams : make (map [jsonrpc.ID ]string ),
401401 }
402402 if t .connection .eventStore == nil {
403403 t .connection .eventStore = NewMemoryEventStore (nil )
@@ -442,14 +442,14 @@ type streamableServerConn struct {
442442 // bound. If we deleted a stream when the response is sent, we would lose the ability
443443 // to replay if there was a cut just before the response was transmitted.
444444 // Perhaps we could have a TTL for streams that starts just after the response.
445- streams map [StreamID ]* stream
445+ streams map [string ]* stream
446446
447447 // requestStreams maps incoming requests to their logical stream ID.
448448 //
449449 // Lifecycle: requestStreams persist for the duration of the session.
450450 //
451451 // TODO: clean up once requests are handled. See the TODO for streams above.
452- requestStreams map [jsonrpc.ID ]StreamID
452+ requestStreams map [jsonrpc.ID ]string
453453}
454454
455455func (c * streamableServerConn ) SessionID () string {
@@ -466,7 +466,7 @@ func (c *streamableServerConn) SessionID() string {
466466type stream struct {
467467 // id is the logical ID for the stream, unique within a session.
468468 // an empty string is used for messages that don't correlate with an incoming request.
469- id StreamID
469+ id string
470470
471471 // If isInitialize is set, the stream is in response to an initialize request,
472472 // and therefore should include the session ID header.
@@ -500,7 +500,7 @@ type stream struct {
500500 requests map [jsonrpc.ID ]struct {}
501501}
502502
503- func (c * streamableServerConn ) newStream (ctx context.Context , id StreamID , isInitialize , jsonResponse bool ) (* stream , error ) {
503+ func (c * streamableServerConn ) newStream (ctx context.Context , id string , isInitialize , jsonResponse bool ) (* stream , error ) {
504504 if err := c .eventStore .Open (ctx , c .sessionID , id ); err != nil {
505505 return nil , err
506506 }
@@ -517,10 +517,6 @@ func signalChanPtr() *chan struct{} {
517517 return & c
518518}
519519
520- // A StreamID identifies a stream of SSE events. It is globally unique.
521- // [ServerSession].
522- type StreamID string
523-
524520// We track the incoming request ID inside the handler context using
525521// idContextValue, so that notifications and server->client calls that occur in
526522// the course of handling incoming requests are correlated with the incoming
@@ -569,7 +565,7 @@ func (t *StreamableServerTransport) ServeHTTP(w http.ResponseWriter, req *http.R
569565// It returns an HTTP status code and error message.
570566func (c * streamableServerConn ) serveGET (w http.ResponseWriter , req * http.Request ) {
571567 // connID 0 corresponds to the default GET request.
572- id := StreamID ( "" )
568+ id := ""
573569 // By default, we haven't seen a last index. Since indices start at 0, we represent
574570 // that by -1. This is incremented just before each event is written, in streamResponse
575571 // around L407.
@@ -669,7 +665,7 @@ func (c *streamableServerConn) servePOST(w http.ResponseWriter, req *http.Reques
669665 // notifications or server->client requests made in the course of handling.
670666 // Update accounting for this incoming payload.
671667 if len (requests ) > 0 {
672- stream , err = c .newStream (req .Context (), StreamID ( randText () ), isInitialize , c .jsonResponse )
668+ stream , err = c .newStream (req .Context (), randText (), isInitialize , c .jsonResponse )
673669 if err != nil {
674670 http .Error (w , fmt .Sprintf ("storing stream: %v" , err ), http .StatusInternalServerError )
675671 return
@@ -860,25 +856,25 @@ func (c *streamableServerConn) messages(ctx context.Context, stream *stream, per
860856// streamID and message index idx.
861857//
862858// See also [parseEventID].
863- func formatEventID (sid StreamID , idx int ) string {
859+ func formatEventID (sid string , idx int ) string {
864860 return fmt .Sprintf ("%s_%d" , sid , idx )
865861}
866862
867863// parseEventID parses a Last-Event-ID value into a logical stream id and
868864// index.
869865//
870866// See also [formatEventID].
871- func parseEventID (eventID string ) (sid StreamID , idx int , ok bool ) {
867+ func parseEventID (eventID string ) (streamID string , idx int , ok bool ) {
872868 parts := strings .Split (eventID , "_" )
873869 if len (parts ) != 2 {
874870 return "" , 0 , false
875871 }
876- stream := StreamID ( parts [0 ])
872+ streamID = parts [0 ]
877873 idx , err := strconv .Atoi (parts [1 ])
878874 if err != nil || idx < 0 {
879875 return "" , 0 , false
880876 }
881- return StreamID ( stream ) , idx , true
877+ return streamID , idx , true
882878}
883879
884880// Read implements the [Connection] interface.
@@ -922,7 +918,7 @@ func (c *streamableServerConn) Write(ctx context.Context, msg jsonrpc.Message) e
922918 //
923919 // For messages sent outside of a request context, this is the default
924920 // connection "".
925- var forStream StreamID
921+ var forStream string
926922 if forRequest .IsValid () {
927923 c .mu .Lock ()
928924 forStream = c .requestStreams [forRequest ]
0 commit comments