Documentation
¶
Overview ¶
Package simulate provides protocol simulation: mock servers, replay, and load testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Replay ¶
func Replay(packets []ReplayPacket, cfg *ReplayConfig) error
Replay replays packets with timing.
Types ¶
type LoadTestConfig ¶
type LoadTestConfig struct {
Target string
Protocol string
RPS int // Requests per second
Duration time.Duration
Concurrency int
Data []byte
}
LoadTestConfig holds load test configuration.
type LoadTestResult ¶
type LoadTestResult struct {
TotalRequests int64 `json:"total_requests"`
Successful int64 `json:"successful"`
Failed int64 `json:"failed"`
Duration time.Duration `json:"duration"`
RPS float64 `json:"rps"`
AvgLatency time.Duration `json:"avg_latency"`
P50Latency time.Duration `json:"p50_latency"`
P95Latency time.Duration `json:"p95_latency"`
P99Latency time.Duration `json:"p99_latency"`
}
LoadTestResult holds load test results.
func RunLoadTest ¶
func RunLoadTest(cfg *LoadTestConfig) (*LoadTestResult, error)
RunLoadTest executes a protocol-level load test.
type MockServer ¶
type MockServer struct {
// contains filtered or unexported fields
}
MockServer serves mock responses for a message protocol.
func NewMockServer ¶
func NewMockServer(lib *protocol.Library, protoName string) (*MockServer, error)
NewMockServer creates a mock server for the given message protocol.
func (*MockServer) Handler ¶
func (m *MockServer) Handler() http.Handler
Handler returns an http.Handler for the mock server.
func (*MockServer) LoadRules ¶
func (m *MockServer) LoadRules(data []byte) error
LoadRules loads custom response rules from JSON.
type ReplayConfig ¶
type ReplayConfig struct {
Speed float64 // Playback speed multiplier (1.0 = normal)
Target string // Target address for replay
Protocol string // Protocol name
}
ReplayConfig holds replay configuration.
type ReplayPacket ¶
ReplayPacket represents a packet to replay.
Click to show internal directories.
Click to hide internal directories.