[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find features d... #34

Merged
Virgil merged 1 commit from agent/read---spec-code-core-go-store-rfc-md-fu into dev 2026-04-03 05:01:12 +00:00
2 changed files with 17 additions and 0 deletions

View file

@ -48,6 +48,8 @@ type Store struct {
purgeWaitGroup sync.WaitGroup
purgeInterval time.Duration // interval between background purge cycles
journal journalConfig
closeLock sync.Mutex
closed bool
// Event dispatch state.
watchers map[string][]chan Event
@ -109,6 +111,14 @@ func New(databasePath string, options ...StoreOption) (*Store, error) {
// Usage example: `storeInstance, err := store.New(":memory:"); if err != nil { return }; defer storeInstance.Close()`
func (storeInstance *Store) Close() error {
storeInstance.closeLock.Lock()
if storeInstance.closed {
storeInstance.closeLock.Unlock()
return nil
}
storeInstance.closed = true
storeInstance.closeLock.Unlock()
storeInstance.cancelPurge()
storeInstance.purgeWaitGroup.Wait()
if err := storeInstance.database.Close(); err != nil {

View file

@ -655,6 +655,13 @@ func TestStore_Close_Good(t *testing.T) {
require.NoError(t, err)
}
func TestStore_Close_Good_Idempotent(t *testing.T) {
storeInstance, _ := New(":memory:")
require.NoError(t, storeInstance.Close())
require.NoError(t, storeInstance.Close())
}
func TestStore_Close_Good_OperationsFailAfterClose(t *testing.T) {
storeInstance, _ := New(":memory:")
require.NoError(t, storeInstance.Close())