simulate

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

type ReplayPacket struct {
	Timestamp time.Time
	Data      []byte
	Protocol  string
}

ReplayPacket represents a packet to replay.

type RequestLog

type RequestLog struct {
	Time     time.Time `json:"time"`
	Method   string    `json:"method"`
	Path     string    `json:"path"`
	Body     string    `json:"body"`
	Response string    `json:"response"`
}

RequestLog records a request to the mock server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL