conf

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

type Conf interface {
	GetDebug() bool
	GetTLSEnable() bool
	GetProjectName() string
	GetProjectTags() []string
	GetAppType() string
	GetAppAddress() string
	GetAppPort() int
	GetServiceDiscoveryAddress() string
	GetServiceDiscoveryPort() int
	GetServiceDiscoveryTimeout() int
	GetDeregisterAfterCritical() int
	GetHealthCheckInterval() int
	GetCAPemFile() string
	GetServerPemFile() string
	GetServerKeyFile() string
	GetClientPemFile() string
	GetClientKeyFile() string
	GetProjectVersion() string
	GetLogRootPath() string
	GetLogName() string
	GetServiceDiscoveryType() string
	GetServiceDiscoveryAutoRegister() bool
	GetAtomicRequest() bool
	GetTablePrefix() string
	GetAppMediaURL() string
	GetAppStaticURL() string
	GetAppMediaPath() string
	GetAppStaticPath() string
	GetCacheSize() int
	GetCacheTimeout() int
	GetPageSize() int
	GetAppBaseURL() string
	GetMigrationPath() string
	GetJwtSecretKey() string
	GetJwtVerifyExpireHour() bool
	GetJwtVerifyIssuer() bool
	GetJwtIssuer() string
	GetJwtHeaderPrefix() string
	GetJwtExpireHour() int
	GetAppReadTimeout() int
	GetAppReadHeaderTimeout() int
	GetAppWriteTimeout() int
	GetAppIdleTimeout() int
	GetAppMaxHeaderBytes() int
	GetAllowOrigins() []string
	GetAllowMethods() []string
	GetAllowHeaders() []string
	GetExposeHeaders() []string
	GetAllowCredentials() bool
	GetMaxAgeHour() int
	GetCorsEnable() bool
	GetDBType() string
	GetDBServer() string
	GetDBTablePrefix() string
	GetDbMaxIdleConn() int
	GetDbMaxOpenConn() int
}

Conf Conf interface

func LoadConfigFile

func LoadConfigFile(configFilePath string) Conf

LoadConfigFile load config file

func NewSetting

func NewSetting(configFilePath string) Conf

NewSetting new setting

type Cors

type Cors struct {
	Enable           bool     `toml:"enable"`
	AllowOrigins     []string `toml:"allow_origins"`
	AllowMethods     []string `toml:"allow_methods"`
	AllowHeaders     []string `toml:"allow_headers"`
	ExposeHeaders    []string `toml:"expose_headers"`
	AllowCredentials bool     `toml:"allow_credentials"`
	MaxAgeHour       int      `toml:"max_age_hour"`
}

Cors coors

type Database

type Database struct {
	DBType      string `toml:"db_type"`
	Server      string `toml:"server"`
	TablePrefix string `toml:"table_prefix"`
	MaxIdleConn int    `toml:"max_idle_conn"`
	MaxOpenConn int    `toml:"max_open_conn"`
}

Database struct

type DefaultConf

