Documentation ¶
Index ¶
- Constants
- Variables
- func FormatLogID(logid string) string
- func GenerateLogID() string
- func GetIndex() string
- func GetLocalIP() string
- func GetLocalIPWithPrefix(prefix string) string
- func GetMiddleNight() time.Time
- func GetNewID() int64
- func GetNextMiddleNight() time.Time
- func GetPosBefore(mid int64, groupMsgIds []int64) int
- func Hashing() int64
- func InitDirtyManager(wds []string) (err error)
- func InitEsClient(hosts []string, index, ttype string, shardNum, replicaNum, refreshInterval int)
- func InitHeartBeat(isMaster bool, port int, cb func(val string), addr string)
- func InitIDFactory(node int64) (err error)
- func InitKafkaLogProducer(addrs []string, topic string, bufSize int, timeout time.Duration, ...)
- func InitKafkaProducer(addrs []string, topic string, bufSize int, timeout time.Duration, ...)
- func InitKafkaProducerA(clientName string, addrs []string, topic string, bufSize int, ...)
- func InitMetrics(service, metricSrv string) (err error)
- func InitTicker()
- func InitUdpClient(token string)
- func Insert2Es(dat string) error
- func Insert2EsBulk(dats []interface{}) error
- func IsForbidden(content string) bool
- func KafkaClose()
- func LookupIP() string
- func MetricCounter(tags map[string]string, cnt int64)
- func MetricTimer(tags map[string]string, latency int64)
- func SendDingDing(title, content string) error
- func SendHeartBeat()
- func SendLog(key, data []byte) error
- func SendMsgA(clientName string, key, data []byte) error
- func SendMsgAWithTopic(topic, clientName string, key, data []byte) error
- func SendTask(key, data []byte) error
- func UDPServer(port int, cb func(string))
- func Ungzip(r io.Reader) (io.ReadCloser, error)
- func Ungzip2Bytes(r io.Reader) ([]byte, error)
- type ApplicationMessage
- type AsyncJob
- type CacheManager
- type CacheRequest
- type Chain
- type CommonCache
- func (localCache *CommonCache) Get(key interface{}) (interface{}, bool)
- func (localCache *CommonCache) IsHit(key interface{}) bool
- func (localCache *CommonCache) Len() int
- func (localCache *CommonCache) Remove(key interface{})
- func (localCache *CommonCache) Set(key, val interface{})
- func (localCache *CommonCache) SetWithTtl(key, val interface{}, ttl int)
- type Comparator
- type ConsumerCallback
- type DBClient
- func NewDBClient(name, server, user, passwd string) *DBClient
- func NewDBClientPhoenix(dataSourceName string, maxConn int, sessionDuration time.Duration) *DBClient
- func NewDBClientV2(name, server, user, passwd string, maxConn int, timeout int) *DBClient
- func NewDBClientV3(name, server, user, passwd string, maxConn int, timeout int, ...) *DBClient
- func NewDBClientV4(name, server, user, passwd string, maxConn int, connectTime int, timeout int, ...) *DBClient
- type GenFixedTimePoint
- type GetData
- type GetDataChain
- type Hadoop
- type HandlerFunc
- type HandlersChain
- type Imgo
- type KafkaConsumer
- type KafkaProducer
- type LocalCache
- func (localCache *LocalCache) Get(key interface{}) (interface{}, bool)
- func (localCache *LocalCache) IsHit(key interface{}) bool
- func (localCache *LocalCache) Len() int
- func (localCache *LocalCache) Remove(key interface{})
- func (localCache *LocalCache) Set(key, val interface{})
- func (localCache *LocalCache) SetWithTtl(key, val interface{}, ttl int)
- type MongoDb
- func (mdb *MongoDb) Find(col string, query interface{}, result interface{}, sortFileds ...string) error
- func (mdb *MongoDb) FindAll(col string, query interface{}, result interface{}, sortFileds ...string) error
- func (mdb *MongoDb) FindOne(col string, query interface{}, result interface{}) error
- func (mdb *MongoDb) FindX(col string, query interface{}, result interface{}, count int, ...) error
- func (mdb *MongoDb) Insert(col string, record interface{}) error
- func (mdb *MongoDb) Remove(col string, selector interface{}) error
- func (mdb *MongoDb) Update(col string, selector interface{}, update interface{}) error
- func (mdb *MongoDb) Upsert(col string, selector interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
- type OrderSet
- func (ors *OrderSet) Add(items ...interface{})
- func (ors *OrderSet) AddTopN(items ...interface{})
- func (ors *OrderSet) Clear()
- func (ors *OrderSet) Contains(items ...interface{}) bool
- func (ors *OrderSet) Empty() bool
- func (ors *OrderSet) Remove(items ...interface{})
- func (ors *OrderSet) Size() int
- func (ors *OrderSet) String() string
- func (ors *OrderSet) Values() []interface{}
- type RedisClient
- func (rc *RedisClient) Del(key string) error
- func (rc *RedisClient) GetAllKeys(pat string) (keys []string)
- func (rc *RedisClient) GetInt(key string) (int, error)
- func (rc *RedisClient) GetInt64(key string) (int64, error)
- func (rc *RedisClient) GetString(key string) (string, error)
- func (rc *RedisClient) HGet(key, member string) (interface{}, error)
- func (rc *RedisClient) HGetInt64(key, member string) (int64, error)
- func (rc *RedisClient) HSet(key, member string, val interface{}) error
- func (rc *RedisClient) MultiGetString(key []string) ([]string, error)
- func (rc *RedisClient) MultiSetString(members map[string]string, ex int) (err error)
- func (rc *RedisClient) Remove(key string)
- func (rc *RedisClient) Scan(pat string, offset int) (keys []string, iter int)
- func (rc *RedisClient) SetInt(key string, val int, ex time.Duration) error
- func (rc *RedisClient) SetInt64(key string, val int64, ex time.Duration) error
- func (rc *RedisClient) SetString(key, val string, ex int) error
- func (rc *RedisClient) ZAdd(key string, members map[string]int64, ttl int)
- func (rc *RedisClient) ZAddAndTrim(key string, members map[string]int64, start int, stop int, ex time.Duration) error
- func (rc *RedisClient) ZAddOne(key string, score int64, val string, limit int, ex time.Duration) error
- func (rc *RedisClient) ZRange(key string, start int, stop int) ([]string, error)
- func (rc *RedisClient) ZRangeWithScore(key string, start int, stop int) (map[string]int64, error)
- func (rc *RedisClient) ZRem(key, member string) (int, error)
- func (rc *RedisClient) ZRemRangeByRank(key string, start int, stop int) (int, error)
- func (rc *RedisClient) ZRevRange(key string, start int, stop int) ([]string, error)
- func (rc *RedisClient) ZScore(key string, member string) (string, error)
- type Ticker
- type UIDFactory
- type UdpClient
Constants ¶
View Source
const (
DateFmt = "_%d_%02d_%02d"
)
View Source
const (
DefaultWorkerNum = 2
)
View Source
const METRIC_SERVICE_DEFAULT = "161.202.208.20:18694"
Variables ¶
View Source
var ( TdyIndex string IndexLock sync.RWMutex EsClient elasticsearch.EsClientV3 // config Hosts []string Index string Type string ShardNum int ReplicaNum int RefreshInterval int )
View Source
var Default = &UIDFactory{}
View Source
var IDFactory *snowflake.Node
View Source
var SERVICE string
Functions ¶
func FormatLogID ¶
func GenerateLogID ¶
func GenerateLogID() string
func GetLocalIP ¶
func GetLocalIP() string
func GetLocalIPWithPrefix ¶
func GetMiddleNight ¶
func GetNextMiddleNight ¶
func InitDirtyManager ¶
func InitEsClient ¶
func InitIDFactory ¶
func InitKafkaLogProducer ¶
func InitKafkaProducer ¶
func InitKafkaProducerA ¶
func InitMetrics ¶
func InitTicker ¶
func InitTicker()
func InitUdpClient ¶
func InitUdpClient(token string)
func Insert2EsBulk ¶
func Insert2EsBulk(dats []interface{}) error
func IsForbidden ¶
func KafkaClose ¶
func KafkaClose()
func MetricCounter ¶
func SendDingDing ¶
func SendHeartBeat ¶
func SendHeartBeat()
func SendMsgAWithTopic ¶
Types ¶
type ApplicationMessage ¶
type AsyncJob ¶
type AsyncJob struct {
// contains filtered or unexported fields
}
AsyncJob 异步写入, 考虑更通用的方式
func NewAsyncJob ¶
func NewAsyncJobA ¶
func (*AsyncJob) AddJobNoLoss ¶
type CacheManager ¶
func NewCacheManager ¶
func NewCacheManager() *CacheManager
func (*CacheManager) GetData ¶
func (cm *CacheManager) GetData(ctx context.Context, key interface{}) interface{}
context.WithValue(ctx, userKey, u) u, ok := ctx.Value(userKey).(*User)
type CacheRequest ¶
type CacheRequest struct {
// contains filtered or unexported fields
}
func (*CacheRequest) Abort ¶
func (c *CacheRequest) Abort()
func (*CacheRequest) GetData ¶
func (c *CacheRequest) GetData() (interface{}, bool)
func (*CacheRequest) GetKey ¶
func (c *CacheRequest) GetKey() interface{}
func (*CacheRequest) Next ¶
func (c *CacheRequest) Next()
func (*CacheRequest) SetData ¶
func (c *CacheRequest) SetData(data interface{})
type Chain ¶
type Chain struct { Errors errorMsgs Val interface{} // contains filtered or unexported fields }
func (*Chain) Handler ¶
func (c *Chain) Handler() HandlerFunc
func (*Chain) Use ¶
func (c *Chain) Use(h HandlerFunc) *Chain
func (*Chain) Uses ¶
func (c *Chain) Uses(h ...HandlerFunc) *Chain
type CommonCache ¶
type CommonCache struct {
// contains filtered or unexported fields
}
key=value 通用存储
func NewCommonCache ¶
func NewCommonCache(size int, expireTime time.Duration) *CommonCache
func (*CommonCache) Get ¶
func (localCache *CommonCache) Get(key interface{}) (interface{}, bool)
func (*CommonCache) Len ¶
func (localCache *CommonCache) Len() int
func (*CommonCache) Remove ¶
func (localCache *CommonCache) Remove(key interface{})
func (*CommonCache) Set ¶
func (localCache *CommonCache) Set(key, val interface{})
func (*CommonCache) SetWithTtl ¶
func (localCache *CommonCache) SetWithTtl(key, val interface{}, ttl int)
type Comparator ¶
type Comparator func(a, b interface{}) int
type ConsumerCallback ¶
type ConsumerCallback interface {
Consume(message *sarama.ConsumerMessage) error
}
type DBClient ¶
func NewDBClient ¶
func NewDBClientPhoenix ¶
func NewDBClientV2 ¶
timeout ms
func NewDBClientV3 ¶
type GenFixedTimePoint ¶
type GenFixedTimePoint struct {
// contains filtered or unexported fields
}
func NewGenFixTimePoint ¶
func NewGenFixTimePoint(fixedHour int) *GenFixedTimePoint
func (*GenFixedTimePoint) GetFixedTime ¶
func (gf *GenFixedTimePoint) GetFixedTime() time.Time
func (*GenFixedTimePoint) GetFixedTimeStr ¶
func (gf *GenFixedTimePoint) GetFixedTimeStr() string
func (*GenFixedTimePoint) GetPrevFixedTimeStr ¶
func (gf *GenFixedTimePoint) GetPrevFixedTimeStr() string
type GetData ¶
type GetData func(*CacheRequest)
type GetDataChain ¶
type GetDataChain []GetData
type HandlerFunc ¶
type HandlerFunc func(*Chain)
type HandlersChain ¶
type HandlersChain []HandlerFunc
func (HandlersChain) Last ¶
func (c HandlersChain) Last() HandlerFunc
Last returns the last handler in the chain. ie. the last handler is the main own.
type KafkaConsumer ¶
type KafkaConsumer struct {
// contains filtered or unexported fields
}
func NewKafkaConsumer ¶
func NewKafkaConsumer(brokers []string, topic, group string, workerNum int, cb ConsumerCallback) *KafkaConsumer
func NewKafkaConsumerV2 ¶
func NewKafkaConsumerV2(brokers []string, topics []string, group string, workerNum int, cb ConsumerCallback) *KafkaConsumer
func (*KafkaConsumer) Close ¶
func (kc *KafkaConsumer) Close()
func (*KafkaConsumer) Run ¶
func (kc *KafkaConsumer) Run()
type KafkaProducer ¶
type KafkaProducer struct {
// contains filtered or unexported fields
}
func NewKafkaProducer ¶
func (*KafkaProducer) AddMsg ¶
func (kw *KafkaProducer) AddMsg(key, data []byte) error
func (*KafkaProducer) AddMsgWithTopic ¶
func (kw *KafkaProducer) AddMsgWithTopic(topic string, key, data []byte) error
func (*KafkaProducer) Close ¶
func (kw *KafkaProducer) Close()
func (*KafkaProducer) Start ¶
func (kw *KafkaProducer) Start()
type LocalCache ¶
type LocalCache struct {
// contains filtered or unexported fields
}
key=value 通用存储
func NewLocalCache ¶
func NewLocalCache(size int, expireTime time.Duration) *LocalCache
func (*LocalCache) Get ¶
func (localCache *LocalCache) Get(key interface{}) (interface{}, bool)
func (*LocalCache) Len ¶
func (localCache *LocalCache) Len() int
func (*LocalCache) Remove ¶
func (localCache *LocalCache) Remove(key interface{})
func (*LocalCache) Set ¶
func (localCache *LocalCache) Set(key, val interface{})
func (*LocalCache) SetWithTtl ¶
func (localCache *LocalCache) SetWithTtl(key, val interface{}, ttl int)
type MongoDb ¶
type MongoDb struct {
// contains filtered or unexported fields
}
type RedisClient ¶
func NewRedisClient ¶
func NewRedisClient(address string, db int) *RedisClient
func (*RedisClient) Del ¶
func (rc *RedisClient) Del(key string) error
func (*RedisClient) GetAllKeys ¶
func (rc *RedisClient) GetAllKeys(pat string) (keys []string)
func (*RedisClient) HGet ¶
func (rc *RedisClient) HGet(key, member string) (interface{}, error)
func (*RedisClient) HSet ¶
func (rc *RedisClient) HSet(key, member string, val interface{}) error
func (*RedisClient) MultiGetString ¶
func (rc *RedisClient) MultiGetString(key []string) ([]string, error)
func (*RedisClient) MultiSetString ¶
func (rc *RedisClient) MultiSetString(members map[string]string, ex int) (err error)
func (*RedisClient) Remove ¶
func (rc *RedisClient) Remove(key string)
func (*RedisClient) Scan ¶
func (rc *RedisClient) Scan(pat string, offset int) (keys []string, iter int)
func (*RedisClient) ZAdd ¶
func (rc *RedisClient) ZAdd(key string, members map[string]int64, ttl int)
func (*RedisClient) ZAddAndTrim ¶
func (*RedisClient) ZRangeWithScore ¶
func (*RedisClient) ZRemRangeByRank ¶
type Ticker ¶
type Ticker struct {
// contains filtered or unexported fields
}
var TickerInstance *Ticker
type UIDFactory ¶ added in v1.0.5
func NewIDFactory ¶ added in v1.0.5
func NewIDFactory(node int64) (*UIDFactory, error)
Click to show internal directories.
Click to hide internal directories.