appdefcompat

package
v0.0.0-...-dbbe934 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 6 Imported by: 0

README

Compatibility

Motivation

Functional Design

Concepts

Compatibility error types:

  • Projector Read compatibility (some projectors reads fail or even crash). Some examples:
    • Table is removed from a workspace
    • Table is removed from a package
    • Table usage is removed form a workspace
    • Field order is changed in a Table
    • Field is added to a View key
    • Table is removed from a workspace scope
    • Field type is changed
  • Projector Write compatibility (some projectors writes fail). Some examples:
    • Constraint is added/changed/removed
  • Other possible compatibility errors examples:
    • ACL entry is added or changed, it changes API behaviour for non-System authorization

Why "Projector..."? To simplify definition, Projector uses System authorization and is not affected by ACL changes.

Principles
  • Only Projector Read compatibility errors are checked
Functions

func CheckBackwardCompatibility(oldAppDef, newAppDef appdef.IAppDef) (cerrs *CompatibilityErrors)

func IgnoreCompatibilityErrors(cerrs *CompatibilityErrors, pathsToIgnore [][]string) (cerrsOut *CompatibilityErrors)

Technical Design

Principles
  • appdef.AppDef is used, not parser.ASTs
    • Rationale: appdef.AppDef is easier to use, e.g.
      • Parser.PackageAST contains multiple definitions of Workspace that must be merged before use
      • AST does not provide list of all QNames in a package
  • Algorythm
    1. Build old and new CompatibilityTree-s
    2. Compare CompatibilityTree-s using NodeConstraint-s
Tree and Constraints
type Constraint string
type NodeType string

const (
	ConstraintValueMatch    Constraint = "ConstraintValueMatch"
    ConstraintAppendOnly    Constraint = "ConstraintAppendOnly"
    ConstraintInsertOnly    Constraint = "ConstraintInsertOnly"
    ConstraintNonModifiable Constraint = "ConstraintNonModifiable"
)

type CompatibilityTreeNode {
    ParentNode *CompatibilityTreeNode
    Name string
    Props []*CompatibilityTreeNode
    Value interface{}
    invisibleInPath bool
}

type NodeConstraint struct {
    NodeName string
    Constraint Constraint
}
CompatibilityTree example
  • AppDef AppDef
    • Packages
      • packagePath1 LocalName1
      • packagePath2 LocalName2
      • packagePath3 LocalName3
      • packagePath4 LocalName4
      • packagePath5 LocalName5
    • Types
      • pkg1.Workspace1 // IWorkspace
        • Types
          • pkg1.Table5
          • pkg5.View2
        • Inheritance // FIXME not implemented???
          • pkg1.Workspace2
          • pkg1.Workspace3
        • Descriptor pkg1.Workspace1Descriptor
      • pkg2.SomeQName // IType
        • Abstract true // IWithAbstract
        • Fields // IFields
          • Name1 int // IField
          • Name2 varchar (no length here) // IField
        • Containers // IContainers
          • Name1 QName1
          • Name2 QName2
      • pkg3.SomeTable // IDoc
        • Abstract true // IWithAbstract
        • Fields // IFields
          • Name1 int // IField
          • Name2 varchar (no length here) // IField
        • Containers // IContainers
          • Name1 QName1
          • Name2 QName2
        • Uniques // IUniques
          • Name1 QName1 // IUnique
            • UniqueFields
              • Name2 varchar
              • Name1 int
            • Parent
              • Abstract true // IWithAbstract
              • Fields // IFields
                • Name1 int
                • Name2 varchar (no length here)
              • Containers // IContainers
                • Name1 QName1
                • Name2 QName2
          • Name2 QName2 // IUnique
            • UniqueFields
            • Name1 int
            • Name2 varchar
            • Parent
              • Abstract true // IWithAbstract
              • Fields // IFields
                • Name1 int
                • Name2 varchar (no length here)
              • Containers // IContainers
                • Name1 QName1
                • Name2 QName2
      • pkg3.View // IView
        • PartKeyFields // Key().Partition()
          • Name1 int
          • Name2 int
        • ClustColsFields // Key().ClustCols()
          • Name1 int
          • Name2 varchar
        • Fields // Value fields
          • ... // FIXME Containers ???
      • pkg3.Projector Props
        • Sync true -pkg3.Command Props // ICommand
        • CommandArgs Props
        • UnloggedArgs Props
        • CommandResult Props
      • pkg3.Query // IQuery
        • QueryArgs Props
        • QueryResult Props
