schema

package
v0.0.59 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetType

type AssetType string

AssetType define an asset type

type Persistor

type Persistor interface {
	SaveSchema(ctx context.Context, sourceName string, sg SchemaGraph) error
	LoadSchema(ctx context.Context, sourceName string) (SchemaGraph, error)
}

Persistor is a persistor of schema

type RelationKeyType

type RelationKeyType string

RelationKeyType define a relation type

type RelationType

type RelationType struct {
	FromType AssetType       `json:"from_type"`
	Type     RelationKeyType `json:"relation_type"`
	ToType   AssetType       `json:"to_type"`
}

RelationType define a relation type

type SchemaGraph

type SchemaGraph struct {
	Vertices mapset.Set
	Edges    mapset.Set
}

SchemaGraph represent the graph of a source

func NewSchemaGraph

func NewSchemaGraph() SchemaGraph

NewSchemaGraph create a source graph

func (*SchemaGraph) AddAsset

func (sg *SchemaGraph) AddAsset(assetType string) AssetType

AddAsset add an asset type as a vertex in the source graph

func (*SchemaGraph) AddRelation

func (sg *SchemaGraph) AddRelation(fromType AssetType, relationType string, toType AssetType) RelationType

AddRelation add a relation between asset types

func (*SchemaGraph) Assets

func (sg *SchemaGraph) Assets() []AssetType

Assets return all the assets in the graph

func (*SchemaGraph) Equal

func (sg *SchemaGraph) Equal(other SchemaGraph) bool

Equal check if two schema graphs are equal

func (*SchemaGraph) MarshalJSON

func (sg *SchemaGraph) MarshalJSON() ([]byte, error)

MarshalJSON marshal the schema graph into json format

func (*SchemaGraph) Merge

func (sg *SchemaGraph) Merge(other SchemaGraph)

Merge merge other graph into the current graph

func (*SchemaGraph) Relations

func (sg *SchemaGraph) Relations() []RelationType

Relations return all the relations in the graph

func (*SchemaGraph) UnmarshalJSON

func (sg *SchemaGraph) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal the schema graph from json payload

type SchemaGraphJSON

type SchemaGraphJSON struct {
	Vertices []AssetType    `json:"vertices"`
	Edges    []RelationType `json:"edges"`
}

SchemaGraphJSON is the json representation of a schema graph

Jump to

Keyboard shortcuts

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