v1beta

package
v0.0.0-...-07d78c7 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MySQLStatements = &Statements{
	InsertGraphData: mysqlInsertGraphData,

	DeleteGraphData:    sqliteDeleteGraphData,
	ListGraphData:      sqliteListGraphData,
	SelectToNeighbor:   sqliteSelectToNeighbor,
	SelectFromNeighbor: sqliteSelectFromNeighbor,
}

MySQLStatements expose statements that are specific to the mysql backend

View Source
var PostgreSQLStatements = &Statements{
	InsertGraphData: postgresqlInsertGraphData,

	DeleteGraphData:    sqliteDeleteGraphData,
	ListGraphData:      sqliteListGraphData,
	SelectToNeighbor:   sqliteSelectToNeighbor,
	SelectFromNeighbor: sqliteSelectFromNeighbor,
}

PostgreSQLStatements expose statements that are specific to the PostgreSQL backend

View Source
var SQLiteStatements = &Statements{
	InsertGraphData:    sqliteInsertGraphData,
	DeleteGraphData:    sqliteDeleteGraphData,
	ListGraphData:      sqliteListGraphData,
	SelectToNeighbor:   sqliteSelectToNeighbor,
	SelectFromNeighbor: sqliteSelectFromNeighbor,
}

SQLiteStatements expose statements that are specific to the SQLite backend

Functions

func ConvertGraphData

func ConvertGraphData(item *GraphData) (*graphstore.Node, *graphstore.Edge, error)

ConvertGraphData transforms itself back into a node or an edge

Types

type Driver

type Driver interface {
	Put(ctx context.Context, data []*GraphData) error
	Delete(ctx context.Context, data []*GraphData) error
	List(ctx context.Context, kind string, offset, limit int) ([]*GraphData, bool, error)
	NeighborsTo(ctx context.Context, toKeys []string) ([]*GraphData, error)
	NeighborsFrom(ctx context.Context, fromKeys []string) ([]*GraphData, error)
}

Driver represents a generic interface for storing a graph.

func Resolve

func Resolve(driver, storageAddress, storageReadOnlyAddress string) (Driver, error)

Resolve takes in connection criteria and returns the appropriate driver

type Encoding

type Encoding = uint8

Encoding describes how the data is stored

const (
	// EncodingUnspecified signals the data format was not specified.
	EncodingUnspecified Encoding = iota
	// EncodingJSON stores the data as JSON.
	EncodingJSON
	// EncodingProtocolBuffers stores the data as encoded protocol buffers.
	EncodingProtocolBuffers
)

type GraphData

type GraphData struct {
	CollectionName string        `json:"-"`
	K1             string        `json:"k1"           db:"k1"            gorm:"column:k1;type:varchar(64);primaryKey;index:secondary,priority:2"`
	K2             string        `json:"k2"           db:"k2"            gorm:"column:k2;type:varchar(64);primaryKey;index:secondary,priority:1"`
	K3             string        `json:"k3"           db:"k3"            gorm:"column:k3;type:varchar(64);primaryKey;index:secondary,priority:3"`
	Kind           string        `json:"kind"         db:"kind"          gorm:"column:kind;type:varchar(55);index:kind"`
	Encoding       Encoding      `json:"encoding"     db:"encoding"      gorm:"column:encoding"`
	Data           string        `json:"data"         db:"data"          gorm:"column:data;type:text"`
	DateDeleted    *sql.NullTime `json:"dateDeleted"  db:"date_deleted"  gorm:"column:date_deleted;index:date_deleted"`
	LastModified   time.Time     `json:"lastModified" db:"last_modified" gorm:"column:last_modified;index:last_modified"`
}

GraphData describes how the data is stored

func ConvertEdge

func ConvertEdge(edge *graphstore.Edge, encoding Encoding) *GraphData

ConvertEdge transforms an Edge to a generalized graph item

func ConvertNode

func ConvertNode(node *graphstore.Node, encoding Encoding) *GraphData

ConvertNode transforms a Node to a generalized graph item

func (*GraphData) TableName

func (d *GraphData) TableName() string

TableName returns the name of the collection or the default if not set.

type GraphStoreServer

type GraphStoreServer struct {
	Driver Driver
}

GraphStoreServer encapsulates the logic for storing a graph using a generic driver.

func (*GraphStoreServer) Delete

Delete ...

func (*GraphStoreServer) List

List ...

func (*GraphStoreServer) Neighbors

Neighbors ...

func (*GraphStoreServer) Put

Put ...

func (*GraphStoreServer) Traverse

func (s *GraphStoreServer) Traverse(traverseServer graphstore.GraphStore_TraverseServer) error

Traverse ...

type Statements

type Statements struct {
	InsertGraphData    string `json:"insertGraphData"`
	DeleteGraphData    string `json:"deleteGraphData"`
	ListGraphData      string `json:"listGraphData"`
	SelectFromNeighbor string `json:"selectFromNeighbors"`
	SelectToNeighbor   string `json:"selectToNeighbors"`
}

Statements are used by the sqlDriver to perform operations against different backends.

Jump to

Keyboard shortcuts

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