options

package
v0.0.0-...-dfe2c77 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateAddress

func ValidateAddress(addr string) error

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 GRPCOptions

type GRPCOptions struct {
	// Network with server network.
	Network string `json:"network" mapstructure:"network"`

	// Addr 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(未经身份验证的) gRPC server, insecure port.

func NewGRPCOptions

func NewGRPCOptions() *GRPCOptions

NewGRPCOptions is for creating an unauthenticated, unauthorized, insecure port.

func (*GRPCOptions) AddFlags

func (g *GRPCOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

AddFlags adds flags related to features for a specific api server to the specified FlagSet.

func (*GRPCOptions) Validate

func (g *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"`

	// Addr 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"`
}

func NewHTTPOptions

func NewHTTPOptions() *HTTPOptions

func (*HTTPOptions) AddFlags

func (h *HTTPOptions) AddFlags(fs *pflag.FlagSet, prefixs ...string)

func (*HTTPOptions) Complete

func (h *HTTPOptions) Complete() error

func (*HTTPOptions) Validate

func (h *HTTPOptions) Validate() []error

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, prefixs ...string)
}

IOptions defines methods to implement a generic options.

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

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) DSN

func (o *MySQLOptions) DSN() string

DSN return DSN from MySQLOptions.

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

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 NewTLSOptions

func NewTLSOptions() *TLSOptions

NewTLSOptions create a `zero` value instance.

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) TLSConfig

func (o *TLSOptions) TLSConfig() (*tls.Config, error)

func (*TLSOptions) Validate

func (o *TLSOptions) Validate() []error

Validate verifies flags passed to TLSOptions.

Jump to

Keyboard shortcuts

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