utils

package
v2.2.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttributeValuetoStr

func AttributeValuetoStr(av interface{}) (string, error)

AttributeValuetoStr returns string representation of an attribute value

func Contains

func Contains(a []interface{}, x interface{}) bool

func Float64Contains

func Float64Contains(a []float64, x float64) bool

func GenerateNewID

func GenerateNewID() string

GenerateNewID generates new uuid.

func GetErrorMessage

func GetErrorMessage(err interface{}) string

GetErrorMessage returns error message

func GetErrorType

func GetErrorType(err interface{}) string

GetErrorType returns type of the error

func GetEventTypeFromContext

func GetEventTypeFromContext(ctx context.Context) interface{}

GetEventTypeFromContext returns event type passed in context

func GetPid

func GetPid() string

GetPid returns pid of this process.

func GetStatusCode

func GetStatusCode(responseInterface *interface{}) (int, error)

func GetStringFieldFromValue

func GetStringFieldFromValue(value reflect.Value, fieldName string) (string, bool)

func GetThisProcess

func GetThisProcess() *process.Process

GetThisProcess returns process info about this process.

func GetTimestamp

func GetTimestamp() int64

GetTimestamp returns current unix timestamp in msec.

func GetXRayTraceInfo

func GetXRayTraceInfo(ctx context.Context) (string, string)

GetXRayTraceInfo parses X-Ray trace information

func Int64Contains

func Int64Contains(a []int64, x int64) bool

func IsTimeout

func IsTimeout(err interface{}) bool

IsTimeout returns whether or not an err is a timeout error

func MarshalJSON

func MarshalJSON(av AttributeValue) ([]byte, error)

MarshalJSON implements custom marshaling for AttributeValue

func MsToTime

func MsToTime(t int64) time.Time

func ReadRequestBody

func ReadRequestBody(body io.ReadCloser, contentLength int) (string, io.ReadCloser)

func Round

func Round(x float64) float64

Round returns the nearest integer, rounding ties away from zero.

func SerializeToMap

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

func SetEventTypeToContext

func SetEventTypeToContext(ctx context.Context, et reflect.Type) context.Context

SetEventTypeToContext returns a context with event type value

func SetSpanError

func SetSpanError(span opentracing.Span, err interface{})

SetSpanError sets the tags related to the given error to the given span

func StringContains

func StringContains(a []string, x string) bool

func TimeToMs

func TimeToMs(t time.Time) int64

Types

type AttributeValue

type AttributeValue struct {
	B    []byte                      `type:"blob" json:",omitempty"`
	BOOL *bool                       `type:"boolean" json:",omitempty"`
	BS   [][]byte                    `type:"list" json:",omitempty"`
	L    []*AttributeValue           `type:"list" json:",omitempty"`
	M    *map[string]*AttributeValue `type:"map" json:",omitempty"`
	N    *string                     `type:"string" json:",omitempty"`
	NS   []*string                   `type:"list" json:",omitempty"`
	NULL *bool                       `type:"boolean" json:",omitempty"`
	S    *string                     `type:"string" json:"S,omitempty"`
	SS   []*string                   `type:"list" json:",omitempty"`
}

AttributeValue is a struct for marshalling dynamodb attribute value without null fields

Jump to

Keyboard shortcuts

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