utils

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsPathify

func AbsPathify(inPath string) string

AbsPathify turns relative path into absolute by expanding all environment variables and analysing the current working directory

func BoolToInt

func BoolToInt(v bool) int

func BuildMapFromString

func BuildMapFromString(mappingStr string) (map[string]string, error)

func BytesToInt64

func BytesToInt64(v []byte) int64

func BytesToUint32

func BytesToUint32(v []byte) uint32

func DiscoverMetaGraph

func DiscoverMetaGraph(val []byte) (string, string)

func DoubleSha256

func DoubleSha256(b []byte) []byte

DoubleSha256 calculates sha256(sha256(b)) and returns the resulting bytes.

func Float64ToString

func Float64ToString(v float64) string

func Int64ToBytes

func Int64ToBytes(v int64) []byte

func Int64ToString

func Int64ToString(v int64) string

func IntToBool

func IntToBool(v int) bool

func IntToString

func IntToString(v int) string

func MarshalToType

func MarshalToType(val any, dest any, allowUnknownFields bool) error

func RandomID

func RandomID(size int) (string, error)

func StringToFloat64

func StringToFloat64(v string) float64

func StringToInt

func StringToInt(v string) int

func StringToInt64

func StringToInt64(v string) int64

func StringToTime

func StringToTime(v string) time.Time

func SubstituteEntities

func SubstituteEntities(template []byte, entityMap map[string]string, nowTimestamp *time.Time) ([]byte, error)

func TimeToString

func TimeToString(t time.Time) string

func Uint32ToBytes

func Uint32ToBytes(v uint32) []byte

func UserHomeDir

func UserHomeDir() string

Types

type BoltClient

type BoltClient struct {
	DB *bbolt.DB
}

func NewBoltClient

func NewBoltClient(boltDBFile string, installSchemaFunc InstallSchemaFunc) (*BoltClient, error)

func (*BoltClient) Close

func (bc *BoltClient) Close() error

func (*BoltClient) FetchBytes

func (bc *BoltClient) FetchBytes(bucket, key string) ([]byte, error)

func (*BoltClient) FetchInt

func (bc *BoltClient) FetchInt(bucket, key string) (int, error)

func (*BoltClient) FetchString

func (bc *BoltClient) FetchString(bucket, key string) (string, error)

func (*BoltClient) Update

func (bc *BoltClient) Update(bucket, key string, value []byte) error

func (*BoltClient) UpdateInline

func (bc *BoltClient) UpdateInline(tx *bbolt.Tx, bucket, key string, value []byte) error

func (*BoltClient) UpdateInt64

func (bc *BoltClient) UpdateInt64(bucket, key string, value int64) error

type GracefulWarden

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

GracefulWarden listens for system signals and invokes Close() methods to all 'subscribed' io.Closers (use CloseOnShutdown method to subscribe a closer)

func NewGracefulWarden

func NewGracefulWarden(patienceTimeout int64) *GracefulWarden

Create a warden. Only one copy of GracefulWarden can be present in the system.

func (*GracefulWarden) CloseOnShutdown

func (gw *GracefulWarden) CloseOnShutdown(closer io.Closer)

Given Closer will have Close() method invoked when the server process receives some system signals (see implementation below for full list)

type InstallSchemaFunc

type InstallSchemaFunc func(bc *BoltClient) error

Directories

Path Synopsis
Package zero contains functions to clear data from byte slices and multi-precision integers.
Package zero contains functions to clear data from byte slices and multi-precision integers.

Jump to

Keyboard shortcuts

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