config

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version represents the release version of lindb(ldflags).
	Version = "unknown"
	// BuildTime represents binary build-time(ldflags).
	BuildTime = "unknown"
)

These variables are populated via the Go linker.

View Source
var (
	// StandaloneMode represents LinDB run as standalone mode
	StandaloneMode = false

	// Profile represents profiling Go programs with pprof
	Profile = false
	// Doc enables swagger api doc.
	Doc = false
)

Functions

func LoadAndSetBrokerConfig

func LoadAndSetBrokerConfig(cfgName, defaultPath string, brokerCfg *Broker) error

LoadAndSetBrokerConfig parses the broker config file this config will be triggered to reload when receiving a SIGHUP signal

func LoadAndSetRootConfig added in v0.2.4

func LoadAndSetRootConfig(cfgName, defaultPath string, rootCfg *Root) error

LoadAndSetRootConfig parses the root config file. this config will be triggered to reload when receiving a SIGHUP signal

func LoadAndSetStandAloneConfig

func LoadAndSetStandAloneConfig(cfgName, defaultPath string, standaloneCfg *Standalone) error

LoadAndSetStandAloneConfig parses the standalone config file then sets the global broker and storage config this config will be triggered to reload when receiving a SIGHUP signal

func LoadAndSetStorageConfig

func LoadAndSetStorageConfig(cfgName, defaultPath string, storageCfg *Storage) error

LoadAndSetStorageConfig parses the storage config file this config will be triggered to reload when receiving a SIGHUP signal

func NewDefaultBrokerTOML

func NewDefaultBrokerTOML() string

NewDefaultBrokerTOML creates broker default toml config

func NewDefaultRootTOML added in v0.2.4

func NewDefaultRootTOML() string

NewDefaultBrokerTOML creates root default toml config.

func NewDefaultStandaloneTOML

func NewDefaultStandaloneTOML() string

NewDefaultStandaloneTOML creates default toml config for standalone

func NewDefaultStorageTOML

func NewDefaultStorageTOML() string

NewDefaultStorageTOML creates storage's default toml config

func PrintEnvFormat added in v0.2.4

func PrintEnvFormat(v any)

PrintEnvFormat prints config as env format.

func SetGlobalBrokerConfig

func SetGlobalBrokerConfig(brokerCfg *BrokerBase)

SetGlobalBrokerConfig sets global broker configuration.

func SetGlobalStorageConfig

func SetGlobalStorageConfig(storageCfg *StorageBase)

SetGlobalStorageConfig sets global storage configuration.

Types

type Broker

type Broker struct {
	Coordinator RepoState  `envPrefix:"LINDB_COORDINATOR_" toml:"coordinator"`
	Query       Query      `envPrefix:"LINDB_QUERY_" toml:"query"`
	BrokerBase  BrokerBase `envPrefix:"LINDB_BROKER_" toml:"broker"`
	Monitor     Monitor    `envPrefix:"LINDB_MONITOR_" toml:"monitor"`
	Logging     Logging    `envPrefix:"LINDB_LOGGING_" toml:"logging"`
}

Broker represents a broker configuration with common settings

func (*Broker) TOML

func (b *Broker) TOML() string

TOML returns broker's configuration string as toml format.

type BrokerBase

type BrokerBase struct {
	SlowSQL   ltoml.Duration `env:"SLOW_SQL" toml:"slow-sql"`
	HTTP      HTTP           `envPrefix:"HTTP_" toml:"http"`
	Ingestion Ingestion      `envPrefix:"INGESTION_" toml:"ingestion"`
	Write     Write          `envPrefix:"WRITE_" toml:"write"`
	GRPC      GRPC           `envPrefix:"GRPC_" toml:"grpc"`
}

BrokerBase represents a broker configuration

func GlobalBrokerConfig

func GlobalBrokerConfig() *BrokerBase

GlobalBrokerConfig returns the global broker config

func NewDefaultBrokerBase

func NewDefaultBrokerBase() *BrokerBase

func (*BrokerBase) TOML

func (bb *BrokerBase) TOML() string

TOML returns broker's base configuration string as toml format.

type BrokerCluster added in v0.2.4

type BrokerCluster struct {
	Config *RepoState `json:"config"`
}

BrokerCluster represents config of broker cluster.

type Configuration

type Configuration interface {
	// TOML returns configuration string as toml format.
	TOML() string
}

Configuration represents node's configuration.

type ETCD

type ETCD struct {
	Dir string `env:"DIR" toml:"dir"`
	URL string `env:"URL" toml:"url"`
}

ETCD represents embed etcd's configuration

func NewDefaultETCD

func NewDefaultETCD() *ETCD

NewDefaultETCD returns a default ETCD

func (*ETCD) TOML

func (etcd *ETCD) TOML() string

TOML returns ETCD's toml config string

type GRPC

type GRPC struct {
	Port                 uint16         `env:"PORT" toml:"port"`
	MaxConcurrentStreams int            `env:"MAX_CONCURRENT_STREAMS" toml:"max-concurrent-streams"`
	ConnectTimeout       ltoml.Duration `env:"CONNECT_TIMEOUT" toml:"connect-timeout"`
}

