Documentation
¶
Index ¶
- Constants
- Variables
- func Black(format string, args ...interface{})
- func Blue(format string, args ...interface{})
- func Bytes2Int64(data []byte) int64
- func Bytes2String(data []byte) string
- func CreatePkcs1Keys(keyLength int) (privateKey, publicKey string)
- func CreatePkcs8Keys(keyLength int) (privateKey, publicKey string)
- 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 Index4Bit(key interface{}, bitCount uint8) uint32
- func Index4Int16(key interface{}) int16
- func Index4Int8(key interface{}) int8
- func Index4Uint8(key interface{}) uint8
- func Ip2Long(ip string) (ipVal uint32, err error)
- func JsonDecode(data []byte, v interface{}) (err error)
- func JsonDecodeFile(filePath string, v interface{}) (err error)
- func JsonEncode(v interface{}) (data []byte, err error)
- func LocalIp() (ip string, err error)
- func Long2Ip(ipVal uint32) string
- func MarshalPkcs8PrivateKey(key *rsa.PrivateKey) []byte
- func Md5(data []byte) string
- func Red(format string, args ...interface{})
- func RedFatal(format string, args ...interface{})
- func Sha1(data []byte) string
- func YamlDecode(data []byte, v interface{}) (err error)
- func YamlDecodeFile(filePath string, v interface{}) (err error)
- func YamlEncode(v interface{}) (data []byte, err error)
- func Yellow(format string, args ...interface{})
- type Aes
- type Bitmap
- type CanHash
- type GetMachineId
- type HashRing
- type HashSet
- type I18n
- type Msg
- type Node
- type NodeList
- type Rsa
- type ShardMap
- type SnowFlake
Constants ¶
View Source
const ( En = `en` ZhTw = `zh-tw` ZhCn = `zh_CN` )
View Source
const ( ModeWait = 1 ModeMaxTime = 2 ModeError = 3 )
Variables ¶
View Source
var ( ErrInvalidPaddingChar = errors.New(`invalid padding char`) ErrAesDecrypt = errors.New(`aes decrypt error`) )
View Source
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") )
View Source
var ( ErrIpV4Address = errors.New(`invalid ip v4 address`) ErrNotFoundIp = errors.New("not found ip address") )
View Source
var ( AcquireArgs = func() []interface{} { return argsPool.Get().([]interface{}) } ReleaseArgs = func(args *[]interface{}) { if args == nil { return } *args = (*args)[:0] argsPool.Put(*args) } )
View Source
var ( ErrOutOfRange = errors.New("out of range") ErrTimeBack = errors.New("time go back") ErrMachineId = errors.New("illegal machine id") ErrLogicId = errors.New("illegal logic id") )
View Source
var ErrNoServer = errors.New("no server")
View Source
var (
SetValue = struct{}{}
)
Functions ¶
func Bytes2Int64 ¶ added in v1.0.7
func Bytes2String ¶ added in v1.0.7
func Index4Int16 ¶
func Index4Int16(key interface{}) int16
func Index4Int8 ¶
func Index4Int8(key interface{}) int8
func Index4Uint8 ¶
func Index4Uint8(key interface{}) uint8
func JsonDecode ¶
func JsonDecodeFile ¶
func JsonEncode ¶
func MarshalPkcs8PrivateKey ¶ added in v1.0.6
func MarshalPkcs8PrivateKey(key *rsa.PrivateKey) []byte
func YamlDecode ¶
func YamlDecodeFile ¶
func YamlEncode ¶
Types ¶
type Aes ¶ added in v1.0.3
type Aes struct {
// contains filtered or unexported fields
}
func (*Aes) CbcDecrypt ¶ added in v1.0.3
func (*Aes) CbcEncrypt ¶ added in v1.0.3
type Bitmap ¶
type GetMachineId ¶ added in v1.0.8
func GetMachineIdByEnv ¶ added in v1.0.8
func GetMachineIdByEnv(key string) GetMachineId
func GetMachineIdByIp ¶ added in v1.0.8
func GetMachineIdByIp() GetMachineId
type HashRing ¶ added in v1.0.9
type HashRing interface {
Store(servers ...CanHash)
Get(key interface{}) (server CanHash, err error)
Add(server CanHash)
Remove(server CanHash)
Length() int
Range(handler func(index int, server CanHash) (handled bool))
}
func NewHashRing ¶ added in v1.0.9
type HashSet ¶
type HashSet interface {
Add(items ...interface{}) (newNum int)
Delete(items ...interface{}) (delNum int)
Exists(item interface{}) (exists bool)
Length() (length int)
}
func NewHashSet ¶
type Rsa ¶ added in v1.0.3
type Rsa struct {
// contains filtered or unexported fields
}
func NewRsaWithPkcs1 ¶ added in v1.0.6
func NewRsaWithPkcs8 ¶ added in v1.0.6
type ShardMap ¶
type ShardMap interface {
Set(key interface{}, value interface{})
Get(key interface{}) (value interface{}, exists bool)
Exists(key interface{}) (exists bool)
Delete(keys ...interface{})
Length() int64
}
func NewShardMap ¶
func NewShardMap() ShardMap
type SnowFlake ¶ added in v1.0.8
type SnowFlake interface {
Id(logicId uint8) (int64, error)
Info(id int64) (timestamp int64, machineId uint8, logicId uint8, index int16)
}
func NewSFByMachineFunc ¶ added in v1.0.8
func NewSFByMachineFunc(mode uint8, machindFunc GetMachineId, timeStampBegin int64) (sfl SnowFlake, err error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.