utils

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDirMode  = 0755
	DefaultFileMode = 0644
)

Variables

This section is empty.

Functions

func CreateDirIfNotExist

func CreateDirIfNotExist(dirpath string) error

func CreateOrOverwriteFile

func CreateOrOverwriteFile(fpath string, data []byte, fileMode os.FileMode) error

func GenCallerID

func GenCallerID() string

timestamp + uuid

func GenClientTLSConfig

func GenClientTLSConfig(caFile string, certFile string, keyFile string) (*tls.Config, error)

GenClientTLSConfig creates the tls Config for client

func GenControlDBServiceUUID

func GenControlDBServiceUUID(volID string) string

func GenMD5

func GenMD5(content string) string

func GenMemberConfigFileID

func GenMemberConfigFileID(memberName string, configFileName string, version int64) string

func GenRequestUUID

func GenRequestUUID() string

func GenServerTLSConfigFromCAFile

func GenServerTLSConfigFromCAFile(caFile string) (*tls.Config, error)

GenServerTLSConfigFromCAFile creates a tls Config with ClientCAs.

func GenServerTLSConfigWithCA

func GenServerTLSConfigWithCA(clientCACert []byte) (*tls.Config, error)

GenServerTLSConfigWithCA creates a tls Config with ClientCAs.

func GenServiceMemberName

func GenServiceMemberName(serviceName string, index int64) string

func GenUUID

func GenUUID() string

GenUUID returns a 32 bytes uuid string

func GetConfigFileVersion

func GetConfigFileVersion(fileID string) (version int64, err error)

func GetControlDBVolumeID

func GetControlDBVolumeID(controldbServiceUUID string) string

GetControlDBVolumeID extracts the volume id from the controldb serviceUUID

func GetNextIP added in v0.8.1

func GetNextIP(usedIPs map[string]bool, ipnet *net.IPNet, lastIP net.IP) (nextIP net.IP, err error)

GetNextIP gets the next unused ip. aws reserves like 10.0.0.0, 10.0.0.1, 10.0.0.2, 10.0.0.3 and 10.0.0.255, http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html

func GetReqIDFromContext

func GetReqIDFromContext(ctx context.Context) string

GetReqIDFromContext gets the requuid from ctx.

func GetServiceJournalVolumeName added in v0.9.1

func GetServiceJournalVolumeName(serviceUUID string) string

func Hash

func Hash(s string) uint32

func IsControlDBService

func IsControlDBService(serviceUUID string) bool

func IsDirExist

func IsDirExist(dirpath string) (bool, error)

func IsFileExist

func IsFileExist(fpath string) (bool, error)

func NewRequestContext

func NewRequestContext(ctx context.Context, requuid string) context.Context

NewRequestContext returns a new Context carrying requuid.

func SetLogDir

func SetLogDir()

func SetLogToStd

func SetLogToStd()

Types

This section is empty.

Jump to

Keyboard shortcuts

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