feat(scope): restore scoped quota constructor
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
e5c63ee510
commit
4726b73ba6
2 changed files with 10 additions and 7 deletions
10
scope.go
10
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue