manager

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package manager contains the graph managers to query the database.

This package manages all queries that go to the graph database and their interfaces for mocking them out when testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddVertexQuerier

type AddVertexQuerier interface {
	// AddAPIVertex adds a vertex to the graph based on the API struct.
	AddAPIVertex(api model.APIData) (vertex model.Vertex, err error)
	// AddVertexByString adds a vertex to the graph using a string query.
	AddVertexByString(stringQuery string) (vertex model.Vertex, err error)
	// AddVertexLabels adds multiple labels to the graph.
	AddVertexLabels(labels ...string) (vertices []model.Vertex, err error)
	// AddVertexByQuery adds a vertex to the graph using a query object.
	AddVertexByQuery(queryObj query.Query) (vertex model.Vertex, err error)
	// AddVertexByStruct adds a vertex to the graph with a vertex struct.
	AddVertexByStruct(vertexStruct model.Vertex) (vertex model.Vertex, err error)
	// AddVertex adds a vertex to the graph with label and properties provided.
	AddVertex(label string, properties ...interface{}) (vertex model.Vertex, err error)
}

AddVertexQuerier are queries specific to adding vertices.

type DropQuerier

type DropQuerier interface {
	// DropVertexLabel drops all vertices with given label.
	DropVertexLabel(label string) error
	// DropVertexByID drops vertices based on their IDs.
	DropVertexByID(ids ...interface{}) error
	// DropVerticesByString drops vertices using a string query.
	DropVerticesByString(stringQuery string) error
	// DropVerticesByQuery drops vertices using a query object.
	DropVerticesByQuery(queryObj query.Query) error
}

DropQuerier has functions related to dropping vertices from the graph.

type ExecuteQuerier

type ExecuteQuerier interface {
	// ExecuteQuery will execute a query object and return its raw result.
	ExecuteQuery(queryObj query.Query) (res [][]byte, err error)
	// ExecuteStringQuery will execute a string query and return its raw result.
	ExecuteStringQuery(stringQuery string) (res [][]byte, err error)
	// ExecuteBoundQuery will execute a query object with bindings and return its raw result.
	ExecuteBoundQuery(queryObj query.Query, bindings map[string]string, rebindings map[string]string) (res [][]byte, err error)
	// ExecuteBoundStringQuery will execute a string query with bindings and return its raw result.
	ExecuteBoundStringQuery(stringQuery string, bindings map[string]string, rebindings map[string]string) (res [][]byte, err error)
}

ExecuteQuerier handles the raw queries to the server.

type GetVertexIDQuerier

type GetVertexIDQuerier interface {
	// VertexIDsByString returns a slice of IDs from a string query.
	VertexIDsByString(stringQuery string) (ids []interface{}, err error)
	// VertexIDsByQuery returns a slice of IDs from a query object.
	VertexIDsByQuery(queryObj query.Query) (ids []interface{}, err error)
	// VertexIDs returns a slice of IDs based on the label and properties.
	VertexIDs(label string, properties ...interface{}) (ids []interface{}, err error)
}

GetVertexIDQuerier holds functions to gather IDs from the graph.

type GetVertexQuerier

type GetVertexQuerier interface {
	// AllVertices will return a slice of all vertices on the graph.
	AllVertices() (vertices []model.Vertex, err error)
	// VertexByID will return a single vertex based on the ID provided.
	VertexByID(id interface{}) (vertex model.Vertex, err error)
	// VerticesByString will return already unmarshalled vertex structs from a string query.
	VerticesByString(stringQuery string) (vertices []model.Vertex, err error)
	// VerticesByQuery will return already unmarshalled vertex structs from a query object.
	VerticesByQuery(queryObj query.Query) (vertices []model.Vertex, err error)
	// Vertices will return vertices based on the label and properties.
	Vertices(label string, properties ...interface{}) (vertices []model.Vertex, err error)
}

GetVertexQuerier are functions specifically related to getting vertices.

type GraphManager

type GraphManager interface {
	MiscQuerier
	VertexQuerier
	ExecuteQuerier
	SchemaQuerier

	// Returns the interface and functions associated with the MiscQuerier.
	MiscQuerier() MiscQuerier
	// Returns the interface and functions associated with the AddVertexQuerier.
	AddVertexQuerier() AddVertexQuerier
	// Returns the interface and functions associated with the GetVertexQuerier.
	GetVertexQuerier() GetVertexQuerier
	// Returns the interface and functions associated with the GetVertexIDQuerier.
	GetVertexIDQuerier() GetVertexIDQuerier
	// Returns the interface and functions associated with the DropQuerier.
	DropQuerier() DropQuerier
	// Returns the interface and functions associated with the VertexQuerier.
	VertexQuerier() VertexQuerier
	// Returns the interface and functions associated with the ExecuteQuerier.
	ExecuteQuerier() ExecuteQuerier
	// Returns the interface and functions associated with the SchemaQuerier.
	SchemaQuerier() SchemaQuerier

	// Sets the logging object used by the GraphManager.
	SetLogger(logging.Logger)
}

GraphManager will handle all interactions with the graph itself.

type GraphQueryManager

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

GraphQueryManager has all the function related to interacting with the graph.

func NewGraphManager

func NewGraphManager(dialer gremconnect.Dialer, logger logging.Logger, executeRequest executor) *GraphQueryManager

NewGraphManager will give a manager to handle all graph interactions through the TinkerPop server.

func (GraphQueryManager) AddEdgeLabel

