config

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: Apache-2.0, MIT Imports: 11 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Client custom http client
	Client *http.Client

	HttpURL         string           `env:"LONGBRIDGE_HTTP_URL,LONGPORT_HTTP_URL" yaml:"http_url" toml:"http_url"`
	HTTPTimeout     time.Duration    `env:"LONGBRIDGE_HTTP_TIMEOUT,LONGPORT_HTTP_TIMEOUT" yaml:"http_timeout" toml:"http_timeout"`
	AppKey          string           `env:"LONGBRIDGE_APP_KEY,LONGPORT_APP_KEY" yaml:"app_key" toml:"app_key"`
	AppSecret       string           `env:"LONGBRIDGE_APP_SECRET,LONGPORT_APP_SECRET" yaml:"app_secret" toml:"app_secret"`
	AccessToken     string           `env:"LONGBRIDGE_ACCESS_TOKEN,LONGPORT_ACCESS_TOKEN" yaml:"access_token" toml:"access_token"`
	TradeUrl        string           `env:"LONGBRIDGE_TRADE_URL,LONGPORT_TRADE_URL" yaml:"trade_url" toml:"trade_url"`
	QuoteUrl        string           `env:"LONGBRIDGE_QUOTE_URL,LONGPORT_QUOTE_URL" yaml:"quote_url" toml:"quote_url"`
	EnableOvernight bool             `env:"LONGPORT_ENABLE_OVERNIGHT" yaml:"enable_overnight" toml:"enable_overnight"`
	Language        openapi.Language `env:"LONGPORT_LANGUAGE" yaml:"language" toml:"language"`

	LogLevel string `env:"LONGBRIDGE_LOG_LEVEL,LONGPORT_LOG_LEVEL" yaml:"log_level" toml:"log_level"`

	// longbridge protocol config
	AuthTimeout    time.Duration `env:"LONGBRIDGE_AUTH_TIMEOUT,LONGPORT_AUTH_TIMEOUT" yaml:"auth_timeout" toml:"auth_timeout"`
	Timeout        time.Duration `env:"LONGBRIDGE_TIMEOUT,LONGPORT_TIMEOUT" yaml:"timeout" toml:"timeout"`
	WriteQueueSize int           `env:"LONGBRIDGE_WRITE_QUEUE_SIZE,LONGPORT_WRITE_QUEUE_SIZE" yaml:"write_queue_size" toml:"write_queue_size"`
	ReadQueueSize  int           `env:"LONGBRIDGE_READ_QUEUE_SIZE,LONGPORT_READ_QUEUE_SIZE" yaml:"read_queue_size" toml:"read_queue_size"`
	ReadBufferSize int           `env:"LONGBRIDGE_READ_BUFFER_SIZE,LONGPORT_READ_BUFFER_SIZE" yaml:"read_buffer_size" toml:"read_buffer_size"`
	MinGzipSize    int           `env:"LONGBRIDGE_MIN_GZIP_SIZE,LONGPORT_MIN_GZIP_SIZE" yaml:"min_gzip_size" toml:"min_gzip_size"`
	Region         Region        `env:"LONGPORT_REGION" yaml:"region" toml:"region"`
	// contains filtered or unexported fields
}

Config store Longbridge config

func New

func New(opts ...Option) (configData *Config, err error)

func NewFormEnv deprecated

func NewFormEnv() (*Config, error)

Deprecated: NewFormEnv to create config with enviromente variables

func (*Config) Logger

func (c *Config) Logger() log.Logger

func (*Config) SetLogger

func (c *Config) SetLogger(l log.Logger)

type ConfigType

type ConfigType string
const (
	ConfigTypeEnv  ConfigType = ".env"
	ConfigTypeYAML ConfigType = ".yaml"
	ConfigTypeTOML ConfigType = ".toml"
)

type EnvConfig

type EnvConfig struct {
}

func (*EnvConfig) GetConfig

func (c *EnvConfig) GetConfig(_ *Options) (data *Config, err error)

type IConfig

type IConfig interface {
	GetConfig(opts *Options) (*Config, error)
}

type Option

type Option func(*Options)

func WithConfigKey added in v0.9.2

func WithConfigKey(appKey string, appSecret string, accessToken string) Option

WithConfigKey config appKey, appSecret, accessToken

func WithFilePath

func WithFilePath(filePath string) Option

WithFilePath config path

type Options

type Options struct {
	// contains filtered or unexported fields
}

type Region added in v0.9.1

type Region string
var (
	RegionCN Region = "cn"
)

type TOMLConfig

type TOMLConfig struct {
}

func (*TOMLConfig) GetConfig

func (c *TOMLConfig) GetConfig(opts *Options) (*Config, error)

type YAMLConfig

type YAMLConfig struct {
}

func (*YAMLConfig) GetConfig

func (c *YAMLConfig) GetConfig(opts *Options) (*Config, error)

Jump to

Keyboard shortcuts

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