Documentation
¶
Index ¶
- func CORSMiddleware(next http.Handler) http.Handler
- func ChaosMiddleware(next http.Handler, engine *ChaosEngine) http.Handler
- func FastTestModeServer(identity *service.CallerIdentity, region, accountID string, ...) *fasthttp.Server
- func GenerateSpanID() string
- func GenerateTraceID() string
- func LoggingMiddleware(next http.Handler, log *RequestLog, stats *RequestStats, ...) http.Handler
- func LoggingMiddlewareWithOpts(next http.Handler, log *RequestLog, stats *RequestStats, ...) http.Handler
- func SetServicePrefixes(prefixes []string)
- func StartProxy(routes []ProxyRoute, tlsCert *CertPair)
- func StartProxyWithOpts(routes []ProxyRoute, tlsCert *CertPair, opts ProxyOpts)
- func TestModeHandler(cfg *service.CallerIdentity, region, accountID string, ...) http.Handler
- type CertPair
- type ChaosEngine
- func (ce *ChaosEngine) AddRule(rule ChaosRule) ChaosRule
- func (ce *ChaosEngine) DeleteRule(id string) bool
- func (ce *ChaosEngine) DisableAll()
- func (ce *ChaosEngine) HasActiveRules() bool
- func (ce *ChaosEngine) Match(svcName, action string) *ChaosRule
- func (ce *ChaosEngine) Rules() []ChaosRule
- func (ce *ChaosEngine) UpdateRule(id string, update ChaosRule) (ChaosRule, bool)
- type ChaosRule
- type Gateway
- type LoggingMiddlewareOpts
- type OnRequestFunc
- type ProxyOpts
- type ProxyRoute
- type ProxyServer
- type RedactionConfig
- type RequestBroadcaster
- type RequestEntry
- type RequestFilter
- type RequestLog
- type RequestStats
- type SLOAlert
- type SLOAlertFunc
- type SLOEngine
- type SLOStatus
- type SLOWindow
- type SLOWindowStatus
- type ServicePorts
- type TimelineSpan
- type TraceContext
- type TraceStore
- type TraceSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CORSMiddleware ¶
CORSMiddleware adds CORS headers to all responses. Enabled when CLOUDMOCK_CORS=true (default in dev).
func ChaosMiddleware ¶
func ChaosMiddleware(next http.Handler, engine *ChaosEngine) http.Handler
ChaosMiddleware wraps a gateway handler and applies chaos/fault injection rules before forwarding requests.
func FastTestModeServer ¶
func FastTestModeServer(identity *service.CallerIdentity, region, accountID string, registry *routing.Registry) *fasthttp.Server
FastTestModeServer returns a fasthttp.Server configured for maximum throughput. It bypasses net/http entirely and handles AWS requests with minimal allocation.
func GenerateSpanID ¶
func GenerateSpanID() string
GenerateSpanID returns a new W3C-compatible span ID.
func GenerateTraceID ¶
func GenerateTraceID() string
GenerateTraceID returns a new W3C-compatible trace ID.
func LoggingMiddleware ¶
func LoggingMiddleware(next http.Handler, log *RequestLog, stats *RequestStats, broadcasters ...RequestBroadcaster) http.Handler
LoggingMiddleware wraps a gateway handler and records request data.
func LoggingMiddlewareWithOpts ¶
func LoggingMiddlewareWithOpts(next http.Handler, log *RequestLog, stats *RequestStats, opts LoggingMiddlewareOpts) http.Handler
LoggingMiddlewareWithOpts wraps a gateway handler and records request data with full options.
func SetServicePrefixes ¶
func SetServicePrefixes(prefixes []string)
SetServicePrefixes configures the prefixes used by extractCallerID to recognize caller-service identifiers embedded in User-Agent or X-Cloudmock-Source headers. Safe to call once during startup.
func StartProxy ¶
func StartProxy(routes []ProxyRoute, tlsCert *CertPair)
StartProxy forwards to pkg/edge.
func StartProxyWithOpts ¶
func StartProxyWithOpts(routes []ProxyRoute, tlsCert *CertPair, opts ProxyOpts)
StartProxyWithOpts forwards to pkg/edge.
func TestModeHandler ¶
func TestModeHandler(cfg *service.CallerIdentity, region, accountID string, registry *routing.Registry) http.Handler
TestModeHandler creates a minimal HTTP handler that bypasses all middleware (logging, chaos, CORS, rate limiting) for maximum throughput. Services are pre-resolved into a lock-free map at construction time.
This handler skips: IAM auth, event bus, plugin manager, account registry, response recording, tracing, SLO, body capture, and all observability.
Types ¶
type CertPair ¶
CertPair lives in pkg/edge — this alias preserves the previous gateway.* name for any importer that still references it.
func EnsureCerts ¶
EnsureCerts forwards to pkg/edge.
type ChaosEngine ¶
type ChaosEngine struct {
PersistFunc func(rules []ChaosRule) // called after any mutation, if non-nil
// contains filtered or unexported fields
}
ChaosEngine manages a set of chaos/fault injection rules.
func NewChaosEngine ¶
func NewChaosEngine() *ChaosEngine
NewChaosEngine creates a new ChaosEngine with no rules.
func NewChaosEngineWithRules ¶
func NewChaosEngineWithRules(rules []ChaosRule) *ChaosEngine
NewChaosEngineWithRules creates a ChaosEngine pre-loaded with rules. The seq counter is set to len(rules) so new IDs don't collide.
func (*ChaosEngine) AddRule ¶
func (ce *ChaosEngine) AddRule(rule ChaosRule) ChaosRule
AddRule adds a new chaos rule and returns it with its assigned ID.
func (*ChaosEngine) DeleteRule ¶
func (ce *ChaosEngine) DeleteRule(id string) bool
DeleteRule removes a rule by ID, returning whether it was found.
func (*ChaosEngine) HasActiveRules ¶
func (ce *ChaosEngine) HasActiveRules() bool
HasActiveRules returns true if any rule is enabled.
func (*ChaosEngine) Match ¶
func (ce *ChaosEngine) Match(svcName, action string) *ChaosRule
Match finds the first enabled rule that matches the given service and action, applies the percentage check, and returns the rule (or nil if no match/no fire).
func (*ChaosEngine) Rules ¶
func (ce *ChaosEngine) Rules() []ChaosRule
Rules returns all configured chaos rules.
func (*ChaosEngine) UpdateRule ¶
func (ce *ChaosEngine) UpdateRule(id string, update ChaosRule) (ChaosRule, bool)
UpdateRule updates a rule by ID, returning the updated rule and whether it was found.
type ChaosRule ¶
type ChaosRule struct {
ID string `json:"id"`
Service string `json:"service"` // target service ("dynamodb", "s3", "*" for all)
Action string `json:"action"` // target action ("*" for all)
Enabled bool `json:"enabled"`
Type string `json:"type"` // "error", "latency", "timeout", "blackhole"
ErrorCode int `json:"errorCode"` // HTTP status code for "error" type
ErrorMsg string `json:"errorMsg"` // error message
LatencyMs int `json:"latencyMs"` // added latency for "latency" type
Percentage int `json:"percentage"` // 0-100, probability of applying
}
ChaosRule defines a fault injection rule that the ChaosEngine applies to matching requests.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is the main HTTP handler that routes AWS API requests to service mocks.
func NewWithIAM ¶
func NewWithIAM(cfg *config.Config, registry *routing.Registry, store *iampkg.Store, engine *iampkg.Engine) *Gateway
NewWithIAM creates a Gateway with IAM store and engine for authentication/authorization.
func (*Gateway) ServeHTTP ¶
func (g *Gateway) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*Gateway) SetAccountRegistry ¶
SetAccountRegistry attaches an account registry for multi-account support. When set, the gateway resolves the target account from credentials and dispatches requests to per-account service instances. When not set, the gateway uses the single shared routing.Registry (backward compatible).
func (*Gateway) SetEventBus ¶
SetEventBus attaches an event bus to the gateway for publishing API call events. CloudTrail and Config subscribe to these events.
func (*Gateway) SetPluginManager ¶
SetPluginManager attaches a plugin manager to the gateway. When set, the gateway will attempt to route requests to plugins before falling back to the legacy service registry.
type LoggingMiddlewareOpts ¶
type LoggingMiddlewareOpts struct {
Broadcaster RequestBroadcaster
TraceStore *TraceStore
SLOEngine *SLOEngine
DataPlane *dataplane.DataPlane
OnRequest OnRequestFunc
CaptureStacks bool // if true, capture call stacks per-request into trace store (expensive)
Redaction *RedactionConfig // if non-nil, redact sensitive fields before storage
}
type OnRequestFunc ¶
LoggingMiddlewareOpts holds optional dependencies for LoggingMiddleware. OnRequestFunc is called after each request is logged with the service name, latency in milliseconds, and HTTP status code. Used for anomaly detection.
type ProxyOpts ¶
L7 reverse-proxy types and functions live in pkg/edge — these aliases / forwarders preserve the previous gateway.* API for cmd/gateway/main.go and any external importers (e.g. autotend tooling) that still reference them by their gateway-package names.
type ProxyRoute ¶
type ProxyRoute = edge.ProxyRoute
L7 reverse-proxy types and functions live in pkg/edge — these aliases / forwarders preserve the previous gateway.* API for cmd/gateway/main.go and any external importers (e.g. autotend tooling) that still reference them by their gateway-package names.
func BuildRoutes ¶
func BuildRoutes(primaryDomain, cloudmockDomain string) []ProxyRoute
BuildRoutes forwards to pkg/edge.
func BuildRoutesWithPorts ¶
func BuildRoutesWithPorts(primaryDomain, cloudmockDomain string, p ServicePorts) []ProxyRoute
BuildRoutesWithPorts forwards to pkg/edge.
type ProxyServer ¶
type ProxyServer = edge.ProxyServer
L7 reverse-proxy types and functions live in pkg/edge — these aliases / forwarders preserve the previous gateway.* API for cmd/gateway/main.go and any external importers (e.g. autotend tooling) that still reference them by their gateway-package names.
func NewProxyServer ¶
func NewProxyServer(routes []ProxyRoute) *ProxyServer
NewProxyServer forwards to pkg/edge.
func NewProxyServerWithOpts ¶
func NewProxyServerWithOpts(routes []ProxyRoute, opts ProxyOpts) *ProxyServer
NewProxyServerWithOpts forwards to pkg/edge.
type RedactionConfig ¶
type RedactionConfig struct {
// Enabled turns on field redaction for all stored data.
Enabled bool
// RedactHeaders is a list of header names to redact (case-insensitive).
// Defaults: Authorization, Cookie, Set-Cookie, X-API-Key, X-Auth-Token.
RedactHeaders []string
// RedactBodyFields is a list of JSON field names whose values are redacted.
// Defaults: password, secret, token, ssn, social_security, credit_card,
// card_number, cvv, date_of_birth, dob, medical_record, diagnosis.
RedactBodyFields []string
// RedactBodyPatterns is a list of regex patterns to redact in body text.
// Defaults: SSN pattern, email addresses.
RedactBodyPatterns []*regexp.Regexp
}
RedactionConfig controls which headers and body fields are redacted before storage in traces, request logs, and audit entries.
When HIPAA mode is enabled, sensitive headers are replaced with "[REDACTED]" and body fields matching PII patterns are masked.
func DefaultRedactionConfig ¶
func DefaultRedactionConfig() *RedactionConfig
DefaultRedactionConfig returns the default HIPAA-safe redaction config.
func (*RedactionConfig) RedactBody ¶
func (c *RedactionConfig) RedactBody(body string) string
RedactBody scrubs sensitive JSON field values and PII patterns from body text.
func (*RedactionConfig) RedactRequestHeaders ¶
func (c *RedactionConfig) RedactRequestHeaders(headers map[string]string) map[string]string
RedactHeaders returns a copy of headers with sensitive values replaced.
type RequestBroadcaster ¶
type RequestBroadcaster = observability.RequestBroadcaster
Request observability types live in pkg/observability — these aliases preserve the previous gateway.* API for the ~50 service tests, the admin API, and dataplane stores that already import them by their gateway-package names.
type RequestEntry ¶
type RequestEntry = observability.RequestEntry
Request observability types live in pkg/observability — these aliases preserve the previous gateway.* API for the ~50 service tests, the admin API, and dataplane stores that already import them by their gateway-package names.
type RequestFilter ¶
type RequestFilter = observability.RequestFilter
Request observability types live in pkg/observability — these aliases preserve the previous gateway.* API for the ~50 service tests, the admin API, and dataplane stores that already import them by their gateway-package names.
type RequestLog ¶
type RequestLog = observability.RequestLog
Request observability types live in pkg/observability — these aliases preserve the previous gateway.* API for the ~50 service tests, the admin API, and dataplane stores that already import them by their gateway-package names.
func NewRequestLog ¶
func NewRequestLog(capacity int) *RequestLog
NewRequestLog constructs a RequestLog. Forwards to pkg/observability.
type RequestStats ¶
type RequestStats = observability.RequestStats
Request observability types live in pkg/observability — these aliases preserve the previous gateway.* API for the ~50 service tests, the admin API, and dataplane stores that already import them by their gateway-package names.
func NewRequestStats ¶
func NewRequestStats() *RequestStats
NewRequestStats constructs a RequestStats. Forwards to pkg/observability.
type SLOAlert ¶
type SLOAlert struct {
Severity string `json:"severity"` // "warning", "critical"
Service string `json:"service"`
Action string `json:"action"`
Message string `json:"message"`
}
SLOAlert represents an active SLO alert.
type SLOAlertFunc ¶
SLOAlertFunc is called when a breaching window is detected during Record. It receives the service, action, current burn rate, and fraction of error budget used.
type SLOEngine ¶
type SLOEngine struct {
// contains filtered or unexported fields
}
SLOEngine evaluates requests against configured SLO thresholds and tracks error budgets with burn rate calculation.
func NewSLOEngine ¶
NewSLOEngine creates an SLO engine with the given rules.
func (*SLOEngine) SetAlertFunc ¶
func (e *SLOEngine) SetAlertFunc(fn SLOAlertFunc)
SetAlertFunc registers a callback that is invoked on every Record call where the window is found to be breaching. Passing nil disables alerting.
type SLOStatus ¶
type SLOStatus struct {
Windows []SLOWindowStatus `json:"windows"`
Healthy bool `json:"healthy"`
Alerts []SLOAlert `json:"alerts"`
}
SLOStatus is the current state of all SLO windows.
type SLOWindow ¶
type SLOWindow struct {
Service string `json:"service"`
Action string `json:"action"`
Total int64 `json:"total"`
Violations int64 `json:"violations"` // requests exceeding SLO
Errors int64 `json:"errors"`
P50Target float64 `json:"p50_target_ms"`
P95Target float64 `json:"p95_target_ms"`
P99Target float64 `json:"p99_target_ms"`
ErrorTarget float64 `json:"error_target"`
// contains filtered or unexported fields
}
SLOWindow tracks SLO compliance over a rolling window.
type SLOWindowStatus ¶
type SLOWindowStatus struct {
Service string `json:"service"`
Action string `json:"action"`
Total int64 `json:"total"`
Violations int64 `json:"violations"`
Errors int64 `json:"errors"`
ErrorRate float64 `json:"error_rate"`
BudgetUsed float64 `json:"budget_used"` // 0-1, >1 = budget exhausted
BurnRate float64 `json:"burn_rate"` // current burn rate (1.0 = normal)
P50Ms float64 `json:"p50_ms"`
P95Ms float64 `json:"p95_ms"`
P99Ms float64 `json:"p99_ms"`
P50Target float64 `json:"p50_target_ms"`
P95Target float64 `json:"p95_target_ms"`
P99Target float64 `json:"p99_target_ms"`
Breaching bool `json:"breaching"`
}
SLOWindowStatus is the status of a single SLO window.
type ServicePorts ¶
type ServicePorts = edge.ServicePorts
L7 reverse-proxy types and functions live in pkg/edge — these aliases / forwarders preserve the previous gateway.* API for cmd/gateway/main.go and any external importers (e.g. autotend tooling) that still reference them by their gateway-package names.
func DefaultServicePorts ¶
func DefaultServicePorts() ServicePorts
DefaultServicePorts forwards to pkg/edge.
type TimelineSpan ¶
type TimelineSpan = observability.TimelineSpan
Trace types live in pkg/observability — these aliases preserve the previous gateway.* API for the ~50 service tests, the admin API, and dataplane stores that already import them by their gateway-package names.
type TraceContext ¶
type TraceContext = observability.TraceContext
Trace types live in pkg/observability — these aliases preserve the previous gateway.* API for the ~50 service tests, the admin API, and dataplane stores that already import them by their gateway-package names.
type TraceStore ¶
type TraceStore = observability.TraceStore
Trace types live in pkg/observability — these aliases preserve the previous gateway.* API for the ~50 service tests, the admin API, and dataplane stores that already import them by their gateway-package names.
func NewTraceStore ¶
func NewTraceStore(capacity int) *TraceStore
NewTraceStore constructs a TraceStore. Forwards to pkg/observability.
type TraceSummary ¶
type TraceSummary = observability.TraceSummary
Trace types live in pkg/observability — these aliases preserve the previous gateway.* API for the ~50 service tests, the admin API, and dataplane stores that already import them by their gateway-package names.