Documentation
¶
Index ¶
- Constants
- Variables
- func NewDbPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewHttpPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewMaxMindPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewMemCachePool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewMemoryPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewMongoPool(iObj iface.IObject, args ...interface{}) iface.IObject
- func NewRabbitMqPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewRedisPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- type Db
- func (d *Db) Begin(opts ...*sql.TxOptions) ITx
- func (d *Db) BeginContext(ctx context.Context, opts *sql.TxOptions) ITx
- func (d *Db) Exec(query string, args ...interface{}) sql.Result
- func (d *Db) ExecContext(ctx context.Context, query string, args ...interface{}) sql.Result
- func (d *Db) GetClient() *db.Client
- func (d *Db) GetDb(master bool) *sql.DB
- func (d *Db) Master() bool
- func (d *Db) Prepare(query string) IStmt
- func (d *Db) PrepareContext(ctx context.Context, query string) IStmt
- func (d *Db) Query(query string, args ...interface{}) *sql.Rows
- func (d *Db) QueryContext(ctx context.Context, query string, args ...interface{}) *sql.Rows
- func (d *Db) QueryOne(query string, args ...interface{}) IRow
- func (d *Db) QueryOneContext(ctx context.Context, query string, args ...interface{}) IRow
- func (d *Db) SetMaster(v bool)
- type Http
- func (h *Http) Do(req *http.Request, option ...*phttp.Option) *http.Response
- func (h *Http) DoMulti(requests []*http.Request, option ...*phttp.Option) []*http.Response
- func (h *Http) Get(addr string, data interface{}, option ...*phttp.Option) *http.Response
- func (h *Http) GetClient() *phttp.Client
- func (h *Http) Post(addr string, data interface{}, option ...*phttp.Option) *http.Response
- func (h *Http) SetPanicRecover(v bool)
- type IDb
- type IHttp
- type IMaxMind
- type IMemCache
- type IMemory
- type IMongo
- type IRabbitMq
- type IRedis
- type IRow
- type IStmt
- type ITx
- type MaxMind
- type MemCache
- func (m *MemCache) Add(key string, value interface{}, expire ...time.Duration) bool
- func (m *MemCache) Del(key string) bool
- func (m *MemCache) Exists(key string) bool
- func (m *MemCache) Get(key string) *value.Value
- func (m *MemCache) GetClient() *memcache.Client
- func (m *MemCache) Incr(key string, delta int) int
- func (m *MemCache) MAdd(items map[string]interface{}, expire ...time.Duration) bool
- func (m *MemCache) MDel(keys []string) bool
- func (m *MemCache) MGet(keys []string) map[string]*value.Value
- func (m *MemCache) MSet(items map[string]interface{}, expire ...time.Duration) bool
- func (m *MemCache) MultiRetrieve(cmd string, keys []string) []*memcache.Item
- func (m *MemCache) MultiStore(cmd string, items []*memcache.Item, expire ...time.Duration) bool
- func (m *MemCache) Retrieve(cmd, key string) *memcache.Item
- func (m *MemCache) Set(key string, value interface{}, expire ...time.Duration) bool
- func (m *MemCache) SetPanicRecover(v bool)
- func (m *MemCache) Store(cmd string, item *memcache.Item, expire ...time.Duration) bool
- type Memory
- func (m *Memory) Add(key string, value interface{}, expire ...time.Duration) bool
- func (m *Memory) Client() *memory.Client
- func (m *Memory) Del(key string) bool
- func (m *Memory) Exists(key string) bool
- func (m *Memory) Get(key string) *value.Value
- func (m *Memory) Incr(key string, delta int) int
- func (m *Memory) MAdd(items map[string]interface{}, expire ...time.Duration) bool
- func (m *Memory) MDel(keys []string) bool
- func (m *Memory) MGet(keys []string) map[string]*value.Value
- func (m *Memory) MSet(items map[string]interface{}, expire ...time.Duration) bool
- func (m *Memory) Set(key string, value interface{}, expire ...time.Duration) bool
- func (m *Memory) SetPanicRecover(v bool)
- type Mongo
- func (m *Mongo) Count(query interface{}, options ...bson.M) (int, error)
- func (m *Mongo) DeleteAll(query interface{}) error
- func (m *Mongo) DeleteOne(query interface{}) error
- func (m *Mongo) FindAll(query interface{}, result interface{}, options ...bson.M) error
- func (m *Mongo) FindAndModify(query interface{}, change mgo.Change, result interface{}, options ...bson.M) error
- func (m *Mongo) FindDistinct(query interface{}, key string, result interface{}, options ...bson.M) error
- func (m *Mongo) FindOne(query interface{}, result interface{}, options ...bson.M) error
- func (m *Mongo) GetClient() *mongo.Client
- func (m *Mongo) InsertAll(docs []interface{}) error
- func (m *Mongo) InsertOne(doc interface{}) error
- func (m *Mongo) MapReduce(query interface{}, job *mgo.MapReduce, result interface{}, options ...bson.M) error
- func (m *Mongo) PipeAll(pipeline interface{}, result interface{}) error
- func (m *Mongo) PipeOne(pipeline interface{}, result interface{}) error
- func (m *Mongo) UpdateAll(query interface{}, update interface{}) error
- func (m *Mongo) UpdateOne(query interface{}, update interface{}) error
- func (m *Mongo) UpdateOrInsert(query interface{}, update interface{}) error
- type RabbitMq
- func (r *RabbitMq) Consume(queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery
- func (r *RabbitMq) ConsumeExchange(exchangeName, exchangeType, queueName string, opCodes []string, limit int, ...) <-chan amqp.Delivery
- func (r *RabbitMq) DecodeBody(d amqp.Delivery, ret interface{}) error
- func (r *RabbitMq) DecodeHeaders(d amqp.Delivery) *rabbitmq.RabbitHeaders
- func (r *RabbitMq) ExchangeDeclare(dftExchange ...*rabbitmq.ExchangeData)
- func (r *RabbitMq) GetClient() *rabbitmq.Client
- func (r *RabbitMq) GetConsumeChannelBox(queueName string, opCodes []string, dftExchange ...*rabbitmq.ExchangeData) *rabbitmq.ChannelBox
- func (r *RabbitMq) Publish(opCode string, data interface{}, dftOpUid ...string) bool
- func (r *RabbitMq) PublishExchange(serviceName, exchangeName, exchangeType, opCode string, data interface{}, ...) bool
- func (r *RabbitMq) SetPanicRecover(v bool)
- type Redis
- func (r *Redis) Add(key string, value interface{}, expire ...time.Duration) bool
- func (r *Redis) Del(key string) bool
- func (r *Redis) Do(cmd string, args ...interface{}) interface{}
- func (r *Redis) Exists(key string) bool
- func (r *Redis) Get(key string) *value.Value
- func (r *Redis) GetClient() *redis.Client
- func (r *Redis) Incr(key string, delta int) int
- func (r *Redis) MAdd(items map[string]interface{}, expire ...time.Duration) bool
- func (r *Redis) MDel(keys []string) bool
- func (r *Redis) MGet(keys []string) map[string]*value.Value
- func (r *Redis) MSet(items map[string]interface{}, expire ...time.Duration) bool
- func (r *Redis) Set(key string, value interface{}, expire ...time.Duration) bool
- func (r *Redis) SetPanicRecover(v bool)
- type Row
- type Stmt
- func (s *Stmt) Close()
- func (s *Stmt) Exec(args ...interface{}) sql.Result
- func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) sql.Result
- func (s *Stmt) Query(args ...interface{}) *sql.Rows
- func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) *sql.Rows
- func (s *Stmt) QueryOne(args ...interface{}) IRow
- func (s *Stmt) QueryOneContext(ctx context.Context, args ...interface{}) IRow
- type Tx
- func (t *Tx) Commit() bool
- func (t *Tx) Exec(query string, args ...interface{}) sql.Result
- func (t *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) sql.Result
- func (t *Tx) Prepare(query string) IStmt
- func (t *Tx) PrepareContext(ctx context.Context, query string) IStmt
- func (t *Tx) Query(query string, args ...interface{}) *sql.Rows
- func (t *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) *sql.Rows
- func (t *Tx) QueryOne(query string, args ...interface{}) IRow
- func (t *Tx) QueryOneContext(ctx context.Context, query string, args ...interface{}) IRow
- func (t *Tx) Rollback() bool
Constants ¶
const ( DefaultMongoId = "mongo" ErrInvalidOpt = "mongo: invalid option " )
mongo
const ( DefaultDbTimeout = 10 * time.Second DefaultDbId = "db" )
db
const (
DefaultHttpId = "http"
)
http
const (
DefaultMaxMindId = "maxMind"
)
maxMind
const (
DefaultMemCacheId = "memCache"
)
memCache
const (
DefaultMemoryId = "memory"
)
memory
const (
DefaultRabbitId = "rabbitMq"
)
rabbitMq
const (
DefaultRedisId = "redis"
)
redis
Variables ¶
var DbClass string
var HttpClass string
var MaxMindClass string
var MemCacheClass string
var MemoryClass string
var MongoClass string
var RabbitMqClass string
var RedisClass string
Functions ¶
func NewDbPool ¶
NewDbPool of db Client from pool, add context support. usage: db := this.GetObjPool(adapter.DbClass, adapter.NewDbPool).(adapter.IDb)/(*adapter.Db)
func NewHttpPool ¶
Http of Http Client from pool, add context support. usage: http := this.GetObjPool(adapter.HttpClass, adapter.NewHttpPool).(adapter.IHttp)/(*adapter.Http)
func NewMaxMindPool ¶
NewMaxMindPool of MaxMind Client from pool, add context support. usage: mmd := this.GetObjPool(adapter.MaxMindClass, adapter.NewMaxMindPool).(adapter.IMaxMind)/(*adapter.MaxMind)
func NewMemCachePool ¶
NewMemCachePool of MemCache Client from pool, add context support. usage: mc := this.GetObjPool(adapter.MemCacheClass, adapter.NewMemCachePool).(adapter.IMemCache)/(*adapter.MemCache)
func NewMemoryPool ¶
NewMemoryPool of Memory Client from object pool, add context support. usage: memory := this.GetObjPool(adapter.MemoryClass, adapter.NewMemoryPool).(adapter.IMemory)/(*adapter.Memory)
func NewMongoPool ¶
NewMongoPool of Mongo Client from pool, add context support. usage: mongo := this.GetObjectPool(adapter.MongoClass, adapter.NewMongoPool,db, coll)).(adapter.IMongo)/(*adapter.Mongo)
func NewRabbitMqPool ¶
NewRabbitMqPool of RabbitMq Client from pool, add context support. usage: rabbitMq := this.GetObjPool(adapter.RabbitMqClass,adapter.NewRabbitMqPool).(adapter.IRabbitMq)/(*adapter.RabbitMq)
Types ¶
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
func NewDb ¶
NewDb of db Client, add context support. usage: db := this.GetObj(adapter.NewDb()).(adapter.IDb)/(*adapter.Db)
func (*Db) Begin ¶
Begin start a transaction with default timeout context and optional opts, if opts is nil, default driver option will be used.
func (*Db) BeginContext ¶
BeginContext start a transaction with specified context and optional opts, if opts is nil, default driver option will be used.
func (*Db) ExecContext ¶
ExecContext perform exec using a specified context.
func (*Db) Prepare ¶
Prepare creates a prepared statement for later queries or executions, the Close method must be called by caller.
func (*Db) PrepareContext ¶
PrepareContext creates a prepared statement for later queries or executions, the Close method must be called by caller.
func (*Db) QueryContext ¶
QueryContext perform query using a specified context.
func (*Db) QueryOne ¶
QueryOne perform one row query using a default timeout context, and always returns a non-nil value, Errors are deferred until Row's Scan method is called.
func (*Db) QueryOneContext ¶
QueryOneContext perform one row query using a specified context, and always returns a non-nil value, Errors are deferred until Row's Scan method is called.
type Http ¶
func NewHttp ¶
Http of Http Client, add context support. usage: http := this.GetObj(adapter.NewHttp()).(adapter.IHttp)/(*adapter.Http)
func (*Http) SetPanicRecover ¶
type IDb ¶
type IDb interface { SetMaster(v bool) GetDb(master bool) *sql.DB Begin(opts ...*sql.TxOptions) ITx BeginContext(ctx context.Context, opts *sql.TxOptions) ITx QueryOne(query string, args ...interface{}) IRow QueryOneContext(ctx context.Context, query string, args ...interface{}) IRow Query(query string, args ...interface{}) *sql.Rows QueryContext(ctx context.Context, query string, args ...interface{}) *sql.Rows Exec(query string, args ...interface{}) sql.Result ExecContext(ctx context.Context, query string, args ...interface{}) sql.Result Prepare(query string) IStmt PrepareContext(ctx context.Context, query string) IStmt }
type IHttp ¶
type IHttp interface { SetPanicRecover(v bool) Get(addr string, data interface{}, option ...*phttp.Option) *http.Response Post(addr string, data interface{}, option ...*phttp.Option) *http.Response Do(req *http.Request, option ...*phttp.Option) *http.Response DoMulti(requests []*http.Request, option ...*phttp.Option) []*http.Response }
type IMemCache ¶
type IMemCache interface { SetPanicRecover(v bool) Get(key string) *value.Value MGet(keys []string) map[string]*value.Value Set(key string, value interface{}, expire ...time.Duration) bool MSet(items map[string]interface{}, expire ...time.Duration) bool Add(key string, value interface{}, expire ...time.Duration) bool MAdd(items map[string]interface{}, expire ...time.Duration) bool Del(key string) bool MDel(keys []string) bool Exists(key string) bool Incr(key string, delta int) int Retrieve(cmd, key string) *memcache.Item MultiRetrieve(cmd string, keys []string) []*memcache.Item Store(cmd string, item *memcache.Item, expire ...time.Duration) bool MultiStore(cmd string, items []*memcache.Item, expire ...time.Duration) bool }
type IMemory ¶
type IMemory interface { SetPanicRecover(v bool) Get(key string) *value.Value MGet(keys []string) map[string]*value.Value Set(key string, value interface{}, expire ...time.Duration) bool MSet(items map[string]interface{}, expire ...time.Duration) bool Add(key string, value interface{}, expire ...time.Duration) bool MAdd(items map[string]interface{}, expire ...time.Duration) bool Del(key string) bool MDel(keys []string) bool Exists(key string) bool Incr(key string, delta int) int }
type IMongo ¶
type IMongo interface { FindOne(query interface{}, result interface{}, options ...bson.M) error FindAll(query interface{}, result interface{}, options ...bson.M) error FindAndModify(query interface{}, change mgo.Change, result interface{}, options ...bson.M) error FindDistinct(query interface{}, key string, result interface{}, options ...bson.M) error InsertOne(doc interface{}) error InsertAll(docs []interface{}) error UpdateOne(query interface{}, update interface{}) error UpdateAll(query interface{}, update interface{}) error UpdateOrInsert(query interface{}, update interface{}) error DeleteOne(query interface{}) error DeleteAll(query interface{}) error Count(query interface{}, options ...bson.M) (int, error) PipeOne(pipeline interface{}, result interface{}) error PipeAll(pipeline interface{}, result interface{}) error MapReduce(query interface{}, job *mgo.MapReduce, result interface{}, options ...bson.M) error }
type IRabbitMq ¶
type IRabbitMq interface { SetPanicRecover(v bool) ExchangeDeclare(dftExchange ...*rabbitmq.ExchangeData) Publish(opCode string, data interface{}, dftOpUid ...string) bool PublishExchange(serviceName, exchangeName, exchangeType, opCode string, data interface{}, dftOpUid ...string) bool GetConsumeChannelBox(queueName string, opCodes []string, dftExchange ...*rabbitmq.ExchangeData) *rabbitmq.ChannelBox Consume(queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery ConsumeExchange(exchangeName, exchangeType, queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery DecodeBody(d amqp.Delivery, ret interface{}) error DecodeHeaders(d amqp.Delivery) *rabbitmq.RabbitHeaders }
type IRedis ¶
type IRedis interface { SetPanicRecover(v bool) Get(key string) *value.Value MGet(keys []string) map[string]*value.Value Set(key string, value interface{}, expire ...time.Duration) bool MSet(items map[string]interface{}, expire ...time.Duration) bool Add(key string, value interface{}, expire ...time.Duration) bool MAdd(items map[string]interface{}, expire ...time.Duration) bool Del(key string) bool MDel(keys []string) bool Exists(key string) bool Incr(key string, delta int) int Do(cmd string, args ...interface{}) interface{} }
type IStmt ¶
type IStmt interface { iface.IObject Close() QueryOne(args ...interface{}) IRow QueryOneContext(ctx context.Context, args ...interface{}) IRow Query(args ...interface{}) *sql.Rows QueryContext(ctx context.Context, args ...interface{}) *sql.Rows Exec(args ...interface{}) sql.Result ExecContext(ctx context.Context, args ...interface{}) sql.Result }
type ITx ¶
type ITx interface { iface.IObject Commit() bool Rollback() bool QueryOne(query string, args ...interface{}) IRow QueryOneContext(ctx context.Context, query string, args ...interface{}) IRow Query(query string, args ...interface{}) *sql.Rows QueryContext(ctx context.Context, query string, args ...interface{}) *sql.Rows Exec(query string, args ...interface{}) sql.Result ExecContext(ctx context.Context, query string, args ...interface{}) sql.Result Prepare(query string) IStmt PrepareContext(ctx context.Context, query string) IStmt }
type MaxMind ¶
func NewMaxMind ¶
NewMaxMind of MaxMind Client, add context support. usage: mmd := this.GetObj(adapter.NewMaxMind()).(adapter.IMaxMind)/(*adapter.MaxMind)
type MemCache ¶
func NewMemCache ¶
NewMemCache of MemCache Client, add context support. usage: mc := this.GetObj(adapter.NewMemCache()).(adapter.IMemCache)/(*adapter.MemCache)
func (*MemCache) MultiRetrieve ¶
func (*MemCache) MultiStore ¶
func (*MemCache) SetPanicRecover ¶
type Memory ¶
func NewMemory ¶
NewMemory of Memory Client, add context support. usage: memory := this.GetObj(adapter.NewMemory()).(adapter.IMemory)/(*adapter.Memory)
func (*Memory) SetPanicRecover ¶
type Mongo ¶
func NewMongo ¶
NewMongo of Mongo Client, add context support. usage: mongo := this.GetObject(adapter.NewMongo(db, coll)).(adapter.IMongo)/(*adapter.Mongo)
func (*Mongo) FindAll ¶
FindAll retrieve all documents that match the query, param result must be a slice(interface{}, map, bson.M or bson compatible struct) other params see FindOne()
func (*Mongo) FindAndModify ¶
func (m *Mongo) FindAndModify(query interface{}, change mgo.Change, result interface{}, options ...bson.M) error
FindAndModify execute findAndModify command, which allows atomically update or remove one document, param change specify the change operation, eg. mgo.Change{Update:bson.M{"$inc": bson.M{"n":1}}, ReturnNew:true}, other params see FindOne()
func (*Mongo) FindDistinct ¶
func (m *Mongo) FindDistinct(query interface{}, key string, result interface{}, options ...bson.M) error
FindDistinct retrieve distinct values for the param key, param result must be a slice, other params see FindOne()
func (*Mongo) FindOne ¶
FindOne retrieve the first document that match the query, query can be a map or bson compatible struct, such as bson.M or properly typed map, nil query is equivalent to empty query such as bson.M{}. result is pointer to interface{}, map, bson.M or bson compatible struct, if interface{} type is provided, the output result is a bson.M. options provided optional query option listed as follows: fields: bson.M, set output fields, eg. bson.M{"_id":0, "name":1}, sort: string or []string, set sort order, eg. "key1" or []string{"key1", "-key2"}, skip: int, set skip number, eg. 100, limit: int, set result limit, eg. 1, hint: string or []string, set index hint, eg. []string{"key1", "key2"}
for example:
var v1 interface{} // type of output v1 is bson.M m.FindOne(bson.M{"_id":"k1"}, &v1) var v2 struct { Id string `bson:"_id"` Name string `bson:"name"` Value string `bson:"value"` } m.FindOne(bson.M{"_id": "k1"}, &v2)
func (*Mongo) InsertAll ¶
InsertAll insert all documents provided by params docs into collection, for example:
docs := []interface{}{ bson.M{"_id":1, "name":"v1"}, bson.M{"_id":2, "name":"v2"}, } m.InsertAll(docs)
func (*Mongo) InsertOne ¶
InsertOne insert one document into collection, param doc can be a map, bson.M, bson compatible struct, for example:
m.InsertOne(bson.M{"field1":"value1", "field2":"value2"}) doc := struct { Field1 string `bson:"field1"` Field2 string `bson:"field2"` } {"value1", "value2"} m.InsertOne(doc)
func (*Mongo) MapReduce ¶
func (m *Mongo) MapReduce(query interface{}, job *mgo.MapReduce, result interface{}, options ...bson.M) error
MapReduce execute map/reduce job that match the query. param result is a slice(interface{}, map, bson.M, bson compatible struct), param query and options see FindOne(). for example:
job := &mgo.MapReduce{ Map: "function() { emit(this.n, 1) }", Reduce: "function(key, values) { return Array.sum(values) }", } result := []bson.M{} m.MapReduce(query, job, &result)
func (*Mongo) PipeAll ¶
PipeAll execute aggregation queries and get all item from result set. param result must be slice(interface{}, map, bson.M or bson compatible struct). see PipeOne().
func (*Mongo) PipeOne ¶
PipeOne execute aggregation queries and get the first item from result set. param pipeline must be a slice, such as []bson.M, param result is a pointer to interface{}, map, bson.M or bson compatible struct. for example:
pipeline := []bson.M{ bson.M{"$match": bson.M{"status":"A"}}, bson.M{"$group": bson.M{"_id":"$field1", "total":"$field2"}}, } m.PipeOne(pipeline, &result)
func (*Mongo) UpdateOne ¶
UpdateOne update one document that match the query, mgo.ErrNotFound is returned if a document not found, a value of *LastError is returned if other error occurred.
func (*Mongo) UpdateOrInsert ¶
UpdateOrInsert update a existing document that match the query, or insert a new document base on the update document if no document match, an error of *LastError is returned if error is detected.
type RabbitMq ¶
func NewRabbitMq ¶
NewRabbitMq of RabbitMq Client, add context support. usage: rabbitMq := this.GetObj(adapter.NewRabbitMq()).(adapter.IRabbitMq)/(*adapter.RabbitMq)
func (*RabbitMq) Consume ¶
func (r *RabbitMq) Consume(queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery
消费,返回chan 可以不停取数据 queueName 队列名字 opCodes 绑定队列的code limit 每次接收多少条 autoAck 是否自动答复 如果为false 需要手动调用Delivery.ack(false) noWait 是否一直等待 exclusive 是否独占队列
func (*RabbitMq) ConsumeExchange ¶ added in v0.1.99
func (r *RabbitMq) ConsumeExchange(exchangeName, exchangeType, queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery
消费,返回chan 可以不停取数据 exchangeName 交换机名 exchangeType 交换机type queueName 队列名字 opCodes 绑定队列的code limit 每次接收多少条 autoAck 是否自动答复 如果为false 需要手动调用Delivery.ack(false) noWait 是否一直等待 exclusive 是否独占队列
func (*RabbitMq) DecodeHeaders ¶
func (r *RabbitMq) DecodeHeaders(d amqp.Delivery) *rabbitmq.RabbitHeaders
func (*RabbitMq) ExchangeDeclare ¶
func (r *RabbitMq) ExchangeDeclare(dftExchange ...*rabbitmq.ExchangeData)
func (*RabbitMq) GetConsumeChannelBox ¶
func (r *RabbitMq) GetConsumeChannelBox(queueName string, opCodes []string, dftExchange ...*rabbitmq.ExchangeData) *rabbitmq.ChannelBox
func (*RabbitMq) PublishExchange ¶ added in v0.1.99
func (*RabbitMq) SetPanicRecover ¶
type Redis ¶
func NewRedis ¶
NewRedis of Redis Client, add context support. usage: redis := this.GetObject(adapter.NewRedis()).(*adapter.Redis)
func (*Redis) Do ¶
支持的命令请查阅:Redis.allRedisCmd args = [0:"key"] Example: redis := t.GetObject(Redis.AdapterClass).(*Redis.Adapter) retI := redis.Do("SADD","myTest", "test1" ret := retI.(int) fmt.Println(ret) = 1 retList :=redis.Do("SMEMBERS","myTest" retListI,_:=ret.([]interface{})
for _,v:=range retListI{ vv :=pgo.NewValue(v) // 写入的时候有pgo.Encode(),如果存入的是结构体或slice map 需要decode,其他类型直接断言类型 fmt.Println(vv.String()) // test1 }
func (*Redis) SetPanicRecover ¶
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
Stmt wrap sql.Stmt, add context support
func (*Stmt) ExecContext ¶
ExecContext perform exec using a specified context.
func (*Stmt) QueryContext ¶
QueryContext perform query using a specified context.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx wrapper for sql.Tx
func (*Tx) ExecContext ¶
ExecContext perform exec using a specified context.
func (*Tx) Prepare ¶
Prepare creates a prepared statement for later queries or executions, the Close method must be called by caller.
func (*Tx) PrepareContext ¶
PrepareContext creates a prepared statement for later queries or executions, the Close method must be called by caller.
func (*Tx) QueryContext ¶
QueryContext perform query using a specified context.
func (*Tx) QueryOne ¶
QueryOne perform one row query using a default timeout context, and always returns a non-nil value, Errors are deferred until Row's Scan method is called.
func (*Tx) QueryOneContext ¶
QueryOneContext perform one row query using a specified context, and always returns a non-nil value, Errors are deferred until Row's Scan method is called.