Documentation
¶
Index ¶
- type AuditLogDecoder
- type AuditLogExtensionDecoder
- func (decoder *AuditLogExtensionDecoder) Decode(reader LineReader) (retCmd *Command, err error)
- func (decoder *AuditLogExtensionDecoder) EnableFilterCommandWithRetry()
- func (decoder *AuditLogExtensionDecoder) SetCommandEndTime(t time.Time)
- func (decoder *AuditLogExtensionDecoder) SetCommandStartTime(t time.Time)
- func (decoder *AuditLogExtensionDecoder) SetIDAllocator(alloc *ConnIDAllocator)
- func (decoder *AuditLogExtensionDecoder) SetPSCloseStrategy(s PSCloseStrategy)
- func (decoder *AuditLogExtensionDecoder) SetUserAllowlist(users []string)
- type AuditLogPluginDecoder
- func (decoder *AuditLogPluginDecoder) Decode(reader LineReader) (*Command, error)
- func (decoder *AuditLogPluginDecoder) EnableFilterCommandWithRetry()
- func (decoder *AuditLogPluginDecoder) SetCommandEndTime(t time.Time)
- func (decoder *AuditLogPluginDecoder) SetCommandStartTime(t time.Time)
- func (decoder *AuditLogPluginDecoder) SetIDAllocator(alloc *ConnIDAllocator)
- func (decoder *AuditLogPluginDecoder) SetPSCloseStrategy(s PSCloseStrategy)
- func (decoder *AuditLogPluginDecoder) SetUserAllowlist(users []string)
- type CmdDecoder
- type CmdEncoder
- type Command
- type ConnIDAllocator
- type DeDup
- type DupItem
- type LineReader
- type NativeDecoder
- type NativeEncoder
- type PSCloseStrategy
- type TrafficFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditLogDecoder ¶
type AuditLogDecoder interface {
CmdDecoder
SetPSCloseStrategy(s PSCloseStrategy)
SetIDAllocator(alloc *ConnIDAllocator)
SetCommandEndTime(t time.Time)
EnableFilterCommandWithRetry()
SetUserAllowlist(users []string)
}
func NewAuditLogExtensionDecoder ¶
func NewAuditLogExtensionDecoder(lg *zap.Logger) AuditLogDecoder
func NewAuditLogPluginDecoder ¶
func NewAuditLogPluginDecoder(dedup *DeDup, lg *zap.Logger) AuditLogDecoder
type AuditLogExtensionDecoder ¶
type AuditLogExtensionDecoder struct {
// contains filtered or unexported fields
}
func (*AuditLogExtensionDecoder) Decode ¶
func (decoder *AuditLogExtensionDecoder) Decode(reader LineReader) (retCmd *Command, err error)
func (*AuditLogExtensionDecoder) EnableFilterCommandWithRetry ¶
func (decoder *AuditLogExtensionDecoder) EnableFilterCommandWithRetry()
EnableFilterCommandWithRetry implements AuditLogDecoder.
func (*AuditLogExtensionDecoder) SetCommandEndTime ¶
func (decoder *AuditLogExtensionDecoder) SetCommandEndTime(t time.Time)
SetCommandEndTime implements AuditLogDecoder.
func (*AuditLogExtensionDecoder) SetCommandStartTime ¶
func (decoder *AuditLogExtensionDecoder) SetCommandStartTime(t time.Time)
SetCommandStartTime implements AuditLogDecoder.
func (*AuditLogExtensionDecoder) SetIDAllocator ¶
func (decoder *AuditLogExtensionDecoder) SetIDAllocator(alloc *ConnIDAllocator)
SetIDAllocator implements AuditLogDecoder.
func (*AuditLogExtensionDecoder) SetPSCloseStrategy ¶
func (decoder *AuditLogExtensionDecoder) SetPSCloseStrategy(s PSCloseStrategy)
SetPSCloseStrategy implements AuditLogDecoder.
func (*AuditLogExtensionDecoder) SetUserAllowlist ¶
func (decoder *AuditLogExtensionDecoder) SetUserAllowlist(users []string)
SetUserAllowlist implements AuditLogDecoder.
type AuditLogPluginDecoder ¶
type AuditLogPluginDecoder struct {
// contains filtered or unexported fields
}
func (*AuditLogPluginDecoder) Decode ¶
func (decoder *AuditLogPluginDecoder) Decode(reader LineReader) (*Command, error)
func (*AuditLogPluginDecoder) EnableFilterCommandWithRetry ¶
func (decoder *AuditLogPluginDecoder) EnableFilterCommandWithRetry()
EnableFilterCommandWithRetry enables filtering out commands that are retries according to the audit log.
func (*AuditLogPluginDecoder) SetCommandEndTime ¶
func (decoder *AuditLogPluginDecoder) SetCommandEndTime(t time.Time)
func (*AuditLogPluginDecoder) SetCommandStartTime ¶
func (decoder *AuditLogPluginDecoder) SetCommandStartTime(t time.Time)
func (*AuditLogPluginDecoder) SetIDAllocator ¶
func (decoder *AuditLogPluginDecoder) SetIDAllocator(alloc *ConnIDAllocator)
func (*AuditLogPluginDecoder) SetPSCloseStrategy ¶
func (decoder *AuditLogPluginDecoder) SetPSCloseStrategy(s PSCloseStrategy)
func (*AuditLogPluginDecoder) SetUserAllowlist ¶
func (decoder *AuditLogPluginDecoder) SetUserAllowlist(users []string)
SetUserAllowlist restricts decoding to audit log lines whose USER field is in the list. Matching is case-insensitive; names are stored in lowercase. Empty or all-blank entries are ignored. When users is empty after trimming, filtering is disabled.
type CmdDecoder ¶
type CmdDecoder interface {
Decode(reader LineReader) (c *Command, err error)
SetCommandStartTime(t time.Time)
}
func NewCmdDecoder ¶
func NewCmdDecoder(format TrafficFormat, dedup *DeDup, lg *zap.Logger) CmdDecoder
type CmdEncoder ¶
func NewCmdEncoder ¶
func NewCmdEncoder(_ TrafficFormat) CmdEncoder
type Command ¶
type Command struct {
PreparedStmt string
// CapturedPsID is the prepared statement ID in capture.
// The Execute command needs to update the prepared statement ID in replay.
CapturedPsID uint32
Params []any
// Payload starts with command type so that replay can reuse this byte array.
Payload []byte
StartTs time.Time
// For audit log plugin, the decoder will allocate a new id to avoid id collision. To make it easier
// to debug, we keep the upstream connection id here to store it in the exception report.
UpstreamConnID uint64
ConnID uint64
Type pnet.Command
// When the replay connection disconnects, the replayer reconnects based on the current DB of the next command.
CurDB string
// The place in the traffic file, used to report.
FileName string
Line int
// Logged only in audit log.
StmtType string
EndTs time.Time
// Logged only in native log.
Success bool
// contains filtered or unexported fields
}
type ConnIDAllocator ¶
type ConnIDAllocator struct {
// contains filtered or unexported fields
}
ConnIDAllocator allocates connection IDs for new connections. It uses the first 10bits to distinguish different decoders, and the last 54bits are auto-incremented.
func NewConnIDAllocator ¶
func NewConnIDAllocator(decoderID int) (*ConnIDAllocator, error)
NewConnIDAllocator creates a new ConnIDAllocator.
type LineReader ¶
type NativeDecoder ¶
type NativeDecoder struct {
// contains filtered or unexported fields
}
func NewNativeDecoder ¶
func NewNativeDecoder() *NativeDecoder
func (*NativeDecoder) Decode ¶
func (rw *NativeDecoder) Decode(reader LineReader) (c *Command, err error)
func (*NativeDecoder) SetCommandStartTime ¶
func (rw *NativeDecoder) SetCommandStartTime(t time.Time)
type NativeEncoder ¶
type NativeEncoder struct {
}
func NewNativeEncoder ¶
func NewNativeEncoder() *NativeEncoder
type PSCloseStrategy ¶
type PSCloseStrategy string
PSCloseStrategy defines when to close the prepared statements.
const ( // PSCloseStrategyAlways means a prepared statement is closed right after it's executed. PSCloseStrategyAlways PSCloseStrategy = "always" // PSCloseStrategyNever means a prepared statement is never closed. It's re-used if the same statement // occurs again in the connection. PSCloseStrategyNever PSCloseStrategy = "never" // PSCloseStrategyDirected means a prepared statement is closed only when there's close command in the // traffic file. PSCloseStrategyDirected PSCloseStrategy = "directed" )
type TrafficFormat ¶
type TrafficFormat string
TrafficFormat is the supported format of traffic files.
const ( FormatNative TrafficFormat = "native" FormatAuditLogPlugin TrafficFormat = "audit_log_plugin" FormatAuditLogExtension TrafficFormat = "audit_log_extension" )
func (TrafficFormat) IsAuditLogFormat ¶
func (f TrafficFormat) IsAuditLogFormat() bool
func (TrafficFormat) String ¶
func (f TrafficFormat) String() string