driver

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Query = iota
	QueryRow
	Exec
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseConnStrut

type BaseConnStrut struct {
	UserName string
	Pass     string
	DB       string
	Addr     string
	Port     string
	SSLMode  string
}

type DialOptions

type DialOptions struct {
	DBNum          int
	ConnectTimeout time.Duration
	WriteTimeout   time.Duration
	ReadTimeout    time.Duration
	KeepAlive      time.Duration
	UseTLS         bool
}

type DockerClient

type DockerClient struct {
	*client.Client
}

func NewDocker

func NewDocker(opt DockerOptions) (cli *DockerClient, err error)

type DockerOptions

type DockerOptions struct {
	Host    string
	Version string
	*http.Client
	HttpHeader map[string]string
}

DOC :https://docs.docker.com/engine/api/sdk/examples/ docker命令详情见官网

type FieldInfo

type FieldInfo struct {
	Name     string
	TypeInfo interface{}
}

type IDriverHelper

type IDriverHelper interface {
}

type MongoDBStrut

type MongoDBStrut struct {
	*mongo.Client
	*mongo.Database
	*mongo.Collection
}

func NewMongoDB

func NewMongoDB(database string, opt *options.ClientOptions, collection string) (client *MongoDBStrut, err error)

type MysqlSetting

type MysqlSetting struct {
	MaxOpenConn int
	MaxLifetime time.Duration
	MaxIdleConn int
}

type PoolOptions

type PoolOptions struct {
	MaxIdle         int
	MaxActive       int
	IdleTimeout     time.Duration
	Wait            bool
	MaxConnLifetime time.Duration
}

type RedisOptions

type RedisOptions struct {
	BaseConnStrut
	DialOptions
	PoolOptions
}

type RedisStrut

type RedisStrut struct {
	*redis.Pool
}
var (
	RedisClient *RedisStrut
)

func NewRedis

func NewRedis(opt RedisOptions) (pool *RedisStrut, err error)

func (*RedisStrut) Do

func (p *RedisStrut) Do(commandName string, args ...interface{}) (reply interface{}, err error)

func (*RedisStrut) Flush

func (p *RedisStrut) Flush() error

清空缓冲区

func (*RedisStrut) Receive

func (p *RedisStrut) Receive() (reply interface{}, err error)

读取队列,未响应时堵塞

func (*RedisStrut) Send

func (p *RedisStrut) Send(commandName string, args ...interface{}) error

发送至缓冲区

type RelationSqlOption

type RelationSqlOption struct {
	BaseConnStrut
	ConnectString string
	MysqlSetting
}

type RelationSqlStrut

type RelationSqlStrut struct {
	*sql.DB
}

func NewMSSQL

func NewMSSQL(opt RelationSqlOption, query url.Values) (rst *RelationSqlStrut, err error)

驱动地址: https://github.com/denisenkom/go-mssqldb 建议的连接字符串使用 URL 格式:下面列出了其他受支持的格式。sqlserver://username:password@host/instance?param1=value&param2=value

func NewMySQL

func NewMySQL(opt RelationSqlOption) (itf *RelationSqlStrut, err error)

func NewPostgreSQL

func NewPostgreSQL(opt RelationSqlOption) (rst *RelationSqlStrut, err error)

https://github.com/lib/pq postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full doc : https://godoc.org/github.com/lib/pq

相关连接参数:

  • dbname - The name of the database to connect to
  • user - The user to sign in as
  • password - The user's password
  • host - The host to connect to. Values that start with / are for unix domain sockets. (default is localhost)
  • port - The port to bind to. (default is 5432)
  • sslmode - Whether or not to use SSL (default is require, this is not the default for libpq)
  • fallback_application_name - An application_name to fall back to if one isn't provided.
  • connect_timeout - Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.
  • sslcert - Cert file location. The file must contain PEM encoded data.
  • sslkey - Key file location. The file must contain PEM encoded data.
  • sslrootcert - The location of the root certificate file. The file must contain PEM encoded data.

Valid values for sslmode are:

  • disable - No SSL
  • require - Always SSL (skip verification)
  • verify-ca - Always SSL (verify that the certificate presented by the server was signed by a trusted CA)
  • verify-full - Always SSL (verify that the certification presented by the server was signed by a trusted CA and the server host name matches the one in the certificate)

TODO 待实现更方便的命令执行方法

func (*RelationSqlStrut) Affair

func (itf *RelationSqlStrut) Affair(ctx context.Context, opt *sql.TxOptions, f []SqlFunc) (err error)

func (*RelationSqlStrut) ExecCtx

func (itf *RelationSqlStrut) ExecCtx(ctx context.Context, query string, args ...interface{}) (resultRow ResultRowInfo, err error)

func (*RelationSqlStrut) FindOfCtx

func (itf *RelationSqlStrut) FindOfCtx(ctx context.Context, query string, rely interface{}, args ...interface{}) (list []map[string]interface{}, err error)

获取多条记录 TODO 2020年11月15日20:21:13 指明要返回的字段,在参数rely里填入默认值以明确要返回的列

func (*RelationSqlStrut) GetSingleCtx

func (itf *RelationSqlStrut) GetSingleCtx(ctx context.Context, query string, rely interface{}, args ...interface{}) (single map[string]interface{}, err error)

获取单条记录 TODO 2020年11月3日20:52:53 仅支持常用内置类型 指明要返回的字段,在参数rely里填入默认值以明确要返回的列

func (*RelationSqlStrut) Status

func (itf *RelationSqlStrut) Status() (status sql.DBStats)

MYSQL 运行状态

type ResultRowInfo

type ResultRowInfo struct {
	RowsAffected int64 // 影响行数
	LastInsertId int64 // 最高行ID
}

执行操作 TODO 2020年11月16日13:47:21

type SqlFunc

type SqlFunc func(tx *sql.Tx, wg sync.WaitGroup)

事务相关 TODO 2020年11月18日20:39:24

Jump to

Keyboard shortcuts

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