Documentation
¶
Index ¶
- Constants
- func CreateListener(addr string) (net.Listener, int, error)
- func ValidateAddress(addr string) error
- type ChainOptions
- type ConsulOptions
- type EtcdOptions
- type GRPCOptions
- type HTTPOptions
- type HealthOptions
- type IOptions
- type JWTOptions
- type MySQLOptions
- type RedisOptions
- type SocialOptions
- type TLSOptions
Constants ¶
const ( KiB = 1 << (10 * iota) MiB GiB TiB )
Define unit constant.
Variables ¶
This section is empty.
Functions ¶
func CreateListener ¶
CreateListener create net listener by given address and returns it and port.
func ValidateAddress ¶
ValidateAddress takes an address as a string and validates it. If the input address is not in a valid :port or IP:port format, it returns an error. It also checks if the host part of the address is a valid IP address and if the port number is valid.
Types ¶
type ChainOptions ¶
type ChainOptions struct {
ChainId int32 `json:"chain-id" mapstructure:"chain-id"`
RPC string `json:"rpc" mapstructure:"rpc"`
SignerKey string `json:"signer-key" mapstructure:"signer-key"`
}
func NewChainOptions ¶
func NewChainOptions() *ChainOptions
func (*ChainOptions) AddFlags ¶
func (o *ChainOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
func (*ChainOptions) Validate ¶
func (o *ChainOptions) Validate() []error
type ConsulOptions ¶
type ConsulOptions struct {
// Address is the address of the Consul server
Addr string `json:"addr,omitempty" mapstructure:"addr"`
// Scheme is the URI scheme for the Consul server
Scheme string `json:"scheme,omitempty" mapstructure:"scheme"`
}
ConsulOptions defines options for consul client.
func NewConsulOptions ¶
func NewConsulOptions() *ConsulOptions
NewConsulOptions create a `zero` value instance.
func (*ConsulOptions) AddFlags ¶
func (o *ConsulOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to mysql storage for a specific APIServer to the specified FlagSet.
func (*ConsulOptions) Validate ¶
func (o *ConsulOptions) Validate() []error
Validate verifies flags passed to ConsulOptions.
type EtcdOptions ¶
type EtcdOptions struct {
Endpoints []string `json:"endpoints" mapstructure:"endpoints"`
DialTimeout time.Duration `json:"dial-timeout" mapstructure:"dial-timeout"`
Username string `json:"username" mapstructure:"username"`
Password string `json:"password" mapstructure:"password"`
TLSOptions *TLSOptions `json:"tls" mapstructure:"tls"`
}
EtcdOptions defines options for etcd cluster.
func NewEtcdOptions ¶
func NewEtcdOptions() *EtcdOptions
NewEtcdOptions create a `zero` value instance.
func (*EtcdOptions) AddFlags ¶
func (o *EtcdOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.
func (*EtcdOptions) Validate ¶
func (o *EtcdOptions) Validate() []error
Validate verifies flags passed to EtcdOptions.
type GRPCOptions ¶
type GRPCOptions struct {
// Network with server network.
Network string `json:"network" mapstructure:"network"`
// Address with server address.
Addr string `json:"addr" mapstructure:"addr"`
// Timeout with server timeout. Used by grpc client side.
Timeout time.Duration `json:"timeout" mapstructure:"timeout"`
}
GRPCOptions are for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.
func NewGRPCOptions ¶
func NewGRPCOptions() *GRPCOptions
NewGRPCOptions is for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.
func (*GRPCOptions) AddFlags ¶
func (o *GRPCOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to features for a specific api server to the specified FlagSet.
func (*GRPCOptions) Validate ¶
func (o *GRPCOptions) Validate() []error
Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.
type HTTPOptions ¶
type HTTPOptions struct {
// Network with server network.
Network string `json:"network" mapstructure:"network"`
// Address with server address.
Addr string `json:"addr" mapstructure:"addr"`
// Timeout with server timeout. Used by http client side.
Timeout time.Duration `json:"timeout" mapstructure:"timeout"`
}
HTTPOptions contains configuration items related to HTTP server startup.
func NewHTTPOptions ¶
func NewHTTPOptions() *HTTPOptions
NewHTTPOptions creates a HTTPOptions object with default parameters.
func (*HTTPOptions) AddFlags ¶
func (o *HTTPOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to HTTPS server for a specific APIServer to the specified FlagSet.
func (*HTTPOptions) Complete ¶
func (s *HTTPOptions) Complete() error
Complete fills in any fields not set that are required to have valid data.
func (*HTTPOptions) Validate ¶
func (o *HTTPOptions) Validate() []error
Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.
type HealthOptions ¶
type HealthOptions struct {
// Enable debugging by exposing profiling information.
HTTPProfile bool `json:"enable-http-profiler" mapstructure:"enable-http-profiler"`
HealthCheckPath string `json:"check-path" mapstructure:"check-path"`
HealthCheckAddress string `json:"check-address" mapstructure:"check-address"`
}
HealthOptions defines options for redis cluster.
func NewHealthOptions ¶
func NewHealthOptions() *HealthOptions
NewHealthOptions create a `zero` value instance.
func (*HealthOptions) AddFlags ¶
func (o *HealthOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.
func (*HealthOptions) ServeHealthCheck ¶
func (o *HealthOptions) ServeHealthCheck()
func (*HealthOptions) Validate ¶
func (o *HealthOptions) Validate() []error
Validate verifies flags passed to HealthOptions.
type IOptions ¶
type IOptions interface {
// Validate validates all the required options.
// It can also used to complete options if needed.
Validate() []error
// AddFlags adds flags related to given flagset.
AddFlags(fs *pflag.FlagSet, prefixes ...string)
}
IOptions defines methods to implement a generic options.
type JWTOptions ¶
type JWTOptions struct {
Key string `json:"key" mapstructure:"key"`
Expired time.Duration `json:"expired" mapstructure:"expired"`
MaxRefresh time.Duration `json:"max-refresh" mapstructure:"max-refresh"`
SigningMethod string `json:"signing-method" mapstructure:"signing-method"`
}
JWTOptions contains configuration items related to API server features.
func NewJWTOptions ¶
func NewJWTOptions() *JWTOptions
NewJWTOptions creates a JWTOptions object with default parameters.
func (*JWTOptions) AddFlags ¶
func (s *JWTOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to features for a specific api server to the specified FlagSet.
func (*JWTOptions) Validate ¶
func (s *JWTOptions) Validate() []error
Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.
type MySQLOptions ¶
type MySQLOptions struct {
Addr string `json:"addr,omitempty" mapstructure:"addr"`
Username string `json:"username,omitempty" mapstructure:"username"`
Password string `json:"-" mapstructure:"password"`
Database string `json:"database" mapstructure:"database"`
MaxIdleConnections int `json:"max-idle-connections,omitempty" mapstructure:"max-idle-connections,omitempty"`
MaxOpenConnections int `json:"max-open-connections,omitempty" mapstructure:"max-open-connections"`
MaxConnectionLifeTime time.Duration `json:"max-connection-life-time,omitempty" mapstructure:"max-connection-life-time"`
LogLevel int `json:"log-level" mapstructure:"log-level"`
}
MySQLOptions defines options for mysql database.
func NewMySQLOptions ¶
func NewMySQLOptions() *MySQLOptions
NewMySQLOptions create a `zero` value instance.
func (*MySQLOptions) AddFlags ¶
func (o *MySQLOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to mysql storage for a specific APIServer to the specified FlagSet.
func (*MySQLOptions) NewDB ¶
func (o *MySQLOptions) NewDB() (*gorm.DB, error)
NewDB create mysql store with the given config.
func (*MySQLOptions) Validate ¶
func (o *MySQLOptions) Validate() []error
Validate verifies flags passed to MySQLOptions.
type RedisOptions ¶
type RedisOptions struct {
Addr string `json:"addr" mapstructure:"addr"`
Username string `json:"username" mapstructure:"username"`
Password string `json:"password" mapstructure:"password"`
Database int `json:"database" mapstructure:"database"`
MaxRetries int `json:"max-retries" mapstructure:"max-retries"`
MinIdleConns int `json:"min-idle-conns" mapstructure:"min-idle-conns"`
DialTimeout time.Duration `json:"dial-timeout" mapstructure:"dial-timeout"`
ReadTimeout time.Duration `json:"read-timeout" mapstructure:"read-timeout"`
WriteTimeout time.Duration `json:"write-timeout" mapstructure:"write-timeout"`
PoolTimeout time.Duration `json:"pool-time" mapstructure:"pool-time"`
PoolSize int `json:"pool-size" mapstructure:"pool-size"`
// tracing switch
EnableTrace bool `json:"enable-trace" mapstructure:"enable-trace"`
}
RedisOptions defines options for redis cluster.
func NewRedisOptions ¶
func NewRedisOptions() *RedisOptions
NewRedisOptions create a `zero` value instance.
func (*RedisOptions) AddFlags ¶
func (o *RedisOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.
func (*RedisOptions) NewClient ¶
func (o *RedisOptions) NewClient() (*redis.Client, error)
func (*RedisOptions) Validate ¶
func (o *RedisOptions) Validate() []error
Validate verifies flags passed to RedisOptions.
type SocialOptions ¶
type SocialOptions struct {
TelegramBotToken string `json:"telegram-bot-token" mapstructure:"telegram-bot-token"`
XBearerToken string `json:"x-bearer-token" mapstructure:"x-bearer-token"`
XClientID string `json:"x-client-id" mapstructure:"x-client-id"`
XClientSecret string `json:"x-client-secret" mapstructure:"x-client-secret"`
XRedirectURL string `json:"x-redirect-url" mapstructure:"x-redirect-url"`
XOfficials []string `json:"x-officials" mapstructure:"x-officials"`
}
func NewSocialOptions ¶
func NewSocialOptions() *SocialOptions
func (*SocialOptions) AddFlags ¶
func (o *SocialOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
func (*SocialOptions) Validate ¶
func (o *SocialOptions) Validate() []error
type TLSOptions ¶
type TLSOptions struct {
// UseTLS specifies whether should be encrypted with TLS if possible.
UseTLS bool `json:"use-tls" mapstructure:"use-tls"`
InsecureSkipVerify bool `json:"insecure-skip-verify" mapstructure:"insecure-skip-verify"`
CaCert string `json:"ca-cert" mapstructure:"ca-cert"`
Cert string `json:"cert" mapstructure:"cert"`
Key string `json:"key" mapstructure:"key"`
}
TLSOptions is the TLS cert info for serving secure traffic.
func (*TLSOptions) AddFlags ¶
func (o *TLSOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.
func (*TLSOptions) MustTLSConfig ¶
func (o *TLSOptions) MustTLSConfig() *tls.Config
func (*TLSOptions) Scheme ¶
func (o *TLSOptions) Scheme() string
Scheme returns the URL scheme based on the TLS configuration.
func (*TLSOptions) Validate ¶
func (o *TLSOptions) Validate() []error
Validate verifies flags passed to TLSOptions.