Documentation
¶
Index ¶
- Constants
- func ApplyA2AAgentPatch(cur *A2AAgent, ...) error
- func ApplyMCPBackendPatch(cur *MCPBackend, alias, name, baseURL, apiKeyEnv *string, ...) error
- func ApplyPolicyPatch(cur *RequestPolicy, name, expression *string, actions []PolicyAction, ...) error
- func ApplyWasmHookPatch(cur *WasmHook, name, phase, moduleURI, digest *string, enabled *bool, ...) error
- func AssertProviderInOrg(ctx context.Context, orgID, providerID string, providers ProviderRepository) error
- func AssertScopeInOrg(ctx context.Context, orgID, scopeType, scopeID string, m MembershipReader) error
- func NormalizeActionConfig(action string, raw json.RawMessage, v ExpressionValidator) (string, json.RawMessage, error)
- func NormalizeMethodAllowlist(raw json.RawMessage) (json.RawMessage, error)
- func NormalizeProviderConfig(raw json.RawMessage) (json.RawMessage, error)
- func NormalizeRoutingStrategy(strategy string) (string, error)
- func NormalizeWeight(w int) (int, error)
- func NormalizeWindow(window string) string
- func ParseA2AAlias(alias string) (string, error)
- func ParseA2AURL(raw string) (string, error)
- func ParseMCPAlias(alias string) (string, error)
- func ParseMCPBaseURL(raw string) (string, error)
- func ParseWasmPhase(phase string) (string, error)
- func ReorderPolicies(ctx context.Context, repo PolicyRepository, orgID string, ...) error
- func ValidateLimit(limitValue int64) error
- func ValidateMetric(metric string) error
- func ValidateNewFields(orgID, scopeType, scopeID, metric string, limitValue int64, window string) error
- func ValidateRetry(c *RetryConfig) error
- func ValidateScopeType(scopeType string) error
- func ValidateWindow(window string) error
- type A2AAgent
- func CreateA2AAgent(ctx context.Context, repo A2AAgentRepository, ...) (*A2AAgent, error)
- func NewA2AAgent(id, orgID, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme string, ...) (*A2AAgent, error)
- func UpdateA2AAgent(ctx context.Context, repo A2AAgentRepository, id string, ...) (*A2AAgent, error)
- type A2AAgentRepository
- type ActionConfigSetHeader
- type ActionConfigUseCredential
- type BackoffConfig
- type ExpressionValidator
- type MCPBackend
- type MCPBackendRepository
- type MembershipReader
- type ObjectStoreConfig
- type PolicyAction
- type PolicyPriorityUpdate
- type PolicyRepository
- type Provider
- type ProviderRepository
- type Quota
- type QuotaMetric
- type QuotaRepository
- type QuotaScope
- type QuotaWindow
- type RequestPolicy
- func CreatePolicy(ctx context.Context, repo PolicyRepository, validator ExpressionValidator, ...) (*RequestPolicy, error)
- func NewRequestPolicy(id, orgID, name, expression string, actions []PolicyAction, enabled bool, ...) (*RequestPolicy, error)
- func UpdatePolicy(ctx context.Context, repo PolicyRepository, validator ExpressionValidator, ...) (*RequestPolicy, error)
- type RetryConfig
- type Route
- func CreateRoute(ctx context.Context, repo RouteRepository, providers ProviderRepository, ...) (*Route, error)
- func NewRoute(id, orgID, model, providerID, targetModel string, fallbacks []RouteFallback, ...) (*Route, error)
- func UpdateRoute(ctx context.Context, repo RouteRepository, providers ProviderRepository, ...) (*Route, error)
- type RouteFallback
- type RouteRepository
- type WasmHook
- func CreateWasmHook(ctx context.Context, repo WasmHookRepository, ...) (*WasmHook, error)
- func NewWasmHook(id, orgID, name, phase, moduleURI, digest string, enabled bool, priority int, ...) (*WasmHook, error)
- func UpdateWasmHook(ctx context.Context, repo WasmHookRepository, id string, ...) (*WasmHook, error)
- type WasmHookRepository
Constants ¶
const ( ActionAllow = "allow" ActionDeny = "deny" ActionSetHeader = "set_header" ActionUseCredential = "use_credential" )
Policy action kinds (THEN clause).
const ( BackoffFixed = "fixed" BackoffExponential = "exponential" )
Backoff strategies for route retry.
const ( RoutingOrdered = "ordered" RoutingWeighted = "weighted" RoutingLatency = "latency" RoutingCost = "cost" )
Routing strategy values persisted on routes and compiled into snapshots.
const ( WasmPhaseBeforeCall = "before_call" WasmPhaseBeforeChat = "before_chat" WasmPhaseAfterCall = "after_call" )
Wasm hook phases compiled into the gateway snapshot.
Variables ¶
This section is empty.
Functions ¶
func ApplyA2AAgentPatch ¶
func ApplyA2AAgentPatch( cur *A2AAgent, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme *string, cardCache json.RawMessage, enabled *bool, ) error
ApplyA2AAgentPatch mutates optional fields.
func ApplyMCPBackendPatch ¶
func ApplyMCPBackendPatch( cur *MCPBackend, alias, name, baseURL, apiKeyEnv *string, methodAllowlist json.RawMessage, enabled *bool, ) error
ApplyMCPBackendPatch mutates optional fields.
func ApplyPolicyPatch ¶
func ApplyPolicyPatch(cur *RequestPolicy, name, expression *string, actions []PolicyAction, enabled *bool, priority *int, v ExpressionValidator) error
ApplyPolicyPatch mutates a policy with optional field updates.
func ApplyWasmHookPatch ¶
func ApplyWasmHookPatch(cur *WasmHook, name, phase, moduleURI, digest *string, enabled *bool, priority *int, config json.RawMessage) error
ApplyWasmHookPatch mutates optional fields.
func AssertProviderInOrg ¶
func AssertProviderInOrg(ctx context.Context, orgID, providerID string, providers ProviderRepository) error
AssertProviderInOrg ensures providerID belongs to orgID.
func AssertScopeInOrg ¶
func AssertScopeInOrg(ctx context.Context, orgID, scopeType, scopeID string, m MembershipReader) error
AssertScopeInOrg verifies the scope entity belongs to the organization.
func NormalizeActionConfig ¶
func NormalizeActionConfig(action string, raw json.RawMessage, v ExpressionValidator) (string, json.RawMessage, error)
NormalizeActionConfig validates action + config and returns canonical JSON. When v is non-nil, dynamic *_expr fields are validated as string CEL.
func NormalizeMethodAllowlist ¶
func NormalizeMethodAllowlist(raw json.RawMessage) (json.RawMessage, error)
NormalizeMethodAllowlist validates a JSON array of method strings.
func NormalizeProviderConfig ¶
func NormalizeProviderConfig(raw json.RawMessage) (json.RawMessage, error)
NormalizeProviderConfig returns a JSON object; nil/empty become {}.
func NormalizeRoutingStrategy ¶
NormalizeRoutingStrategy trims/lowercases strategy; empty becomes ordered.
func NormalizeWeight ¶
NormalizeWeight returns a positive weight; omitted/zero defaults to 1.
func NormalizeWindow ¶
NormalizeWindow defaults empty window to total.
func ParseA2AAlias ¶
ParseA2AAlias validates a URL path–safe alias slug (same rules as MCP).
func ParseA2AURL ¶
ParseA2AURL validates an absolute http(s) URL.
func ParseMCPAlias ¶
ParseMCPAlias validates a URL path–safe alias slug.
func ParseMCPBaseURL ¶
ParseMCPBaseURL validates an absolute http(s) URL.
func ParseWasmPhase ¶
ParseWasmPhase validates a lifecycle phase.
func ReorderPolicies ¶
func ReorderPolicies(ctx context.Context, repo PolicyRepository, orgID string, items []PolicyPriorityUpdate) error
ReorderPolicies validates and applies a batch of priority updates for one org.
func ValidateLimit ¶
ValidateLimit ensures limit_value is positive.
func ValidateMetric ¶
ValidateMetric ensures the quota metric is supported.
func ValidateNewFields ¶
func ValidateNewFields(orgID, scopeType, scopeID, metric string, limitValue int64, window string) error
ValidateNewFields checks pure field invariants before persistence.
func ValidateRetry ¶
func ValidateRetry(c *RetryConfig) error
ValidateRetry ensures retry fields are well-formed.
func ValidateScopeType ¶
ValidateScopeType ensures the scope type is known.
func ValidateWindow ¶
ValidateWindow ensures the quota window is supported.
Types ¶
type A2AAgent ¶
type A2AAgent struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Alias string `json:"alias"`
Name string `json:"name"`
UpstreamURL string `json:"upstream_url"`
CardURL string `json:"card_url"`
CardCache json.RawMessage `json:"card_cache,omitempty"`
APIKeyEnv string `json:"api_key_env"`
AuthScheme string `json:"auth_scheme"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"created_at"`
}
A2AAgent is the write-model for an org-scoped A2A upstream agent.
func CreateA2AAgent ¶
func CreateA2AAgent( ctx context.Context, repo A2AAgentRepository, id, orgID, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme string, cardCache json.RawMessage, enabled bool, ) (*A2AAgent, error)
CreateA2AAgent validates and persists.
func NewA2AAgent ¶
func NewA2AAgent( id, orgID, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme string, cardCache json.RawMessage, enabled bool, now time.Time, ) (*A2AAgent, error)
NewA2AAgent builds a validated entity.
func UpdateA2AAgent ¶
func UpdateA2AAgent( ctx context.Context, repo A2AAgentRepository, id string, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme *string, cardCache json.RawMessage, enabled *bool, ) (*A2AAgent, error)
UpdateA2AAgent loads, patches, and persists.
type A2AAgentRepository ¶
type A2AAgentRepository interface {
ListByOrg(ctx context.Context, orgID string) ([]A2AAgent, error)
Insert(ctx context.Context, a A2AAgent) error
Get(ctx context.Context, id string) (*A2AAgent, error)
Update(ctx context.Context, a A2AAgent) (*A2AAgent, error)
Delete(ctx context.Context, id string) error
OrgID(ctx context.Context, id string) (string, error)
}
A2AAgentRepository persists write-model A2A agents.
type ActionConfigSetHeader ¶
type ActionConfigSetHeader struct {
Header string `json:"header"`
Value string `json:"value,omitempty"`
ValueExpr string `json:"value_expr,omitempty"` // CEL → string; wins over Value when set
}
ActionConfigAllow/Deny have no fields.
type BackoffConfig ¶
type BackoffConfig struct {
Strategy string `json:"strategy"` // fixed | exponential
BaseDelay string `json:"base_delay"` // duration, e.g. "100ms"
MaxDelay string `json:"max_delay,omitempty"` // exponential only
Multiplier float64 `json:"multiplier,omitempty"` // exponential only; default 2 when omitted
}
BackoffConfig selects the delay between retry attempts.
type ExpressionValidator ¶
type ExpressionValidator interface {
Validate(expression string) error
ValidateString(expression string) error
}
ExpressionValidator checks CEL expressions without owning the engine.
type MCPBackend ¶
type MCPBackend struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Alias string `json:"alias"`
Name string `json:"name"`
BaseURL string `json:"base_url"`
APIKeyEnv string `json:"api_key_env"`
MethodAllowlist json.RawMessage `json:"method_allowlist"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"created_at"`
}
MCPBackend is the write-model for an org-scoped MCP Streamable HTTP upstream.
func CreateMCPBackend ¶
func CreateMCPBackend( ctx context.Context, repo MCPBackendRepository, id, orgID, alias, name, baseURL, apiKeyEnv string, methodAllowlist json.RawMessage, enabled bool, ) (*MCPBackend, error)
CreateMCPBackend validates and persists.
func NewMCPBackend ¶
func NewMCPBackend( id, orgID, alias, name, baseURL, apiKeyEnv string, methodAllowlist json.RawMessage, enabled bool, now time.Time, ) (*MCPBackend, error)
NewMCPBackend builds a validated entity.
func UpdateMCPBackend ¶
func UpdateMCPBackend( ctx context.Context, repo MCPBackendRepository, id string, alias, name, baseURL, apiKeyEnv *string, methodAllowlist json.RawMessage, enabled *bool, ) (*MCPBackend, error)
UpdateMCPBackend loads, patches, and persists.
type MCPBackendRepository ¶
type MCPBackendRepository interface {
ListByOrg(ctx context.Context, orgID string) ([]MCPBackend, error)
Insert(ctx context.Context, b MCPBackend) error
Get(ctx context.Context, id string) (*MCPBackend, error)
Update(ctx context.Context, b MCPBackend) (*MCPBackend, error)
Delete(ctx context.Context, id string) error
OrgID(ctx context.Context, id string) (string, error)
}
MCPBackendRepository persists write-model MCP backends.
type MembershipReader ¶
type MembershipReader interface {
ProjectBelongsToOrg(ctx context.Context, projectID, orgID string) error
TeamBelongsToOrg(ctx context.Context, teamID, orgID string) error
UserIsOrgMember(ctx context.Context, userID, orgID string) error
APIKeyBelongsToOrg(ctx context.Context, keyID, orgID string) error
}
MembershipReader resolves whether a quota scope belongs to an organization.
type ObjectStoreConfig ¶
type ObjectStoreConfig struct {
Enabled bool `json:"enabled"`
Endpoint string `json:"endpoint,omitempty"`
Region string `json:"region,omitempty"`
Bucket string `json:"bucket,omitempty"`
UseSSL bool `json:"use_ssl"`
PathStyle bool `json:"path_style"`
CredentialID string `json:"credential_id,omitempty"`
AccessKeyEnv string `json:"access_key_env,omitempty"`
SecretKeyEnv string `json:"secret_key_env,omitempty"`
PresignTTLSeconds int `json:"presign_ttl_seconds,omitempty"`
}
ObjectStoreConfig is per-org optional S3-compatible asset persistence. Nil or Enabled=false means the gateway does not persist generated assets.
func NormalizeObjectStore ¶
func NormalizeObjectStore(c *ObjectStoreConfig) (*ObjectStoreConfig, error)
NormalizeObjectStore validates and returns a canonical config. A nil input returns (nil, nil). Clearing persistence uses enabled:false (not nil) or DELETE semantics via nil.
func (*ObjectStoreConfig) ToSnapshot ¶
func (c *ObjectStoreConfig) ToSnapshot() *snapshot.ObjectStoreConfig
ToSnapshot copies this config into the compiled snapshot shape.
type PolicyAction ¶
type PolicyAction struct {
Type string `json:"type"`
Config json.RawMessage `json:"config,omitempty"`
}
PolicyAction is one Then step for a when/then policy.
func LegacySingleAction ¶
func LegacySingleAction(action string, actionConfig json.RawMessage) []PolicyAction
LegacySingleAction converts old action + action_config fields into an actions slice.
func NormalizeAction ¶
func NormalizeAction(a PolicyAction, v ExpressionValidator) (PolicyAction, error)
NormalizeAction validates one Then action and returns a canonical copy.
func NormalizeActions ¶
func NormalizeActions(actions []PolicyAction, v ExpressionValidator) ([]PolicyAction, error)
NormalizeActions validates a Then list (at least one action required).
type PolicyPriorityUpdate ¶
PolicyPriorityUpdate is one policy's new priority in a batch reorder.
type PolicyRepository ¶
type PolicyRepository interface {
ListByOrg(ctx context.Context, orgID string) ([]RequestPolicy, error)
Insert(ctx context.Context, p RequestPolicy) error
Get(ctx context.Context, policyID string) (*RequestPolicy, error)
Update(ctx context.Context, p RequestPolicy) (*RequestPolicy, error)
UpdatePriorities(ctx context.Context, orgID string, items []PolicyPriorityUpdate) error
Delete(ctx context.Context, policyID string) error
OrgID(ctx context.Context, policyID string) (string, error)
}
PolicyRepository persists write-model request policies.
type Provider ¶
type Provider struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Name string `json:"name"`
Type string `json:"type"`
BaseURL string `json:"base_url"`
APIKeyEnv string `json:"api_key_env"`
Capabilities snapshot.ProviderCapabilities `json:"capabilities"`
Config json.RawMessage `json:"config,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Provider is the write-model upstream provider configuration.
func CreateProvider ¶
func CreateProvider( ctx context.Context, repo ProviderRepository, id, orgID, name, typ, baseURL, apiKeyEnv string, caps snapshot.ProviderCapabilities, config json.RawMessage, ) (*Provider, error)
CreateProvider validates and persists a provider.
func NewProvider ¶
func NewProvider(id, orgID, name, typ, baseURL, apiKeyEnv string, caps snapshot.ProviderCapabilities, config json.RawMessage, now time.Time) (*Provider, error)
NewProvider builds a validated provider entity.
func UpdateProvider ¶
func UpdateProvider( ctx context.Context, repo ProviderRepository, providerID, name, baseURL, apiKeyEnv string, config *json.RawMessage, ) (*Provider, error)
UpdateProvider validates and persists provider field updates. When config is nil, the stored config JSON is left unchanged.
type ProviderRepository ¶
type ProviderRepository interface {
ListByOrg(ctx context.Context, orgID string) ([]Provider, error)
Insert(ctx context.Context, p Provider) error
Update(ctx context.Context, providerID, name, baseURL, apiKeyEnv string, config *json.RawMessage) (*Provider, error)
Delete(ctx context.Context, providerID string) error
OrgID(ctx context.Context, providerID string) (string, error)
}
ProviderRepository persists write-model providers.
type Quota ¶
type Quota struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
ScopeType string `json:"scope_type"`
ScopeID string `json:"scope_id"`
Metric string `json:"metric"`
LimitValue int64 `json:"limit_value"`
Window string `json:"window"`
CreatedAt time.Time `json:"created_at"`
}
Quota is the write-model quota configuration for an organization.
func CreateQuota ¶
func CreateQuota( ctx context.Context, repo QuotaRepository, members MembershipReader, id string, orgID, scopeType, scopeID, metric string, limitValue int64, window string, ) (*Quota, error)
CreateQuota validates fields + membership, then persists the quota.
type QuotaMetric ¶
type QuotaMetric string
QuotaMetric is a typed quota metric.
const ( MetricRequests QuotaMetric = snapshot.MetricRequests MetricTokens QuotaMetric = snapshot.MetricTokens )
func ParseQuotaMetric ¶
func ParseQuotaMetric(metric string) (QuotaMetric, error)
ParseQuotaMetric validates a quota metric.
func (QuotaMetric) String ¶
func (m QuotaMetric) String() string
type QuotaRepository ¶
type QuotaRepository interface {
ListByOrg(ctx context.Context, orgID string) ([]Quota, error)
Insert(ctx context.Context, q Quota) error
UpdateLimit(ctx context.Context, quotaID string, limitValue int64) (*Quota, error)
Delete(ctx context.Context, quotaID string) error
OrgID(ctx context.Context, quotaID string) (string, error)
}
QuotaRepository persists write-model quotas.
type QuotaScope ¶
type QuotaScope string
QuotaScope is a typed quota scope type.
const ( ScopeOrganization QuotaScope = snapshot.ScopeOrganization ScopeTeam QuotaScope = snapshot.ScopeTeam ScopeProject QuotaScope = snapshot.ScopeProject ScopeUser QuotaScope = snapshot.ScopeUser ScopeAPIKey QuotaScope = snapshot.ScopeAPIKey )
func ParseQuotaScope ¶
func ParseQuotaScope(scopeType string) (QuotaScope, error)
ParseQuotaScope validates a scope type.
func (QuotaScope) IsOrganization ¶
func (s QuotaScope) IsOrganization() bool
IsOrganization reports whether the scope is org-wide.
func (QuotaScope) String ¶
func (s QuotaScope) String() string
type QuotaWindow ¶
type QuotaWindow string
QuotaWindow is a typed quota time window.
const ( WindowTotal QuotaWindow = snapshot.WindowTotal WindowMinute QuotaWindow = snapshot.WindowMinute WindowHour QuotaWindow = snapshot.WindowHour WindowDay QuotaWindow = snapshot.WindowDay )
func ParseQuotaWindow ¶
func ParseQuotaWindow(window string) (QuotaWindow, error)
ParseQuotaWindow validates and returns a QuotaWindow. Empty defaults to total.
func (QuotaWindow) String ¶
func (w QuotaWindow) String() string
type RequestPolicy ¶
type RequestPolicy struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Name string `json:"name"`
Expression string `json:"expression"`
Actions []PolicyAction `json:"actions"`
Enabled bool `json:"enabled"`
Priority int `json:"priority"`
CreatedAt time.Time `json:"created_at"`
}
RequestPolicy is a when/then CEL policy for an organization. WHEN Expression is true, THEN Actions run in order.
func CreatePolicy ¶
func CreatePolicy( ctx context.Context, repo PolicyRepository, validator ExpressionValidator, id, orgID, name, expression string, actions []PolicyAction, enabled bool, priority int, ) (*RequestPolicy, error)
CreatePolicy validates and persists a new request policy.
func NewRequestPolicy ¶
func NewRequestPolicy(id, orgID, name, expression string, actions []PolicyAction, enabled bool, priority int, now time.Time, v ExpressionValidator) (*RequestPolicy, error)
NewRequestPolicy builds a validated policy entity.
func UpdatePolicy ¶
func UpdatePolicy( ctx context.Context, repo PolicyRepository, validator ExpressionValidator, policyID string, name, expression *string, actions []PolicyAction, enabled *bool, priority *int, ) (*RequestPolicy, error)
UpdatePolicy loads, patches, and persists a request policy.
type RetryConfig ¶
type RetryConfig struct {
MaxAttempts int `json:"max_attempts"` // includes first try; must be >= 1 when set
Backoff BackoffConfig `json:"backoff"`
}
RetryConfig controls same-target retries before failover. Nil means no same-target retries (single attempt per route target).
func NormalizeRetry ¶
func NormalizeRetry(c *RetryConfig) (*RetryConfig, error)
NormalizeRetry validates and returns a canonical retry config. A nil input returns (nil, nil).
func (*RetryConfig) Delay ¶
func (c *RetryConfig) Delay(n int) time.Duration
Delay returns the wait before retry attempt index n (0 = first retry after the initial failure). Negative n or a nil/invalid config yields 0.
func (*RetryConfig) ToSnapshot ¶
func (c *RetryConfig) ToSnapshot() *snapshot.RetryConfig
ToSnapshot copies this config into the compiled snapshot shape.
type Route ¶
type Route struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Model string `json:"model"`
ProviderID string `json:"provider_id"`
TargetModel string `json:"target_model"`
Fallbacks []RouteFallback `json:"fallbacks"`
Retry *RetryConfig `json:"retry,omitempty"`
RoutingStrategy string `json:"routing_strategy,omitempty"`
Weight int `json:"weight,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Route maps a virtual model to a provider target (+ optional fallbacks / retry).
func CreateRoute ¶
func CreateRoute( ctx context.Context, repo RouteRepository, providers ProviderRepository, id, orgID, model, providerID, targetModel string, fallbacks []RouteFallback, retry *RetryConfig, strategy string, weight int, ) (*Route, error)
CreateRoute validates and persists a route.
func NewRoute ¶
func NewRoute(id, orgID, model, providerID, targetModel string, fallbacks []RouteFallback, retry *RetryConfig, strategy string, weight int, now time.Time) (*Route, error)
NewRoute builds a validated route entity.
func UpdateRoute ¶
func UpdateRoute( ctx context.Context, repo RouteRepository, providers ProviderRepository, routeID, orgID, model, providerID, targetModel string, fallbacks []RouteFallback, retry *RetryConfig, strategy string, weight int, ) (*Route, error)
UpdateRoute validates provider ownership then persists.
type RouteFallback ¶
type RouteFallback struct {
ProviderID string `json:"provider_id"`
TargetModel string `json:"target_model"`
Weight int `json:"weight,omitempty"`
}
RouteFallback is a secondary provider target for a model route.
func NormalizeRouteRouting ¶
func NormalizeRouteRouting(strategy string, weight int, fallbacks []RouteFallback) (string, int, []RouteFallback, error)
NormalizeRouteRouting normalizes strategy and primary/fallback weights.
type RouteRepository ¶
type RouteRepository interface {
ListByOrg(ctx context.Context, orgID string) ([]Route, error)
Insert(ctx context.Context, r Route) error
Update(ctx context.Context, routeID, model, providerID, targetModel string, fallbacks []RouteFallback, retry *RetryConfig, strategy string, weight int) (*Route, error)
Delete(ctx context.Context, routeID string) error
OrgID(ctx context.Context, routeID string) (string, error)
}
RouteRepository persists write-model routes.
type WasmHook ¶
type WasmHook struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Name string `json:"name"`
Phase string `json:"phase"`
ModuleURI string `json:"module_uri"`
Digest string `json:"digest"`
Enabled bool `json:"enabled"`
Priority int `json:"priority"`
Config json.RawMessage `json:"config"`
CreatedAt time.Time `json:"created_at"`
}
WasmHook is the write-model for an org-scoped sandboxed lifecycle hook.
func CreateWasmHook ¶
func CreateWasmHook( ctx context.Context, repo WasmHookRepository, id, orgID, name, phase, moduleURI, digest string, enabled bool, priority int, config json.RawMessage, ) (*WasmHook, error)
CreateWasmHook validates and persists.
func NewWasmHook ¶
func NewWasmHook(id, orgID, name, phase, moduleURI, digest string, enabled bool, priority int, config json.RawMessage, now time.Time) (*WasmHook, error)
NewWasmHook builds a validated entity.
func UpdateWasmHook ¶
func UpdateWasmHook( ctx context.Context, repo WasmHookRepository, id string, name, phase, moduleURI, digest *string, enabled *bool, priority *int, config json.RawMessage, ) (*WasmHook, error)
UpdateWasmHook loads, patches, and persists.
type WasmHookRepository ¶
type WasmHookRepository interface {
ListByOrg(ctx context.Context, orgID string) ([]WasmHook, error)
Insert(ctx context.Context, h WasmHook) error
Get(ctx context.Context, id string) (*WasmHook, error)
Update(ctx context.Context, h WasmHook) (*WasmHook, error)
Delete(ctx context.Context, id string) error
OrgID(ctx context.Context, id string) (string, error)
}
WasmHookRepository persists write-model WASM hooks.