Documentation
¶
Overview ¶
Package override provides per-tenant config override entities and store interface.
Index ¶
Constants ¶
View Source
const (
// ContextKeyTenantID is the context key for tenant ID (matches flag.ContextKeyTenantID).
ContextKeyTenantID contextKey = "vault.tenant_id"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Override ¶
type Override struct {
core.Entity
ID id.ID `json:"id"`
Key string `json:"key"`
Value any `json:"value"`
AppID string `json:"app_id"`
TenantID string `json:"tenant_id"`
Metadata map[string]string `json:"metadata,omitempty"`
}
Override represents a per-tenant override for a config entry.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves config values with per-tenant override support.
Resolution order:
- If tenant ID is present in context, look up tenant override → use if found.
- Fall back to app-level config value.
- Cache results when a cache TTL is configured.
func NewResolver ¶
func NewResolver(configStore config.Store, overrideStore Store, opts ...ResolverOption) *Resolver
NewResolver creates a config resolver with override support.
func (*Resolver) Invalidate ¶
Invalidate removes cached entries for a specific config key and app ID.
func (*Resolver) InvalidateAll ¶
func (r *Resolver) InvalidateAll()
InvalidateAll removes all cached entries.
type ResolverOption ¶
type ResolverOption func(*Resolver)
ResolverOption configures the Resolver.
func WithCacheTTL ¶
func WithCacheTTL(ttl time.Duration) ResolverOption
WithCacheTTL enables result caching with the given TTL.
func WithLogger ¶
func WithLogger(l log.Logger) ResolverOption
WithLogger sets the logger for the resolver.
type Store ¶
type Store interface {
// GetOverride retrieves a tenant override by key, app ID, and tenant ID.
GetOverride(ctx context.Context, key, appID, tenantID string) (*Override, error)
// SetOverride creates or updates a tenant override.
SetOverride(ctx context.Context, o *Override) error
// DeleteOverride removes a tenant override.
DeleteOverride(ctx context.Context, key, appID, tenantID string) error
// ListOverridesByTenant returns all overrides for a specific tenant.
ListOverridesByTenant(ctx context.Context, appID, tenantID string) ([]*Override, error)
// ListOverridesByKey returns all tenant overrides for a specific config key.
ListOverridesByKey(ctx context.Context, key, appID string) ([]*Override, error)
// CountOverrides returns the total number of tenant overrides for an app,
// across every key and tenant.
CountOverrides(ctx context.Context, appID string) (int64, error)
}
Store defines the persistence interface for per-tenant overrides.
Click to show internal directories.
Click to hide internal directories.