func (s GraphQueryManager) AddEdgeLabel(multi multiplicity.Multiplicity, label string) (id interface{}, err error)

AddEdgeLabel adds the edge label to the graph directly. This method returns the schema id of the edge label added.

func (GraphQueryManager) AddEdgeLabels

func (s GraphQueryManager) AddEdgeLabels(multiplicityAndLabels ...interface{}) (ids []interface{}, err error)

AddEdgeLabels does the same thing as AddEdgeLabel but with the ability to do multiple labels at a time. This function is called similarly to your favorite logger.

func (GraphQueryManager) AddPropertyKey

func (s GraphQueryManager) AddPropertyKey(propertyName string, datatype datatype.DataType, cardinality cardinality.Cardinality) (id interface{}, err error)

AddPropertyKey adds the edge label to the graph directly. This method returns the schema id of the edge label added.

func (*GraphQueryManager) AddVertexQuerier

func (g *GraphQueryManager) AddVertexQuerier() AddVertexQuerier

AddVertexQuerier returns the manager for adding vertices to the graph.

func (GraphQueryManager) CommitSchema

func (s GraphQueryManager) CommitSchema() ([][]byte, error)

Commit will take all of your schema changes and apply them to the schema once they are ready.

func (GraphQueryManager) DropAll

func (m GraphQueryManager) DropAll() error

func (*GraphQueryManager) DropQuerier

func (g *GraphQueryManager) DropQuerier() DropQuerier

DropQuerier returns the manager for dropping elements from the graph.

func (GraphQueryManager) ExecuteBoundQuery

func (m GraphQueryManager) ExecuteBoundQuery(query query.Query, bindings, rebindings map[string]string) ([][]byte, error)

ExecuteBoundQuery takes a query object and bindings to allow for simplified queries to the gremlin server.

func (GraphQueryManager) ExecuteBoundStringQuery

func (m GraphQueryManager) ExecuteBoundStringQuery(query string, bindings, rebindings map[string]string) ([][]byte, error)

ExecuteBoundStringQuery uses bindings and rebindings to allow for simplified queries to the gremlin server.

func (*GraphQueryManager) ExecuteQuerier

func (g *GraphQueryManager) ExecuteQuerier() ExecuteQuerier

ExecuteQuerier returns the manager for executing the raw queries.

func (GraphQueryManager) ExecuteQuery

func (m GraphQueryManager) ExecuteQuery(query query.Query) ([][]byte, error)

ExecuteQuery takes a query object to form a request to the gremlin server after turning it into a string.

func (GraphQueryManager) ExecuteStringQuery

func (m GraphQueryManager) ExecuteStringQuery(query string) ([][]byte, error)

ExecuteStringQuery takes a string query and uses it to make a request to the gremlin server.

func (*GraphQueryManager) GetVertexIDQuerier

func (g *GraphQueryManager) GetVertexIDQuerier() GetVertexIDQuerier

GetVertexIDQuerier returns the manager for getting vertex IDs.

func (*GraphQueryManager) GetVertexQuerier

func (g *GraphQueryManager) GetVertexQuerier() GetVertexQuerier

GetVertexQuerier returns the manager for getting vertices from the graph.

func (*GraphQueryManager) MiscQuerier

func (g *GraphQueryManager) MiscQuerier() MiscQuerier

MiscQuerier returns the manager for miscellaneous queries.

func (*GraphQueryManager) SchemaQuerier

func (g *GraphQueryManager) SchemaQuerier() SchemaQuerier

SchemaQuerier returns the manager for executing the raw queries.

func (*GraphQueryManager) SetLogger

func (g *GraphQueryManager) SetLogger(newLogger logging.Logger)

SetLogger will set the logger being used by all of the functions in the graph functions.

func (GraphQueryManager) SetVertexProperty

func (m GraphQueryManager) SetVertexProperty(id interface{}, keyAndVals ...interface{}) error

func (GraphQueryManager) VertexCount

func (m GraphQueryManager) VertexCount() (int64, error)

VertexCount retrieves the number of vertices that are currently on the graph as an int64.

func (*GraphQueryManager) VertexQuerier

func (g *GraphQueryManager) VertexQuerier() VertexQuerier

VertexQuerier returns the manager for all vertex related queries.

type MiscQuerier

type MiscQuerier interface {
	// DropAll will drop all vertices on the graph.
	DropAll() error
	// VertexCount will return the number of vertices on the graph.
	VertexCount() (count int64, err error)
	// SetVertexProperty will either add or set the property of a vertex.
	SetVertexProperty(id interface{}, keyAndVals ...interface{}) error
}

MiscQuerier are miscellaneous queries for the server to perform.

type SchemaQuerier

type SchemaQuerier interface {
	// AddEdgeLabel adds a new edge label to the schema.
	AddEdgeLabel(multi multiplicity.Multiplicity, label string) (id interface{}, err error)
	// AddEdgeLabels adds new edge labels to the schema.
	AddEdgeLabels(multiplicityAndLabels ...interface{}) (ids []interface{}, err error)
	// AddPropertyKey adds a new property key to the schema.
	AddPropertyKey(label string, dt datatype.DataType, card cardinality.Cardinality) (id interface{}, err error)
	// CommitSchema will finalize your changes and apply them to the schema.
	CommitSchema() (res [][]byte, err error)
}

SchemaQuerier handles all schema related queries to the graph.

type VertexQuerier

VertexQuerier handles the vertices on the graph.

Jump to

Keyboard shortcuts

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