feat: Python(Locust) + Go(boomer) 混合压测框架(演示版)

This commit is contained in:
WbiubiuW
2026-09-22 21:35:03 +08:00
commit 26cdd4b5c1
63 changed files with 6171 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package boomer
import (
"github.com/ugorji/go/codec"
)
var (
mh codec.MsgpackHandle
)
type message struct {
Type string `codec:"type"`
Data interface{} `codec:"data"`
NodeID string `codec:"node_id"`
}
func newMessage(t string, data interface{}, nodeID string) (msg *message) {
return &message{
Type: t,
Data: data,
NodeID: nodeID,
}
}
func (m *message) serialize() (out []byte, err error) {
mh.StructToArray = true
enc := codec.NewEncoderBytes(&out, &mh)
err = enc.Encode(m)
return out, err
}
func newMessageFromBytes(raw []byte) (newMsg *message, err error) {
mh.StructToArray = true
dec := codec.NewDecoderBytes(raw, &mh)
newMsg = &message{}
err = dec.Decode(newMsg)
return newMsg, err
}