Documentation
¶
Overview ¶
Package scope defines scoped provider configuration for app/org/user overrides.
Index ¶
Constants ¶
const ( ViaUser = "user" // a user-level routing rule ViaOrg = "org" // an org-level routing rule ViaApp = "app" // the app-level routing rule ViaFallback = "fallback" // no rule: the first enabled provider by priority ViaChosen = "chosen" // the caller named the provider )
How a provider was chosen, reported in ResolveResult.Via.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ID id.ScopedConfigID `json:"id"`
AppID string `json:"app_id"`
Scope ScopeType `json:"scope"`
ScopeID string `json:"scope_id"`
EmailProviderID string `json:"email_provider_id,omitempty"`
SMSProviderID string `json:"sms_provider_id,omitempty"`
PushProviderID string `json:"push_provider_id,omitempty"`
WebhookProviderID string `json:"webhook_provider_id,omitempty"`
ChatProviderID string `json:"chat_provider_id,omitempty"`
FromEmail string `json:"from_email,omitempty"`
FromName string `json:"from_name,omitempty"`
FromPhone string `json:"from_phone,omitempty"`
DefaultLocale string `json:"default_locale,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Config represents a scoped provider configuration override.
func (*Config) ProviderIDFor ¶
ProviderIDFor returns the provider ID override for the given channel.
type ResolveResult ¶
ResolveResult holds the resolved provider and scoped configuration.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves the appropriate notification provider for a given app/org/user scope using the fallback chain: user → org → app → default.
func NewResolver ¶
NewResolver creates a new scoped provider resolver.
func (*Resolver) ResolveProvider ¶
func (r *Resolver) ResolveProvider( ctx context.Context, appID, orgID, userID string, channel string, ) (*ResolveResult, error)
ResolveProvider resolves the best provider for a given channel through the scope chain: user → org → app → first enabled provider. A rule naming a provider of another app or channel is skipped. A store failure other than "not found" is returned. A nil result with a nil error means nothing handles the channel.
type ScopeType ¶
type ScopeType string //nolint:revive // renaming would break the public API
ScopeType identifies the level at which configuration is applied.
type Store ¶
type Store interface {
GetScopedConfig(ctx context.Context, appID string, scopeType ScopeType, scopeID string) (*Config, error)
SetScopedConfig(ctx context.Context, cfg *Config) error
DeleteScopedConfig(ctx context.Context, configID id.ScopedConfigID) error
ListScopedConfigs(ctx context.Context, appID string) ([]*Config, error)
}
Store defines persistence operations for scoped configurations.