ScuttleBot

scuttlebot / internal / bots / systembot / store.go
Blame History Raw 26 lines
1
package systembot
2
3
import "sync"
4
5
// MemoryStore is an in-memory Store implementation for testing.
6
type MemoryStore struct {
7
mu sync.Mutex
8
entries []Entry
9
}
10
11
func (s *MemoryStore) Append(e Entry) error {
12
s.mu.Lock()
13
defer s.mu.Unlock()
14
s.entries = append(s.entries, e)
15
return nil
16
}
17
18
// All returns a snapshot of all entries.
19
func (s *MemoryStore) All() []Entry {
20
s.mu.Lock()
21
defer s.mu.Unlock()
22
out := make([]Entry, len(s.entries))
23
copy(out, s.entries)
24
return out
25
}
26

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button