Documentation ¶
Overview ¶
Package utils contains all the utilites used across the repo
Index ¶
- Constants
- Variables
- func AckTrimStreamSegment(redisClient *redis.Client, segmentLength int, streamKey, consumerGroup string, ...) (int64, error)
- func DecodeAvro(record avro.AvroRecord, buffer []byte) error
- func EncodeAvro(record avro.AvroRecord) ([]byte, error)
- func ExpandPath(fsPath string) string
- func GetConfig(fs *flag.FlagSet) []string
- func GetLogLocationURL(logPath string) (*url.URL, error)
- func HomeDir() string
- func MapToAvroUnion(data map[string]interface{}) map[string]interface{}
- func NewEthClient(address string) (*ethclient.Client, error)
- func NewGCPStorageClient(serviceAccount string) (*storage.Client, error)
- func NewRedisClient(rconfig *config.RedisConfig) (*redis.Client, string, string, error)
- func StructToMap(data interface{}) (map[string]interface{}, error)
- func UnwrapAvroUnion(data map[string]interface{}) map[string]interface{}
- func Version()
- func Writable(path string) bool
- type BsploggerOutput
Constants ¶
const ( // BspAgentVersionMajor is Major version component of the current release BspAgentVersionMajor = 1 // BspAgentVersionMinor is Minor version component of the current release BspAgentVersionMinor = 2 // BspAgentVersionPatch is Patch version component of the current release BspAgentVersionPatch = 8 )
Variables ¶
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 ¶
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 ¶
EncodeAvro returns a byte slice representing the binary encoding of the input avro record
func ExpandPath ¶
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 GetLogLocationURL ¶
GetLogLocationURL gets full path of log directory for current user or creates it
func MapToAvroUnion ¶ added in v1.2.3
MapToAvroUnion converts the "to" field in the replica map to an Avro Union type allowing <nil>
func NewEthClient ¶
NewEthClient initializes a new ethereum client using an address string
func NewGCPStorageClient ¶
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 ¶
StructToMap converts a struct to go map
func UnwrapAvroUnion ¶ added in v1.2.3
UnwrapAvroUnion "unwraps" the "to" field from the replica map
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