Documentation ¶
Index ¶
- Constants
- Variables
- func DateEndTimeString(t time.Time) string
- func DateStartTimeString(t time.Time) string
- func Decimal(value float64, preciseDigits int) float64
- func ID() uint64
- func IDGen() string
- func IsChineseChar(str string) bool
- func IsEmail(emailaddress string) bool
- func IsHomePhone(phone string) bool
- func IsIdCard(Identnumber string) bool
- func IsPhone(phonenumber string) bool
- func IsTimeString(timeString string, timeFormat string) bool
- func JsonString(obj interface{}) string
- func MetricExpHandler() http.Handler
- func PprofHttpHandler() (string, http.Handler)
- func RandCode(len int, onlynumber bool) string
- func RemoveStringArrayDuplicate(list []string) []string
- func SetLogger(lg logs.Logger)
- func StartMetrics(influxdbURL string, influxdbName string, influxdbUser string, ...)
- func StopMetrics()
- func StringSliceIsRepeat(slc []string) bool
- func TimeNow() string
- func UUID() string
- type Circle
- type Context
- type Ellipse
- type EtcdLockFactory
- type HandleFunc
- type IContext
- type JSTemplate
- type Lock
- type Ms15LenIDGenerator
- type RedisKeyValue
- type RedisUtil
- func (r *RedisUtil) DEL(key ...interface{}) int
- func (r *RedisUtil) Debug(b bool)
- func (r *RedisUtil) EXPIRE(key string, expireTime int64) int
- func (r *RedisUtil) GET(key string) string
- func (r *RedisUtil) GETEXP(key string, expireTime int64) string
- func (r *RedisUtil) GETSET(key, value string) string
- func (r *RedisUtil) GetConn(fun func(redis.Conn))
- func (r *RedisUtil) INCRBY(key string, increment int64) (int64, error)
- func (r *RedisUtil) KEYS(pattern string) ([]string, error)
- func (r *RedisUtil) MGET(keys ...string) ([]string, error)
- func (r *RedisUtil) MGETWithKeyPattern(pattern string) ([]*RedisKeyValue, error)
- func (r *RedisUtil) Mutex(key string, options ...redsync.Option) *redsync.Mutex
- func (r *RedisUtil) Prefix() string
- func (r *RedisUtil) SADD(key, member string) (int64, error)
- func (r *RedisUtil) SCARD(key string) (int64, error)
- func (r *RedisUtil) SET(key, value string) bool
- func (r *RedisUtil) SETEX(key, value string, expireTime int64) bool
- func (r *RedisUtil) SISMEMBER(key string, member string) bool
- func (r *RedisUtil) SMEMBERS(key string) ([]string, error)
- func (r *RedisUtil) SREM(key string, member string) (int64, error)
- func (r *RedisUtil) SetLogger(lg logs.Logger)
- func (r *RedisUtil) SetPrefix(prefix string)
- func (r *RedisUtil) ZADD(key string, score float64, member string) (int64, error)
- func (r *RedisUtil) ZCARD(key string) (int64, error)
- func (r *RedisUtil) ZINCRBY(key string, increment int64, member string) (int64, error)
- func (r *RedisUtil) ZRANGE(key string, start, stop int64, withscores bool) ([]string, error)
- func (r *RedisUtil) ZRANK(key string, member string) (int64, error)
- func (r *RedisUtil) ZREM(key string, member string) (int64, error)
- func (r *RedisUtil) ZREVRANGE(key string, start, stop int64, withscores bool) ([]string, error)
- func (r *RedisUtil) ZREVRANK(key string, member string) (int64, error)
- func (r *RedisUtil) ZSCORE(key string, member string) (float64, error)
- type TracingContext
- type TracingSpan
- type TracingSpanImpl
- func (t *TracingSpanImpl) ChildOf(operationName string) TracingSpan
- func (t *TracingSpanImpl) Context(ctx context.Context) context.Context
- func (t *TracingSpanImpl) Finish()
- func (t *TracingSpanImpl) FollowsFrom(operationName string) TracingSpan
- func (t *TracingSpanImpl) InjectHttpHeader(header http.Header)
- func (t *TracingSpanImpl) Logf(fields ...opentracinglog.Field)
- func (t *TracingSpanImpl) Span() opentracing.Span
- func (t *TracingSpanImpl) SpanContext() opentracing.SpanContext
- func (t *TracingSpanImpl) Start(operationName string) TracingSpan
Constants ¶
const ( DateFormat = "2006-01-02" DateTimeFormat = "2006-01-02 15:04:05" TimeFormat = "15:04:05" )
时间格式
const TracingChild = 1
const TracingFollowsFrom = 2
Variables ¶
var ( LockFail = err1.NewError(-100, "锁失败") UnlockFail = err1.NewError(-101, "解锁失败") )
var EnableMetrics = false //是否开启性能统计
var MetricsCancel context.CancelFunc
var MetricsRegistry metrics.Registry
var Tracing = true
开启追踪
Functions ¶
func PprofHttpHandler ¶
func StartMetrics ¶
开启性能统计
Types ¶
type Circle ¶
type Circle struct {
// contains filtered or unexported fields
}
圆形 https://blog.golang.org/go-imagedraw-package
func (*Circle) ColorModel ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
上下文
func (*Context) SetTracingType ¶
type Ellipse ¶
type Ellipse struct {
// contains filtered or unexported fields
}
椭圆形
func (*Ellipse) ColorModel ¶
type EtcdLockFactory ¶
type EtcdLockFactory struct {
// contains filtered or unexported fields
}
func NewEtcdLockFactory ¶
func NewEtcdLockFactory(endpoints []string) (*EtcdLockFactory, error)
初始化ETCD连接
func (*EtcdLockFactory) GetEtcdClient ¶
func (e *EtcdLockFactory) GetEtcdClient() *clientv3.Client
获取etcd连接对象
func (*EtcdLockFactory) GetEtcdSession ¶
func (e *EtcdLockFactory) GetEtcdSession() (*concurrency.Session, error)
获取etcd会话
type HandleFunc ¶
type HandleFunc func()
type IContext ¶
type IContext interface { TracingContext Copy() IContext SetTracingType(int) Logf(fields ...opentracinglog.Field) IContext TracingSpan() TracingSpan }
type JSTemplate ¶
type JSTemplate struct { ExtendType string //扩展文件名 Cache bool //是否缓存 // contains filtered or unexported fields }
JSTemplate JS模版引擎
func NewJSTemplate ¶
func NewJSTemplate(TemplateDIR string, ExtendType ...string) *JSTemplate
NewJSTemplate 深层JS模版引擎对象
func (*JSTemplate) SetTemplateDir ¶
func (je *JSTemplate) SetTemplateDir(TemplateDir string)
SetTemplateDir 设置模版目录
type Ms15LenIDGenerator ¶
type Ms15LenIDGenerator struct {
// contains filtered or unexported fields
}
毫秒级15位ID生成器
func NewMs15LenIDGenerator ¶
func NewMs15LenIDGenerator(workID int64) *Ms15LenIDGenerator
实例化毫秒15位一个ID生成器
type RedisUtil ¶
type RedisUtil struct {
// contains filtered or unexported fields
}
RedisUtil redis操作工具
func InitializeRedis ¶
初始化redis,host=地址,password密码,db数据名称,maxidle最大有效连接数,active 最大可用连接数
func (*RedisUtil) KEYS ¶
KEYS 获取key集合 @param {string} pattern 匹配模式 Supported glob-style patterns: h?llo matches hello, hallo and hxllo h*llo matches hllo and heeeello h[ae]llo matches hello and hallo, but not hillo h[^e]llo matches hallo, hbllo, ... but not hello h[a-b]llo matches hallo and hbllo Use \ to escape special characters if you want to match them verbatim. @return 返回符合patten的key
func (*RedisUtil) MGETWithKeyPattern ¶
func (r *RedisUtil) MGETWithKeyPattern(pattern string) ([]*RedisKeyValue, error)
按key的正则方式批量获取
type TracingContext ¶
type TracingContext interface { //Start 注意:由于该方法可能会进行连级调用所以不允许返回nil Start(operationName string) TracingContext //Finish 标记追踪结束 Finish() }
追踪上下文
type TracingSpan ¶
type TracingSpan interface { //SpanContext SpanContext() opentracing.SpanContext //context.Context Context(ctx context.Context) context.Context //Span Span() opentracing.Span //ChildOf ChildOf(operationName string) TracingSpan //FollowsFrom FollowsFrom(operationName string) TracingSpan //日志 Logf(fields ...opentracinglog.Field) //Finish Finish() //Start Start(operationName string) TracingSpan //InjectHttpHeader InjectHttpHeader(header http.Header) }
func NewTracingSpanExtractHttpRequest ¶
func NewTracingSpanExtractHttpRequest(req *http.Request) TracingSpan
解析一个HTTP追踪请求
type TracingSpanImpl ¶
type TracingSpanImpl struct {
// contains filtered or unexported fields
}
数据
func (*TracingSpanImpl) ChildOf ¶
func (t *TracingSpanImpl) ChildOf(operationName string) TracingSpan
ChildOf
func (*TracingSpanImpl) Context ¶
func (t *TracingSpanImpl) Context(ctx context.Context) context.Context
context.Context
func (*TracingSpanImpl) FollowsFrom ¶
func (t *TracingSpanImpl) FollowsFrom(operationName string) TracingSpan
FollowsFrom
func (*TracingSpanImpl) InjectHttpHeader ¶
func (t *TracingSpanImpl) InjectHttpHeader(header http.Header)
编码HTTP请求
func (*TracingSpanImpl) SpanContext ¶
func (t *TracingSpanImpl) SpanContext() opentracing.SpanContext
SpanContext
func (*TracingSpanImpl) Start ¶
func (t *TracingSpanImpl) Start(operationName string) TracingSpan
Start