GRPC represents grpc server config

func (*GRPC) TOML

func (g *GRPC) TOML() string

type HTTP

type HTTP struct {
	Port         uint16         `env:"PORT" toml:"port"`
	IdleTimeout  ltoml.Duration `env:"IDLE_TIMEOUT" toml:"idle-timeout"`
	WriteTimeout ltoml.Duration `env:"WRITE_TIMEOUT" toml:"write-timeout"`
	ReadTimeout  ltoml.Duration `env:"READ_TIMEOUT" toml:"read-timeout"`
}

HTTP represents an HTTP level configuration of broker.

func (*HTTP) TOML

func (h *HTTP) TOML() string

type Ingestion

type Ingestion struct {
	MaxConcurrency int            `env:"CONCURRENCY" toml:"max-concurrency"`
	IngestTimeout  ltoml.Duration `env:"TIMEOUT" toml:"ingest-timeout"`
}

func (*Ingestion) TOML

func (i *Ingestion) TOML() string

type Logging

type Logging struct {
	Dir        string     `env:"DIR" toml:"dir"`
	Level      string     `env:"LEVEL" toml:"level"`
	MaxSize    ltoml.Size `env:"MAX_SIZE" toml:"maxsize"`
	MaxBackups uint16     `env:"MAX_BACKUPS" toml:"maxbackups"`
	MaxAge     uint16     `env:"MAX_AGE" toml:"maxage"`
}

Logging represents a logging configuration

func NewDefaultLogging

func NewDefaultLogging() *Logging

NewDefaultLogging returns a new default logging config

func (*Logging) TOML

func (l *Logging) TOML() string

TOML returns Logging's toml config string

type Monitor

type Monitor struct {
	PushTimeout    ltoml.Duration `env:"PUSH_TIMEOUT" toml:"push-timeout"`
	ReportInterval ltoml.Duration `env:"REPORT_INTERVAL" toml:"report-interval"`
	URL            string         `env:"URL" toml:"url"`
}

Monitor represents a configuration for the internal monitor

func NewDefaultMonitor

func NewDefaultMonitor() *Monitor

NewDefaultMonitor returns a new default monitor config

func (*Monitor) TOML

func (m *Monitor) TOML() string

TOML returns Monitor's toml config

type Query

type Query struct {
	QueryConcurrency int            `env:"CONCURRENCY" toml:"query-concurrency"`
	IdleTimeout      ltoml.Duration `env:"IDLE_TIMEOUT" toml:"idle-timeout"`
	Timeout          ltoml.Duration `env:"TIMEOUT" toml:"timeout"`
}

Query represents query rpc config

func NewDefaultQuery

func NewDefaultQuery() *Query

func (*Query) TOML

func (q *Query) TOML() string

type RepoState

type RepoState struct {
	Namespace   string         `env:"NAMESPACE" toml:"namespace" json:"namespace" validate:"required"`
	Endpoints   []string       `env:"ENDPOINTS" envSeparator:"," toml:"endpoints" json:"endpoints" validate:"required,gt=0"`
	LeaseTTL    ltoml.Duration `env:"LEASE_TTL" toml:"lease-ttl" json:"leaseTTL"`
	Timeout     ltoml.Duration `env:"TIMEOUT" toml:"timeout" json:"timeout"`
	DialTimeout ltoml.Duration `env:"DIAL_TIMEOUT" toml:"dial-timeout" json:"dialTimeout"`
	Username    string         `env:"USERNAME" toml:"username" json:"username"`
	Password    string         `env:"PASSWORD" toml:"password" json:"password"`
}

RepoState represents state repository config

func NewDefaultCoordinator

func NewDefaultCoordinator() *RepoState

func (*RepoState) String

func (rs *RepoState) String() string

String returns string value of RepoState.

func (*RepoState) TOML

func (rs *RepoState) TOML() string

TOML returns RepoState's toml config string

func (*RepoState) WithSubNamespace

func (rs *RepoState) WithSubNamespace(subDir string) *RepoState

type Root added in v0.2.4

type Root struct {
	Coordinator RepoState `envPrefix:"LINDB_COORDINATOR_" toml:"coordinator"`
	Query       Query     `envPrefix:"LINDB_QUERY_" toml:"query"`
	HTTP        HTTP      `envPrefix:"LINDB_ROOT_HTTP_" toml:"http"`
	Monitor     Monitor   `envPrefix:"LINDB_MONITOR_" toml:"monitor"`
	Logging     Logging   `envPrefix:"LINDB_LOGGING_" toml:"logging"`
}

Root represents a root configuration with common settings.

func NewDefaultRoot added in v0.2.4

func NewDefaultRoot() *Root

NewDefaultRoot creates root default config.

func (*Root) TOML added in v0.2.4

func (r *Root) TOML() string

TOML returns root's configuration string as toml format.

type Standalone

