engine

package
v0.0.0-...-4b2efa1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoticeColor  = "\033[1;36m%s\033[0m"
	WarningColor = "\033[1;33m%s\033[0m"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BenchmarkConfig

type BenchmarkConfig struct {
	Plugin string `mapstructure:"benchmark"`

	// Plugin specific config
	PluginConfig interface{}
}

type Config

type Config struct {
	GlobalCfg    GlobalConfig      `mapstructure:"global"`
	DB           util.DBConnParams `mapstructure:"database"`
	GeneratorCfg GeneratorConfig   `mapstructure:"generator"`
	WriterCfg    WriterConfig      `mapstructure:"writer"`
	BenchmarkCfg BenchmarkConfig   `mapstructure:"benchmark"`

	// print config usage
	Usage func()

	NewGeneratorFunc NewGeneratorFunc
	NewWriterFunc    NewWriterFunc
	NewBenchmarkFunc NewBenchmarkFunc
}

func NewConfig

func NewConfig() (*Config, error)

func (*Config) DBFlagSet

func (cfg *Config) DBFlagSet() *pflag.FlagSet

func (*Config) GlobalFlagSet

func (cfg *Config) GlobalFlagSet() *pflag.FlagSet

type ConfigurablePlugin

type ConfigurablePlugin interface {
	// CreatePluginConfig returns a plugin specific config struct, can have any k=>v pairs
	// It is plugin author's responsibility to tag "`mapstructure:"<key-name>"`" on struct members
	// to make it able to export/import with config file
	CreatePluginConfig() interface{}

	// GetDefaultFlags returns a flagSet struct which have all flags with specified name, value, and usage string.
	// Those key names should be consistent with tags "`mapstructure:"<key-name>"`" on the config struct
	// The second return value is the plugin config struct created inside this function
	GetDefaultFlags() (*pflag.FlagSet, interface{})
}

type Engine

type Engine struct {
	IGenerator IGenerator
	IWriter    IWriter
	IBenchmark IBenchmark
	Metadata   *metadata.Metadata
	VolumeDesc VolumeDesc

	Config *Config
	// contains filtered or unexported fields
}

func NewEngineFromConfig

func NewEngineFromConfig(cfg *Config) (*Engine, error)

func (*Engine) Close

func (e *Engine) Close() error

func (*Engine) GetFormattedSummary

func (e *Engine) GetFormattedSummary()

func (*Engine) IsNil

func (e *Engine) IsNil() bool

func (*Engine) PrintProgress

func (e *Engine) PrintProgress()

func (*Engine) PrintStat

func (e *Engine) PrintStat()

func (*Engine) Run

func (e *Engine) Run() error

func (*Engine) Watch

func (e *Engine) Watch()

type ExecBenchFunc

type ExecBenchFunc func(context.Context, Query, Stat) error

type ExecBenchOption

type ExecBenchOption struct {
	Parallel int
	RunTimes int64
	Duration time.Duration
}

type ExecBenchStat

type ExecBenchStat struct {
	TPS        int           `json:"tps"`
	AvgLatency time.Duration `json:"avg-latency"`
	MaxLatency time.Duration `json:"max-latency"`
	P75Latency time.Duration `json:"p75-latency"`
	P50Latency time.Duration `json:"p50-latency"`
	P25Latency time.Duration `json:"p25-latency"`

	TimeElapsed int64 `json:"overall-duration"`
	// contains filtered or unexported fields
}

func NewExecBenchStat

func NewExecBenchStat(opt ExecBenchOption, query Query) *ExecBenchStat

func (*ExecBenchStat) AddSubStat

func (ebs *ExecBenchStat) AddSubStat(_ Stat)

func (*ExecBenchStat) GetCurrentProgress

func (ebs *ExecBenchStat) GetCurrentProgress(_ ...interface{}) map[string]interface{}

func (*ExecBenchStat) GetFormattedSummary

func (ebs *ExecBenchStat) GetFormattedSummary() string

GetFormattedSummary is aimed at outputing statistics in certain format. No data in will be rounded.

func (*ExecBenchStat) GetName

func (ebs *ExecBenchStat) GetName() string

func (*ExecBenchStat) GetProgress

func (ebs *ExecBenchStat) GetProgress() string

func (*ExecBenchStat) GetSubStats

func (ebs *ExecBenchStat) GetSubStats() []Stat

func (*ExecBenchStat) GetSummary

func (ebs *ExecBenchStat) GetSummary() string

GetSummary is aimed at presenting statistics to the user in the form of a table empowered by go-pretty. Any data in float will be rounded to 2 decimal places.

type ExecDDLFunc

type ExecDDLFunc func() error

type ExecSetGUCsFunc

type ExecSetGUCsFunc func() error

type GeneratorConfig

