Documentation ¶
Index ¶
- Constants
- Variables
- func AbsInt(value int) int
- func AbsInt16(value int16) int16
- func AbsInt32(value int32) int32
- func AbsInt64(value int64) int64
- func AbsInt8(value int8) int8
- func BigCamels(sep byte, data string) string
- func BinPath() string
- func Black(format string, args ...interface{})
- func Blue(format string, args ...interface{})
- func Bytes2Float64(data []byte) float64
- func Bytes2Int64(data []byte) int64
- func Bytes2String(data []byte) string
- func Bytes2Uint32(data []byte) uint32
- func Bytes2Uint64(data []byte) uint64
- func CreatePkcs1Keys(keyLength int) (privateKey, publicKey string)
- func CreatePkcs8Keys(keyLength int) (privateKey, publicKey string)
- func DPanic(msg string, fields ...zap.Field)
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func FileExists(fileName string) bool
- func Fuchsia(format string, args ...interface{})
- func Green(format string, args ...interface{})
- func HMac(key []byte, data []byte, hash crypto.Hash) string
- func Hash(data []byte, hash crypto.Hash) string
- func HashValue(key interface{}) uint32
- func Hex2Int64(value string) int64
- func Hex2Uint64(value string) uint64
- func Index4Bit(key interface{}, bitCount uint8) uint32
- func Index4Int16(key interface{}) int16
- func Index4Int8(key interface{}) int8
- func Index4Uint8(key interface{}) uint8
- func Info(msg string, fields ...zap.Field)
- func InitZapWithOption(conf zaplogger.Option, zapOpts ...zap.Option) error
- func Int64ToHex(value int64) string
- func Int64ToHexWithPad(value int64, padLength int) string
- func Ip2Long(ip string) (ipVal uint32, err error)
- func IsLevel(level zapcore.Level) bool
- func JoinInt(sep string, elems ...int) string
- func JoinInt16(sep string, elems ...int16) string
- func JoinInt32(sep string, elems ...int32) string
- func JoinInt64(sep string, elems ...int64) string
- func JoinInt8(sep string, elems ...int8) string
- func JoinUint(sep string, elems ...uint) string
- func JoinUint16(sep string, elems ...uint16) string
- func JoinUint32(sep string, elems ...uint32) string
- func JoinUint64(sep string, elems ...uint64) string
- func JoinUint8(sep string, elems ...uint8) string
- func JsonDecode(data string, v interface{}) (err error)
- func JsonDecodeFile(filePath string, v interface{}) (err error)
- func JsonEncode(v interface{}) (data string, err error)
- func LcFirst(str string) string
- func LocalIp() (ip string, err error)
- func Long2Ip(ipVal uint32) string
- func MarshalPkcs8PrivateKey(key *rsa.PrivateKey) []byte
- func Max6() int64
- func Max8() int64
- func Md5(data []byte) string
- func NewError(code codes.Code, msg string) error
- func NewGoPool(size int, opts ...gopool.Option) (*gopool.Pool, error)
- func NewIdCode(alphanumericSet []byte, salt6, salt8 int64) (*IdCode, *BError)
- func PackIn32(value int32) []byte
- func PackUin32(value uint32) []byte
- func Panic(msg string, fields ...zap.Field)
- func PprofIsRun() bool
- func RandBytes(length int) []byte
- func Recover(eventName string, f func())
- func Red(format string, args ...interface{})
- func RedFatal(format string, args ...interface{})
- func Sha1(data []byte) string
- func SmallCamels(sep byte, data string) string
- func StartPprof(addr string, handler http.Handler) error
- func StopPprof(ctx context.Context) error
- func StopPprofWithTimeout(seconds int64) error
- func ToString(val interface{}) string
- func UcFirst(str string) string
- func Uint64ToHex(value uint64) string
- func UnpackInt32(data []byte) (value int32, err error)
- func UnpackUint32(data []byte) (value uint32, err error)
- func Warn(msg string, fields ...zap.Field)
- func WorkWithAffinity(id int) (uint64, error)
- func YamlDecode(data string, v interface{}) (err error)
- func YamlDecodeFile(filePath string, v interface{}) (err error)
- func YamlEncode(v interface{}) (data string, err error)
- func Yellow(format string, args ...interface{})
- func ZapDPanic(msg string, fields ...zap.Field)
- func ZapDebug(msg string, fields ...zap.Field)
- func ZapError(msg string, fields ...zap.Field)
- func ZapFatal(msg string, fields ...zap.Field)
- func ZapInfo(msg string, fields ...zap.Field)
- func ZapPanic(msg string, fields ...zap.Field)
- func ZapSync() error
- func ZapWarn(msg string, fields ...zap.Field)
- type Accept
- type Aes
- type BError
- func Code2Id(code []byte) (id int64, err *BError)
- func Code6(id int64) (code []byte, err *BError)
- func Code6String(id int64) (code string, err *BError)
- func Code6To8(code6 []byte) (code8 []byte, err *BError)
- func Code8(id int64) (code []byte, err *BError)
- func Code8String(id int64) (code string, err *BError)
- func CodeString2Id(code string) (id int64, err *BError)
- func CodeString6To8(code6 string) (code8 string, err *BError)
- func NewBError(code codes.Code, msg string) *BError
- func (be *BError) Clone() *BError
- func (be *BError) Code() codes.Code
- func (be *BError) Equal(target error) bool
- func (be *BError) Error() string
- func (be *BError) Is(target error) bool
- func (be *BError) JsonMarshal() []byte
- func (be *BError) ToStatus() *Status
- func (be *BError) WithFlag(flag uint8) *BError
- type Bitmap
- type CanHash
- type Config
- type Container
- type Context
- func (c *Context) Abort()
- func (c *Context) Close()
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) Get(key string) (value interface{}, exists bool)
- func (c *Context) GetBool(key string) (value bool, exists bool)
- func (c *Context) GetInt(key string) (value int, exists bool)
- func (c *Context) GetInt64(key string) (value int64, exists bool)
- func (c *Context) GetInt8(key string) (value int8, exists bool)
- func (c *Context) GetString(key string) (value string, exists bool)
- func (c *Context) IsAborted() bool
- func (c *Context) Next()
- func (c *Context) Set(key string, value interface{})
- func (c *Context) Value(key interface{}) interface{}
- type GetMachineId
- type GracefulHttp
- func (hs *GracefulHttp) HandlerSig(pprofAddr string, timeoutSecond int64)
- func (hs *GracefulHttp) Listen() (err error)
- func (hs *GracefulHttp) Reload() (pid int, err error)
- func (hs *GracefulHttp) Shutdown(ctx context.Context) error
- func (hs *GracefulHttp) ShutdownWithTimeout(timeoutSecond int64) error
- type HashRing
- type HashSet
- type I18n
- type IdCode
- func (ic *IdCode) Code2Id(code []byte) (id int64, err *BError)
- func (ic *IdCode) Code6(id int64) (code []byte, err *BError)
- func (ic *IdCode) Code6String(id int64) (code string, err *BError)
- func (ic *IdCode) Code6To8(code6 []byte) (code8 []byte, err *BError)
- func (ic *IdCode) Code8(id int64) (code []byte, err *BError)
- func (ic *IdCode) Code8String(id int64) (code string, err *BError)
- func (ic *IdCode) CodeString2Id(code string) (id int64, err *BError)
- func (ic *IdCode) CodeString6To8(code6 string) (code8 string, err *BError)
- func (ic *IdCode) Max6() int64
- func (ic *IdCode) Max8() int64
- type JsonParam
- func (jp JsonParam) Exists(key string) bool
- func (jp JsonParam) Float64(key string) float64
- func (jp JsonParam) Int(key string) int
- func (jp JsonParam) Int64(key string) int64
- func (jp JsonParam) Int64Slice(key string) []int64
- func (jp JsonParam) IntSlice(key string) []int
- func (jp JsonParam) JsonMarshal() []byte
- func (jp JsonParam) String(key string) string
- func (jp JsonParam) StringSlice(key string) []string
- func (jp JsonParam) Uint32Slice(key string) []uint32
- type Mysql
- type MysqlOption
- type Node
- type NodeList
- type Package
- type Protocol
- type Rsa
- func NewRsa(publicKey, privateKey string) (r *Rsa, err error)
- func NewRsaBytes(public, private []byte) (r *Rsa, err error)
- func NewRsaWithPkcs1(publicKey, privateKey string) (r *Rsa, err error)
- func NewRsaWithPkcs1Bytes(public, private []byte) (r *Rsa, err error)
- func NewRsaWithPkcs8(publicKey, privateKey string) (r *Rsa, err error)
- func NewRsaWithPkcs8Bytes(public, private []byte) (r *Rsa, err error)
- type ShardMap
- type SnowFlake
- type State
- func (s *State) Add(indexList ...uint8) error
- func (s *State) Has(index uint8) bool
- func (s *State) Intersection(val State) []uint8
- func (s *State) Merge(val State)
- func (s *State) Remove(index uint8)
- func (s *State) RemoveAll()
- func (s *State) Slice() []uint8
- func (s *State) UnionSet(val State) []uint8
- func (s *State) ValueSlice() []int32
- type Status
- func (s *Status) Close()
- func (s *Status) ConvertGrpcStatus(details ...proto.Message) (*status.Status, error)
- func (s *Status) Error() error
- func (s *Status) Is(code codes.Code) bool
- func (s *Status) IsOK() bool
- func (s *Status) JsonMarshal() []byte
- func (s *Status) ToError() error
- func (s *Status) WithData(data interface{}) *Status
- func (s *Status) WithFlag(flag uint8) *Status
- func (s *Status) WithMsg(msg string) *Status
Constants ¶
const ( LevelJson = 0 LevelV1 = 1 LevelV2 = 2 )
const ( // OK 成功返回 OK = codes.OK // CodeCanceled 表示操作已取消(通常由调用者取消) CodeCanceled = codes.Canceled // CodeUnknown 未知错误 CodeUnknown = codes.Unknown // CodeInvalidArgument 客户端传递了一个无效的参数 CodeInvalidArgument = codes.InvalidArgument // CodeDeadlineExceeded 表示操作在完成前过期。对于改变系统状态的操作,即使操作成功完成,也可能会返回此错误。 // 例如,来自服务器的成功响应可能已延迟足够长的时间以使截止日期到期 CodeDeadlineExceeded = codes.DeadlineExceeded // CodeNotFound 表示未找到某些请求的实体(例如文件或目录) CodeNotFound = codes.NotFound // CodeAlreadyExists 表示创建实体的尝试失败,因为实体已经存在 CodeAlreadyExists = codes.AlreadyExists // CodePermissionDenied 表示调用者没有执行指定操作的权限 CodePermissionDenied = codes.PermissionDenied // CodeResourceExhausted 表示某些资源已用尽,可能是每个用户的配额,或者可能是整个文件系统空间不足 CodeResourceExhausted = codes.ResourceExhausted // CodeFailedPrecondition 操作被拒绝,因为系统未处于操作执行所需的状态。 // 例如,要删除的目录可能是非空的,rmdir 操作应用于非目录等 CodeFailedPrecondition = codes.FailedPrecondition // CodeAborted 操作已取消,通常是由于并发问题,如排序器检查失败、事务中止 CodeAborted = codes.Aborted // CodeOutRange 超出范围的操作 CodeOutRange = codes.OutOfRange // CodeUnimplemented 未实现或不支持的操作 CodeUnimplemented = codes.Unimplemented // CodeInternal 系统内部错误 CodeInternal = codes.Internal // 请注意,重试非幂等操作是不安全的 CodeUnavailable = codes.Unavailable // CodeDataLoss 表示不可恢复的数据丢失或损坏 CodeDataLoss = codes.DataLoss // CodeUnauthenticated 表示请求没有用于操作的有效身份验证凭据 CodeUnauthenticated = codes.Unauthenticated )
const ( EnvPro = `pro` EnvDev = `dev` EnvTest = `test` )
const ( EventConnectSuccess = 0x0100 EventTick = 0x0101 EventClose = 0x0102 EventError = 0x0103 EventLogin = 0x0200 EventLoginSuccess = 0x0201 EventLoginFailed = 0x0202 )
const ( ModeWait = 1 ModeMaxTime = 2 ModeError = 3 )
const (
StateIndexMax = 30
)
const (
ZhCn = `zh_CN`
)
Variables ¶
var ( ErrInvalidPaddingChar = NewError(CodeInvalidArgument, `invalid padding char`) ErrAesDecrypt = NewError(CodeInvalidArgument, `aes decrypt error`) )
var ( ErrForbidden = NewBError(CodePermissionDenied, "permissin denied") ErrDataEmpty = NewBError(CodeDataLoss, "data is empty") ErrKeyFormat = NewBError(CodeInvalidArgument, "invalid key format") ErrDataFormat = NewBError(CodeInvalidArgument, "invalid data format") ErrDataSign = NewBError(CodePermissionDenied, "invalid data sign") ErrState = NewBError(CodeOutRange, "state index must lte 30") ErrOutOfRange = NewBError(CodeOutRange, "out of range") ErrAlphanumeric = NewBError(CodeInvalidArgument, "alphanumeric must be [a-zA-Z0-9] and not repeat") ErrAlphanumericLength = NewBError(CodeInvalidArgument, "alphanumeric length must be [50, 62]") ErrTimeBack = NewBError(CodeInternal, "time go back") ErrMachineId = NewBError(CodeInvalidArgument, "illegal machine id") )
var ( ErrMsgMapEmpty = errors.New("msgMap can not empty") ErrNoYamlFiles = errors.New("there are no `.yml` or `.yaml` files in this directory") ErrNoJsonFiles = errors.New("there are no `.json` files in this directory") )
var ( ErrIpV4Address = errors.New(`invalid ip v4 address`) ErrNotFoundIp = errors.New("not found ip address") )
var ( JsonMarshal = jsoniter.Marshal JsonUnmarshal = jsoniter.Unmarshal )
var ( // AcquireArgs 获取参数 AcquireArgs = func() []interface{} { return argsPool.Get().([]interface{}) } // ReleaseArgs 释放参数 ReleaseArgs = func(args *[]interface{}) { if args == nil { return } *args = (*args)[:0] argsPool.Put(*args) } )
var ( YamlMarshal = yaml.Marshal YamlUnmarshal = yaml.Unmarshal )
var (
DefaultContainer = &Container{}
)
var ErrNoServer = errors.New("no server")
var (
ErrNotTcpListener = NewError(CodeInvalidArgument, "listener is not tcp listener")
)
var (
SetValue = struct{}{}
)
Functions ¶
func Bytes2Float64 ¶ added in v1.0.12
Bytes2Float64 字节切片转换为float64
func Bytes2Uint32 ¶ added in v1.2.5
Bytes2Uint32 字节切片转换为uint32
func Bytes2Uint64 ¶ added in v1.2.18
Bytes2Uint64 字节切片转换为uint64
func CreatePkcs1Keys ¶ added in v1.0.6
CreatePkcs1Keys 生成pkcs1格式公钥私钥
func CreatePkcs8Keys ¶ added in v1.0.3
CreatePkcs8Keys 生成pkcs8格式公钥私钥
func InitZapWithOption ¶ added in v1.2.5
func Int64ToHexWithPad ¶ added in v1.2.6
Int64ToHexWithPad _
func JoinUint16 ¶ added in v1.2.21
func JoinUint32 ¶ added in v1.2.21
func JoinUint64 ¶ added in v1.2.21
func JsonDecodeFile ¶
JsonDecodeFile ---
func MarshalPkcs8PrivateKey ¶ added in v1.0.6
func MarshalPkcs8PrivateKey(key *rsa.PrivateKey) []byte
func SmallCamels ¶ added in v1.0.20
SmallCamels 转换为小驼峰
func StartPprof ¶ added in v1.2.6
StartPprof _
func StopPprofWithTimeout ¶ added in v1.3.0
StopPprofWithTimeout _
func UnpackInt32 ¶ added in v1.2.11
func UnpackUint32 ¶ added in v1.2.11
func WorkWithAffinity ¶ added in v1.2.26
WorkWithAffinity 绑定CPU
func YamlDecodeFile ¶
YamlDecodeFile ---
Types ¶
type Accept ¶ added in v1.2.7
type Accept struct {
// contains filtered or unexported fields
}
func (*Accept) AcceptBase64Url ¶ added in v1.2.7
type Aes ¶ added in v1.0.3
type Aes struct {
// contains filtered or unexported fields
}
Aes Aes加密
func NewAesWithBytes ¶ added in v1.1.4
NewAesWithBytes 实例化Aes
func (*Aes) CbcDecrypt ¶ added in v1.0.3
CbcDecrypt cbc解密
func (*Aes) CbcEncrypt ¶ added in v1.0.3
CbcEncrypt cbc加密
type BError ¶ added in v1.3.4
type BError struct {
// contains filtered or unexported fields
}
func Code6String ¶ added in v1.3.8
func Code8String ¶ added in v1.3.8
func CodeString2Id ¶ added in v1.3.8
func CodeString6To8 ¶ added in v1.3.8
func (*BError) JsonMarshal ¶ added in v1.3.4
type Bitmap ¶
type Bitmap interface { // HasBit 是否有值 HasBit() bool // BitCount 值的数量 BitCount() int // Exists 标签是否存在 Exists(tag int) (exists bool) // AddTag 添加标签 AddTag(tag int) Bitmap // DelTag 删除标签 DelTag(tag int) Bitmap // Data 原始数据 Data() (data []byte) // SprinfBinary 二进制打印 SprinfBinary() string }
Bitmap bitmap数据结构
type CanHash ¶
type CanHash interface { // HashCode 计算hash值 HashCode() (hashValue uint32) }
CanHash hash接口
type Config ¶ added in v1.2.5
type Config struct { Name string `json:"name" yaml:"name"` Addr string `json:"addr" yaml:"addr"` PprofAddr string `json:"pprofAddr" yaml:"pprofAddr"` Env string `json:"env" yaml:"env"` Ver string `json:"ver" yaml:"ver"` Logger zaplogger.Option `json:"logger" yaml:"logger"` Params JsonParam `json:"params" yaml:"params"` }
type Container ¶ added in v1.2.5
type Container struct {
// contains filtered or unexported fields
}
type Context ¶ added in v1.1.3
type Context struct {
// contains filtered or unexported fields
}
Context 上下文
func AcquireCtx ¶ added in v1.1.3
AcquireCtx 申请Context
type GetMachineId ¶ added in v1.0.8
GetMachineId 获取机器Id
func GetMachineIdByEnv ¶ added in v1.0.8
func GetMachineIdByEnv(key string) GetMachineId
GetMachineIdByEnv 根据环境变量获取机器Id
func GetMachineIdByIp ¶ added in v1.0.8
func GetMachineIdByIp() GetMachineId
GetMachineIdByIp 根据Ip获取机器Id
type GracefulHttp ¶ added in v1.2.25
type GracefulHttp struct {
// contains filtered or unexported fields
}
func NewGracefulHttp ¶ added in v1.2.25
func NewGracefulHttp(server *http.Server) *GracefulHttp
func (*GracefulHttp) HandlerSig ¶ added in v1.2.25
func (hs *GracefulHttp) HandlerSig(pprofAddr string, timeoutSecond int64)
func (*GracefulHttp) Listen ¶ added in v1.2.25
func (hs *GracefulHttp) Listen() (err error)
func (*GracefulHttp) Reload ¶ added in v1.2.25
func (hs *GracefulHttp) Reload() (pid int, err error)
func (*GracefulHttp) Shutdown ¶ added in v1.2.25
func (hs *GracefulHttp) Shutdown(ctx context.Context) error
func (*GracefulHttp) ShutdownWithTimeout ¶ added in v1.2.25
func (hs *GracefulHttp) ShutdownWithTimeout(timeoutSecond int64) error
type HashRing ¶ added in v1.0.9
type HashRing interface { // Store 存储servers Store(servers ...CanHash) // Get 获取server Get(key interface{}) (server CanHash, err error) // Index 根据index获取server Index(index int) (server CanHash, err error) // Add 添加server Add(server CanHash) // Remove 移除server Remove(server CanHash) // Length 获取servers长度 Length() int // Range 遍历servers Range(handler func(index int, server CanHash, hitCount uint64) (handled bool)) }
HashRing Hash环
func NewHashRing ¶ added in v1.0.9
type HashSet ¶
type HashSet interface { // Add 添加元素 Add(items ...interface{}) (newNum int) // Delete 删除元素 Delete(items ...interface{}) (delNum int) // Exists 元素是否存在 Exists(item interface{}) (exists bool) // Length 长度 Length() (length int) }
HashSet 接口
type I18n ¶ added in v1.0.3
I18n 多语言接口
func NewI18nFromJson ¶ added in v1.0.3
NewI18nFromJson 从Json文件配置实例化多语言
type IdCode ¶ added in v1.3.8
type IdCode struct {
// contains filtered or unexported fields
}
func (*IdCode) Code6String ¶ added in v1.3.8
func (*IdCode) Code8String ¶ added in v1.3.8
func (*IdCode) CodeString2Id ¶ added in v1.3.8
func (*IdCode) CodeString6To8 ¶ added in v1.3.8
type JsonParam ¶ added in v1.2.1
type JsonParam map[string]interface{}
func UnmarshalJsonParam ¶ added in v1.2.1
UnmarshalJsonParam _
func (JsonParam) Int64Slice ¶ added in v1.2.1
Int64Slice 获取[]int64,获取失败返回nil
func (JsonParam) JsonMarshal ¶ added in v1.2.1
JsonMarshal _
func (JsonParam) StringSlice ¶ added in v1.2.1
StringSlice 获取[]string,如果不是[]string返回nil
func (JsonParam) Uint32Slice ¶ added in v1.2.1
Uint32Slice 获取[]uint32,获取失败返回nil
type Mysql ¶ added in v1.2.22
type Mysql struct { *sql.DB Options MysqlOption }
func NewMysql ¶ added in v1.2.22
func NewMysql(opt MysqlOption) (mysql *Mysql, err error)
type MysqlOption ¶ added in v1.2.22
type MysqlOption struct { DbName string `json:"dbName" yaml:"dbName"` Host string `json:"host" yaml:"host"` Port uint32 `json:"port" yaml:"port"` UserName string `json:"userName" yaml:"userName"` Password string `json:"password" yaml:"password"` CharSet string `json:"charSet" yaml:"charSet"` MaxIdleConns int `json:"maxIdleConns" yaml:"maxIdleConns"` MaxOpenConns int `json:"maxOpenConns" yaml:"maxOpenConns"` ConnMaxIdleTimeSecond int64 `json:"connMaxIdleTimeSecond" yaml:"connMaxIdleTimeSecond"` ConnMaxLifetimeSecond int64 `json:"connMaxLifetimeSecond" yaml:"connMaxLifetimeSecond"` }
func DefaultMysqlOption ¶ added in v1.2.22
func DefaultMysqlOption() MysqlOption
func MysqlOptionWithJson ¶ added in v1.2.22
func MysqlOptionWithJson(conf string) (opt MysqlOption, err error)
func MysqlOptionWithYaml ¶ added in v1.2.22
func MysqlOptionWithYaml(conf string) (opt MysqlOption, err error)
func (*MysqlOption) Dsn ¶ added in v1.2.22
func (mo *MysqlOption) Dsn() string
type Package ¶ added in v1.2.6
type Protocol ¶ added in v1.2.7
type Rsa ¶ added in v1.0.3
type Rsa struct {
// contains filtered or unexported fields
}
Rsa Rsa
func NewRsaBytes ¶ added in v1.2.20
NewRsaBytes 实例化Rsa
func NewRsaWithPkcs1 ¶ added in v1.0.6
NewRsaWithPkcs1 pkcs1实例化Rsa
func NewRsaWithPkcs1Bytes ¶ added in v1.2.20
NewRsaWithPkcs1Bytes pkc1实例化Rsa
func NewRsaWithPkcs8 ¶ added in v1.0.6
NewRsaWithPkcs8 pkcs8实例化Rsa
func NewRsaWithPkcs8Bytes ¶ added in v1.2.20
type ShardMap ¶
type ShardMap interface { // Set 存储 Set(key interface{}, value interface{}) (isCreate bool) // Get 获取 Get(key interface{}) (value interface{}, exists bool) // Exists 是否存在 Exists(key interface{}) (exists bool) // Delete 删除 Delete(keys ...interface{}) (delNum int) // Length 长度 Length() int64 }
ShardMap 分片Map
func NewSharMapWithChannel ¶ added in v1.1.0
func NewSharMapWithChannel(size int) (sm ShardMap, ch <-chan shardmap.ChangeEvent)
NewSharMapWithChannel 实例化ShardMap并返回changeChannel
type SnowFlake ¶ added in v1.0.8
type SnowFlake interface { // Id 生成id Id() (int64, error) // Info 根据id获取信息 Info(id int64) (timestamp int64, machineId uint8, index int16) }
SnowFlake 雪花算法接口,1位0,41位毫秒时间戳,8位机器码,14位递增值
func NewSFByMachineFunc ¶ added in v1.0.8
func NewSFByMachineFunc(mode uint8, machindFunc GetMachineId, beginSeconds int64) (sfl SnowFlake, err error)
NewSFByMachineFunc GetMachineId方式实例化雪花算法
type State ¶ added in v1.2.17
type State int32
func StateFromSlice ¶ added in v1.2.17
func StatusFromValueSlice ¶ added in v1.2.17
func (*State) Intersection ¶ added in v1.2.17
func (*State) ValueSlice ¶ added in v1.2.17
type Status ¶ added in v1.2.3
type Status struct { Code codes.Code `json:"code"` Msg string `json:"msg"` Flag uint8 `json:"flag"` Data interface{} `json:"data"` }
func StatusWithCode ¶ added in v1.2.3
StatusWithCode 指定Code获取一个Status
func StatusWithCodeMsg ¶ added in v1.3.2
StatusWithCodeMsg 实例化Status
func StatusWithJsonUnmarshal ¶ added in v1.2.3
StatusWithJsonUnmarshal 指定json []byte获取一个Status
func (*Status) ConvertGrpcStatus ¶ added in v1.2.3
ConvertGrpcStatus 转换为grpc状态码
Source Files ¶
- abs.go
- accept.go
- aes.go
- affinity.go
- affinity_linux.go
- bitmap.go
- codes.go
- color.go
- config.go
- container.go
- context.go
- convert.go
- db.go
- errors.go
- file.go
- func.go
- gopool.go
- graceful.go
- hash.go
- hashring.go
- hashset.go
- i18n.go
- id-code.go
- ip.go
- join.go
- json.go
- jsonparam.go
- package.go
- path.go
- pool.go
- pprof.go
- protocol.go
- rand.go
- recover.go
- rsa.go
- shardmap.go
- snow-flake.go
- state.go
- status.go
- yaml.go
- zap.go