Files
perf-harness-demo/go/main.go
T

27 lines
695 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"flag"
"log"
"github.com/myzhan/boomer"
)
func main() {
// 注意:boomer 在 init 里已注册 --master-host/--master-port 等 flag,
// 这里只新增自己的 flag,绝不能重复定义(会 panic)。
target := flag.String("target", "http://127.0.0.1:18099", "被测 mock 地址(只打本机)")
flag.Parse()
client := NewAPIClient(*target)
tasks := buildBoomerTasks(client)
log.Printf("[go-worker] target=%s, tasks=%d", *target, len(tasks))
boomer.Events.Subscribe("boomer:spawn", func(workers int, spawnRate float64) {
log.Printf("[go-worker] master asks to spawn %d workers (rate %.0f)", workers, spawnRate)
})
boomer.Run(tasks...)
}