feat(go): add load simulator hold mode

This commit is contained in:
lingniu
2026-07-03 18:01:40 +08:00
parent c1fe1fbfb5
commit 291bffa340
7 changed files with 58 additions and 5 deletions

View File

@@ -37,6 +37,9 @@ func (r Runner) Run(ctx context.Context, cfg Config) (Stats, error) {
if err != nil {
return Stats{}, err
}
if !cfg.SendFrames {
payload = nil
}
dial := r.Dial
if dial == nil {
dialer := &net.Dialer{Timeout: 5 * time.Second, KeepAlive: 30 * time.Second}
@@ -68,7 +71,11 @@ func (r Runner) Run(ctx context.Context, cfg Config) (Stats, error) {
go func() {
defer wg.Done()
defer conn.Close()
writeLoop(runCtx, conn, payload, cfg.SendInterval, &stats)
if cfg.SendFrames {
writeLoop(runCtx, conn, payload, cfg.SendInterval, &stats)
return
}
<-runCtx.Done()
}()
}
}