Documentation ¶
Index ¶
- Constants
- Variables
- func GetUserConfigFilePath() string
- func InstallDefaultUserConfig() error
- type Config
- func (c *Config) Check() (err error)
- func (c *Config) InitHTTPClient()
- func (c *Config) LoadConfigFromContent(content []byte) (err error)
- func (c *Config) LoadConfigFromFilePath(filePath string) (err error)
- func (c *Config) LoadDefaultConfig() (err error)
- func (c *Config) LoadUserConfig() (err error)
- type HTTPClientSettings
Constants ¶
const ( // DefaultConfigFile is the filename of default config file. DefaultConfigFile = "~/.qingstor/config.yaml" // EnvConfigPath is config environment variable. EnvConfigPath = "QINGSTOR_CONFIG_PATH" // EnvAccessKeyID is config envrionment variable. EnvAccessKeyID = "QINGSTOR_ACCESS_KEY_ID" // EnvSecretAccessKey is config envrionment variable. EnvSecretAccessKey = "QINGSTOR_SECRET_ACCESS_KEY" // EnvEnableVirtualHostStyle is config envrionment variable. EnvEnableVirtualHostStyle = "QINGSTOR_ENABLE_VIRTUAL_HOST_STYLE" // EnvEnableDualStack is config envrionment variable. EnvEnableDualStack = "QINGSTOR_ENABLE_DUAL_STACK" )
const DefaultConfigFileContent = `` /* 288-byte string literal not displayed */
DefaultConfigFileContent is the content of default config file.
Variables ¶
var DefaultHTTPClientSettings = HTTPClientSettings{ ConnectTimeout: time.Second * 30, ReadTimeout: time.Second * 30, WriteTimeout: time.Second * 30, TLSHandshakeTimeout: time.Second * 10, IdleConnTimeout: time.Second * 20, TCPKeepAlive: 0, DualStack: false, MaxIdleConns: 100, MaxIdleConnsPerHost: 10, ExpectContinueTimeout: time.Second * 2, }
DefaultHTTPClientSettings is the default http client settings.
Functions ¶
func GetUserConfigFilePath ¶
func GetUserConfigFilePath() string
GetUserConfigFilePath returns the user config file path.
func InstallDefaultUserConfig ¶
func InstallDefaultUserConfig() error
InstallDefaultUserConfig will install default config file.
Types ¶
type Config ¶
type Config struct { AccessKeyID string `yaml:"access_key_id"` SecretAccessKey string `yaml:"secret_access_key"` Host string `yaml:"host"` Port int `yaml:"port"` Protocol string `yaml:"protocol"` Endpoint string `yaml:"endpoint"` AdditionalUserAgent string `yaml:"additional_user_agent"` DisableURICleaning bool `yaml:"disable_uri_cleaning"` LogLevel string `yaml:"log_level"` EnableVirtualHostStyle bool `yaml:"enable_virtual_host_style"` EnableDualStack bool `yaml:"enable_dual_stack"` HTTPSettings HTTPClientSettings Connection *http.Client }
A Config stores a configuration of this sdk.
func NewDefault ¶
NewDefault create a Config with default configuration.
func (*Config) InitHTTPClient ¶
func (c *Config) InitHTTPClient()
InitHTTPClient : After modifying Config.HTTPSettings, you should always call this to initialize the HTTP Client.
func (*Config) LoadConfigFromContent ¶
LoadConfigFromContent loads configuration from a given byte slice. It returns error if yaml decode failed.
func (*Config) LoadConfigFromFilePath ¶
LoadConfigFromFilePath loads configuration from a specified local path. It returns error if file not found or yaml decode failed.
func (*Config) LoadDefaultConfig ¶
LoadDefaultConfig loads the default configuration for Config. It returns error if yaml decode failed.
func (*Config) LoadUserConfig ¶
LoadUserConfig loads user configuration in ~/.qingstor/config.yaml for Config. It returns error if file not found.
type HTTPClientSettings ¶
type HTTPClientSettings struct { // ConnectTimeout affects making new socket connection ConnectTimeout time.Duration `yaml:"connect_timeout"` // ReadTimeout affect each call to HTTPResponse.Body.Read() ReadTimeout time.Duration `yaml:"read_timeout"` // WriteTimeout affect each write in io.Copy while sending HTTPRequest WriteTimeout time.Duration `yaml:"write_timeout" ` // TLSHandshakeTimeout affects https hand shake timeout TLSHandshakeTimeout time.Duration `yaml:"tls_timeout"` // IdleConnTimeout affects the time limit to re-use http connections IdleConnTimeout time.Duration `yaml:"idle_timeout"` TCPKeepAlive time.Duration `yaml:"tcp_keepalive_time"` DualStack bool `yaml:"dual_stack"` // MaxIdleConns affects the idle connections kept for re-use MaxIdleConns int `yaml:"max_idle_conns"` MaxIdleConnsPerHost int `yaml:"max_idle_conns_per_host"` ExpectContinueTimeout time.Duration `yaml:"expect_continue_timeout"` }
HTTPClientSettings is the http client settings.