toolkit

package
v0.0.0-...-3f61646 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: Apache-2.0 Imports: 27 Imported by: 4

Documentation

Index

Constants

View Source
const (
	CreatedAtColumn = "created_at"
	UpdatedAtColumn = "updated_at"
)

Variables

This section is empty.

Functions

func CloseNSQConsumer

func CloseNSQConsumer(client *nsq.Consumer)

func CloseNSQConsumerList

func CloseNSQConsumerList(clientList []*nsq.Consumer)

func CreateConcurrentNSQConsumer

func CreateConcurrentNSQConsumer(topicName, channelName string, lookupAddressList []string,
	messageHandler nsq.Handler, count int) []*nsq.Consumer

func CreateConsumer

func CreateConsumer(cnf *std.ConfigNsqConsumer) (*nsq.Consumer, error)

func CreateDB

func CreateDB(config std.ConfigMysql) *gorm.DB

func CreateDB_test

func CreateDB_test(config std.ConfigMysql) *gorm.DB

CreateDB 初始化MYSQL实例

func CreateNSQConsumer

func CreateNSQConsumer(topicName, channelName string, lookupAddressList []string,
	messageHandler nsq.Handler) *nsq.Consumer

TODO consumer

func CreateProducer

func CreateProducer(nsqdAddress string) *nsq.Producer

func Death

func Death(will func())

func GO

func GO(goroutine StdGoRoutine)

func GenerateRangeNum

func GenerateRangeNum(min, max int) int

GenerateRangeNum 生成一个区间范围的随机数

func GetAppFlagFromUid

func GetAppFlagFromUid(uid int64) std.AppFlag

func GetAppTypeFromUid

func GetAppTypeFromUid(uid int64) string

func GetDBIdFromUserID

func GetDBIdFromUserID(uid int64) int64

func GetDBIdsFromUserIDs

func GetDBIdsFromUserIDs(uids []int64) []int64

func GetUserIDFromDBId

func GetUserIDFromDBId(appType string, dbId int64) int64

func InitRedis

func InitRedis(config std.ConfigRedis) *redis.Client

InitRedis initializes the redis connection. Usage: client := InitRedis(config)

func InitRedisRing

func InitRedisRing(config ...std.ConfigRedis) *redis.Ring

func MapToSyncMap

func MapToSyncMap(m map[interface{}]interface{}) *sync.Map

func PostRequest

func PostRequest(url string, data interface{}) ([]byte, int, error)

func RandomDateTimeString

func RandomDateTimeString(strlen int, stype string) string

func SyncMapToMap

func SyncMapToMap(m *sync.Map) map[interface{}]interface{}

Types

type CassandraHelp

type CassandraHelp struct {
	Session       *gocql.Session
	ClusterConfig *gocql.ClusterConfig
}

func GetCassandraHelp

func GetCassandraHelp() *CassandraHelp

func InitNewCassandraHelp

func InitNewCassandraHelp(config std.ConfigCassandra) *CassandraHelp

func (*CassandraHelp) Close

func (c *CassandraHelp) Close()

Close closes the cassandra session

type DbClient

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

func ConfigDatabase

func ConfigDatabase(c ...std.ConfigMysql) *DbClient

func (*DbClient) Close

func (s *DbClient) Close()

func (*DbClient) Master

func (s *DbClient) Master() *gorm.DB

func (*DbClient) Slave

func (s *DbClient) Slave() *gorm.DB

func (*DbClient) TableRead

func (s *DbClient) TableRead(t string) *gorm.DB

func (*DbClient) TableWrite

func (s *DbClient) TableWrite(t string) *gorm.DB

type DbSession

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

func BeginDbSession

func BeginDbSession(db *gorm.DB) *DbSession

func (*DbSession) Api

func (s *DbSession) Api() *gorm.DB

func (*DbSession) Commit

func (s *DbSession) Commit() *gorm.DB

func (*DbSession) End

func (s *DbSession) End() *gorm.DB

为什么要加 defer sessin.End() 呢,不怕你现在写错,怕以后维护的人写错 为什么要给 goroutine 加 defer recover 呢? 同理,这不是php或者python,挂了就真挂了

func (*DbSession) Rollback

func (s *DbSession) Rollback() *gorm.DB

type Logger

type Logger struct {
}

Logger customizes the gorm logger.

func (Logger) Print

func (Logger Logger) Print(values ...interface{})

Print uses logrus to log SQL.

type MemoPool

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

func NewSimpleMemoPool

func NewSimpleMemoPool() *MemoPool

func (*MemoPool) Memoize

func (mp *MemoPool) Memoize(key string, caller func() interface{}, timeout uint) interface{}

memorize result return from caller() block, timeout in N seconds

func (*MemoPool) UnMemoize

func (mp *MemoPool) UnMemoize(key string)

func (*MemoPool) UnMemoizeAll

func (mp *MemoPool) UnMemoizeAll()

type QueueWorker

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

func NewQueueWorker

func NewQueueWorker(workers int, onWork WorkAction) *QueueWorker

func (*QueueWorker) Enqueue

func (sl *QueueWorker) Enqueue(job interface{})

func (*QueueWorker) Start

func (sl *QueueWorker) Start()

func (*QueueWorker) Stop

func (sl *QueueWorker) Stop()

func (*QueueWorker) Work

func (sl *QueueWorker) Work(index int)

type RequestAggregator

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

func NewRequestAggregator

func NewRequestAggregator(batchSize, workers int, sendRequestFunc SendRequest) *RequestAggregator

func (*RequestAggregator) Enqueue

func (sa *RequestAggregator) Enqueue(req interface{})

func (*RequestAggregator) Start

func (sa *RequestAggregator) Start()

func (*RequestAggregator) Stop

func (sa *RequestAggregator) Stop()

type SendEmail

type SendEmail struct {
	ToEmail []string
	Subject string
	Body    string
}

func (*SendEmail) Start

func (self *SendEmail) Start()

type SendRequest

type SendRequest func([]interface{}) error

type StdGoRoutine

type StdGoRoutine interface {
	Start()
}

type TimeMixin

type TimeMixin struct {
	CreatedAt time.Time `gorm:"column:created_at;type:TIMESTAMP(6);default:CURRENT_TIMESTAMP(6);index"`
	UpdatedAt time.Time `gorm:"column:updated_at;type:TIMESTAMP(6);default:CURRENT_TIMESTAMP(6);index"`
}

TimeMixin mixin

type WorkAction

type WorkAction func(int)

Directories

Path Synopsis
Package jsonpb provides marshaling and unmarshaling between protocol buffers and JSON.
Package jsonpb provides marshaling and unmarshaling between protocol buffers and JSON.

Jump to

Keyboard shortcuts

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