utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureException

func CaptureException()

func ConsistentHashSelector

func ConsistentHashSelector(cons *consistent.Consistent, id string) selector.SelectOption

select node by consistent hash

func ErrCheck

func ErrCheck(err error, param ...interface{}) (*zerolog.Event, bool)

return event and pass

func InitMachineID

func InitMachineID(machineID int16)

snow flakes machine_id: 10 bits machineID + 6 bits plugin_type

func MachineID

func MachineID(id int64) int16

func MachineIDHigh

func MachineIDHigh(id int64) int16

func MachineIDLow

func MachineIDLow(id int64) int16

func NewPrometheusHandlerWrapper

func NewPrometheusHandlerWrapper(opts ...server.Option) server.HandlerWrapper

func NextID

func NextID(tp int) (int64, error)

func RelocatePath

func RelocatePath() error

relocate to project root path

func SectionIDRandSelector

func SectionIDRandSelector(id int64) selector.SelectOption

select node by section id: game_id / 10

func SpecificIDSelector

func SpecificIDSelector(id int64) selector.SelectOption

select node by specific game_id

Types

type FakeRandom

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

func NewFakeRandom

func NewFakeRandom(seed int) *FakeRandom

func (*FakeRandom) Rand

func (f *FakeRandom) Rand() int

------------------------------------------------------------------------------- 生成一个SHORT伪随机数 -------------------------------------------------------------------------------

func (*FakeRandom) RandSection

func (f *FakeRandom) RandSection(min, max int) int

func (*FakeRandom) Reset

func (f *FakeRandom) Reset(seed int)

------------------------------------------------------------------------------- 重置种子 -------------------------------------------------------------------------------

type Snowflakes

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

type WaitGroupWrapper

type WaitGroupWrapper struct {
	sync.WaitGroup
}

func (*WaitGroupWrapper) Wrap

func (w *WaitGroupWrapper) Wrap(cb func())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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