config

package
v2.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DiscoveryWaySerf uint = iota
	DiscoveryWayMemberlist
	DiscoveryWayMDNS
	DiscoveryWayStatic
)
View Source
const (
	RaftImplHashicorp uint = iota
	RaftImplEtcd
)
View Source
const (
	StorageWayMemory uint = iota
	StorageWayBolt
	StorageWayBadger
	StorageWayRedis
)
View Source
const (
	AuthModeAnonymous uint = iota
	AuthModeUsername
	AuthModeClientid
)
View Source
const (
	AuthDSFree uint = iota
	AuthDSRedis
	AuthDSMysql
	AuthDSPostgresql
	AuthDSHttp
)
View Source
const (
	BridgeWayNone uint = iota
	BridgeWayKafka
)

Variables

View Source
var (
	ErrAuthWay     = errors.New("auth-way is incorrectly configured")
	ErrStorageWay  = errors.New("only redis can be used in cluster mode")
	ErrClusterOpts = errors.New("cluster options must be configured")

	ErrAppendCerts      = errors.New("append ca cert failure")
	ErrMissingCertOrKey = errors.New("missing server certificate or private key files")
)

Functions

func GenTlsConfig

func GenTlsConfig(conf *Config) (*tls2.Config, error)

Types

type Cluster

type Cluster struct {
	DiscoveryWay         uint              `yaml:"discovery-way"  json:"discovery-way"`
	NodeName             string            `yaml:"node-name" json:"node-name"`
	BindAddr             string            `yaml:"bind-addr" json:"bind-addr"`
	BindPort             int               `yaml:"bind-port" json:"bind-port"`
	AdvertiseAddr        string            `yaml:"advertise-addr" json:"advertise-addr"`
	AdvertisePort        int               `yaml:"advertise-port" json:"advertise-port"`
	Members              []string          `yaml:"members" json:"members"`
	QueueDepth           int               `yaml:"queue-depth" json:"queue-depth"`
	Tags                 map[string]string `yaml:"tags" json:"tags"`
	RaftImpl             uint              `yaml:"raft-impl" json:"raft-impl"`
	RaftPort             int               `yaml:"raft-port" json:"raft-port"`
	RaftDir              string            `yaml:"raft-dir" json:"raft-dir"`
	RaftBootstrap        bool              `yaml:"raft-bootstrap" json:"raft-bootstrap"`
	GrpcEnable           bool              `yaml:"grpc-enable" json:"grpc-enable"`
	GrpcPort             int               `yaml:"grpc-port" json:"grpc-port"`
	InboundPoolSize      int               `yaml:"inbound-pool-size" json:"inbound-pool-size"`
	OutboundPoolSize     int               `yaml:"outbound-pool-size" json:"outbound-pool-size"`
	InoutPoolNonblocking bool              `yaml:"inout-pool-nonblocking" json:"inout-pool-nonblocking"`
}

type Config

type Config struct {
	StorageWay  uint    `yaml:"storage-way"`
	StoragePath string  `yaml:"storage-path"`
	BridgeWay   uint    `yaml:"bridge-way"`
	BridgePath  string  `yaml:"bridge-path"`
	Auth        auth    `yaml:"auth"`
	Mqtt        mqtt    `yaml:"mqtt"`
	Cluster     Cluster `yaml:"cluster"`
	Redis       redis   `yaml:"redis"`
	Log         Log     `yaml:"log"`
}

func Load

func Load(yamlFile string) (*Config, error)

func New

func New() *Config

type Log

type Log struct {
	// Enable Log enabled or not
	Enable bool `json:"enable" yaml:"enable"`

	// Env app running environment,0 development or 1 production
	Env int `json:"env" yaml:"env"`

	// NodeName used in a cluster environment to distinguish nodes
	NodeName string `json:"node-name" yaml:"node-name"`

	// Format output format 0 console or 1 json
	Format int `json:"format" yaml:"format"`

	// Whether to display code line number
	Caller bool `json:"caller" yaml:"caller"`

	// Filename is the file to write logs to.  Backup log files will be retained
	// in the same directory.  It uses <processname>-lumberjack.log in
	// os.TempDir() if empty.
	InfoFile       string `json:"info-file" yaml:"info-file"`
	ErrorFile      string `json:"error-file" yaml:"error-file"`
	ThirdpartyFile string `json:"thirdparty-file" yaml:"thirdparty-file"`

	// MaxSize is the maximum size in megabytes of the log file before it gets
	// rotated. It defaults to 100 megabytes.
	MaxSize int `json:"maxsize" yaml:"maxsize"`

	// MaxAge is the maximum number of days to retain old log files based on the
	// timestamp encoded in their filename.  Note that a day is defined as 24
	// hours and may not exactly correspond to calendar days due to daylight
	// savings, leap seconds, etc. The default is not to remove old log files
	// based on age.
	MaxAge int `json:"max-age" yaml:"max-age"`

	// MaxBackups is the maximum number of old log files to retain.  The default
	// is to retain all old log files (though MaxAge may still cause them to get
	// deleted.)
	MaxBackups int `json:"max-backups" yaml:"max-backups"`

	// LocalTime determines if the time used for formatting the timestamps in
	// backup files is the computer's local time.  The default is to use UTC
	// time.
	Localtime bool `json:"localtime" yaml:"localtime"`

	// Compress determines if the rotated log files should be compressed
	// using gzip. The default is not to perform compression.
	Compress bool `json:"compress" yaml:"compress"`

	// Log Level: -1Trace 0Debug 1Info 2Warn 3Error(default) 4Fatal 5Panic 6NoLevel 7Off
	Level int `json:"level" yaml:"level"`
	Sampler
}

type Sampler

type Sampler struct {
	Burst  int `json:"burst" yaml:"burst"`
	Period int `json:"period" yaml:"period"`
}

Jump to

Keyboard shortcuts

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