Documentation
¶
Index ¶
- Variables
- type ChaosRule
- type Engine
- func (e *Engine) AddChaosRule(rule *ChaosRule) error
- func (e *Engine) AddMapLocal(rule *MapLocalRule) error
- func (e *Engine) AddMapRemote(rule *MapRemoteRule) error
- func (e *Engine) ApplyChaos(rawURL string) (injectedError bool, status int, body string)
- func (e *Engine) ClearAll()
- func (e *Engine) DeleteRule(id string) bool
- func (e *Engine) GetRulesSummary() map[string]interface{}
- func (e *Engine) GetThrottlingProfile() string
- func (e *Engine) MatchMapLocal(rawURL string) (*MapLocalRule, []byte, error)
- func (e *Engine) MatchMapRemote(rawURL, host string) (newURL string, newHost string, matched bool)
- func (e *Engine) SetThrottlingProfile(name string) error
- type MapLocalRule
- type MapRemoteRule
- type ThrottlingProfile
Constants ¶
This section is empty.
Variables ¶
var StandardProfiles = map[string]ThrottlingProfile{ "slow-3g": { Name: "slow-3g", DownloadBps: 50 * 1024, UploadBps: 50 * 1024, LatencyMs: 400, JitterMs: 50, Offline: false, }, "fast-3g": { Name: "fast-3g", DownloadBps: 200 * 1024, UploadBps: 90 * 1024, LatencyMs: 150, JitterMs: 20, Offline: false, }, "lte": { Name: "lte", DownloadBps: 1250 * 1024, UploadBps: 625 * 1024, LatencyMs: 40, JitterMs: 10, Offline: false, }, "offline": { Name: "offline", Offline: true, }, }
Functions ¶
This section is empty.
Types ¶
type ChaosRule ¶
type ChaosRule struct {
ID string `json:"id"`
Enabled bool `json:"enabled"`
Pattern string `json:"pattern"` // regex matching target URLs (or ".*" for all)
DelayMs int `json:"delay_ms"` // delay in milliseconds
JitterMs int `json:"jitter_ms"` // random variance +/- jitter
ErrorRate float64 `json:"error_rate"` // probability (0.0 to 1.0) of simulated failure
ErrorStatus int `json:"error_status"` // e.g. 500, 502, 503
ErrorBody string `json:"error_body"`
// contains filtered or unexported fields
}
ChaosRule injects latency, jitter, or simulated errors to test client resilience.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine coordinates Map Local, Map Remote, Chaos injection, and Network Throttling.
func (*Engine) AddChaosRule ¶
AddChaosRule registers a new Chaos / Latency injection rule.
func (*Engine) AddMapLocal ¶
func (e *Engine) AddMapLocal(rule *MapLocalRule) error
AddMapLocal registers a new Map Local rule.
func (*Engine) AddMapRemote ¶
func (e *Engine) AddMapRemote(rule *MapRemoteRule) error
AddMapRemote registers a new Map Remote rule.
func (*Engine) ApplyChaos ¶
ApplyChaos checks if network throttling, latency, or error simulation applies to the given URL.
func (*Engine) DeleteRule ¶
DeleteRule removes a rule with the specified ID across all rule types.
func (*Engine) GetRulesSummary ¶
GetRulesSummary returns current configuration for the dashboard.
func (*Engine) GetThrottlingProfile ¶
GetThrottlingProfile returns the name of the currently active profile.
func (*Engine) MatchMapLocal ¶
func (e *Engine) MatchMapLocal(rawURL string) (*MapLocalRule, []byte, error)
MatchMapLocal checks if a URL matches any active Map Local rules.
func (*Engine) MatchMapRemote ¶
MatchMapRemote rewrites host/URL if matching any active Map Remote rules.
func (*Engine) SetThrottlingProfile ¶
SetThrottlingProfile configures the active global network condition preset.
type MapLocalRule ¶
type MapLocalRule struct {
ID string `json:"id"`
Enabled bool `json:"enabled"`
Pattern string `json:"pattern"` // regex matching URL or path
FilePath string `json:"file_path,omitempty"` // local file to serve
InlineBody string `json:"inline_body,omitempty"`
StatusCode int `json:"status_code"`
ContentType string `json:"content_type"`
Headers map[string]string `json:"headers,omitempty"`
// contains filtered or unexported fields
}
MapLocalRule serves a local file or inline payload instead of hitting the upstream server.
type MapRemoteRule ¶
type MapRemoteRule struct {
ID string `json:"id"`
Enabled bool `json:"enabled"`
Pattern string `json:"pattern"` // regex matching source URL
TargetHost string `json:"target_host"` // target host/base (e.g. localhost:3000)
TargetURL string `json:"target_url,omitempty"`
// contains filtered or unexported fields
}
MapRemoteRule redirects requests matching a pattern to a different remote or local destination.
type ThrottlingProfile ¶
type ThrottlingProfile struct {
Name string `json:"name"`
DownloadBps int64 `json:"download_bps"`
UploadBps int64 `json:"upload_bps"`
LatencyMs int `json:"latency_ms"`
JitterMs int `json:"jitter_ms"`
Offline bool `json:"offline"`
}
ThrottlingProfile defines network condition simulation parameters.