From f6a602f064940f1b971586674e6629ea3d1236b9 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 12:08:14 +0000 Subject: [PATCH] docs(store): improve agent-facing examples Co-Authored-By: Virgil --- scope.go | 2 +- store.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scope.go b/scope.go index 71e01b6..8153822 100644 --- a/scope.go +++ b/scope.go @@ -22,7 +22,7 @@ type QuotaConfig struct { MaxGroups int } -// Usage example: `scopedStore := store.NewScoped(storeInstance, "tenant-a"); if scopedStore == nil { return }; if err := scopedStore.Set("colour", "blue"); err != nil { return }; if err := scopedStore.SetIn("config", "language", "en-GB"); err != nil { return }` +// Usage example: `scopedStore, err := store.NewScopedConfigured(storeInstance, store.ScopedStoreConfig{Namespace: "tenant-a", Quota: store.QuotaConfig{MaxKeys: 100, MaxGroups: 10}}); if err != nil { return }; _ = scopedStore.Set("colour", "blue")` // ScopedStore keeps one namespace isolated behind helpers such as Set and // GetFrom so callers do not repeat the `tenant-a:` prefix manually. type ScopedStore struct { diff --git a/store.go b/store.go index d5dfdfd..27b9ae2 100644 --- a/store.go +++ b/store.go @@ -27,7 +27,7 @@ const ( entryValueColumn = "entry_value" ) -// Usage example: `storeOptions := []store.StoreOption{store.WithJournal("http://127.0.0.1:8086", "core", "events")}` +// Usage example: `configuredStore, err := store.NewConfigured(store.StoreConfig{DatabasePath: ":memory:", Journal: store.JournalConfiguration{EndpointURL: "http://127.0.0.1:8086", Organisation: "core", BucketName: "events"}})` // Prefer `store.NewConfigured(store.StoreConfig{...})` when the configuration // is already known as a struct literal. Use `StoreOption` only when the values // need to be assembled incrementally. @@ -137,7 +137,7 @@ func (storeInstance *Store) ensureReady(operation string) error { return nil } -// Usage example: `storeInstance, err := store.New("/tmp/go-store.db", store.WithJournal("http://127.0.0.1:8086", "core", "events"))` +// Usage example: `storeInstance, err := store.NewConfigured(store.StoreConfig{DatabasePath: "/tmp/go-store.db", Journal: store.JournalConfiguration{EndpointURL: "http://127.0.0.1:8086", Organisation: "core", BucketName: "events"}})` func WithJournal(endpointURL, organisation, bucketName string) StoreOption { return func(storeConfig *StoreConfig) { if storeConfig == nil { -- 2.45.3