config

package
v2.2.10+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConfigFile = "~/.qingstor/config.yaml"

DefaultConfigFile is the filename of default config file.

View Source
const DefaultConfigFileContent = `` /* 310-byte string literal not displayed */

DefaultConfigFileContent is the content of default config file.

Variables

View Source
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,
}

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"`
	ConnectionRetries int    `yaml:"connection_retries"`

	AdditionalUserAgent string `yaml:"additional_user_agent"`

	LogLevel string `yaml:"log_level"`

	HTTPSettings HTTPClientSettings

	Connection *http.Client
}

A Config stores a configuration of this sdk.

func New

func New(accessKeyID, secretAccessKey string) (c *Config, err error)

New create a Config with given AccessKeyID and SecretAccessKey.

func NewDefault

func NewDefault() (c *Config, err error)

NewDefault create a Config with default configuration.

func (*Config) Check

func (c *Config) Check() (err error)

Check checks the configuration.

func (*Config) InitHTTPClient

func (c *Config) InitHTTPClient()

InitHTTPClient will init the HTTP Client.

func (*Config) LoadConfigFromContent

func (c *Config) LoadConfigFromContent(content []byte) (err error)

LoadConfigFromContent loads configuration from a given byte slice. It returns error if yaml decode failed.

func (*Config) LoadConfigFromFilePath

func (c *Config) LoadConfigFromFilePath(filePath string) (err error)

LoadConfigFromFilePath loads configuration from a specified local path. It returns error if file not found or yaml decode failed.

func (*Config) LoadDefaultConfig

func (c *Config) LoadDefaultConfig() (err error)

LoadDefaultConfig loads the default configuration for Config. It returns error if yaml decode failed.

func (*Config) LoadUserConfig

func (c *Config) LoadUserConfig() (err error)

LoadUserConfig loads user configuration in ~/.qingstor/config.yaml for Config. It returns error if file not found.

type HTTPClientSettings

type HTTPClientSettings struct {
	ConnectTimeout      time.Duration `yaml:"connect_timeout"`
	ReadTimeout         time.Duration `yaml:"read_timeout"`
	WriteTimeout        time.Duration `yaml:"write_timeout" `
	TLSHandshakeTimeout time.Duration `yaml:"tls_timeout"`
	IdleConnTimeout     time.Duration `yaml:"idle_timeout"`
	TCPKeepAlive        time.Duration `yaml:"tcp_keepalive_time"`
	DualStack           bool          `yaml:"dual_stack"`
	MaxIdleConns        int           `yaml:"max_idle_conns"`
	MaxIdleConnsPerHost int           `yaml:"max_idle_conns_per_host"`
}

HTTPClientSettings is the http client settings.

Jump to

Keyboard shortcuts

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