config

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(dir, env string, conf *Config) (string, error)

Init ...

func LoadConfig

func LoadConfig(dir string, name string, env string, conf interface{}) (string, error)

LoadConfig ...

Types

type Client

type Client struct {
	Name     string
	Host     string
	Port     int
	Protocol string

	Timeout        time.Duration
	TimeoutMillSec time.Duration
	Transport      HTTPTransport
}

Client ...

type Config

type Config struct {
	Server        Server
	Redis         []Redis
	Database      []Database
	Client        []Client
	Elasticsearch []Elasticsearch
	Kafka         []Kafka
}

Config config

type Database

type Database struct {
	Name              string
	Driver            string
	DataSource        string
	Host              string
	Port              int
	User              string
	Pass              string
	DB                string
	Charset           string
	InterpolateParams string
}

Database config ...

type Elasticsearch

type Elasticsearch struct {
	Name           string
	Addrs          []string
	Username       string
	Password       string
	CustomTranport bool
	Transport      HTTPTransport
}

Elasticsearch ...

type HTTP

type HTTP struct {
	Addr string
}

HTTP http config

type HTTPTransport

type HTTPTransport struct {
	Customized  bool
	MillSecUnit bool

	IdleConnTimeout       time.Duration
	TLSHandshakeTimeout   time.Duration
	ExpectContinueTimeout time.Duration
	ResponseHeaderTimeout time.Duration

	MaxConnsPerHost     int
	MaxIdleConns        int
	MaxIdleConnsPerHost int

	DisableKeepAlives  bool
	DisableCompression bool
}

HTTPTransport ...

type Kafka

type Kafka struct {
	Name         string
	Addrs        []string
	CustomConfig bool
	Producer     KafkaProducer
	Consumer     KafkaConsumer
}

Kafka ...

type KafkaConsumer

type KafkaConsumer struct {
	GroupID string
}

KafkaConsumer ...

type KafkaProducer

type KafkaProducer struct {
	MaxMessageBytes int
}

KafkaProducer ...

type Log

type Log struct {
	Level             string `toml:"level"`
	Development       bool   `toml:"development"`
	DisableCaller     bool   `toml:"disableCaller"`
	DisableStacktrace bool   `toml:"disableStacktrace"`
	OutputPath        string `toml:"outputPath"`
	Rotate            LogRotate
}

Log log config

type LogRotate

type LogRotate struct {
	Filename   string
	MaxSize    int // megabytes
	MaxBackups int
	MaxAge     int // days
	LocalTime  bool
	Compress   bool
}

LogRotate ...

type Metrics

type Metrics struct {
	Prometheus Prometheus
}

Metrics ...

type PProf

type PProf struct {
	Addr string
}

PProf ...

type Prometheus

type Prometheus struct {
	Addr string

	DisableHTTPServerRequestsTotalCounter      bool
	DisableHTTPServerRequestsDurationHistogram bool
	DisableHTTPServerRequestsDurationSummary   bool
	DisableHTTPClientRequestsTotalCounter      bool
	DisableHTTPClientRequestsDurationHistogram bool
	DisableHTTPClientRequestsDurationSummary   bool
	DisableLogTotalCounter                     bool

	HTTPServerRequestsDurationHistogramBuckets  []float64
	HTTPServerRequestsDurationSummaryObjectives map[float64]float64
	HTTPClientRequestsDurationHistogramBuckets  []float64
	HTTPClientRequestsDurationSummaryObjectives map[float64]float64
}

Prometheus ...

type Redis

type Redis struct {
	Name string
	Host string
	Port int
	Auth string
	DB   int
}

Redis redis config

type Reporter

type Reporter struct {
	CollectorEndpoint   string
	LocalAgentHostPort  string
	BufferFlushInterval time.Duration
}

Reporter ...

type Server

type Server struct {
	Name    string
	HTTP    HTTP
	PProf   PProf
	Metrics Metrics
	Trace   Trace
	Log     Log
}

Server server config

type Trace

type Trace struct {
	Reporter Reporter
}

Trace ...

Jump to

Keyboard shortcuts

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