type DefaultConf struct {
	Project  Project  `toml:"project"`
	Runtime  Runtime  `toml:"runtime"`
	Security Security `toml:"security"`
	App      struct {
		// Type support GRPC HTTP
		Type    string `toml:"type"`
		Address string `toml:"address"`
		Port    int    `toml:"port"`
		// ReadTimeout is the maximum duration for reading the entire
		// request, including the body.
		//
		// Because ReadTimeout does not let Handlers make per-request
		// decisions on each request body's acceptable deadline or
		// upload rate, most users will prefer to use
		// ReadHeaderTimeout. It is valid to use them both.
		ReadTimeout int `toml:"read_timeout"`

		// ReadHeaderTimeout is the amount of time allowed to read
		// request headers. The connection's read deadline is reset
		// after reading the headers and the Handler can decide what
		// is considered too slow for the body. If ReadHeaderTimeout
		// is zero, the value of ReadTimeout is used. If both are
		// zero, there is no timeout.
		ReadHeaderTimeout int `toml:"read_header_timeout"`

		// WriteTimeout is the maximum duration before timing out
		// writes of the response. It is reset whenever a new
		// request's header is read. Like ReadTimeout, it does not
		// let Handlers make decisions on a per-request basis.
		WriteTimeout int `toml:"writer_timeout"`

		// IdleTimeout is the maximum amount of time to wait for the
		// next request when keep-alives are enabled. If IdleTimeout
		// is zero, the value of ReadTimeout is used. If both are
		// zero, there is no timeout.
		IdleTimeout int `toml:"idle_timeout"`

		// MaxHeaderBytes controls the maximum number of bytes the
		// server will read parsing the request header's keys and
		// values, including the request line. It does not limit the
		// size of the request body.
		// If zero, DefaultMaxHeaderBytes is used.
		MaxHeaderBytes int    `toml:"max_header_bytes"`
		TemplatePath   string `toml:"template_path"`
		MediaURL       string `toml:"media_url"`
		MediaPath      string `toml:"media_path"`
		StaticURL      string `toml:"static_url"`
		StaticPath     string `toml:"static_path"`
		MigrationPath  string `toml:"migration_path"`
		PageSize       int    `toml:"page_size"`
		MaxBodySize    int    `toml:"max_body_size"`
		AtomicRequest  bool   `toml:"atomic_request"`
		// if api root is not root , replease with base url
		// e.g : /assetgo
		BaseURL string `toml:"base_url"`
	}
	Log struct {
		LogRootPath string `toml:"log_root_path"` //   /var/log/mold
		LogName     string `toml:"log_name"`      //  app.log
	}
	Cache struct {
		Redis struct {
			Host        string `toml:"host"`
			Port        int    `toml:"port"`
			Password    string `toml:"password"`
			MaxIdle     int    `toml:"max_idle"`
			MaxActive   int    `toml:"max_active"`
			IdleTimeout int    `toml:"idle_timeout"`
		}
		Gcache struct {
			CacheAlgorithm string `toml:"cache_algorithm"`
			CacheSize      int    `toml:"cachesize"`
			Timeout        int    `toml:"timeout"` // hour
		}
	}
	Database         Database         `toml:"database"`
	ServiceDiscovery ServiceDiscovery `toml:"service_discovery"`
}

DefaultConf default conf

func (*DefaultConf) GetAllowCredentials

func (s *DefaultConf) GetAllowCredentials() bool

GetAllowCredentials get allow credentials

func (*DefaultConf) GetAllowHeaders

func (s *DefaultConf) GetAllowHeaders() []string

GetAllowHeaders get allow headers

func (*DefaultConf) GetAllowMethods

func (s *DefaultConf) GetAllowMethods() []string

GetAllowMethods get allow method

func (*DefaultConf) GetAllowOrigins

func (s *DefaultConf) GetAllowOrigins() []string

GetAllowOrigins get allow origins

func (*DefaultConf) GetAppAddress

func (s *DefaultConf) GetAppAddress() string

GetAppAddress get web service ip address

func (*DefaultConf) GetAppBaseURL

func (s *DefaultConf) GetAppBaseURL() string

GetAppBaseURL get GetAppBaseURL

func (*DefaultConf) GetAppIdleTimeout

func (s *DefaultConf) GetAppIdleTimeout() int

GetAppIdleTimeout get GetIdleTimeoutSecond

func (*DefaultConf) GetAppMaxHeaderBytes

func (s *DefaultConf) GetAppMaxHeaderBytes() int

GetAppMaxHeaderBytes get GetMaxHeaderBytes

func (*DefaultConf) GetAppMediaPath

func (s *DefaultConf) GetAppMediaPath() string

GetAppMediaPath get web app media path

func (*DefaultConf) GetAppMediaURL

func (s *DefaultConf) GetAppMediaURL() string

GetAppMediaURL get web app media url

func (*DefaultConf) GetAppPort

func (s *DefaultConf) GetAppPort() int

GetAppPort get web service port

func (*DefaultConf) GetAppReadHeaderTimeout

func (s *DefaultConf) GetAppReadHeaderTimeout() int

GetAppReadHeaderTimeout get GetReadHeaderTimeoutSecond

func (*DefaultConf) GetAppReadTimeout

func (s *DefaultConf) GetAppReadTimeout() int

GetAppReadTimeout get readtimeoout

func (*DefaultConf) GetAppStaticPath

