delta

package
v4.1.12+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MissingValue = "_*_NoT_PReSeNT_*_"
View Source
const Separator = "|"

Variables

This section is empty.

Functions

This section is empty.

Types

type ComparableKind

type ComparableKind int

ComparableKind is used to avoid trying to compare uncomparable types like map[string]interface{} and []interface{}

const (
	Normal ComparableKind = iota
	MSI
	AI
)

type D

type D map[string]Deltizer

D is the type implemented by our Deltizer functions.

func New

func New() D

New returns an empty D.

func (D) ApplyDelta

func (d D) ApplyDelta(target interface{}, delta Delta) error

ApplyDelta applies a delta to a pointer to a base object Only fields in the delta that match the base object are modified

func (D) CreateDelta

func (d D) CreateDelta(current, previous interface{}) (Delta, error)

CreateDelta takes two structs, which must be of the same type, and constructs a Delta object from them using reflection.

func (D) Register

func (d D) Register(name string, dm Deltizer)

Register registers data for a custom field

type Delta

type Delta map[string]interface{}

Delta is a map of extended field names to values. Basically, it represents a possibly-nested struct as a flat list of key/value pairs, where the keys are a dotted name as you might see it in the source code: Foo.Buzz, for example. https://play.golang.org/p/1zkXshcT4d shows how it works.

type Deltizer

type Deltizer interface {
	// MakeDelta takes the field name and its value and returns
	// a Delta map of all the values contained within the field
	// at the appropriate level of granularity
	MakeDelta(delt Delta, name string, value interface{})
	// ApplyDelta takes a pointer to a field (from reflect)
	// plus the name of the particular item and its value
	// It expects that the field will be modified in place.
	ApplyDelta(field *reflect.Value, name string, value interface{})
}

Deltizer is the interface that must be implemented in order to use custom fields with the delta generator.

Jump to

Keyboard shortcuts

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