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
| 162 | // |
| 163 | // All of an EventStore's methods must be safe for use by multiple goroutines. |
| 164 | type 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. |
no outgoing calls
no test coverage detected
searching dependent graphs…