serializer

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONPayload

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

func (JSONPayload) Add

func (jpayload JSONPayload) Add(field string, value interface{}) moleculer.Payload

func (JSONPayload) AddItem

func (jpayload JSONPayload) AddItem(value interface{}) moleculer.Payload

func (JSONPayload) AddMany

func (jpayload JSONPayload) AddMany(toAdd map[string]interface{}) moleculer.Payload

func (JSONPayload) Array

func (payload JSONPayload) Array() []moleculer.Payload

func (JSONPayload) At

func (payload JSONPayload) At(index int) moleculer.Payload

func (JSONPayload) Bool

func (payload JSONPayload) Bool() bool

func (JSONPayload) BoolArray

func (payload JSONPayload) BoolArray() []bool

func (JSONPayload) Bson

func (jp JSONPayload) Bson() bson.M

func (JSONPayload) BsonArray

func (jp JSONPayload) BsonArray() bson.A

func (JSONPayload) ByteArray

func (payload JSONPayload) ByteArray() []byte

func (JSONPayload) Error

func (payload JSONPayload) Error() error

func (JSONPayload) ErrorPayload

func (p JSONPayload) ErrorPayload() moleculer.Payload

func (JSONPayload) Exists

func (payload JSONPayload) Exists() bool

func (JSONPayload) First

func (jp JSONPayload) First() moleculer.Payload

func (JSONPayload) Float

func (payload JSONPayload) Float() float64

func (JSONPayload) Float32

func (payload JSONPayload) Float32() float32

func (JSONPayload) Float32Array

func (payload JSONPayload) Float32Array() []float32

func (JSONPayload) FloatArray

func (payload JSONPayload) FloatArray() []float64

func (JSONPayload) ForEach

func (payload JSONPayload) ForEach(iterator func(key interface{}, value moleculer.Payload) bool)

func (JSONPayload) Get

func (jp JSONPayload) Get(path string, defaultValue ...interface{}) moleculer.Payload

func (JSONPayload) Int

func (payload JSONPayload) Int() int

func (JSONPayload) Int64

func (payload JSONPayload) Int64() int64

func (JSONPayload) Int64Array

func (payload JSONPayload) Int64Array() []int64

func (JSONPayload) IntArray

func (payload JSONPayload) IntArray() []int

func (JSONPayload) IsArray

func (payload JSONPayload) IsArray() bool

func (JSONPayload) IsError

func (payload JSONPayload) IsError() bool

func (JSONPayload) IsMap

func (payload JSONPayload) IsMap() bool

func (JSONPayload) Len

func (jp JSONPayload) Len() int

func (JSONPayload) Map

func (payload JSONPayload) Map() map[string]moleculer.Payload

func (JSONPayload) MapArray

func (payload JSONPayload) MapArray() []map[string]interface{}

func (JSONPayload) MapOver

func (p JSONPayload) MapOver(transform func(in moleculer.Payload) moleculer.Payload) moleculer.Payload

func (JSONPayload) Only

func (p JSONPayload) Only(path string) moleculer.Payload

Only return a payload containing only the field specified

func (JSONPayload) RawMap

func (payload JSONPayload) RawMap() map[string]interface{}

func (JSONPayload) Remove

func (jpayload JSONPayload) Remove(fields ...string) moleculer.Payload

func (JSONPayload) Sort

func (p JSONPayload) Sort(field string) moleculer.Payload

func (JSONPayload) String

func (jp JSONPayload) String() string

func (JSONPayload) StringArray

func (payload JSONPayload) StringArray() []string

func (JSONPayload) StringIdented

func (jp JSONPayload) StringIdented(ident string) string

func (JSONPayload) Time

func (payload JSONPayload) Time() time.Time

func (JSONPayload) TimeArray

func (payload JSONPayload) TimeArray() []time.Time

func (JSONPayload) Uint

func (payload JSONPayload) Uint() uint64

func (JSONPayload) UintArray

func (payload JSONPayload) UintArray() []uint64

func (JSONPayload) Value

func (payload JSONPayload) Value() interface{}

func (JSONPayload) ValueArray

func (payload JSONPayload) ValueArray() []interface{}

type JSONSerializer

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

func CreateJSONSerializer

func CreateJSONSerializer(logger *log.Entry) JSONSerializer

func (JSONSerializer) BytesToPayload

func (serializer JSONSerializer) BytesToPayload(bytes *[]byte) moleculer.Payload

func (JSONSerializer) MapToPayload

func (serializer JSONSerializer) MapToPayload(mapValue *map[string]interface{}) (moleculer.Payload, error)

func (JSONSerializer) MapToString

func (serializer JSONSerializer) MapToString(m interface{}) string

MapToString serialize a map into a string This implementation uses the standard library json pkg and it needs to be compared with others for performance. Performance: it should be experimented with multiple implementations. This is just he initial one.

func (JSONSerializer) PayloadToBytes

func (serializer JSONSerializer) PayloadToBytes(payload moleculer.Payload) []byte

func (JSONSerializer) PayloadToContextMap

func (serializer JSONSerializer) PayloadToContextMap(message moleculer.Payload) map[string]interface{}

func (JSONSerializer) PayloadToString

func (serializer JSONSerializer) PayloadToString(payload moleculer.Payload) string

func (JSONSerializer) ReaderToPayload

func (serializer JSONSerializer) ReaderToPayload(r io.Reader) moleculer.Payload

ReaderToPayload transform an io.Reader into a Payload assusming the contes is a valid json :)

func (JSONSerializer) StringToMap

func (serializer JSONSerializer) StringToMap(j string) map[string]interface{}

StringToMap deserialize a string (json) into map Same implementation and performance notes as MapToString

type Serializer

type Serializer interface {
	ReaderToPayload(io.Reader) moleculer.Payload
	BytesToPayload(*[]byte) moleculer.Payload
	PayloadToBytes(moleculer.Payload) []byte
	PayloadToString(moleculer.Payload) string
	MapToString(interface{}) string
	StringToMap(string) map[string]interface{}
	PayloadToContextMap(moleculer.Payload) map[string]interface{}
	MapToPayload(*map[string]interface{}) (moleculer.Payload, error)
}

func New

func New(broker *moleculer.BrokerDelegates) Serializer

Jump to

Keyboard shortcuts

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