refactor(store): clarify journal configuration names
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
f4492b1861
commit
12809c8d64
3 changed files with 14 additions and 23 deletions
|
|
@ -163,13 +163,10 @@ func (storeInstance *Store) queryJournalFlux(flux string) (string, []any, error)
|
|||
}
|
||||
|
||||
func (storeInstance *Store) journalBucket() string {
|
||||
if storeInstance.bucket != "" {
|
||||
return storeInstance.bucket
|
||||
}
|
||||
if storeInstance.journal.bucketName == "" {
|
||||
if storeInstance.journalConfiguration.bucketName == "" {
|
||||
return defaultJournalBucket
|
||||
}
|
||||
return storeInstance.journal.bucketName
|
||||
return storeInstance.journalConfiguration.bucketName
|
||||
}
|
||||
|
||||
func ensureJournalSchema(database schemaDatabase) error {
|
||||
|
|
|
|||
22
store.go
22
store.go
|
|
@ -32,7 +32,7 @@ const (
|
|||
// Usage example: `storeOptions := []store.StoreOption{store.WithJournal("http://127.0.0.1:8086", "core", "events")}`
|
||||
type StoreOption func(*Store)
|
||||
|
||||
type journalDestinationConfig struct {
|
||||
type journalConfiguration struct {
|
||||
endpointURL string
|
||||
organisation string
|
||||
bucketName string
|
||||
|
|
@ -40,15 +40,13 @@ type journalDestinationConfig struct {
|
|||
|
||||
// Usage example: `storeInstance, err := store.New(":memory:")`
|
||||
type Store struct {
|
||||
database *sql.DB
|
||||
cancelPurge context.CancelFunc
|
||||
purgeWaitGroup sync.WaitGroup
|
||||
purgeInterval time.Duration // interval between background purge cycles
|
||||
journal journalDestinationConfig
|
||||
bucket string
|
||||
org string
|
||||
closeLock sync.Mutex
|
||||
closed bool
|
||||
database *sql.DB
|
||||
cancelPurge context.CancelFunc
|
||||
purgeWaitGroup sync.WaitGroup
|
||||
purgeInterval time.Duration // interval between background purge cycles
|
||||
journalConfiguration journalConfiguration
|
||||
closeLock sync.Mutex
|
||||
closed bool
|
||||
|
||||
// Event dispatch state.
|
||||
watchers map[string][]chan Event
|
||||
|
|
@ -61,13 +59,11 @@ type Store struct {
|
|||
// Usage example: `storeInstance, err := store.New("/tmp/go-store.db", store.WithJournal("http://127.0.0.1:8086", "core", "events"))`
|
||||
func WithJournal(endpointURL, organisation, bucketName string) StoreOption {
|
||||
return func(storeInstance *Store) {
|
||||
storeInstance.journal = journalDestinationConfig{
|
||||
storeInstance.journalConfiguration = journalConfiguration{
|
||||
endpointURL: endpointURL,
|
||||
organisation: organisation,
|
||||
bucketName: bucketName,
|
||||
}
|
||||
storeInstance.bucket = bucketName
|
||||
storeInstance.org = organisation
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,11 +103,9 @@ func TestStore_New_Good_WithJournalOption(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
defer storeInstance.Close()
|
||||
|
||||
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)
|
||||
assert.Equal(t, "events", storeInstance.bucket)
|
||||
assert.Equal(t, "core", storeInstance.org)
|
||||
assert.Equal(t, "events", storeInstance.journalConfiguration.bucketName)
|
||||
assert.Equal(t, "core", storeInstance.journalConfiguration.organisation)
|
||||
assert.Equal(t, "http://127.0.0.1:8086", storeInstance.journalConfiguration.endpointURL)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue