utils

package
v0.0.0-...-a7402c0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SlotsCount = 16384
)

Variables

View Source
var Int32HashCode = func(key int32) uint32 {
	hash := fnv.New32()
	hash.Write([]byte(fmt.Sprintf("%v", key)))
	return hash.Sum32() >> 24
}
View Source
var StringHashCode = func(key string) int32 {
	hash := fnv.New32()
	hash.Write([]byte(key))
	return int32(hash.Sum32() >> 24)
}

Functions

func BytesToJson

func BytesToJson(bytes []byte, x any)

func Decode

func Decode(data []byte, messageEntity proto.Message) error

func Encode

func Encode(m proto.Message) []byte

func LoadConfigurationFile

func LoadConfigurationFile(configPath string) map[string]any

func ReadByte

func ReadByte(rd io.Reader) ([]byte, error)

func RouteSlot

func RouteSlot(serviceName string) int32

RouteSlot Route the service to the slot

func TcpDecode

func TcpDecode(reader *bufio.Reader) ([]byte, error)

func TcpEncode

func TcpEncode(message []byte) ([]byte, error)

func ToJson

func ToJson(x any) string

func ToJsonByte

func ToJsonByte(x any) []byte

func ValidateIntType

func ValidateIntType(data any, errType string) int32

func ValidateRegexp

func ValidateRegexp(data string, regex string, errMsg string)

func ValidateStringType

func ValidateStringType(data any, errType string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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