config

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// 最大打开连接数
	Open int `default:"150" yaml:"open" json:"open" xml:"open" toml:"open"`
	// 最大休眠连接数
	Idle int `default:"30" yaml:"idle" json:"idle" xml:"idle" toml:"idle"`
	// 每个连接最大存活时间
	Lifetime time.Duration `default:"5s" yaml:"lifetime" json:"lifetime" xml:"lifetime" toml:"lifetime"`
}

type DB added in v0.1.3

type DB struct {
	// 数据库类型
	// nolint:lll
	Type string `` /* 139-byte string literal not displayed */

	// 主机
	Host string `json:"host,omitempty" yaml:"host" xml:"host" toml:"host" validate:"required,hostname|ip"`
	// 端口
	Port int `default:"3306" json:"port,omitempty" yaml:"port" xml:"port" toml:"port" validate:"required,max=65535"`
	// 授权,用户名
	Username string `json:"username,omitempty" yaml:"username" xml:"username" toml:"username"`
	// 授权,密码
	Password string `json:"password,omitempty" yaml:"password" xml:"password" toml:"password"`
	// 连接协议
	// nolint: lll
	Protocol string `default:"tcp" json:"protocol,omitempty" yaml:"protocol" xml:"protocol" toml:"password" validate:"required,oneof=tcp udp"`

	// 连接池配置
	Connection Connection `json:"connection,omitempty" yaml:"connection" xml:"connection" toml:"connection"`

	// 表名规则
	// nolint: lll
	Mapper string `default:"gonic" json:"mapper,omitempty" yaml:"mapper" xml:"mapper" toml:"mapper" validate:"required,oneof=snake same gonic"`
	// 表名的前缀
	Suffix string `json:"suffix,omitempty" yaml:"suffix" xml:"suffix" toml:"suffix"`
	// 表名后缀
	Prefix string `json:"prefix,omitempty" yaml:"prefix" xml:"prefix" toml:"prefix"`
	// 连接的数据库名
	Schema string `json:"schema,omitempty" yaml:"schema" xml:"schema" toml:"schema" validate:"required"`
	// 路径
	// nolint:lll
	Path string `default:"data.db" json:"path,omitempty" yaml:"path" xml:"path" toml:"path" validate:"required_if=Type sqlite3"`

	// 额外参数
	// nolint: lll
	Parameters internal.Parameters `` /* 126-byte string literal not displayed */
	// 是否连接时测试数据库连接是否完好
	Ping *bool `default:"true" json:"ping,omitempty" yaml:"ping" xml:"ping" toml:"ping"`
	// 是否显示执行语句
	Verbose bool `json:"verbose,omitempty" yaml:"verbose" xml:"verbose" toml:"verbose"`

	// 代理连接
	SSH *Ssh `json:"ssh,omitempty" yaml:"ssh" xml:"ssh" toml:"ssh"`
	// 同步
	Sync Sync `json:"sync,omitempty" yaml:"sync" xml:"sync" toml:"sync"`
	// 参数配置
	Sqlite internal.Sqlite `json:"sqlite,omitempty" yaml:"sqlite" xml:"sqlite" toml:"sqlite"`
}

func (*DB) DSN added in v0.1.3

func (d *DB) DSN() (dsn string, err error)

func (*DB) SSHEnabled added in v0.1.3

func (d *DB) SSHEnabled() bool

func (*DB) TableMapper added in v0.1.3

func (d *DB) TableMapper() (mapper names.Mapper)

type Ssh

type Ssh struct {
	// 是否开户
	Enabled *bool `json:"enabled" yaml:"enabled" xml:"enabled" toml:"enabled"`
	// 地址
	Addr string `json:"addr" yaml:"addr" xml:"addr" toml:"addr" validate:"required,hostname_port|hostname"`
	// 用户名
	Username string `json:"username" yaml:"username" xml:"username" toml:"username"`
	// 密码
	Password string `json:"password" yaml:"password" xml:"password" toml:"password" validate:"required_without=Keyfile"`
	// 私钥文件地址
	Keyfile string `json:"keyfile" yaml:"keyfile" xml:"keyfile" toml:"keyfile" validate:"required_without=Password"`
}

func (*Ssh) Enable

func (s *Ssh) Enable() bool

type Sync added in v0.1.2

type Sync struct {
	Enabled bool            `default:"true" json:"enabled,omitempty" yaml:"enabled" xml:"enabled" toml:"enabled"`
	Ignore  internal.Ignore `json:"ignore,omitempty" yaml:"ignore" xml:"ignore" toml:"ignore"`
	Drop    internal.Drop   `json:"drop,omitempty" yaml:"drop" xml:"drop" toml:"drop"`
	Warn    internal.Warn   `json:"warn,omitempty" yaml:"warn" xml:"warn" toml:"warn"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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