refactor(store): rename journal config fields
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
07bd25816e
commit
294a998282
3 changed files with 16 additions and 12 deletions
|
|
@ -160,10 +160,10 @@ func (storeInstance *Store) queryJournalFlux(flux string) (string, []any, error)
|
|||
}
|
||||
|
||||
func (storeInstance *Store) journalBucket() string {
|
||||
if storeInstance.journal.bucket == "" {
|
||||
if storeInstance.journal.bucketName == "" {
|
||||
return defaultJournalBucket
|
||||
}
|
||||
return storeInstance.journal.bucket
|
||||
return storeInstance.journal.bucketName
|
||||
}
|
||||
|
||||
func ensureJournalSchema(database schemaDatabase) error {
|
||||
|
|
|
|||
18
store.go
18
store.go
|
|
@ -33,10 +33,10 @@ const (
|
|||
// Usage example: `storeInstance, err := store.New("/tmp/go-store.db", store.WithJournal("http://127.0.0.1:8086", "core", "events"))`
|
||||
type StoreOption func(*Store)
|
||||
|
||||
type journalConfig struct {
|
||||
url string
|
||||
org string
|
||||
bucket string
|
||||
type journalDestinationConfig struct {
|
||||
endpointURL string
|
||||
organisation string
|
||||
bucketName string
|
||||
}
|
||||
|
||||
// Store provides SQLite-backed grouped entries with TTL expiry, namespace
|
||||
|
|
@ -47,7 +47,7 @@ type Store struct {
|
|||
cancelPurge context.CancelFunc
|
||||
purgeWaitGroup sync.WaitGroup
|
||||
purgeInterval time.Duration // interval between background purge cycles
|
||||
journal journalConfig
|
||||
journal journalDestinationConfig
|
||||
closeLock sync.Mutex
|
||||
closed bool
|
||||
|
||||
|
|
@ -62,9 +62,13 @@ type Store struct {
|
|||
// WithJournal records journal connection metadata for workspace commits,
|
||||
// journal queries, and archive generation.
|
||||
// Usage example: `storeInstance, err := store.New("/tmp/go-store.db", store.WithJournal("http://127.0.0.1:8086", "core", "events"))`
|
||||
func WithJournal(url, org, bucket string) StoreOption {
|
||||
func WithJournal(endpointURL, organisation, bucketName string) StoreOption {
|
||||
return func(storeInstance *Store) {
|
||||
storeInstance.journal = journalConfig{url: url, org: org, bucket: bucket}
|
||||
storeInstance.journal = journalDestinationConfig{
|
||||
endpointURL: endpointURL,
|
||||
organisation: organisation,
|
||||
bucketName: bucketName,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,9 +103,9 @@ func TestStore_New_Good_WithJournalOption(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
defer storeInstance.Close()
|
||||
|
||||
assert.Equal(t, "events", storeInstance.journal.bucket)
|
||||
assert.Equal(t, "core", storeInstance.journal.org)
|
||||
assert.Equal(t, "http://127.0.0.1:8086", storeInstance.journal.url)
|
||||
assert.Equal(t, "events", storeInstance.journal.bucketName)
|
||||
assert.Equal(t, "core", storeInstance.journal.organisation)
|
||||
assert.Equal(t, "http://127.0.0.1:8086", storeInstance.journal.endpointURL)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue