utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package utils contains all the utilites used across the repo

Index

Constants

This section is empty.

Variables

This section is empty.

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 NewEthClient

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

NewEthClient initializes a new ethereum client using an address string

func NewGCPStorageClient

func NewGCPStorageClient(serviceAccount string) (*storage.Client, error)

NewGCPStorageClient initializes a new gcp storage client using a service account 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 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