Documentation
¶
Index ¶
- Variables
- func LoadMergedManagedManifest(ctx context.Context, c *Client, ref string, fileManifest *proxy.RouteManifest) (*proxy.RouteManifest, error)
- func RouteManifestKey(ref string) string
- type Client
- func (c *Client) Close()
- func (c *Client) Del(ctx context.Context, keys ...string) error
- func (c *Client) GetBytes(ctx context.Context, key string) ([]byte, error)
- func (c *Client) GetTenantConfig(ctx context.Context, ref string) (*TenantConfig, error)
- func (c *Client) ScanPage(ctx context.Context, cursor uint64, pattern string, count int) (keys []string, next uint64, err error)
- func (c *Client) SetBytes(ctx context.Context, key string, value []byte, ttlSeconds int) error
- func (c *Client) TTLSeconds(ctx context.Context, key string) (int, error)
- type TenantConfig
- type TenantManifestCache
Constants ¶
This section is empty.
Variables ¶
var ErrCircuitOpen = errors.New("valkey: circuit breaker open")
ErrCircuitOpen is returned when the circuit breaker is open and requests are being shed to protect Valkey from cascading failures.
Functions ¶
func LoadMergedManagedManifest ¶
func LoadMergedManagedManifest(ctx context.Context, c *Client, ref string, fileManifest *proxy.RouteManifest) (*proxy.RouteManifest, error)
LoadMergedManagedManifest builds the effective route manifest for a managed pod: start from fileManifest (typically SUPATYPE_MANIFEST_PATH), overlay routing fields from tenant:{ref}:config, then overlay tenant:{ref}:manifest when present.
func RouteManifestKey ¶
RouteManifestKey returns the Valkey key for a full route manifest override (same JSON shape as .supatype/manifest.json).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a valkey-go client with a simple circuit breaker. After cbFailThreshold consecutive errors the circuit opens and all requests return ErrCircuitOpen immediately. After cbOpenDuration the circuit enters half-open state: one probe request is allowed through.
func (*Client) GetTenantConfig ¶
GetTenantConfig fetches the TenantConfig for ref from Valkey. Key pattern: tenant:{ref}:config
Returns ErrCircuitOpen if the circuit breaker is open. Returns (nil, nil) when the key is absent (cache miss). Returns (nil, err) if the value cannot be decoded.
func (*Client) ScanPage ¶
func (c *Client) ScanPage(ctx context.Context, cursor uint64, pattern string, count int) (keys []string, next uint64, err error)
ScanPage scans keys matching pattern starting at cursor. count is a hint per page.
type TenantConfig ¶
type TenantConfig struct {
PostgRESTURL string `json:"postgrest_url,omitempty"`
GraphQLURL string `json:"graphql_url,omitempty"`
StorageURL string `json:"storage_url,omitempty"`
AppMode string `json:"app_mode,omitempty"`
AppUpstream string `json:"app_upstream,omitempty"`
ViteDevURL string `json:"vite_dev_url,omitempty"`
AppStaticDir string `json:"app_static_dir,omitempty"`
Schema string `json:"schema,omitempty"`
DatabaseURL string `json:"databaseUrl,omitempty"`
JWTSecret string `json:"jwtSecret,omitempty"`
AnonKey string `json:"anonKey,omitempty"`
ServiceRoleKey string `json:"serviceRoleKey,omitempty"`
RealtimeEnabled *bool `json:"realtime_enabled,omitempty"`
RealtimeURL string `json:"realtime_url,omitempty"`
FunctionsEnabled *bool `json:"functions_enabled,omitempty"`
FunctionsWorkerURL string `json:"functions_worker_url,omitempty"`
FunctionWorkerURLs map[string]string `json:"function_worker_urls,omitempty"`
// Hooks is the model-hook map, table → event → config, as `supatype push` computes it.
//
// Cloud has no manifest file on disk, so without this a project's hooks are declared in its schema
// and never called: the server would find nothing to dispatch and every hooked write would proceed
// unvalidated, silently. Same shape as the manifest's field so one type describes both paths.
Hooks map[string]proxy.TableHooks `json:"hooks,omitempty"`
// CorsAllowedOrigins is merged into the route manifest when present.
CorsAllowedOrigins []string `json:"cors_allowed_origins,omitempty"`
StaticCacheHTML string `json:"static_cache_html,omitempty"`
StaticCacheHashedAssets string `json:"static_cache_hashed_assets,omitempty"`
StaticCachePrefixes map[string]string `json:"static_cache_prefixes,omitempty"`
// RestCacheEnabled gates Valkey-backed REST GET caching on Cloud (false on free tier).
RestCacheEnabled *bool `json:"rest_cache_enabled,omitempty"`
}
TenantConfig holds routing and configuration for a single tenant, as written by the cloud provisioner and read by supatype-server in managed mode.
func (*TenantConfig) RestCacheOffered ¶
func (tc *TenantConfig) RestCacheOffered() bool
RestCacheOffered returns whether server-side REST caching is offered for this tenant. When unset on a managed pod, defaults to false (fail closed for Cloud cost control).
type TenantManifestCache ¶
type TenantManifestCache struct {
// contains filtered or unexported fields
}
TenantManifestCache caches merged route manifests per tenant ref for managed mode when SUPATYPE_MANAGED_PROJECT_REF is not set (multi-tenant edge).
func NewTenantManifestCache ¶
func NewTenantManifestCache(vk *Client, ttl time.Duration, base func() *proxy.RouteManifest) *TenantManifestCache
NewTenantManifestCache returns a cache. base must return a fresh clone or immutable manifest used as the file layer for each merge. ttl <= 0 defaults to 30s.
func (*TenantManifestCache) Flush ¶
func (c *TenantManifestCache) Flush()
Flush drops all cached entries (e.g. after local manifest file changes).
func (*TenantManifestCache) Get ¶
func (c *TenantManifestCache) Get(ctx context.Context, ref string) (*proxy.RouteManifest, error)
Get returns the merged manifest for ref, or base() when ref is empty.