loader

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 10 Imported by: 0

README

MongoDB-Bson-Version-Loader-Helper

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidVersionValue = xerrors.New("Invalid version value")
View Source
var LoaderNotFoundError = xerrors.New("cannot found loader handlers for src version")
View Source
var NoVersionTagError = xerrors.New("data not version field or with invalid 0.0 version")
View Source
var TransformerNotFoundError = xerrors.New("cannot found next transformer to the target version")
View Source
var TransformerSrcTypeIncorrectError = xerrors.New("src type for transformer is incorrect and failed to cast")
View Source
var VersionWrapperStructs = map[reflect.Type]dynamicstruct.DynamicStruct{}

Functions

func AddVersionWrapperType added in v0.0.2

func AddVersionWrapperType(typeVal interface{}) dynamicstruct.DynamicStruct

func GetVersionWrapperStruct added in v0.0.2

func GetVersionWrapperStruct(typeVal interface{}) dynamicstruct.DynamicStruct

Types

type AVersionCapture added in v0.0.2

type AVersionCapture VersionCapture

type D

type D interface{}

type HasVersion

type HasVersion interface {
	GetVersion() Version
	SetVersion(Version)
	GetData() interface{}
	SetData(interface{})
}

type Loader

type Loader func([]byte, HasVersion) error

func DefaultLoader added in v0.0.3

func DefaultLoader(typeVal interface{}) Loader

type LoaderRegistry

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

func NewLoaderRegistry

func NewLoaderRegistry(loadersL SLoaders, transformersT STransformers) *LoaderRegistry

func (*LoaderRegistry) Load

func (l *LoaderRegistry) Load(src []byte, target Version) (HasVersion, error)

func (*LoaderRegistry) Transform

func (l *LoaderRegistry) Transform(data HasVersion, target Version) error

type SLoaders

type SLoaders map[string]interface{}

type SLoaders map[string]Loader

func (SLoaders) SrcLoaders

func (l SLoaders) SrcLoaders() SrcLoaders

type STargetTransformers

type STargetTransformers map[string]Transformer

type STransformers

type STransformers map[string]STargetTransformers

func (STransformers) SrcToTargetTransformers

func (t STransformers) SrcToTargetTransformers() SrcToTargetTransformers

type SrcLoaders

type SrcLoaders map[Version]Loader

type SrcToTargetTransformers

type SrcToTargetTransformers map[Version]TargetTransformers

type SrcToTargetVersions

type SrcToTargetVersions map[Version]Versions

type TargetTransformers

type TargetTransformers map[Version]Transformer

type Transformer

type Transformer func(HasVersion) error

type Version

type Version struct {
	MINOR int
	PATCH int
}

func NewVersion

func NewVersion(value string) (Version, error)

func NewVersionPanic

func NewVersionPanic(value string) Version

func (Version) Greater

func (v Version) Greater(anotherVersion Version) bool

func (Version) Less

func (v Version) Less(anotherVersion Version) bool

func (Version) MarshalBSONValue

func (v Version) MarshalBSONValue() (bsontype.Type, []byte, error)

func (Version) NextMINOR

func (v Version) NextMINOR() Version

func (Version) NextPATCH

func (v Version) NextPATCH() Version

func (Version) String

func (v Version) String() string

func (*Version) UnmarshalBSONValue

func (v *Version) UnmarshalBSONValue(t bsontype.Type, src []byte) error

type VersionCapture

type VersionCapture struct {
	Version Version
	D
}

func (VersionCapture) GetData

func (v VersionCapture) GetData() interface{}

func (VersionCapture) GetVersion

func (v VersionCapture) GetVersion() Version

func (VersionCapture) MarshalBSON added in v0.0.2

func (v VersionCapture) MarshalBSON() ([]byte, error)

func (*VersionCapture) SetData

func (v *VersionCapture) SetData(d interface{})

func (*VersionCapture) SetVersion

func (v *VersionCapture) SetVersion(vv Version)

func (*VersionCapture) UnmarshalBSON added in v0.0.2

func (v *VersionCapture) UnmarshalBSON(src []byte) error

type Versions

type Versions []Version

func (*Versions) Max

func (vs *Versions) Max() *Version

Jump to

Keyboard shortcuts

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