type Standalone struct {
	ETCD        ETCD        `envPrefix:"LINDB_ETCD_" toml:"etcd"`
	Coordinator RepoState   `envPrefix:"LINDB_COORDINATOR_" toml:"coordinator"`
	Query       Query       `envPrefix:"LINDB_QUERY_" toml:"query"`
	BrokerBase  BrokerBase  `envPrefix:"LINDB_BROKER_" toml:"broker"`
	StorageBase StorageBase `envPrefix:"LINDB_STORAGE_" toml:"storage"`
	Logging     Logging     `envPrefix:"LINDB_LOGGING_" toml:"logging"`
	Monitor     Monitor     `envPrefix:"LINDB_MONITOR_" toml:"monitor"`
}

Standalone represents the configuration of standalone mode

func NewDefaultStandalone

func NewDefaultStandalone() Standalone

NewDefaultStandalone creates standalone default configuration.

type Storage

type Storage struct {
	Coordinator RepoState   `envPrefix:"LINDB_COORDINATOR_" toml:"coordinator"`
	Query       Query       `envPrefix:"LINDB_QUERY_" toml:"query"`
	StorageBase StorageBase `envPrefix:"LINDB_STORAGE_" toml:"storage"`
	Monitor     Monitor     `envPrefix:"LINDB_MONITOR_" toml:"monitor"`
	Logging     Logging     `envPrefix:"LINDB_LOGGING_" toml:"logging"`
}

Storage represents a storage configuration with common settings

func (*Storage) TOML

func (s *Storage) TOML() string

TOML returns storage's configuration string as toml format.

type StorageBase

type StorageBase struct {
	// Broker http endpoint, auto register current storage cluster.
	BrokerEndpoint  string         `env:"BROKER_ENDPOINT" toml:"broker-endpoint"`
	TTLTaskInterval ltoml.Duration `env:"TTL_TASK_INTERVAL" toml:"ttl-task-interval"`
	HTTP            HTTP           `envPrefix:"HTTP_" toml:"http"`
	GRPC            GRPC           `envPrefix:"GRPC_" toml:"grpc"`
	TSDB            TSDB           `envPrefix:"TSDB_" toml:"tsdb"`
	WAL             WAL            `envPrefix:"WAL_" toml:"wal"`
}

StorageBase represents a storage configuration

func GlobalStorageConfig

func GlobalStorageConfig() *StorageBase

GlobalStorageConfig returns the global storage config

func NewDefaultStorageBase

func NewDefaultStorageBase() *StorageBase

NewDefaultStorageBase returns a new default StorageBase struct

func (*StorageBase) TOML

func (s *StorageBase) TOML() string

TOML returns StorageBase's toml config string

type StorageCluster

type StorageCluster struct {
	Config *RepoState `json:"config"`
}

StorageCluster represents config of storage cluster.

type TSDB

type TSDB struct {
	Dir                      string         `env:"DIR" toml:"dir"`
	MaxMemDBSize             ltoml.Size     `env:"MAX_MEMDB_SIZE" toml:"max-memdb-size"`
	MutableMemDBTTL          ltoml.Duration `env:"MUTABLE_MEMDB_TTL" toml:"mutable-memdb-ttl"`
	MaxMemUsageBeforeFlush   float64        `env:"MAX_MEM_USAGE_BEFORE_FLUSH" toml:"max-mem-usage-before-flush"`
	TargetMemUsageAfterFlush float64        `env:"TARGET_MEM_USAGE_AFTER_FLUSH" toml:"target-mem-usage-after-flush"`
	FlushConcurrency         int            `env:"FLUSH_CONCURRENCY" toml:"flush-concurrency"`
	SeriesSequenceCache      uint32         `env:"SERIES_SEQ_CACHE" toml:"series-sequence-cache"`
	MetaSequenceCache        uint32         `env:"META_SEQ_CACHE" toml:"meta-sequence-cache"`
}

TSDB represents the tsdb configuration.

func (*TSDB) TOML

func (t *TSDB) TOML() string

type User

type User struct {
	UserName string `toml:"username" json:"username" binding:"required"`
	Password string `toml:"password" json:"password" binding:"required"`
}

User represents user model

func (*User) TOML

func (u *User) TOML() string

type WAL

type WAL struct {
	Dir                string         `env:"DIR" toml:"dir"`
	DataSizeLimit      ltoml.Size     `env:"DATA_SIZE_LIMIT" toml:"data-size-limit"`
	RemoveTaskInterval ltoml.Duration `env:"REMOVE_TASK_INTERVAL" toml:"remove-task-interval"`
}

WAL represents config for write ahead log in storage.

func (*WAL) GetDataSizeLimit

func (rc *WAL) GetDataSizeLimit() int64

func (*WAL) TOML

func (rc *WAL) TOML() string

type Write

type Write struct {
	BatchTimeout   ltoml.Duration `env:"BATCH_TIMEOUT" toml:"batch-timeout"`
	BatchBlockSize ltoml.Size     `env:"BLOCK_SIZE" toml:"batch-block-size"`
	GCTaskInterval ltoml.Duration `env:"GC_INTERVAL" toml:"gc-task-interval"`
}

Write represents config for write replication in broker.

func (*Write) TOML

func (rc *Write) TOML() string

Jump to

Keyboard shortcuts

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