metago

package module
v0.0.0-...-31aee33 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2015 License: MIT Imports: 6 Imported by: 0

README

Metago

A meta-language for building Go types with some interesting built in functionality:

  • Forwards and backwards compatibility through statically assigned type and attribute identifiers
  • A form of subtyping polymorphism
  • Self-differencing: err, d = a.Diff(b) produces a record of the differences between two objects of the same type
  • Self-patching: err = a.Apply(d) where d is a difference record generated by a.Diff(b) will transform a into b
  • Compact and efficient binary serialization/deserialization of both objects and difference records to io.Writer/io.Reader

Docs: GoDoc

views views 24h

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttrID

type AttrID struct {
	*TypeID
	Attr int
	Name string
}

AttrID is a globally unique identifier for an attribute in a metago object type

func (*AttrID) Compare

func (a *AttrID) Compare(o *AttrID) int

func (*AttrID) Equals

func (a *AttrID) Equals(o *AttrID) bool

type Attrdef

type Attrdef struct {
	ID          *AttrID
	Persistence PersistenceClass
}

func (*Attrdef) String

func (a *Attrdef) String() string

type BaseChg

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

func (BaseChg) AttributeID

func (d BaseChg) AttributeID() *AttrID

func (BaseChg) PersistenceClass

func (d BaseChg) PersistenceClass() PersistenceClass

func (BaseChg) Schemaref

func (d BaseChg) Schemaref() *Attrdef

func (BaseChg) WriteTo

func (d BaseChg) WriteTo(w *Writer) error

type ByteChg

type ByteChg struct {
	BaseChg
	OldValue byte
	NewValue byte
}

func (*ByteChg) WriteIndented

func (c *ByteChg) WriteIndented(w io.Writer, lev int)

type ByteMapChg

type ByteMapChg struct {
	BaseChg
	Key  byte
	Typ  ChangeType
	Chgs []Chg
}

func (*ByteMapChg) WriteIndented

func (c *ByteMapChg) WriteIndented(w io.Writer, lev int)

type ChangeType

type ChangeType int
const (
	ChangeTypeInsert ChangeType = iota
	ChangeTypeDelete
	ChangeTypeModify
)

func (ChangeType) String

func (i ChangeType) String() string

type Chg

type Chg interface {
	AttributeID() *AttrID
	Schemaref() *Attrdef
	WriteIndented(w io.Writer, lev int)
}

func NewByteChg

func NewByteChg(s *Attrdef, values ...byte) Chg

func NewByteMapChg

func NewByteMapChg(s *Attrdef, key byte, typ ChangeType, chgs []Chg) Chg

func NewFloat32Chg

func NewFloat32Chg(s *Attrdef, values ...float32) Chg

func NewFloat64Chg

func NewFloat64Chg(s *Attrdef, values ...float64) Chg

func NewInt16Chg

func NewInt16Chg(s *Attrdef, values ...int16) Chg

func NewInt16MapChg

func NewInt16MapChg(s *Attrdef, key int16, typ ChangeType, chgs []Chg) Chg

func NewInt32Chg

func NewInt32Chg(s *Attrdef, values ...int32) Chg

func NewInt32MapChg

func NewInt32MapChg(s *Attrdef, key int32, typ ChangeType, chgs []Chg) Chg

func NewInt64Chg

func NewInt64Chg(s *Attrdef, values ...int64) Chg

func NewInt64MapChg

func NewInt64MapChg(s *Attrdef, key int64, typ ChangeType, chgs []Chg) Chg

func NewInt8Chg

func NewInt8Chg(s *Attrdef, values ...int8) Chg

func NewInt8MapChg

func NewInt8MapChg(s *Attrdef, key int8, typ ChangeType, chgs []Chg) Chg

func NewIntChg

func NewIntChg(s *Attrdef, values ...int) Chg

func NewIntMapChg

func NewIntMapChg(s *Attrdef, key int, typ ChangeType, chgs []Chg) Chg

func NewSliceChg

func NewSliceChg(sref *Attrdef, idx int, typ ChangeType, chgs []Chg) Chg

func NewStringChg

func NewStringChg(s *Attrdef, values ...string) Chg

func NewStringMapChg

func NewStringMapChg(s *Attrdef, key string, typ ChangeType, chgs []Chg) Chg

func NewStructChg

func NewStructChg(sref *Attrdef, chg Diff) Chg

func NewTimeChg

func NewTimeChg(s *Attrdef, values ...time.Time) Chg

func NewTimeMapChg

func NewTimeMapChg(s *Attrdef, key time.Time, typ ChangeType, chgs []Chg) Chg

func NewUint16Chg

func NewUint16Chg(s *Attrdef, values ...uint16) Chg

func NewUint16MapChg

func NewUint16MapChg(s *Attrdef, key uint16, typ ChangeType, chgs []Chg) Chg

