MCPcopy Index your code
hub / github.com/modelcontextprotocol/go-sdk / EventStore

Interface EventStore

mcp/event.go:164–192  ·  view source on GitHub ↗

An EventStore tracks data for SSE streams. A single EventStore suffices for all sessions, since session IDs are globally unique. So one EventStore can be created per process, for all Servers in the process. Such a store is able to bound resource usage for the entire process. All of an EventStore's

Source from the content-addressed store, hash-verified

162//
163// All of an EventStore's methods must be safe for use by multiple goroutines.
164type EventStore interface {
165 // Open is called when a new stream is created. It may be used to ensure that
166 // the underlying data structure for the stream is initialized, making it
167 // ready to store and replay event streams.
168 Open(_ context.Context, sessionID, streamID string) error
169
170 // Append appends data for an outgoing event to given stream, which is part of the
171 // given session.
172 Append(_ context.Context, sessionID, streamID string, data []byte) error
173
174 // After returns an iterator over the data for the given session and stream, beginning
175 // just after the given index.
176 //
177 // Once the iterator yields a non-nil error, it will stop.
178 // After's iterator must return an error immediately if any data after index was
179 // dropped; it must not return partial results.
180 // The stream must have been opened previously (see [EventStore.Open]).
181 After(_ context.Context, sessionID, streamID string, index int) iter.Seq2[[]byte, error]
182
183 // SessionClosed informs the store that the given session is finished, along
184 // with all of its streams.
185 //
186 // A store cannot rely on this method being called for cleanup. It should institute
187 // additional mechanisms, such as timeouts, to reclaim storage.
188 SessionClosed(_ context.Context, sessionID string) error
189
190 // There is no StreamClosed method. A server doesn't know when a stream is finished, because
191 // the client can always send a GET with a Last-Event-ID referring to the stream.
192}
193
194// A dataList is a list of []byte.
195// The zero dataList is ready to use.

Callers 13

newStreamMethod · 0.65
withFileFunction · 0.65
servePOSTMethod · 0.65
WriteMethod · 0.65
Example_cancellationFunction · 0.65
TestCancellationFunction · 0.65
TestStreamableTransportsFunction · 0.65
TestPingEventFilteringFunction · 0.65
CloseMethod · 0.65
acquireStreamMethod · 0.65
connectSSEMethod · 0.65

Implementers 1

MemoryEventStoremcp/event.go

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…