[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find features d... #52
2 changed files with 36 additions and 0 deletions
23
store.go
23
store.go
|
|
@ -38,6 +38,17 @@ type journalConfiguration struct {
|
|||
bucketName string
|
||||
}
|
||||
|
||||
// JournalConfiguration is the public snapshot returned by Store.JournalConfiguration().
|
||||
// Usage example: `config := storeInstance.JournalConfiguration(); fmt.Println(config.EndpointURL, config.Organisation, config.BucketName)`
|
||||
type JournalConfiguration struct {
|
||||
// Usage example: `config := store.JournalConfiguration{EndpointURL: "http://127.0.0.1:8086"}`
|
||||
EndpointURL string
|
||||
// Usage example: `config := store.JournalConfiguration{Organisation: "core"}`
|
||||
Organisation string
|
||||
// Usage example: `config := store.JournalConfiguration{BucketName: "events"}`
|
||||
BucketName string
|
||||
}
|
||||
|
||||
// Usage example: `storeInstance, err := store.New(":memory:")`
|
||||
type Store struct {
|
||||
database *sql.DB
|
||||
|
|
@ -67,6 +78,18 @@ func WithJournal(endpointURL, organisation, bucketName string) StoreOption {
|
|||
}
|
||||
}
|
||||
|
||||
// Usage example: `config := storeInstance.JournalConfiguration(); fmt.Println(config.EndpointURL, config.Organisation, config.BucketName)`
|
||||
func (storeInstance *Store) JournalConfiguration() JournalConfiguration {
|
||||
if storeInstance == nil {
|
||||
return JournalConfiguration{}
|
||||
}
|
||||
return JournalConfiguration{
|
||||
EndpointURL: storeInstance.journalConfiguration.endpointURL,
|
||||
Organisation: storeInstance.journalConfiguration.organisation,
|
||||
BucketName: storeInstance.journalConfiguration.bucketName,
|
||||
}
|
||||
}
|
||||
|
||||
// Usage example: `storeInstance, err := store.New(":memory:", store.WithPurgeInterval(20*time.Millisecond))`
|
||||
func WithPurgeInterval(interval time.Duration) StoreOption {
|
||||
return func(storeInstance *Store) {
|
||||
|
|
|
|||
|
|
@ -108,6 +108,19 @@ func TestStore_New_Good_WithJournalOption(t *testing.T) {
|
|||
assert.Equal(t, "http://127.0.0.1:8086", storeInstance.journalConfiguration.endpointURL)
|
||||
}
|
||||
|
||||
func TestStore_JournalConfiguration_Good(t *testing.T) {
|
||||
storeInstance, err := New(":memory:", WithJournal("http://127.0.0.1:8086", "core", "events"))
|
||||
require.NoError(t, err)
|
||||
defer storeInstance.Close()
|
||||
|
||||
config := storeInstance.JournalConfiguration()
|
||||
assert.Equal(t, JournalConfiguration{
|
||||
EndpointURL: "http://127.0.0.1:8086",
|
||||
Organisation: "core",
|
||||
BucketName: "events",
|
||||
}, config)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Set / Get — core CRUD
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue