Documentation ¶
Index ¶
- Variables
- func AddVersionWrapperType(typeVal interface{}) dynamicstruct.DynamicStruct
- func GetVersionWrapperStruct(typeVal interface{}) dynamicstruct.DynamicStruct
- type AVersionCapture
- type Loader
- type Registry
- type SLoaders
- type STargetTransformers
- type STransformers
- type SrcLoaders
- type SrcToTargetTransformers
- type SrcToTargetVersions
- type TargetTransformers
- type Transformer
- type Version
- func (v Version) Greater(anotherVersion Version) bool
- func (v Version) Less(anotherVersion Version) bool
- func (v Version) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (v Version) NextMINOR() Version
- func (v Version) NextPATCH() Version
- func (v Version) String() string
- func (v *Version) UnmarshalBSONValue(t bsontype.Type, src []byte) error
- type VersionCapture
- type VersionWrapper
- type Versions
Constants ¶
This section is empty.
Variables ¶
var DynamicVersionWrapperStructs = map[reflect.Type]dynamicstruct.DynamicStruct{}
var InvalidVersionValue = errors.New("Invalid version value")
var LoaderNotFoundError = errors.New("cannot found loader handlers for src version")
LoaderNotFoundError while can't found loader for the specified version
var NoVersionTagError = errors.New("data has no _version field or with invalid 0.0 version")
NoVersionTagError while loaded data not contain any valid _version tag
var TransformerNotFoundError = errors.New("cannot found next transformer to the target version")
TransformerNotFoundError while can't found Transformer for specified version path transformation progress
var TransformerSrcTypeIncorrectError = errors.New("src type for transformer is incorrect and failed to cast")
TransformerSrcTypeIncorrectError while Transformer trying to cast interface{} src data into desired version struct and failed
Functions ¶
func AddVersionWrapperType ¶
func AddVersionWrapperType(typeVal interface{}) dynamicstruct.DynamicStruct
func GetVersionWrapperStruct ¶
func GetVersionWrapperStruct(typeVal interface{}) dynamicstruct.DynamicStruct
Types ¶
type AVersionCapture ¶
type AVersionCapture VersionCapture
AVersionCapture use for prevent MarshalBSON loop
type Loader ¶
type Loader func([]byte, VersionWrapper) error
Loader func that responsible for load data for specified Version
func DefaultLoader ¶
func DefaultLoader(typeVal interface{}) Loader
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry(loadersL SLoaders, transformersT STransformers) *Registry
NewRegistry Registry the Loaders and Transformers for migration
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 SrcToTargetTransformers ¶
type SrcToTargetTransformers map[Version]TargetTransformers
type SrcToTargetVersions ¶
type TargetTransformers ¶
type TargetTransformers map[Version]Transformer
type Transformer ¶
type Transformer func(VersionWrapper) error
Transformer func that responsible for transform the data between Versions
type Version ¶
func NewVersion ¶
func NewVersionPanic ¶
NewVersionPanic use with no error but panic directly
func (Version) Greater ¶
Greater operator to compare to another Version,return true if it is greater then another one
func (Version) Less ¶
Less operator to compare to another Version,return true if it is less then another one
func (Version) MarshalBSONValue ¶
type VersionCapture ¶
type VersionCapture struct { Version Version `bson:"_version"` Data interface{} }
VersionCapture a Capture for extract the version info from byte data and carry the corresponding version structure data though the progress
func (VersionCapture) GetVersion ¶
func (v VersionCapture) GetVersion() Version
GetVersion get Version
func (VersionCapture) MarshalBSON ¶
func (v VersionCapture) MarshalBSON() ([]byte, error)
MarshalBSON where VersionCapture deal with version and inline Data
func (*VersionCapture) SetVersion ¶
func (v *VersionCapture) SetVersion(vv Version)
SetVersion set Version
func (*VersionCapture) UnmarshalBSON ¶
func (v *VersionCapture) UnmarshalBSON(src []byte) error
UnmarshalBSON where VersionCapture deal with version and inline Data
type VersionWrapper ¶
type VersionWrapper interface { GetVersion() Version SetVersion(Version) GetData() interface{} SetData(interface{}) }
VersionWrapper wrapper that contain data and version