func (s *DefaultConf) GetAppStaticPath() string

GetAppStaticPath get web app static path

func (*DefaultConf) GetAppStaticURL

func (s *DefaultConf) GetAppStaticURL() string

GetAppStaticURL get web app static url

func (*DefaultConf) GetAppType

func (s *DefaultConf) GetAppType() string

GetAppType get web app type

func (*DefaultConf) GetAppWriteTimeout

func (s *DefaultConf) GetAppWriteTimeout() int

GetAppWriteTimeout get GetWriteTimeoutSecond

func (*DefaultConf) GetAtomicRequest

func (s *DefaultConf) GetAtomicRequest() bool

GetAtomicRequest get automic request is open

func (*DefaultConf) GetCAPemFile

func (s *DefaultConf) GetCAPemFile() string

GetCAPemFile get ca pem file

func (*DefaultConf) GetCacheSize

func (s *DefaultConf) GetCacheSize() int

GetCacheSize get GetCacheSize

func (*DefaultConf) GetCacheTimeout

func (s *DefaultConf) GetCacheTimeout() int

GetCacheTimeout get GetCacheTimeout

func (*DefaultConf) GetClientKeyFile

func (s *DefaultConf) GetClientKeyFile() string

GetClientKeyFile get client key file

func (*DefaultConf) GetClientPemFile

func (s *DefaultConf) GetClientPemFile() string

GetClientPemFile get client pem file

func (*DefaultConf) GetCorsEnable

func (s *DefaultConf) GetCorsEnable() bool

GetCorsEnable get if enable cors

func (*DefaultConf) GetDBServer

func (s *DefaultConf) GetDBServer() string

GetDBServer get db host

func (*DefaultConf) GetDBTablePrefix

func (s *DefaultConf) GetDBTablePrefix() string

GetDBTablePrefix get db table prefix

func (*DefaultConf) GetDBType

func (s *DefaultConf) GetDBType() string

GetDBType get db type

func (*DefaultConf) GetDbMaxIdleConn

func (s *DefaultConf) GetDbMaxIdleConn() int

GetDbMaxIdleConn get db max idle connection

func (*DefaultConf) GetDbMaxOpenConn

func (s *DefaultConf) GetDbMaxOpenConn() int

GetDbMaxOpenConn get db max open connection

func (*DefaultConf) GetDebug

func (s *DefaultConf) GetDebug() bool

GetDebug get debug

func (*DefaultConf) GetDefaultConf

func (s *DefaultConf) GetDefaultConf() *DefaultConf

GetDefaultConf get DefaultConf

func (*DefaultConf) GetDeregisterAfterCritical

func (s *DefaultConf) GetDeregisterAfterCritical() int

GetDeregisterAfterCritical deregister service after critical second

func (*DefaultConf) GetExposeHeaders

func (s *DefaultConf) GetExposeHeaders() []string

GetExposeHeaders get expoose headers

func (*DefaultConf) GetHealthCheckInterval

func (s *DefaultConf) GetHealthCheckInterval() int

GetHealthCheckInterval health check interval

func (*DefaultConf) GetJwtExpireHour

func (s *DefaultConf) GetJwtExpireHour() int

GetJwtExpireHour get GetJwtExpireHour

func (*DefaultConf) GetJwtHeaderPrefix

func (s *DefaultConf) GetJwtHeaderPrefix() string

GetJwtHeaderPrefix get GetJwtHeaderPrefix

func (*DefaultConf) GetJwtIssuer

func (s *DefaultConf) GetJwtIssuer() string

GetJwtIssuer get GetJwtIssuer

func (*DefaultConf) GetJwtSecretKey

func (s *DefaultConf) GetJwtSecretKey() string

GetJwtSecretKey get GetSecretKey

func (*DefaultConf) GetJwtVerifyExpireHour

func (s *DefaultConf) GetJwtVerifyExpireHour() bool

GetJwtVerifyExpireHour get GetJwtVerifyExpireHour

func (*DefaultConf) GetJwtVerifyIssuer

func (s *DefaultConf) GetJwtVerifyIssuer() bool

GetJwtVerifyIssuer get GetJwtVerifyIssuer

func (*DefaultConf) GetLogName