func NewUint32Chg

func NewUint32Chg(s *Attrdef, values ...uint32) Chg

func NewUint32MapChg

func NewUint32MapChg(s *Attrdef, key uint32, typ ChangeType, chgs []Chg) Chg

func NewUint64Chg

func NewUint64Chg(s *Attrdef, values ...uint64) Chg

func NewUint64MapChg

func NewUint64MapChg(s *Attrdef, key uint64, typ ChangeType, chgs []Chg) Chg

func NewUint8Chg

func NewUint8Chg(s *Attrdef, values ...uint8) Chg

func NewUint8MapChg

func NewUint8MapChg(s *Attrdef, key uint8, typ ChangeType, chgs []Chg) Chg

func NewUintChg

func NewUintChg(s *Attrdef, values ...uint) Chg

func NewUintMapChg

func NewUintMapChg(s *Attrdef, key uint, typ ChangeType, chgs []Chg) Chg

type Diff

type Diff struct {
	Chgs []Chg
}

func (Diff) WriteIndented

func (d Diff) WriteIndented(w io.Writer, lev int)

type DiffApplyError

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

func (DiffApplyError) Error

func (e DiffApplyError) Error() string

type Float32Chg

type Float32Chg struct {
	BaseChg
	OldValue float32
	NewValue float32
}

func (*Float32Chg) WriteIndented

func (c *Float32Chg) WriteIndented(w io.Writer, lev int)

type Float64Chg

type Float64Chg struct {
	BaseChg
	OldValue float64
	NewValue float64
}

func (*Float64Chg) WriteIndented

func (c *Float64Chg) WriteIndented(w io.Writer, lev int)

type Int16Chg

type Int16Chg struct {
	BaseChg
	OldValue int16
	NewValue int16
}

func (*Int16Chg) WriteIndented

func (c *Int16Chg) WriteIndented(w io.Writer, lev int)

type Int16MapChg

type Int16MapChg struct {
	BaseChg
	Key  int16
	Typ  ChangeType
	Chgs []Chg
}

func (*Int16MapChg) WriteIndented

func (c *Int16MapChg) WriteIndented(w io.Writer, lev int)

type Int32Chg

type Int32Chg struct {
	BaseChg
	OldValue int32
	NewValue int32
}

func (*Int32Chg) WriteIndented

func (c *Int32Chg) WriteIndented(w io.Writer, lev int)

type Int32MapChg

type Int32MapChg struct {
	BaseChg
	Key  int32
	Typ  ChangeType
	Chgs []Chg
}

func (*Int32MapChg) WriteIndented

func (c *Int32MapChg) WriteIndented(w io.Writer, lev int)

type Int64Chg

type Int64Chg struct {
	BaseChg
	OldValue int64
	NewValue int64
}

func (*Int64Chg) WriteIndented

func (c *Int64Chg) WriteIndented(w io.Writer, lev int)

type Int64MapChg

type Int64MapChg struct {
	BaseChg
	Key  int64
	Typ  ChangeType
	Chgs []Chg
}

func (*Int64MapChg) WriteIndented

func (c *Int64MapChg) WriteIndented(w io.Writer, lev int)

type Int8Chg

type Int8Chg struct {
	BaseChg
	OldValue int8
	NewValue int8
}

func (*Int8Chg) WriteIndented

func (c *Int8Chg) WriteIndented(w io.Writer, lev int)

type Int8MapChg

type Int8MapChg struct {
	BaseChg
	Key  int8
	Typ  ChangeType
	Chgs []Chg
}

func (*Int8MapChg) WriteIndented

func (c *Int8MapChg) WriteIndented(w io.Writer, lev int)

type IntChg

type IntChg struct {
	BaseChg
	OldValue int
	NewValue int
}

func (*IntChg) WriteIndented

func (c *IntChg) WriteIndented(w io.Writer, lev int)

type IntMapChg

type IntMapChg struct {
	BaseChg
	Key  int
	Typ  ChangeType
	Chgs []Chg
}

func (*IntMapChg) WriteIndented

func (c *IntMapChg) WriteIndented(w io.Writer, lev int)

type PersistenceClass

type PersistenceClass int
const (
	PersistenceClassPersistent    PersistenceClass = iota // serialized to disk and wire
	PersistenceClassNonPersistent                         // serialized to wire
	PersistenceClassEphemeral                             // computed or temporary storage - not serialized
)

func (PersistenceClass) ShortString

func (p PersistenceClass) ShortString() string

func (PersistenceClass) String

func (i PersistenceClass) String() string

type SliceChg

type SliceChg struct {
	BaseChg
	Idx  int
	Typ  ChangeType
	Chgs []Chg
}

func (SliceChg) WriteIndented

func (c SliceChg) WriteIndented(w io.Writer, lev int)

