config

package
v0.0.0-...-721af93 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SeedsToBytes

func SeedsToBytes(s *Seeds) []byte

SeedsToBytes marshal the seeds

func SeedsToFile

func SeedsToFile(seeds *Seeds, file string) error

SeedsToFile write the seeds to file

func ToBytes

func ToBytes(config *Config) []byte

ToBytes marshal the config

Types

type Cluster

type Cluster struct {
	Gossip bool   `yaml:"gossip"` // if run as gossip cluster mode
	Group  string `yaml:"group"`  // cluster name
	Port   uint16 `yaml:"port"`   // gossip binding port, random if not set
}

Cluster specify the arguments to run cluster

type Config

type Config struct {
	Slave           bool              `yaml:"slave"`           // run as slave in the cluster
	Port            uint16            `yaml:"serverport"`      // server port
	Interval        uint16            `yaml:"interval"`        // report interval
	SlowThresholdMs int64             `yaml:"slowthresholdms"` // threshold to record slow query
	Cluster         Cluster           `yaml:"cluster"`         // cluster config
	Probe           Probe             `yaml:"probe"`           // probe conifg, only slave will start a probe
	Pusher          Pusher            `yaml:"pusher"`          // pusher config
	Watcher         ConnectionWatcher `yaml:"watcher"`         // connection watcher config
	Websocket       Websocket         `yaml:"websocket"`       // websocket config
	Role            string            `yaml:"-"`               // role of this node
	Path            string            `yaml:"-"`               // config file path
}

Config holds the parameters starting probe, server and cluster

func ReadFile

func ReadFile(file string) (*Config, error)

ReadFile load config from file

type ConnectionWatcher

type ConnectionWatcher struct {
	Uname    string `yaml:"uname"`
	Password string `yaml:"password"`
}

ConnectionWatcher is the config of util.ConnectionWatcher

type Probe

type Probe struct {
	Device  string `yaml:"device"`       // local devices probe monitor, splited by ','
	Port    uint16 `yaml:"port"`         // port for bpf filter
	SnapLen int32  `yaml:"snappylength"` // snappy buffer length
	Workers int    `yaml:"workers"`      // worker number
}

Probe specify the arguments to initialize pcap

type Pusher

type Pusher struct {
	Servers    string `yaml:"servers"`    // server list splited by ','
	Path       string `yaml:"path"`       // websocket path
	Preconnect bool   `yaml:"preconnect"` // preconnect to all servers
}

Pusher specify the arguments to create static receiver pool

type Seeds

type Seeds struct {
	Epic  uint64   `yaml:"epic"`
	Name  string   `yaml:"name"`
	Addrs []string `yaml:"seeds"`
	Role  string   `yaml:"role"`
}

Seeds holds the basic cluster infomation

func SeedsFromFile

func SeedsFromFile(file string) (*Seeds, error)

SeedsFromFile read seed from file

type Websocket

type Websocket struct {
	ConnectTimeoutMs int   `yaml:"connecttimeoutms"`
	WriteTimeoutMs   int   `yaml:"writetimeoutms"`
	PingTimeoutS     int   `yaml:"pingtimeouts"`
	ReconnectPeriodS int   `yaml:"reconnectperiods"`
	MaxMessageSize   int64 `yaml:"maxmessagesize"`
}

Websocket is the config of websocket client and server

Jump to

Keyboard shortcuts

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