func (s *DefaultConf) GetLogName() string

GetLogName get log name

func (*DefaultConf) GetLogRootPath

func (s *DefaultConf) GetLogRootPath() string

GetLogRootPath get log root path

func (*DefaultConf) GetMaxAgeHour

func (s *DefaultConf) GetMaxAgeHour() int

GetMaxAgeHour get max age hour

func (*DefaultConf) GetMigrationPath

func (s *DefaultConf) GetMigrationPath() string

GetMigrationPath get GetMigrationPath

func (*DefaultConf) GetPageSize

func (s *DefaultConf) GetPageSize() int

GetPageSize get GetPageSize

func (*DefaultConf) GetProjectName

func (s *DefaultConf) GetProjectName() string

GetProjectName get project name

func (*DefaultConf) GetProjectTags

func (s *DefaultConf) GetProjectTags() []string

GetProjectTags get project tags

func (*DefaultConf) GetProjectVersion

func (s *DefaultConf) GetProjectVersion() string

GetProjectVersion get project name

func (*DefaultConf) GetServerKeyFile

func (s *DefaultConf) GetServerKeyFile() string

GetServerKeyFile get server key file

func (*DefaultConf) GetServerPemFile

func (s *DefaultConf) GetServerPemFile() string

GetServerPemFile get server pem file

func (*DefaultConf) GetServiceDiscoveryAddress

func (s *DefaultConf) GetServiceDiscoveryAddress() string

GetServiceDiscoveryAddress get service mesh address

func (*DefaultConf) GetServiceDiscoveryAutoRegister

func (s *DefaultConf) GetServiceDiscoveryAutoRegister() bool

GetServiceDiscoveryAutoRegister get auto register

func (*DefaultConf) GetServiceDiscoveryPort

func (s *DefaultConf) GetServiceDiscoveryPort() int

GetServiceDiscoveryPort get service mesh port

func (*DefaultConf) GetServiceDiscoveryTimeout added in v0.0.20

func (s *DefaultConf) GetServiceDiscoveryTimeout() int

GetServiceDiscoveryTimeout get service mesh port

func (*DefaultConf) GetServiceDiscoveryType

func (s *DefaultConf) GetServiceDiscoveryType() string

GetServiceDiscoveryType get s m type

func (*DefaultConf) GetTLSEnable

func (s *DefaultConf) GetTLSEnable() bool

GetTLSEnable get tls enabled

func (*DefaultConf) GetTablePrefix

func (s *DefaultConf) GetTablePrefix() string

GetTablePrefix get table prefix

type Jwt

type Jwt struct {
	SecretKey        string `toml:"secret_key"`
	Issuer           string `toml:"issuer"`
	ExpireHour       int    `toml:"expire_hour"`
	HeaderPrefix     string `toml:"header_prefix"`
	VerifyIssuer     bool   `toml:"verify_issuer"`
	VerifyExpireHour bool   `toml:"verify_expire_hour"`
}

Jwt jwt

type Project

type Project struct {
	Name    string
	Version string
	Tags    []string
}

Project struct

type Runtime

type Runtime struct {
	Debug bool `toml:"debug"`
}

Runtime struct

type Security

type Security struct {
	Jwt  Jwt  `toml:"jwt"`
	Cors Cors `toml:"cors"`
	TLS  TLS  `toml:"tls"`
}

Security security

type ServiceDiscovery

type ServiceDiscovery struct {
	Type                    string // etcd oor consul
	Address                 string
	Port                    int
	Timeout                 int
	DeregisterAfterCritical int  `toml:"deregister_after_critical"` //second
	HealthCheckInterval     int  `toml:"health_check_interval"`     //second
	AutoRegister            bool `toml:"auto_register"`
}

ServiceDiscovery service delivery

type TLS

type TLS struct {
	Enable        bool   `toml:"enable"`
	CAPemFile     string `toml:"ca_pem_file"`
	ServerPemFile string `toml:"server_pem_file"`
	ServerKeyFile string `toml:"server_key_file"`
	ClientPemFile string `toml:"client_pem_file"`
	ClientKeyFile string `toml:"client_key_file"`
}

TLS tls

Jump to

Keyboard shortcuts

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