From 4726b73ba6dbd3f418e24656bd16a31adcb1769e Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 19:38:06 +0000 Subject: [PATCH] feat(scope): restore scoped quota constructor Co-Authored-By: Virgil --- scope.go | 10 ++++++++++ test_helpers_test.go | 7 ------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scope.go b/scope.go index 1763b68..a991227 100644 --- a/scope.go +++ b/scope.go @@ -102,6 +102,16 @@ func NewScopedConfigured(storeInstance *Store, scopedConfig ScopedStoreConfig) ( return scopedStore, nil } +// Usage example: `scopedStore, err := store.NewScopedWithQuota(storeInstance, "tenant-a", store.QuotaConfig{MaxKeys: 100, MaxGroups: 10}); if err != nil { return }` +// Prefer `NewScopedConfigured(store.ScopedStoreConfig{...})` when the full +// namespace and quota configuration are already known at the call site. +func NewScopedWithQuota(storeInstance *Store, namespace string, quota QuotaConfig) (*ScopedStore, error) { + return NewScopedConfigured(storeInstance, ScopedStoreConfig{ + Namespace: namespace, + Quota: quota, + }) +} + func (scopedStore *ScopedStore) namespacedGroup(group string) string { return scopedStore.namespace + ":" + group } diff --git a/test_helpers_test.go b/test_helpers_test.go index 155fb90..8d4a052 100644 --- a/test_helpers_test.go +++ b/test_helpers_test.go @@ -78,10 +78,3 @@ func requireResultRows(tb testing.TB, result core.Result) []map[string]any { require.True(tb, ok, "unexpected row type: %T", result.Value) return rows } - -func NewScopedWithQuota(storeInstance *Store, namespace string, quota QuotaConfig) (*ScopedStore, error) { - return NewScopedConfigured(storeInstance, ScopedStoreConfig{ - Namespace: namespace, - Quota: quota, - }) -}