util

package
v0.0.0-...-4d2c057 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsGBK

func ContainsGBK(str string) bool

*

@comment check if gbk characters in string

func FireReload

func FireReload()

func FireTerminate

func FireTerminate()

func GenRandomString

func GenRandomString(seed string) string

func GobDecode

func GobDecode(buf []byte, val interface{}) error

Gob decode

func GobEncode

func GobEncode(val interface{}) ([]byte, error)

Gob encode

func Hash

func Hash(str string) uint64

func IsEmptyStr

func IsEmptyStr(val string) bool

IsEmptyStr returns true if val == nil or val == "" or val == " "

func MD5

func MD5(str string) string

MD5 returns the md5 string according to the given string

func MD5Bytes

func MD5Bytes(buf []byte) string

func OnReloadEvent

func OnReloadEvent(fn SigFunc)

func OnShutdownEvent

func OnShutdownEvent(fn SigFunc)

func SafeReplaceName

func SafeReplaceName(name string) string

func SimpleHash

func SimpleHash(str string) uint64

func StrArrayContains

func StrArrayContains(arr []string, item string) bool

StrArrayContains returns true if array contains the item

func StrArrayEquals

func StrArrayEquals(arr1, arr2 []string) bool

func SubStr

func SubStr(str string, begin, length int) string

func TrapSignals

func TrapSignals()

func ZipDir

func ZipDir(dir, zipFile string) error

zlib the whole dir into target zip file

func ZlibCompress

func ZlibCompress(buf []byte) ([]byte, error)

zlib compress

func ZlibUncompress

func ZlibUncompress(buf []byte) ([]byte, error)

zlib decompress

Types

type HashRing

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

HashRing consistent hashing

func NewHashRing

func NewHashRing(spots int) *HashRing

NewHashRing constructor

func (*HashRing) AddNode

func (h *HashRing) AddNode(nodeKey string, weight int)

AddNode append node

func (*HashRing) AddNodes

func (h *HashRing) AddNodes(nodeWeight map[string]int)

AddNodes append nodes

func (*HashRing) GetNode

func (h *HashRing) GetNode(s string) string

GetNode returns the node

func (*HashRing) RemoveNode

func (h *HashRing) RemoveNode(nodeKey string)

RemoveNode remove node

func (*HashRing) UpdateNode

func (h *HashRing) UpdateNode(nodeKey string, weight int)

UpdateNode update weight of node

type SigFunc

type SigFunc func()

Jump to

Keyboard shortcuts

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