utils

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package utils contains all the utilites used across the repo

Index

Constants

View Source
const (
	// BspAgentVersionMajor is Major version component of the current release
	BspAgentVersionMajor = 1
	// BspAgentVersionMinor is Minor version component of the current release
	BspAgentVersionMinor = 7
	// BspAgentVersionPatch is Patch version component of the current release
	BspAgentVersionPatch = 0
)

Variables

View Source
var BspAgentVersion = func() string {
	return fmt.Sprintf("%d.%d.%d", BspAgentVersionMajor, BspAgentVersionMinor, BspAgentVersionPatch)
}()

BspAgentVersion holds the textual version string.

Functions

func AckTrimStreamSegment

func AckTrimStreamSegment(redisClient *redis.Client, segmentLength int, streamKey, consumerGroup string, streamIDs []string) (int64, error)

AckTrimStreamSegment acknowledges a stream segment from the redis stream

func DecodeAvro

func DecodeAvro(record avro.AvroRecord, buffer []byte) error

DecodeAvro tries to decode a data buffer, read it and store it on the input record. If successfully, the record is filled with data from the buffer, otherwise an error might be returned

func EncodeAvro

func EncodeAvro(record avro.AvroRecord) ([]byte, error)

EncodeAvro returns a byte slice representing the binary encoding of the input avro record

func ExpandPath

func ExpandPath(fsPath string) string

ExpandPath expands a file path 1. replace tilde with users home dir 2. expands embedded environment variables 3. cleans the path, e.g. /a/b/../c -> /a/c Note, it has limitations, e.g. ~someuser/tmp will not be expanded

func GetConfig

func GetConfig(fs *flag.FlagSet) []string

GetConfig retrieves the config from the config packages

func GetLogLocationURL

func GetLogLocationURL(logPath string) (*url.URL, error)

GetLogLocationURL gets full path of log directory for current user or creates it

func HomeDir

func HomeDir() string

HomeDir returns full path of home directory for current user

func MapToAvroUnion added in v1.2.3

func MapToAvroUnion(data map[string]interface{}) map[string]interface{}

MapToAvroUnion converts the several field in the replica map to an Avro Union type allowing <nil>

func NewEthClient

func NewEthClient(address string) (*ethclient.Client, error)

NewEthClient initializes a new ethereum client using an address string

func NewRedisClient

func NewRedisClient(rconfig *config.RedisConfig) (*redis.Client, string, string, error)

NewRedisClient provides a new redis client using a redis config

func StructToMap

func StructToMap(data interface{}) (map[string]interface{}, error)

StructToMap converts a struct to go map

func UnwrapAvroUnion added in v1.2.3

func UnwrapAvroUnion(data map[string]interface{}) map[string]interface{}

UnwrapAvroUnion unwraps avro wrapped maps

func Version added in v1.2.6

func Version()

Version Provides version info on bsp agent binary

func Writable

func Writable(path string) bool

Writable informs if path is writable to or not

Types

type BsploggerOutput

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

BsploggerOutput logger that can log to file (lumberjack) as well as stdout

func NewLoggerOut

func NewLoggerOut(writers ...io.Writer) BsploggerOutput

NewLoggerOut combine all writers to create a new writer

func (*BsploggerOutput) Write

func (logger *BsploggerOutput) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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