···55 "sync"
66)
7788+// Memory store allows messages to be stored in memory
89type MemoryStore struct {
910 mu sync.Mutex
1011 msgs map[int]message
1112 offset int
1213}
13141515+// New memory store initializes a new in memory store
1416func NewMemoryStore() *MemoryStore {
1517 return &MemoryStore{
1618 msgs: make(map[int]message),
1719 }
1820}
19212222+// Write will write the provided message to the in memory store
2023func (m *MemoryStore) Write(msg message) error {
2124 m.mu.Lock()
2225 defer m.mu.Unlock()
···2831 return nil
2932}
30333434+// ReadFrom will read messages from (and including) the provided offset and pass them to the provided handler
3135func (m *MemoryStore) ReadFrom(offset int, handleFunc func(msg message)) error {
3236 if offset < 0 || offset > m.offset {
3337 return fmt.Errorf("invalid offset provided")