config

package
v0.0.0-...-6530c03 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(filePath string) bool

func True

func True(b *bool) bool

True returns true if b is non-nil and true. This is convenience function related to *bool files in config structs, which is required for knowing when a bool config is explicitily set or not. If set, it's not changed; if not, it's set to the default value. That makes a good config experience but a less than ideal code experience because !*b will panic if b is nil, hence the need for this func.

func ValidFreq

func ValidFreq(freq, config string) error

ValidFreq validates the freq value for the given config section and returns nil if valid, else returns an error.

func Vars

func Vars(s string, params map[string]string, numbers bool) (string, error)

Vars changes $params.foo and $FOO to param values and environment variable values, respectively, and human numbers to integers (1k -> 1000). "${var}" is also valid but YAML requires string quotes around {}.

Types

type Base

type Base struct {
	MySQL  MySQL             `yaml:"mysql,omitempty"`
	Params map[string]string `yaml:"params,omitempty"`
	Stats  Stats             `yaml:"stats,omitempty"`
}

Base represents a base config file: _all.yaml. If it exists, it applies to all stage config files in the directory.

func (*Base) Validate

func (c *Base) Validate() error

type ClientGroup

type ClientGroup struct {
	Clients       string   `yaml:"clients,omitempty"` // uint
	Db            string   `yaml:"db,omitempty"`
	DisableStats  bool     `yaml:"disable-stats,omitempty"`
	Iter          string   `yaml:"iter,omitempty"`            // uint
	IterClients   string   `yaml:"iter-clients,omitempty"`    // uint
	IterExecGroup string   `yaml:"iter-exec-group,omitempty"` // uint
	Group         string   `yaml:"group,omitempty"`
	QPS           string   `yaml:"qps,omitempty"`            // uint
	QPSClients    string   `yaml:"qps-clients,omitempty"`    // uint
	QPSExecGroup  string   `yaml:"qps-exec-group,omitempty"` // uint
	Runtime       string   `yaml:"runtime,omitempty"`
	TPS           string   `yaml:"tps,omitempty"`
	TPSClients    string   `yaml:"tps-clients,omitempty"`
	TPSExecGroup  string   `yaml:"tps-exec-group,omitempty"`
	Trx           []string `yaml:"trx,omitempty"`
}

func (*ClientGroup) Validate

func (c *ClientGroup) Validate(w []Trx) error

func (*ClientGroup) Vars

func (c *ClientGroup) Vars(params map[string]string) error

type Compute

type Compute struct {
	DisableLocal bool   `yaml:"disable-local,omitempty"`
	Instances    string `yaml:"instances,omitempty"` // uint
}

func (*Compute) Validate

func (c *Compute) Validate() error

func (*Compute) Vars

func (c *Compute) Vars(params map[string]string) error

type Data

type Data struct {
	Name      string            `yaml:"name"`      // @id
	Generator string            `yaml:"generator"` // data.Generator type
	Scope     string            `yaml:"scope"`
	Params    map[string]string `yaml:"params"` // Generator-specific params
}

func (*Data) Vars

func (c *Data) Vars(params map[string]string) error

type MySQL

type MySQL struct {
	Db             string `yaml:"db,omitempty"`
	DSN            string `yaml:"dsn,omitempty"`
	Hostname       string `yaml:"hostname,omitempty"`
	MyCnf          string `yaml:"mycnf,omitempty"`
	Password       string `yaml:"password,omitempty"`
	PasswordFile   string `yaml:"password-file,omitempty"`
	Socket         string `yaml:"socket,omitempty"`
	TimeoutConnect string `yaml:"timeout-connect,omitempty"`
	TLS            TLS    `yaml:"tls,omitempty"`
	Username       string `yaml:"username,omitempty"`

	DisableAutoTLS *bool `yaml:"disable-auto-tls,omitempty"`
}

func (MySQL) Redacted

func (c MySQL) Redacted() string

func (*MySQL) Validate

func (c *MySQL) Validate() error

func (*MySQL) Vars

func (c *MySQL) Vars(params map[string]string) error

func (*MySQL) With

func (c *MySQL) With(def MySQL)

With returns the MySQL config c with defaults from def. It's called in dbconn/factory.setDSN to apply any defaults from MySQL.MyCnf (a my.cnf defaults file), which mimics how MySQL works.

type Stage

type Stage struct {
	Compute  Compute           `yaml:"compute,omitempty"`
	Disable  bool              `yaml:"disable"`
	File     string            `yaml:"-"`
	Id       string            `yaml:"-"`
	Name     string            `yaml:"name"`
	MySQL    MySQL             `yaml:"mysql,omitempty"`
	N        uint              `yaml:"-"`
	Params   map[string]string `yaml:"params,omitempty"`
	QPS      string            `yaml:"qps,omitempty"` // uint
	Runtime  string            `yaml:"runtime,omitempty"`
	Stats    Stats             `yaml:"stats,omitempty"`
	TPS      string            `yaml:"tps,omitempty"` // uint
	Test     bool              `yaml:"-"`
	Trx      []Trx             `yaml:"trx,omitempty"`
	Workload []ClientGroup     `yaml:"workload,omitempty"`
}

Stage represents one stage config file. The stage config overwrites any base config (_all.yaml).

func Load

func Load(stageFiles []string, kvparams []string, dsn, db string) ([]Stage, error)

func (*Stage) CommandLine

func (c *Stage) CommandLine(dsn, db string)

func (*Stage) Validate

func (c *Stage) Validate() error

func (*Stage) Vars

func (c *Stage) Vars() error

func (*Stage) With

func (c *Stage) With(b Base)

type Stats

type Stats struct {
	Disable *bool                        `yaml:"disable"`
	Freq    string                       `yaml:"freq,omitempty"`
	Report  map[string]map[string]string `yaml:"report,omitempty"`
}

func (*Stats) Validate

func (c *Stats) Validate() error

func (*Stats) Vars

func (c *Stats) Vars(params map[string]string) error

type TLS

type TLS struct {
	CA         string `yaml:"ca,omitempty"`   // ssl-ca
	Cert       string `yaml:"cert,omitempty"` // ssl-cert
	Key        string `yaml:"key,omitempty"`  // ssl-key
	SkipVerify *bool  `yaml:"skip-verify,omitempty"`
	Disable    *bool  `yaml:"disable,omitempty"`

	// ssl-mode from a my.cnf (see dbconn.ParseMyCnf)
	MySQLMode string `yaml:"-"`
}

func (TLS) LoadTLS

func (c TLS) LoadTLS(server string) (*tls.Config, error)

func (TLS) Set

func (c TLS) Set() bool

Set return true if TLS is not disabled and at least one file is specified. If not set, Blip ignores the TLS config. If set, Blip validates, loads, and registers the TLS config.

func (*TLS) Validate

func (c *TLS) Validate() error

func (*TLS) Vars

func (c *TLS) Vars(params map[string]string) error

func (*TLS) With

func (c *TLS) With(def TLS)

type Trx

type Trx struct {
	Name string
	File string
	Data map[string]Data
}

func (*Trx) Vars

func (c *Trx) Vars(params map[string]string) error

Jump to

Keyboard shortcuts

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