Documentation ¶
Index ¶
- Constants
- Variables
- func Anonymize(method string, s string) string
- func AnonymizeSql(method string, sqlId, sql string) string
- func Choose(msg string, items []string) (string, error)
- func Confirm(msg string) bool
- func CountAuditlogs(ctx context.Context, db *sqlx.DB, dbname, table string, opts AuditLogScanOpts) (int, error)
- func DecodeReplaySqls(s *bufio.Scanner, dbs, users map[string]struct{}, from, to int64, maxCount int) (map[string][]*ReplaySql, int64, error)
- func DetectCharset(r *bufio.Reader) (string, error)
- func EncodeReplaySql(ts, client, user, db, queryId, stmt string) string
- func ExpandHome(path string) string
- func ExtractQueriesFromAuditLogs(auditlogPaths []string, encoding string, opts AuditLogScanOpts, parallel int) ([][]string, error)
- func GetDBAuditLogs(ctx context.Context, db *sqlx.DB, dbname, table string, opts AuditLogScanOpts, ...) ([]string, error)
- func GetEncoding(name string) (encoding.Encoding, error)
- func GetLocalIP() string
- func NewDB(host string, port int16, user, password, db string) (*sqlx.DB, error)
- func ParallelGroup(parallel int) *errgroup.Group
- func RandStr(length int) string
- func ReplaySqls(ctx context.Context, host string, port int16, user, password string, ...) error
- func SanitizeLike(s string) string
- func ScpFromRemote(ctx context.Context, privKey, remoteUrl, localPath string) error
- func SetupAnonymizer(idMinLength int, reserveIds ...string)
- func ShowDatabases(ctx context.Context, conn *sqlx.DB, dbnamePrefix string) ([]string, error)
- func ShowFronendsDisksDir(ctx context.Context, conn *sqlx.DB, diskType string) (dir string, err error)
- func SshLs(ctx context.Context, privKey, remoteUrl string) ([]string, error)
- func WriteFile(path string, content string) error
- type AuditLogScanOpts
- type AuditLogScanner
- type BytesEncoder
- type ColumnStats
- type DBSchema
- type DummyEncoder
- type ReplayClient
- type ReplayResult
- type ReplaySql
- type ReplaySqlMeta
- type Schema
- type SchemaType
- type SimpleAuditLogScanner
- type TableStats
- type Utf8Encoder
Constants ¶
View Source
const ( AnonymizeHashBytes = 4 AnonymizeHashFmt = "h%x" // add prefix 'h' )
View Source
const (
ReplayResultFileExt = ".result"
)
Variables ¶
View Source
var ( AnonymizeMinLength int AnonymizerreserveIdHashs map[string]string // Identifiers that should not be anonymized. ReserveIdentifiers = lo.Map([]string{ "olap", "global", "internal", "__internal_schema", "information_schema", }, func(s string, _ int) string { return strings.ToLower(s) }) )
View Source
var ( InternalSqlComment = "/*dorisdump*/" InternalSqlCommentBytes = []byte(InternalSqlComment) )
Functions ¶
func AnonymizeSql ¶
func CountAuditlogs ¶ added in v0.2.1
func DecodeReplaySqls ¶
func EncodeReplaySql ¶
func ExpandHome ¶
func ExtractQueriesFromAuditLogs ¶
func ExtractQueriesFromAuditLogs( auditlogPaths []string, encoding string, opts AuditLogScanOpts, parallel int, ) ([][]string, error)
ExtractQueriesFromAuditLog extracts the query from an audit log.
func GetDBAuditLogs ¶ added in v0.2.1
func GetLocalIP ¶
func GetLocalIP() string
func ParallelGroup ¶
func ReplaySqls ¶
func SanitizeLike ¶
func ScpFromRemote ¶
ScpFromRemote copies a file from a remote server to the local machine using scp.
privKey is the path to the private key to use for authentication. remoteUrl is the address of file on the remote server, format user@host:port/path. localPath is the path of the local file to copy to.
func SetupAnonymizer ¶
func ShowDatabases ¶
func ShowFronendsDisksDir ¶
Types ¶
type AuditLogScanOpts ¶ added in v0.2.1
type AuditLogScanner ¶
type AuditLogScanner interface { Init() ScanOne(oneLine []byte) error Result() (sqls []string) Close() }
func NewAuditLogScanner ¶
func NewAuditLogScanner(opts AuditLogScanOpts) AuditLogScanner
type BytesEncoder ¶
func NewBytesEncoder ¶
func NewBytesEncoder(srcEncoding encoding.Encoding) BytesEncoder
type ColumnStats ¶
type DBSchema ¶
type DBSchema struct { Name string `yaml:"db"` Schemas []*Schema `yaml:"-"` Stats []*TableStats `yaml:"tables,omitempty"` }
type DummyEncoder ¶
type DummyEncoder struct { }
type ReplayClient ¶
type ReplayClient struct {
// contains filtered or unexported fields
}
func (*ReplayClient) Close ¶
func (c *ReplayClient) Close(closefile bool)
type ReplayResult ¶
type ReplayResult struct { QueryId string `json:"queryId"` ReturnRows int `json:"returnRows"` ReturnRowsHash string `json:"returnRowsHash,omitempty"` DurationMs int64 `json:"durationMs"` Err string `json:"err,omitempty"` }
func (*ReplayResult) String ¶
func (re *ReplayResult) String() string
type ReplaySql ¶
type ReplaySql struct { ReplaySqlMeta Stmt string }
type ReplaySqlMeta ¶
type ReplaySqlMeta struct { Ts_ string `json:"ts"` Ts int64 `json:"-"` Client string `json:"client"` User string `json:"user"` Db string `json:"db"` QueryId string `json:"queryId"` }
ReplaySqlMeta will be prepend to every sql as a comment.
e.g. "/*dorisdump{"ts": "2024-09-20 00:00:00", "client": "127.0.0.1:32345", "user": "root", "db": "test", "queryId": "1"}*/ <the sql>"
func (*ReplaySqlMeta) Timestamp ¶
func (m *ReplaySqlMeta) Timestamp() (ms int64, err error)
type Schema ¶
type Schema struct { Name string `db:"TABLE_NAME"` Type SchemaType `db:"TABLE_TYPE"` DB string `db:"TABLE_SCHEMA"` CreateStmt string `db:"-"` }
func ShowCreateTables ¶
func ShowTables ¶
type SchemaType ¶
type SchemaType string
var ( SchemaTypeTable SchemaType = "TABLE" SchemaTypeView SchemaType = "VIEW" SchemaTypeMaterializedView SchemaType = "MATERIALIZED_VIEW" )
func (SchemaType) Lower ¶
func (s SchemaType) Lower() string
type SimpleAuditLogScanner ¶
type SimpleAuditLogScanner struct { AuditLogScanOpts // contains filtered or unexported fields }
func NewSimpleAuditLogScanner ¶
func NewSimpleAuditLogScanner(opts AuditLogScanOpts) *SimpleAuditLogScanner
func (*SimpleAuditLogScanner) Close ¶
func (s *SimpleAuditLogScanner) Close()
func (*SimpleAuditLogScanner) Init ¶
func (s *SimpleAuditLogScanner) Init()
func (*SimpleAuditLogScanner) Result ¶
func (s *SimpleAuditLogScanner) Result() []string
func (*SimpleAuditLogScanner) ScanOne ¶
func (s *SimpleAuditLogScanner) ScanOne(oneLog []byte) error
type TableStats ¶
type TableStats struct { Name string `yaml:"name"` RowCount int64 `yaml:"row_count"` Columns []*ColumnStats `yaml:"columns,omitempty"` }
func GetTablesStats ¶
type Utf8Encoder ¶
type Utf8Encoder struct {
// contains filtered or unexported fields
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.