client

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONNECTION_KEY     = "connections"
	MAX_OPEN_CONNS     = 20
	MAX_IDLE_CONNS     = 10
	CONN_MAX_LIFE_TIME = 14400 * time.Second
)
View Source
const (
	GET_REQUEST_TIMEOUT      = 3
	POST_REQUEST_TIMEOUT     = 5
	DOWNLOAD_REQUEST_TIMEOUT = 10
)
View Source
const (
	REDIS_KEY                       = "redis"
	REDIS_HOST                      = ""
	REDIS_PORT                      = 6379
	REDIS_DATABASE                  = 0
	REDIS_PASSWORD                  = ""
	REDIS_POOL_MAX_IDLE             = 10
	REDIS_POOL_MAX_ACTIVE           = 100
	REDIS_POOL_IDLE_TIMEOUT         = 300
	REDIS_POOL_MAX_CONN_LIFETIME    = 0
	REDIS_POOL_IDLE_CHECK_FREQUENCY = 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseDao

type BaseDao struct {
	Ctx       context.Context
	DbManager *DbManager `wired:"true"`
	// contains filtered or unexported fields
}

func (BaseDao) Delete

func (bd BaseDao) Delete(sql string, p ...interface{}) (int64, error)

*

  • 删除记录

func (BaseDao) Find

func (bd BaseDao) Find(sql string, p ...interface{}) *sql.Row

*

  • 查询一条记录

func (*BaseDao) Init

func (bd *BaseDao) Init(dao interface{})

*

  • 初始化Dao数据库连接

func (*BaseDao) Insert

func (bd *BaseDao) Insert(table string, params map[string]interface{}) (int64, error)

*

  • 插入一条记录

func (*BaseDao) MultiInsert

func (bd *BaseDao) MultiInsert(table string, params []map[string]interface{}) (int, error)

*

  • 插入多条记录

func (BaseDao) Select

func (bd BaseDao) Select(sql string, p ...interface{}) (*sql.Rows, error)

*

  • 查询记录

func (BaseDao) TDelete

func (bd BaseDao) TDelete(conn *sql.Tx, sql string, p ...interface{}) (int64, error)

*

  • 删除记录(事务内使用)

func (BaseDao) TFind

func (bd BaseDao) TFind(conn *sql.Tx, sql string, p ...interface{}) *sql.Row

*

  • 查询一条记录(事务内使用)

func (*BaseDao) TInsert

func (bd *BaseDao) TInsert(conn *sql.Tx, table string, params map[string]interface{}) (int64, error)

*

  • 插入一条记录(事务内使用)

func (*BaseDao) TMultiInsert

func (bd *BaseDao) TMultiInsert(conn *sql.Tx, table string, params []map[string]interface{}) (int, error)

*

  • 插入多条记录(事务内使用)

func (BaseDao) TSelect

func (bd BaseDao) TSelect(conn *sql.Tx, sql string, p ...interface{}) (*sql.Rows, error)

*

  • 查询记录

func (BaseDao) TUpdate

func (bd BaseDao) TUpdate(conn *sql.Tx, sql string, p ...interface{}) (int64, error)

*

  • 更新记录(事务内使用)

func (BaseDao) TUpdateById

func (bd BaseDao) TUpdateById(conn *sql.Tx, table string, id int32, params map[string]interface{}) (int64, error)

*

  • 根据主键id更新记录(事务内使用)

func (BaseDao) Transaction

func (bd BaseDao) Transaction(f func(*sql.Tx) (interface{}, error)) (interface{}, error)

*

  • 事务

func (BaseDao) Update

func (bd BaseDao) Update(sql string, p ...interface{}) (int64, error)

*

  • 更新记录

func (BaseDao) UpdateById

func (bd BaseDao) UpdateById(table string, id int32, params map[string]interface{}) (int64, error)

*

  • 根据主键id更新记录

type DatabaseConf

type DatabaseConf struct {
	Driver      string
	Ip          string
	Port        int
	Database    string
	Username    string
	Password    string
	Charset     string
	MaxConn     int
	MaxIdle     int
	ConnMaxLift int
}

type DbManager

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

func (*DbManager) Construct

func (dm *DbManager) Construct()

func (*DbManager) GetDbConnection

func (dm *DbManager) GetDbConnection(name string) (db *sql.DB)

type HttpClient

type HttpClient struct {
	Ctx context.Context

	Proxy     string `value:"client.http.proxy"`
	SkipHttps bool   `value:"client.http.skip_https"`
	// contains filtered or unexported fields
}

func (*HttpClient) Construct

func (c *HttpClient) Construct()

func (*HttpClient) Get

func (c *HttpClient) Get(r *RequestBody) (res *ResponseBody, err error)

func (*HttpClient) Post

func (c *HttpClient) Post(r *RequestBody) (res *ResponseBody, err error)

type KafkaSyncProducer

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

func NewProducer

func NewProducer(broker []string, debug bool) *KafkaSyncProducer

func (*KafkaSyncProducer) Send

func (sp *KafkaSyncProducer) Send(topic string, key string, value string) error

type Redis

type Redis struct {
	Ctx context.Context
	// contains filtered or unexported fields
}

func (*Redis) Construct

func (p *Redis) Construct()

func (*Redis) Delete

func (p *Redis) Delete(key string) (int64, error)

func (*Redis) Expire

func (p *Redis) Expire(key string, expire int) (bool, error)

func (*Redis) Get

func (p *Redis) Get(key string) (string, error)

func (*Redis) Setex

func (p *Redis) Setex(key string, value string, expire int) (string, error)

type RedisConf

type RedisConf struct {
	Host            string
	Port            int
	Database        int
	Password        string
	MaxIdle         int
	MaxActive       int
	IdleTimeout     int
	MaxConnLifetime int
	IdleCheck       int
}

type RequestBody added in v1.0.8

type RequestBody struct {
	Method  string
	Uri     string
	Header  map[string]string
	Params  map[string]string
	SParam  string
	Host    string
	Timeout int
}

type ResponseBody added in v1.0.8

type ResponseBody struct {
	Code int
	Body []byte
}

Jump to

Keyboard shortcuts

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