type StringChg

type StringChg struct {
	BaseChg
	OldValue string
	NewValue string
}

func (*StringChg) WriteIndented

func (c *StringChg) WriteIndented(w io.Writer, lev int)

type StringMapChg

type StringMapChg struct {
	BaseChg
	Key  string
	Typ  ChangeType
	Chgs []Chg
}

func (*StringMapChg) WriteIndented

func (c *StringMapChg) WriteIndented(w io.Writer, lev int)

type StructChg

type StructChg struct {
	BaseChg
	Chg Diff
}

func (StructChg) WriteIndented

func (c StructChg) WriteIndented(w io.Writer, lev int)

type TimeChg

type TimeChg struct {
	BaseChg
	OldValue time.Time
	NewValue time.Time
}

func (*TimeChg) WriteIndented

func (c *TimeChg) WriteIndented(w io.Writer, lev int)

type TimeMapChg

type TimeMapChg struct {
	BaseChg
	Key  time.Time
	Typ  ChangeType
	Chgs []Chg
}

func (*TimeMapChg) WriteIndented

func (c *TimeMapChg) WriteIndented(w io.Writer, lev int)

type TypeID

type TypeID struct {
	Pkg     *uuid.UUID
	PkgName string
	Typ     int
	Name    string
}

TypeId is a globally unique identifier for a metago object type

func (*TypeID) Compare

func (t *TypeID) Compare(o *TypeID) int

func (*TypeID) Equals

func (t *TypeID) Equals(o *TypeID) bool

type Typedef

type Typedef struct {
	ID TypeID
}

type Uint16Chg

type Uint16Chg struct {
	BaseChg
	OldValue uint16
	NewValue uint16
}

func (*Uint16Chg) WriteIndented

func (c *Uint16Chg) WriteIndented(w io.Writer, lev int)

type Uint16MapChg

type Uint16MapChg struct {
	BaseChg
	Key  uint16
	Typ  ChangeType
	Chgs []Chg
}

func (*Uint16MapChg) WriteIndented

func (c *Uint16MapChg) WriteIndented(w io.Writer, lev int)

type Uint32Chg

type Uint32Chg struct {
	BaseChg
	OldValue uint32
	NewValue uint32
}

func (*Uint32Chg) WriteIndented

func (c *Uint32Chg) WriteIndented(w io.Writer, lev int)

type Uint32MapChg

type Uint32MapChg struct {
	BaseChg
	Key  uint32
	Typ  ChangeType
	Chgs []Chg
}

func (*Uint32MapChg) WriteIndented

func (c *Uint32MapChg) WriteIndented(w io.Writer, lev int)

type Uint64Chg

type Uint64Chg struct {
	BaseChg
	OldValue uint64
	NewValue uint64
}

func (*Uint64Chg) WriteIndented

func (c *Uint64Chg) WriteIndented(w io.Writer, lev int)

type Uint64MapChg

type Uint64MapChg struct {
	BaseChg
	Key  uint64
	Typ  ChangeType
	Chgs []Chg
}

func (*Uint64MapChg) WriteIndented

func (c *Uint64MapChg) WriteIndented(w io.Writer, lev int)

type Uint8Chg

type Uint8Chg struct {
	BaseChg
	OldValue uint8
	NewValue uint8
}

func (*Uint8Chg) WriteIndented

func (c *Uint8Chg) WriteIndented(w io.Writer, lev int)

type Uint8MapChg

type Uint8MapChg struct {
	BaseChg
	Key  uint8
	Typ  ChangeType
	Chgs []Chg
}

func (*Uint8MapChg) WriteIndented

func (c *Uint8MapChg) WriteIndented(w io.Writer, lev int)

type UintChg

type UintChg struct {
	BaseChg
	OldValue uint
	NewValue uint
}

func (*UintChg) WriteIndented

func (c *UintChg) WriteIndented(w io.Writer, lev int)

type UintMapChg

type UintMapChg struct {
	BaseChg
	Key  uint
	Typ  ChangeType
	Chgs []Chg
}

func (*UintMapChg) WriteIndented

func (c *UintMapChg) WriteIndented(w io.Writer, lev int)

type Writable

type Writable interface {
	WriteTo(w *Writer) error
	PersistenceClass() PersistenceClass
}

type Writer

type Writer struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(w io.Writer, p PersistenceClass) *Writer

func (*Writer) WriteBool

func (w *Writer) WriteBool(v bool) int

func (*Writer) WriteObj

func (w *Writer) WriteObj(obj Writable) error

func (*Writer) WriteString

func (w *Writer) WriteString(v string) int

func (*Writer) WriteUVarint

func (w *Writer) WriteUVarint(v uint64) int

func (*Writer) WriteVarint

func (w *Writer) WriteVarint(v int64) int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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