type GeneratorConfig struct {
	Plugin string `mapstructure:"generator"`

	// Plugin specific config
	PluginConfig interface{}

	// derived from elsewhere
	GlobalConfig *GlobalConfig
}

type GeneratorPrediction

type GeneratorPrediction struct {
	Count, Size int64
}

type GetTableSizeFunc

type GetTableSizeFunc func() (int64, error)

type GlobalConfig

type GlobalConfig struct {
	SchemaName               string               `mapstructure:"schema-name"`
	TableName                string               `mapstructure:"table-name"`
	TagNum                   int64                `mapstructure:"tag-num"`
	TimestampStart           string               `mapstructure:"ts-start"`
	TimestampEnd             string               `mapstructure:"ts-end"`
	PartitionIntervalInHour  int64                `mapstructure:"partition-inteval-in-hour"`
	IsRealtimeMode           bool                 `mapstructure:"realtime"`
	MetricsType              metadata.MetricsType `mapstructure:"metrics-type"`
	TotalMetricsCount        int64                `mapstructure:"total-metrics-count"`
	TimestampStepInSecond    uint64               `mapstructure:"ts-step-in-second"`
	Dump                     bool                 `mapstructure:"dump"`
	MetricsDescriptions      string               `mapstructure:"metrics-descriptions"`
	Workspace                string               `mapstructure:"workspace"`
	DDLFilePath              string               `mapstructure:"ddl-file-path"`
	SimultaneousLoadAndQuery bool                 `mapstructure:"simultaneous-loading-and-query"`
	PreBenchmarkQuery        string               `mapstructure:"pre-benchmark-query"`
	SkipSetGUCs              bool                 `mapstructure:"skip-set-gucs"`
	StorageType              string               `mapstructure:"storage-type"`
	Degrade                  bool                 `mapstructure:"degrade"`

	// misc
	Command       string
	CfgFile       string
	HelpWanted    bool   `mapstructure:"help"`
	VersionWanted bool   `mapstructure:"version"`
	LogLevel      string `mapstructure:"log-level"`
	Watch         bool   `mapstructure:"watch"`
	CPUProfile    bool

	StartAt time.Time
	EndAt   time.Time

	ReportPath   string       `mapstructure:"report-path"`
	ReportFormat ReportFormat `mapstructure:"report-format"`
}

func (*GlobalConfig) DoAfterInit

func (cfg *GlobalConfig) DoAfterInit() error

func (*GlobalConfig) NewMetadataConfig

func (cfg *GlobalConfig) NewMetadataConfig() *metadata.Config

type IBenchmark

type IBenchmark interface {
	NilCheck
	ConfigurablePlugin
	Run(<-chan error, Config, *metadata.Metadata, ExecBenchFunc) error
	Close() error
	GetStat() Stat
}

type IEngine

type IEngine interface {
	NilCheck
	Run() error
	Close() error
	PrintStat()
	PrintProgress()
	GetFormattedSummary()
}

type IGenerator

type IGenerator interface {
	NilCheck
	ConfigurablePlugin
	GetPrediction(*metadata.Table) (GeneratorPrediction, error)
	ModifyMetadataConfig(*metadata.Config)
	Run(GlobalConfig, *metadata.Metadata, WriteFunc) error
	Close() error
}

type IWriter

type IWriter interface {
	NilCheck
	ConfigurablePlugin
	// Close finCh after writer ended.
	Start(Config, VolumeDesc) (finCh <-chan error, err error)
	Stop() error
	Write([]byte, int64, int64) error
	WriteEOF() error
	GetStat() Stat
}

type NewBenchmarkFunc

type NewBenchmarkFunc func(cfg BenchmarkConfig) IBenchmark

type NewGeneratorFunc

type NewGeneratorFunc func(cfg GeneratorConfig) IGenerator

type NewWriterFunc

type NewWriterFunc func(cfg WriterConfig) IWriter

type NilCheck

type NilCheck interface {
	IsNil() bool
}

type Query

type Query interface {
	GetSQL() string
	GetName() string
}

type ReportFormat

type ReportFormat = string
const (
	ReportFormatCSV  ReportFormat = "csv"
	ReportFormatJSON ReportFormat = "json"
)

type Stat

type Stat interface {
	AddSubStat(Stat)

	GetName() string
	GetSummary() string
	GetFormattedSummary() string
	GetProgress() string
	GetSubStats() []Stat

	GetCurrentProgress(opt ...interface{}) map[string]interface{}
}

type VolumeDesc

type VolumeDesc struct {
	GeneratorPrediction GeneratorPrediction
	GetTableSizeFunc    GetTableSizeFunc
}

type WriteFunc

type WriteFunc func([]byte, int64, int64) error

type WriterConfig

type WriterConfig struct {
	Plugin string `mapstructure:"writer"`

	// Plugin specific config
	PluginConfig interface{}
}

Directories

Path Synopsis
nil
nil
nil

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL