Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShrinkRandomly ¶ added in v0.0.8
func ShrinkRandomly(r *rand.Rand, schem *Schema)
ShrinkRandomly will deterministically, pseudo-randomly shrink the provided schema by removing the last field from one of the structs or oneofs. This function is used for testing schema changes.
Types ¶
type ArrayType ¶ added in v0.0.8
type ArrayType struct { ElemType FieldType `json:"elem,omitempty"` // contains filtered or unexported fields }
type Compatibility ¶
type Compatibility int
const ( CompatibilityExact Compatibility = iota CompatibilitySuperset CompatibilityIncompatible )
type FieldType ¶
type FieldType struct { // Only one of the following 5 fields should be set. Primitive *PrimitiveType `json:"primitive,omitempty"` Array *ArrayType `json:"array,omitempty"` Struct string `json:"struct,omitempty"` MultiMap string `json:"multimap,omitempty"` Enum string // DictName is the name of the dictionary if the field dictionary-encoded. DictName string `json:"dict,omitempty"` // StructDef and MultimapDef are pointers to the struct or multimap definitions // that are named in Struct or MultiMap fields. StructDef *Struct MultimapDef *Multimap }
FieldType describes a field type of in a struct, multimap key or value or array element.
func (*FieldType) SetRecursive ¶ added in v0.0.8
func (t *FieldType) SetRecursive()
type Multimap ¶
type Multimap struct { Name string `json:"name,omitempty"` Key MultimapField `json:"key"` Value MultimapField `json:"value"` // contains filtered or unexported fields }
type MultimapField ¶
type MultimapField struct {
Type FieldType `json:"type"`
}
MultimapField is either a key or a value field in a multimap.
func (*MultimapField) Clone ¶ added in v0.0.8
func (m *MultimapField) Clone() MultimapField
func (*MultimapField) SetRecursive ¶ added in v0.0.8
func (m *MultimapField) SetRecursive()
type PrimitiveFieldType ¶
type PrimitiveFieldType int
const ( PrimitiveTypeInt64 PrimitiveFieldType = iota PrimitiveTypeUint64 PrimitiveTypeFloat64 PrimitiveTypeBool PrimitiveTypeString PrimitiveTypeBytes )
type PrimitiveType ¶ added in v0.0.8
type PrimitiveType struct {
Type PrimitiveFieldType
}
type Schema ¶
type Schema struct { PackageName []string `json:"package,omitempty"` Structs map[string]*Struct `json:"structs"` Multimaps map[string]*Multimap `json:"multimaps"` Enums map[string]*Enum }
Schema is a STEF schema description, serializable in JSON format.
func (*Schema) Compatible ¶
func (d *Schema) Compatible(oldSchema *Schema) (Compatibility, error)
Compatible checks backward compatibility of this schema with oldSchema. If the schemas are incompatible returns CompatibilityIncompatible and an error.
func (*Schema) FieldCount ¶ added in v0.0.8
FieldCount returns the number of fields in the specified struct.
func (*Schema) PrunedForRoot ¶
PrunedForRoot produces a pruned copy of the schema that includes the specified root struct and parts of schema reachable from that root. Unreachable parts of the schema are excluded.
func (*Schema) ResolveRefs ¶ added in v0.0.8
ResolveRefs resolves all type references by names to structs, multimaps, arrays and enums in the schema to pointers to appropriate objects in the schema.
type Struct ¶
type Struct struct { Name string `json:"name,omitempty"` OneOf bool `json:"oneof,omitempty"` DictName string `json:"dict,omitempty"` IsRoot bool `json:"root,omitempty"` Fields []*StructField `json:"fields"` // contains filtered or unexported fields }
type StructField ¶
type StructField struct { FieldType Name string `json:"name,omitempty"` Optional bool `json:"optional,omitempty"` }
func (*StructField) Clone ¶ added in v0.0.8
func (s *StructField) Clone() *StructField
func (*StructField) Recursive ¶ added in v0.0.8
func (s *StructField) Recursive() bool
func (*StructField) SetRecursive ¶ added in v0.0.8
func (s *StructField) SetRecursive()
type WireSchema ¶ added in v0.0.2
type WireSchema struct {
// contains filtered or unexported fields
}
WireSchema caries only the parts of the schema, which are necessary to be communicated between readers and writers that work with evolving versions of the same schema.
WireSchema allows readers and writers to perform compatibility checks of their schema version with the schema version that a peer they communicate with uses.
The only valid way to evolve a STEF schema is by adding new fields at the end of the existing structs/oneofs. This means that in order to correctly read/write an evolved schema the only necessary information is the number of the fields in in each struct/oneof. This is precisely the information that is recorded in WireSchema.
The full schema information can be recorded in a schema.Schema, however that full information is not necessary for wire compatibility checks. Instead, we use the much simpler and more compact WireSchema to serve that role.
func NewWireSchema ¶ added in v0.0.8
func NewWireSchema(schema *Schema, rootStructName string) WireSchema
NewWireSchema creates a new WireSchema from a schema for the given root. The wire schema will only include the structs that are reachable from the specified root struct.
func (*WireSchema) Compatible ¶ added in v0.0.2
func (w *WireSchema) Compatible(oldSchema *WireSchema) (Compatibility, error)
Compatible checks backward compatibility of this schema with oldSchema. If the schemas are incompatible returns CompatibilityIncompatible and an error.
func (*WireSchema) Deserialize ¶ added in v0.0.2
func (w *WireSchema) Deserialize(src io.ByteReader) error
Deserialize the schema from binary format.
type WireSchemaIter ¶ added in v0.0.8
type WireSchemaIter struct {
// contains filtered or unexported fields
}
WireSchemaIter is an iterator over the structs in a WireSchema.
func NewWireSchemaIter ¶ added in v0.0.8
func NewWireSchemaIter(schema *WireSchema) WireSchemaIter
func (*WireSchemaIter) Done ¶ added in v0.0.8
func (i *WireSchemaIter) Done() bool
func (*WireSchemaIter) NextFieldCount ¶ added in v0.0.8
func (i *WireSchemaIter) NextFieldCount() (fieldCount uint, err error)
NextFieldCount returns the field count for the next struct in the schema.