config

package
v0.0.0-...-cd02152 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDev

func IsDev() bool

func LoadEnv

func LoadEnv() error

Load .env file in root path of module and return err

func MustLoadEnv

func MustLoadEnv()

MustLoadEnv is the same as LoadEnv but panics if an error occurs

func RootDir

func RootDir() string

RootDir returns root dir of project

Types

type Broker

type Broker struct {
	Url string `envconfig:"default=nats"`
}

type Config

type Config struct {
	Service      Service
	Mssql        Mssql
	ProxyService ProxyService
	Ristretto    Ristretto
	Migrate      Migrate
	Telegram     Telegram
	Broker       Broker
}

Config provides the system configuration.

func New

func New() *Config

New returns the settings from the environment.

type Migrate

type Migrate struct {
	User  string `envconfig:"optional"`
	Token string `envconfig:"optional"`
}

type Mssql

type Mssql struct {
	Host        string        `envconfig:"default=localhost"`
	Port        string        `envconfig:"default=1433"`
	User        string        `envconfig:"default=sa"`
	Password    string        `envconfig:"default=Password"`
	Database    string        `envconfig:"default=#temp"`
	AppName     string        `envconfig:"default=no name"`
	DialTimeout string        `envconfig:"default=10"`
	KeepAlive   string        `envconfig:"default=1440"`
	PacketSize  string        `envconfig:"default=4096"`
	Log         string        `envconfig:"default=0"`
	ConnTimeout time.Duration `envconfig:"default=10s"`
}

type Pg

type Pg struct {
	Host       string        `envconfig:"PGHOST"`
	Port       string        `envconfig:"PGPORT"`
	User       string        `envconfig:"PGUSER"`
	Password   string        `envconfig:"PGPASSWORD"`
	Database   string        `envconfig:"PGDATABASE"`
	AppName    string        `envconfig:"PGAPPNAME"`
	DisableTLS bool          `envconfig:"PGDISABLETLS"`
	Timeout    time.Duration `envconfig:"PGTIMEOUT" default:"5s"`
}

type ProxyService

type ProxyService struct {
	CollectPeriod        time.Duration `envconfig:"default=60s"`
	DeleteBadProxyPeriod time.Duration `envconfig:"default=300s"`
	DeleteOldStatPeriod  time.Duration `envconfig:"default=300s"`
	CollectUrl           string        `envconfig:"default=https://www.sslproxies.org/"`

	CollectHttpTimeout time.Duration `envconfig:"default=5s"`
	GrpcTimeout        time.Duration `envconfig:"default=1s"`
	GrpcPort           int           `envconfig:"default=50051"`
	CheckTimeout       time.Duration `envconfig:"default=10s"`
	CheckPeriod        time.Duration `envconfig:"default=10s"`
}

type Ristretto

type Ristretto struct {
	// NumCounters determines the number of counters (keys) to keep that hold
	// access frequency information. It's generally a good idea to have more
	// counters than the max cache capacity, as this will improve eviction
	// accuracy and subsequent hit ratios.
	//
	// For example, if you expect your cache to hold 1,000,000 items when full,
	// NumCounters should be 10,000,000 (10x). Each counter takes up 4 bits, so
	// keeping 10,000,000 counters would require 5MB of memory.
	NumCounters int64 `envconfig:"default=1000000"`
	// MaxCost can be considered as the cache capacity, in whatever units you
	// choose to use.
	//
	// For example, if you want the cache to have a max capacity of 100MB, you
	// would set MaxCost to 100,000,000 and pass an item's number of bytes as
	// the `cost` parameter for calls to Set. If new items are accepted, the
	// eviction process will take care of making room for the new item and not
	// overflowing the MaxCost value.
	MaxCost int64 `envconfig:"default=100000"`
	// Metrics determines whether cache statistics are kept during the cache's
	// lifetime. There *is* some overhead to keeping statistics, so you should
	// only set this flag to true when testing or throughput performance isn't a
	// major factor.
	Metrics bool `envconfig:"default=true"`
}

type Service

type Service struct {
	Name        string        `envconfig:"default=no name"`
	Env         string        `envconfig:"default=dev"`
	TestEnv     bool          `envconfig:"default=false"`
	GrpcHost    string        `envconfig:"default=0.0.0.0"`
	GrpcPort    string        `envconfig:"default=50051"`
	ConfigHost  string        `envconfig:"default=config-service"`
	ConfigPort  string        `envconfig:"default=50051"`
	Debug       bool          `envconfig:"default=false"`
	GrpcTimeout time.Duration `envconfig:"default=1s"`
}

type Telegram

type Telegram struct {
	Token  string `envconfig:"optional"`
	ChatId string `envconfig:"optional"`
	Host   string `envconfig:"default=https://api.telegram.org"`
	Debug  bool   `envconfig:"default=false"`
}

Jump to

Keyboard shortcuts

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