Constraints

NodeConstraint examples:


typesConstraint := NodeConstraint{"Types", ConstraintInsertOnly}
fieldsConstraint := NodeConstraint{"Fields", ConstraintAppendOnly}
CompatibilityError
type CompatibilityError struct {
    Constraint Constraint

    OldTreePath []string

    // NodeRemoved:  (NonModifiable, AppendOnly,InsertOnly) : one error per removed node
    // OrderChanged: (NonModifiable, AppendOnly): one error for the container
    // NodeInserted: (NonModifiable): one error for the container
	// ValueChanged: one error for one node
	// NodeModified: one error for the container
    ErrorType ErrorType
}

OldTreePath example:

[]string{"AppDef", "Types", "sys.Workspace1", "Types", "sys.Table5", "Fields", "Name1"}
type CompatibilityErrors {
    Errors []CompatibilityError
    Error() string
}

Documentation

Overview

* Copyright (c) 2023-present unTill Pro, Ltd. * @author Alisher Nurmanov

* Copyright (c) 2023-present unTill Pro, Ltd. * @author Alisher Nurmanov

Index

Constants

View Source
const (
	NodeNameTypes           = "Types"
	NodeNameFields          = "Fields"
	NodeNameUniques         = "Uniques"
	NodeNameUniqueFields    = "UniqueFields"
	NodeNameAbstract        = "Abstract"
	NodeNameContainers      = "Containers"
	NodeNameAppDef          = "AppDef"
	NodeNameDescriptor      = "Descriptor"
	NodeNamePartKeyFields   = "PartKeyFields"
	NodeNameClustColsFields = "ClustColsFields"
	NodeNameCommandArgs     = "CommandArgs"
	NodeNameCommandResult   = "CommandResult"
	NodeNameQueryArgs       = "QueryArgs"
	NodeNameQueryResult     = "QueryResult"
	NodeNameUnloggedArgs    = "UnloggedArgs"
	NodeNamePackages        = "Packages"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CompatibilityError

type CompatibilityError struct {
	Constraint  Constraint
	OldTreePath []string
	ErrorType   ErrorType
}

func (CompatibilityError) Error

func (e CompatibilityError) Error() string

func (CompatibilityError) Path

func (e CompatibilityError) Path() string

type CompatibilityErrors

type CompatibilityErrors struct {
	Errors []CompatibilityError
}

func CheckBackwardCompatibility

func CheckBackwardCompatibility(oldAppDef, newAppDef appdef.IAppDef) (cerrs *CompatibilityErrors)

func IgnoreCompatibilityErrors

func IgnoreCompatibilityErrors(cerrs *CompatibilityErrors, pathsToIgnore [][]string) (cerrsOut *CompatibilityErrors)

func (*CompatibilityErrors) Error

func (e *CompatibilityErrors) Error() (err string)

type CompatibilityTreeNode

type CompatibilityTreeNode struct {
	Name       string
	Props      []*CompatibilityTreeNode
	Value      interface{}
	ParentNode *CompatibilityTreeNode
}

func (*CompatibilityTreeNode) Path

func (n *CompatibilityTreeNode) Path() []string

type Constraint

type Constraint uint8
const (
	ConstraintValueMatch Constraint = 1 << iota
	ConstraintAppendOnly
	ConstraintInsertOnly
	ConstraintDeleteOnly
	ConstraintOrderChangeOnly
	ConstraintAllAllowed    = 255
	ConstraintNonModifiable = 0
)

type ErrorType

type ErrorType string
const (
	ErrorTypeNodeRemoved  ErrorType = "NodeRemoved"
	ErrorTypeOrderChanged ErrorType = "OrderChanged"
	ErrorTypeNodeInserted ErrorType = "NodeInserted"
	ErrorTypeValueChanged ErrorType = "ValueChanged"
	ErrorTypeNodeModified ErrorType = "NodeModified"
)

type NodeConstraint

type NodeConstraint struct {
	NodeName   string
	Constraint Constraint
}

Jump to

Keyboard shortcuts

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