common

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

TODO XXX remove all this in favor of mfs

Index

Constants

This section is empty.

Variables

View Source
var (
	GRPCMaxMessage = grpc.WithDefaultCallOptions(
		grpc.MaxCallRecvMsgSize(maxMessageSize),
		grpc.MaxCallSendMsgSize(maxMessageSize),
	)

	GRPCMaxServer = []grpc.ServerOption{
		grpc.MaxRecvMsgSize(maxMessageSize),
		grpc.MaxSendMsgSize(maxMessageSize),
	}
)
View Source
var DataError = fmt.Errorf("data error")
View Source
var DbError = fmt.Errorf("database error")
View Source
var TxError = fmt.Errorf("transaction failure")
View Source
var Version = "undefined"

Version will be set by the make system at link time.

Functions

func Error

func Error(message string) error

Encapsulate err in a structured log and return an abstracted high-level error with message as the payload

func ErrorE

func ErrorE(message string, err error) error

Encapsulate err in a structured log and return an abstracted high-level error with message as the payload

func ErrorEF

func ErrorEF(message string, err error, fields log.Fields) error

Encapsulate fields and err in a structured log and return an abstracted high-level error with message as the payload

func ErrorF

func ErrorF(message string, fields log.Fields) error

Encapsulate fields in a structured log and return an abstracted high-level error with message as the payload

func EtcdClient

func EtcdClient() (*clientv3.Client, error)

EtcdClient -----------------------------------------------------------------

Return a pointer to an etcd client suitable for using.

The connection should *not* be closed as it's cached. EtcdClient() takes
care to handle the connection deatails.

func InitLogging

func InitLogging(logname string)

func TrackTime

func TrackTime(start time.Time)

Function to track how long a function takes. Useful for profiling the system. To use call it towards the top of your function, deferred, with the current time. The amount of time taken will be logged when your function completes.

ex:

func myFunc() {
    TrackTime(time.Now())
    ...
}

Types

type CountSet

type CountSet []int

func (CountSet) Add

func (cs CountSet) Add() (int, CountSet)

func (CountSet) Next

func (cs CountSet) Next() (int, int)

func (CountSet) Remove

func (cs CountSet) Remove(i int) CountSet

type TxnBuilder

type TxnBuilder struct {
	Ifs          []clientv3.Cmp
	Thens, Elses []clientv3.Op
}

func (*TxnBuilder) Build

func (x *TxnBuilder) Build(
	cx context.Context, cl *clientv3.Client,
) clientv3.Txn

func (*TxnBuilder) Else

func (t *TxnBuilder) Else(x clientv3.Op) *TxnBuilder

func (*TxnBuilder) If

func (t *TxnBuilder) If(x clientv3.Cmp) *TxnBuilder

func (*TxnBuilder) Merge

func (t *TxnBuilder) Merge(x TxnBuilder)

func (*TxnBuilder) Then

func (t *TxnBuilder) Then(x clientv3.Op) *TxnBuilder

Jump to

Keyboard shortcuts

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