mqutil

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrOK         = iota // 0
	ErrInvalid           // invalid parameters
	ErrNotFound          // resource not found
	ErrExpect            // the REST result doesn't match the expected value
	ErrHttp              // Http request failed
	ErrServerResp        // unexpected server response
	ErrInternal          // unexpected internal error (meqa error)
)

Variables

View Source
var Logger *log.Logger

There is only one logger per process.

View Source
var Verbose bool

Whether verbose mose is on

Functions

func ArrayCopy

func ArrayCopy(src []interface{}) (dst []interface{})

func InterfaceEquals

func InterfaceEquals(criteria interface{}, existing interface{}) bool

Check if existing matches criteria. When criteria is a map, we check whether everything in criteria can be found and equals a field in existing.

func InterfacePrint

func InterfacePrint(m interface{}, printToConsole bool)

func InterfaceToJsonString

func InterfaceToJsonString(i interface{}) string

func IterateFieldsInInterface

func IterateFieldsInInterface(in interface{}, callback FieldIterFunc) error

func IterateMapsInInterface

func IterateMapsInInterface(in interface{}, callback MapIterFunc) error

Iterate all the leaf level fields. For maps iterate all the fields. For arrays we will go through all the entries and see if any of them is a map. The iteration will be done in a width first order, so deeply buried fields will be iterated last. The maps should be map[string]interface{}.

func JsonToYaml

func JsonToYaml(in []byte) ([]byte, error)

func MapAdd

func MapAdd(dst map[string]interface{}, src map[string]interface{}) map[string]interface{}

Just like MapCombine but keep the original dst value if there is an overlap.

func MapCombine

func MapCombine(dst map[string]interface{}, src map[string]interface{}) map[string]interface{}

MapCombine combines two map together. If there is any overlap the dst will be overwritten.

func MapCopy

func MapCopy(src map[string]interface{}) map[string]interface{}

func MapInterfaceToMapString

func MapInterfaceToMapString(src map[string]interface{}) map[string]string

MapInterfaceToMapString converts the params map (all primitive types with exception of array) before passing to resty.

func MapIsCompatible

func MapIsCompatible(big map[string]interface{}, small map[string]interface{}) bool

MapIsCompatible checks if the first map has every key in the second.

func MapReplace

func MapReplace(dst map[string]interface{}, src map[string]interface{}) map[string]interface{}

MapReplace replaces the values in dst with the ones in src with the matching keys.

func MarshalJsonIndentNoEscape

func MarshalJsonIndentNoEscape(i interface{}) ([]byte, error)

func NewError

func NewError(errType int, str string) error

func NewFileLogger

func NewFileLogger(path string) *log.Logger

func NewLogger

func NewLogger(out io.Writer) *log.Logger

func NewStdLogger

func NewStdLogger() *log.Logger

func TimeCompare

func TimeCompare(v1 interface{}, v2 interface{}) bool

func YamlObjToJsonObj

func YamlObjToJsonObj(in interface{}) (interface{}, error)

func YamlToJson

func YamlToJson(in []byte) (json.RawMessage, error)

Given a yaml stream, output a json stream.

Types

type Error

type Error interface {
	error
	Type() int
}

Error implements MQ specific error type.

type FieldIterFunc

type FieldIterFunc func(key string, value interface{}) error

type MapIterFunc

type MapIterFunc func(m map[string]interface{}) error

type TypedError

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

TypedError holds a type and a back trace for easy debugging

func (*TypedError) Error

func (e *TypedError) Error() string

func (*TypedError) Type

func (e *TypedError) Type() int

Jump to

Keyboard shortcuts

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