Documentation
¶
Overview ¶
Package fastdev 流量录制和回放,名称源自 didi fastdev 项目。
Index ¶
- Constants
- func Delete(sessionID string)
- func GetReplaySessionID(ctx context.Context) string
- func NewSessionID() string
- func RecordAction(ctx context.Context, action *Action)
- func RecordMode() bool
- func ReplayAction(ctx context.Context, action *Action) (bool, error)
- func ReplayMode() bool
- func SetAgentConfig(config AgentConfig)
- func SetRecordMode(mode bool)
- func SetReplayMode(mode bool, agent bool)
- func Store(session *Session)
- type Action
- type AgentConfig
- type RawMessageSlice
- type Session
Constants ¶
View Source
const ( HTTP = "http" REDIS = "redis" APCU = "apcu" )
View Source
const RecordSessionIDKey = "RECORD-SESSION-ID"
RecordSessionIDKey 流量录制模式下存储会话 ID 使用的 Key 。
View Source
const ReplaySessionIDKey = "REPLAY-SESSION-ID"
ReplaySessionIDKey 流量回放模式下存储会话 ID 使用的 Key 。
Variables ¶
This section is empty.
Functions ¶
func GetReplaySessionID ¶
GetReplaySessionID 获取绑定在 context.Context 对象上的 Session ID 。
func RecordAction ¶
RecordAction 录制一个动作,会话 ID 从 Context 对象中获取。
func ReplayAction ¶
ReplayAction 根据 action 传入的匹配信息返回对应的响应数据。
Types ¶
type Action ¶
type Action struct {
Protocol string `json:"protocol,omitempty"` // 协议名称
Request interface{} `json:"request,omitempty"` // 请求内容
Response interface{} `json:"response,omitempty"` // 响应内容
Timestamp int64 `json:"timestamp"` // 时间戳
}
Action 将上下游调用、缓存获取、文件写入等抽象为一个动作。
type RawMessageSlice ¶
type RawMessageSlice []json.RawMessage
func (RawMessageSlice) Len ¶
func (p RawMessageSlice) Len() int
func (RawMessageSlice) Less ¶
func (p RawMessageSlice) Less(i, j int) bool
func (RawMessageSlice) Swap ¶
func (p RawMessageSlice) Swap(i, j int)
type Session ¶
type Session struct {
Session string `json:"session,omitempty"` // 会话 ID
Inbound *Action `json:"inbound,omitempty"` // 上游数据
Actions []*Action `json:"actions,omitempty"` // 动作数据
}
Session 一次上游调用称为一个会话。
func RecordInbound ¶
RecordInbound 录制上游流量,会话 ID 从 Context 对象中获取。
Click to show internal directories.
Click to hide internal directories.