graph

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheOnlyMode int = iota
	PersistentOnlyMode
	DefaultMode
)

Define the running cache mode, memory and/or persisent

View Source
const (
	SyncMsgType             = "Sync"
	SyncRequestMsgType      = "SyncRequest"
	SyncReplyMsgType        = "SyncReply"
	HostGraphDeletedMsgType = "HostGraphDeleted"
	NodeUpdatedMsgType      = "NodeUpdated"
	NodeDeletedMsgType      = "NodeDeleted"
	NodeAddedMsgType        = "NodeAdded"
	EdgeUpdatedMsgType      = "EdgeUpdated"
	EdgeDeletedMsgType      = "EdgeDeleted"
	EdgeAddedMsgType        = "EdgeAdded"
)

Graph message type

View Source
const (
	SortByInt64 int = iota + 1
	SortByString
)
View Source
const ESGraphElementMapping = `` /* 752-byte string literal not displayed */

ESGraphElementMapping elasticsearch db mapping scheme

View Source
const (
	// Namespace used for WebSocket message
	Namespace = "Graph"
)

Variables

View Source
var (
	ErrSyncRequestMalFormed = errors.New("SyncRequestMsg malformed")
	ErrSyncMsgMalFormed     = errors.New("SyncMsg/SyncReplyMsg malformed")
)

Graph error message

View Source
var ErrBadConfig = errors.New("elasticsearch : Config file is misconfigured, check elasticsearch key format")

ErrBadConfig elasticsearch configuration file is incorrect

Functions

func NewFilterForEdge added in v0.16.0

func NewFilterForEdge(parent Identifier, child Identifier) *filters.Filter

NewFilterForEdge creates a filter based on parent or child

func SortEdges added in v0.16.0

func SortEdges(edges []*Edge, sortBy string, sortOrder common.SortOrder)

func SortNodes added in v0.16.0

func SortNodes(nodes []*Node, sortBy string, sortOrder common.SortOrder)

func UnmarshalWSMessage

func UnmarshalWSMessage(msg *shttp.WSStructMessage) (string, interface{}, error)

UnmarshalWSMessage deserialize the websocket message

Types

type CachedBackend added in v0.16.0

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

CachedBackend describes a cache mechanism in memory and/or persistent database

func NewCachedBackend added in v0.16.0

func NewCachedBackend(persistent GraphBackend) (*CachedBackend, error)

NewCachedBackend creates new graph cache mechanism

func (*CachedBackend) EdgeAdded added in v0.16.0

func (c *CachedBackend) EdgeAdded(e *Edge) bool

EdgeAdded add an edge in the cache

func (*CachedBackend) EdgeDeleted added in v0.16.0

func (c *CachedBackend) EdgeDeleted(e *Edge) bool

EdgeDeleted delete an edge in the cache

func (*CachedBackend) GetEdge added in v0.16.0

func (c *CachedBackend) GetEdge(i Identifier, t GraphContext) []*Edge

GetEdge retrieve an edge within a time slice

func (*CachedBackend) GetEdgeNodes added in v0.16.0

func (c *CachedBackend) GetEdgeNodes(e *Edge, t GraphContext, parentMetadata, childMetadata GraphElementMatcher) ([]*Node, []*Node)

GetEdgeNodes retrieve a list of nodes from an edge within a time slice, matching metadata

func (*CachedBackend) GetEdges added in v0.16.0

func (c *CachedBackend) GetEdges(t GraphContext, m GraphElementMatcher) []*Edge

GetEdges returns a list of edges with a time slice, matching metadata

func (*CachedBackend) GetNode added in v0.16.0

func (c *CachedBackend) GetNode(i Identifier, t GraphContext) []*Node

GetNode retrieve a node from the cache within a time slice

func (*CachedBackend) GetNodeEdges added in v0.16.0

func (c *CachedBackend) GetNodeEdges(n *Node, t GraphContext, m GraphElementMatcher) (edges []*Edge)

GetNodeEdges retrieve a list of edges from a node within a time slice, matching metadata

func (*CachedBackend) GetNodes added in v0.16.0

func (c *CachedBackend) GetNodes(t GraphContext, m GraphElementMatcher) []*Node

GetNodes returns a list of nodes with a time slice, matching metadata

func (*CachedBackend) IsHistorySupported added in v0.18.0

func (c *CachedBackend) IsHistorySupported() bool

IsHistorySupported returns whether the persistent backend supports history

func (*CachedBackend) MetadataUpdated added in v0.16.0

func (c *CachedBackend) MetadataUpdated(i interface{}) bool

MetadataUpdated updates metadata

func (*CachedBackend) NodeAdded added in v0.16.0

func (c *CachedBackend) NodeAdded(n *Node) bool

NodeAdded same the node in the cache

func (*CachedBackend) NodeDeleted added in v0.16.0

func (c *CachedBackend) NodeDeleted(n *Node) bool

NodeDeleted Delete the node in the cache

func (*CachedBackend) SetMode added in v0.16.0

func (c *CachedBackend) SetMode(mode int)

SetMode set cache mode

type DefaultGraphListener

type DefaultGraphListener struct {
}

DefaultGraphListener default implementation of a graph listener, can be used when not implementing the whole set of callbacks

func (*DefaultGraphListener) OnEdgeAdded

func (c *DefaultGraphListener) OnEdgeAdded(e *Edge)

OnEdgeAdded event

func (*DefaultGraphListener) OnEdgeDeleted

func (c *DefaultGraphListener) OnEdgeDeleted(e *Edge)

OnEdgeDeleted event

func (*DefaultGraphListener) OnEdgeUpdated

func (c *DefaultGraphListener) OnEdgeUpdated(e *Edge)

OnEdgeUpdated event

func (*DefaultGraphListener) OnNodeAdded

func (c *DefaultGraphListener) OnNodeAdded(n *Node)

OnNodeAdded event

func (*DefaultGraphListener) OnNodeDeleted

func (c *DefaultGraphListener) OnNodeDeleted(n *Node)

OnNodeDeleted event

func (*DefaultGraphListener) OnNodeUpdated

func (c *DefaultGraphListener) OnNodeUpdated(n *Node)

OnNodeUpdated event

type Edge

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

Edge of the graph linked by a parent and a child

func (*Edge) Decode

func (e *Edge) Decode(i interface{}) error

Decode deserialize the current edge

func (*Edge) GetChild

func (e *Edge) GetChild() Identifier

GetChild returns child

func (*Edge) GetField added in v0.16.0

func (e *Edge) GetField(name string) (interface{}, error)

func (*Edge) GetFieldInt64 added in v0.16.0

func (e *Edge) GetFieldInt64(field string) (_ int64, err error)

func (*Edge) GetFieldString added in v0.16.0

func (e *Edge) GetFieldString(name string) (string, error)

GetFieldString returns the associated Field name

func (*Edge) GetFieldStringList added in v0.16.0

func (e *Edge) GetFieldStringList(name string) ([]string, error)

func (*Edge) GetFields added in v0.16.0

func (e *Edge) GetFields() ([]string, error)

func (*Edge) GetParent

func (e *Edge) GetParent() Identifier

GetParent returns parent

func (*Edge) Host

func (e *Edge) Host() string

func (*Edge) MarshalJSON

func (e *Edge) MarshalJSON() ([]byte, error)

MarshalJSON serialize in JSON

func (*Edge) MatchMetadata

func (e *Edge) MatchMetadata(f GraphElementMatcher) bool

func (*Edge) Metadata

func (e *Edge) Metadata() Metadata

Metadata returns a copy in order to avoid direct modification of metadata leading in loosing notification.

func (*Edge) String

func (e *Edge) String() string

type ElasticSearchBackend added in v0.9.0

type ElasticSearchBackend struct {
	GraphBackend
	// contains filtered or unexported fields
}

ElasticSearchBackend describes a presisent backend based on ElasticSearch

func NewElasticSearchBackendFromClient added in v0.18.0

func NewElasticSearchBackendFromClient(client elasticsearch.ElasticSearchClientInterface) (*ElasticSearchBackend, error)

func NewElasticSearchBackendFromConfig added in v0.9.0

func NewElasticSearchBackendFromConfig(backend string) (*ElasticSearchBackend, error)

NewElasticSearchBackendFromConfig creates a new graph backend based on configuration file parameters

func (*ElasticSearchBackend) EdgeAdded added in v0.16.0

func (b *ElasticSearchBackend) EdgeAdded(e *Edge) bool

EdgeAdded add an edge in the database

func (*ElasticSearchBackend) EdgeDeleted added in v0.16.0

func (b *ElasticSearchBackend) EdgeDeleted(e *Edge) bool

EdgeDeleted delete an edge in the database

func (*ElasticSearchBackend) GetEdge added in v0.9.0

func (b *ElasticSearchBackend) GetEdge(i Identifier, t GraphContext) []*Edge

GetEdge get an edge within a time slice

func (*ElasticSearchBackend) GetEdgeNodes added in v0.9.0

func (b *ElasticSearchBackend) GetEdgeNodes(e *Edge, t GraphContext, parentMetadata, childMetadata GraphElementMatcher) (parents []*Node, children []*Node)

GetEdgeNodes returns the parents and child nodes of an edge within time slice, matching metadatas

func (*ElasticSearchBackend) GetEdges added in v0.9.0

GetEdges returns a list of edges within time slice, matching metadata

func (*ElasticSearchBackend) GetNode added in v0.9.0

func (b *ElasticSearchBackend) GetNode(i Identifier, t GraphContext) []*Node

GetNode get a node within a time slice

func (*ElasticSearchBackend) GetNodeEdges added in v0.9.0

func (b *ElasticSearchBackend) GetNodeEdges(n *Node, t GraphContext, m GraphElementMatcher) (edges []*Edge)

GetNodeEdges returns a list of a node edges within time slice

func (*ElasticSearchBackend) GetNodes added in v0.9.0

GetNodes returns a list of nodes within time slice, matching metadata

func (*ElasticSearchBackend) IsHistorySupported added in v0.18.0

func (b *ElasticSearchBackend) IsHistorySupported() bool

IsHistorySupported returns that this backend does support history

func (*ElasticSearchBackend) MetadataUpdated added in v0.16.0

func (b *ElasticSearchBackend) MetadataUpdated(i interface{}) bool

MetadataUpdated updates a node metadata in the database

func (*ElasticSearchBackend) NodeAdded added in v0.16.0

func (b *ElasticSearchBackend) NodeAdded(n *Node) bool

NodeAdded add a node

func (*ElasticSearchBackend) NodeDeleted added in v0.16.0

func (b *ElasticSearchBackend) NodeDeleted(n *Node) bool

NodeDeleted delete a node

func (*ElasticSearchBackend) Query added in v0.16.0

func (b *ElasticSearchBackend) Query(obj string, tsq *TimedSearchQuery, index string) (sr *elastic.SearchResult, _ error)

Query the database for a "node" or "edge"

type Graph

type Graph struct {
	common.RWMutex
	// contains filtered or unexported fields
}

Graph describes the graph object based on events and context mechanism An associated backend is used as storage

func NewGraph

func NewGraph(host string, backend GraphBackend) *Graph

NewGraph creates a new graph based on the backend

func NewGraphFromConfig

func NewGraphFromConfig(backend GraphBackend) *Graph

NewGraphFromConfig creates a new graph based on configuration

func (*Graph) AddEdge

func (g *Graph) AddEdge(e *Edge) bool

AddEdge in the graph

func (*Graph) AddEventListener

func (g *Graph) AddEventListener(l GraphEventListener)

AddEventListener subscibe a new graph listener

func (*Graph) AddMetadata

func (g *Graph) AddMetadata(i interface{}, k string, v interface{}) bool

AddMetadata add a metadata to an associated edge or node

func (*Graph) AddNode

func (g *Graph) AddNode(n *Node) bool

AddNode in the graph

func (*Graph) AreLinked

func (g *Graph) AreLinked(n1 *Node, n2 *Node, m GraphElementMatcher) bool

AreLinked returns true if nodes n1, n2 are linked

func (*Graph) CloneWithContext added in v0.18.0

func (g *Graph) CloneWithContext(context GraphContext) (*Graph, error)

CloneWithContext creates a new graph based on the given one and the given context

func (*Graph) DelEdge

func (g *Graph) DelEdge(e *Edge) bool

DelEdge delete an edge

func (*Graph) DelHostGraph added in v0.9.0

func (g *Graph) DelHostGraph(host string)

DelHostGraph delete the associated node with the hostname host

func (*Graph) DelMetadata added in v0.16.0

func (g *Graph) DelMetadata(i interface{}, k string) bool

DelMetadata delete a metadata to an associated edge or node

func (*Graph) DelNode

func (g *Graph) DelNode(n *Node) bool

DelNode delete the node n in the graph

func (*Graph) Diff added in v0.16.0

func (g *Graph) Diff(newGraph *Graph) (addedNodes []*Node, removedNodes []*Node, addedEdges []*Edge, removedEdges []*Edge)

Diff computes the difference between two graphs

func (*Graph) EdgeAdded added in v0.16.0

func (g *Graph) EdgeAdded(e *Edge) bool

EdgeAdded add an edge

func (*Graph) EdgeDeleted added in v0.16.0

func (g *Graph) EdgeDeleted(e *Edge)

EdgeDeleted event

func (*Graph) EdgeUpdated added in v0.16.0

func (g *Graph) EdgeUpdated(e *Edge) bool

EdgeUpdated updates an edge

func (*Graph) GetContext

func (g *Graph) GetContext() GraphContext

GetContext returns the current context

func (*Graph) GetEdge

func (g *Graph) GetEdge(i Identifier) *Edge

GetEdge with Identifier i

func (*Graph) GetEdgeNodes

func (g *Graph) GetEdgeNodes(e *Edge, parentMetadata, childMetadata GraphElementMatcher) ([]*Node, []*Node)

GetEdgeNodes returns a list of nodes of an edge

func (*Graph) GetEdges

func (g *Graph) GetEdges(m GraphElementMatcher) []*Edge

GetEdges returns a list of edges

func (g *Graph) GetFirstLink(parent, child *Node, metadata Metadata) *Edge

GetFirstLink get Link between the parent and the child node or nil

func (*Graph) GetHost added in v0.16.0

func (g *Graph) GetHost() string

GetHost returns the graph host

func (*Graph) GetNode

func (g *Graph) GetNode(i Identifier) *Node

GetNode from Identifier

func (*Graph) GetNodeEdges

func (g *Graph) GetNodeEdges(n *Node, m GraphElementMatcher) []*Edge

GetNodeEdges returns a list of edges of a node

func (*Graph) GetNodes

func (g *Graph) GetNodes(m GraphElementMatcher) []*Node

GetNodes returns a list of nodes

func (*Graph) GetNodesMap added in v0.16.0

func (g *Graph) GetNodesMap(t GraphContext) map[Identifier]*Node

GetNodesMap returns a map of nodes within a time slice

func (g *Graph) Link(n1 *Node, n2 *Node, m Metadata, h ...string) *Edge

Link the nodes n1, n2 with a new edge

func (*Graph) LookupChildren

func (g *Graph) LookupChildren(n *Node, f GraphElementMatcher, em GraphElementMatcher) (nodes []*Node)

LookupChildren returns a list of children nodes

func (*Graph) LookupFirstChild

func (g *Graph) LookupFirstChild(n *Node, f GraphElementMatcher) *Node

LookupFirstChild returns the child

func (*Graph) LookupFirstNode

func (g *Graph) LookupFirstNode(m GraphElementMatcher) *Node

LookupFirstNode returns the fist node matching metadata

func (*Graph) LookupParents added in v0.9.0

func (g *Graph) LookupParents(n *Node, f GraphElementMatcher, em GraphElementMatcher) (nodes []*Node)

LookupParents returns the associated parents edge of a node

func (*Graph) LookupShortestPath

func (g *Graph) LookupShortestPath(n *Node, m GraphElementMatcher, em GraphElementMatcher) []*Node

LookupShortestPath based on Dijkstra algorithm

func (*Graph) MarshalJSON

func (g *Graph) MarshalJSON() ([]byte, error)

MarshalJSON serialize the graph in JSON

func (*Graph) NewEdge

func (g *Graph) NewEdge(i Identifier, p *Node, c *Node, m Metadata, h ...string) *Edge

NewEdge creates a new edge in the graph based on Identifier, parent, child nodes and metadata

func (*Graph) NewNode

func (g *Graph) NewNode(i Identifier, m Metadata, h ...string) *Node

NewNode creates a new node in the graph with attached metadata

func (*Graph) NodeAdded added in v0.16.0

func (g *Graph) NodeAdded(n *Node) bool

NodeAdded in the graph

func (*Graph) NodeDeleted added in v0.16.0

func (g *Graph) NodeDeleted(n *Node)

NodeDeleted event

func (*Graph) NodeUpdated added in v0.16.0

func (g *Graph) NodeUpdated(n *Node) bool

NodeUpdated updates a node

func (*Graph) RemoveEventListener

func (g *Graph) RemoveEventListener(l GraphEventListener)

RemoveEventListener unsubscribe a graph listener

func (*Graph) SetMetadata

func (g *Graph) SetMetadata(i interface{}, m Metadata) bool

SetMetadata associate metadata to an edge or node

func (*Graph) StartMetadataTransaction

func (g *Graph) StartMetadataTransaction(i interface{}) *MetadataTransaction

StartMetadataTransaction start a new transaction

func (*Graph) String

func (g *Graph) String() string
func (g *Graph) Unlink(n1 *Node, n2 *Node)

Unlink the nodes n1, n2 ; delete the associated edge

type GraphBackend

type GraphBackend interface {
	NodeAdded(n *Node) bool
	NodeDeleted(n *Node) bool
	GetNode(i Identifier, at GraphContext) []*Node
	GetNodeEdges(n *Node, at GraphContext, m GraphElementMatcher) []*Edge

	EdgeAdded(e *Edge) bool
	EdgeDeleted(e *Edge) bool
	GetEdge(i Identifier, at GraphContext) []*Edge
	GetEdgeNodes(e *Edge, at GraphContext, parentMetadata, childMetadata GraphElementMatcher) ([]*Node, []*Node)

	MetadataUpdated(e interface{}) bool

	GetNodes(t GraphContext, m GraphElementMatcher) []*Node
	GetEdges(t GraphContext, m GraphElementMatcher) []*Edge

	IsHistorySupported() bool
}

GraphBackend interface mechanism used as storage

func NewBackendByName added in v0.18.0

func NewBackendByName(name string) (backend GraphBackend, err error)

NewBackendByName creates a new graph backend based on the name memory, orientdb, elasticsearch backend are supported

type GraphContext

type GraphContext struct {
	TimeSlice *common.TimeSlice
	TimePoint bool
}

GraphContext describes within time slice

type GraphElementFilter added in v0.16.0

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

GraphElementFilter implements GraphElementMatcher interface based on filter

func NewGraphElementFilter added in v0.16.0

func NewGraphElementFilter(f *filters.Filter) *GraphElementFilter

NewGraphElementFilter returns a new GraphElementFilter

func (*GraphElementFilter) Filter added in v0.16.0

func (mf *GraphElementFilter) Filter() (*filters.Filter, error)

Filter returns the filter

func (*GraphElementFilter) Match added in v0.16.0

func (mf *GraphElementFilter) Match(e *graphElement) bool

Match returns true if the given element matches the filter.

type GraphElementMatcher added in v0.16.0

type GraphElementMatcher interface {
	Match(e *graphElement) bool
	Filter() (*filters.Filter, error)
}

GraphElementMatcher defines an interface used to match an element

type GraphEventHandler added in v0.16.0

type GraphEventHandler struct {
	common.RWMutex
	// contains filtered or unexported fields
}

func NewGraphEventHandler added in v0.16.0

func NewGraphEventHandler(maxEvents int) *GraphEventHandler

func (*GraphEventHandler) AddEventListener added in v0.16.0

func (g *GraphEventHandler) AddEventListener(l GraphEventListener)

AddEventListener subscibe a new graph listener

func (*GraphEventHandler) RemoveEventListener added in v0.16.0

func (g *GraphEventHandler) RemoveEventListener(l GraphEventListener)

RemoveEventListener unsubscribe a graph listener

type GraphEventListener

type GraphEventListener interface {
	OnNodeUpdated(n *Node)
	OnNodeAdded(n *Node)
	OnNodeDeleted(n *Node)
	OnEdgeUpdated(e *Edge)
	OnEdgeAdded(e *Edge)
	OnEdgeDeleted(e *Edge)
}

GraphEventListener describes the graph events interface mechanism

type GraphIndexer added in v0.16.0

type GraphIndexer struct {
	common.RWMutex

	DefaultGraphListener
	// contains filtered or unexported fields
}

GraphIndexer provides a way to index graph nodes. A node can be mapped to multiple hash,value pairs. A hash can also be mapped to multiple nodes.

func NewGraphIndexer added in v0.16.0

func NewGraphIndexer(g *Graph, hashNode NodeHasher, appendOnly bool) *GraphIndexer

NewGraphIndexer returns a new graph indexer with the associated hashing callback

func (*GraphIndexer) AddEventListener added in v0.18.0

func (i *GraphIndexer) AddEventListener(l GraphEventListener)

AddEventListener subscibe a new graph listener

func (*GraphIndexer) FromHash added in v0.16.0

func (i *GraphIndexer) FromHash(hash string) (nodes []*Node, values []interface{})

Fromhash returns the nodes mapped by a hash along with their associated values

func (*GraphIndexer) OnNodeAdded added in v0.16.0

func (i *GraphIndexer) OnNodeAdded(n *Node)

OnNodeAdded event

func (*GraphIndexer) OnNodeDeleted added in v0.16.0

func (i *GraphIndexer) OnNodeDeleted(n *Node)

OnNodeDeleted event

func (*GraphIndexer) OnNodeUpdated added in v0.16.0

func (i *GraphIndexer) OnNodeUpdated(n *Node)

OnNodeUpdated event

func (*GraphIndexer) RemoveEventListener added in v0.18.0

func (i *GraphIndexer) RemoveEventListener(l GraphEventListener)

RemoveEventListener unsubscribe a graph listener

func (*GraphIndexer) Start added in v0.18.0

func (i *GraphIndexer) Start()

Start registers the graph indexer as a graph listener

func (*GraphIndexer) Stop added in v0.18.0

func (i *GraphIndexer) Stop()

Stop removes the graph indexer from the graph listeners

type HostNodeTIDMap added in v0.9.0

type HostNodeTIDMap map[string][]string

HostNodeTIDMap a map of host and node ID

func BuildHostNodeTIDMap added in v0.9.0

func BuildHostNodeTIDMap(nodes []*Node) HostNodeTIDMap

BuildHostNodeTIDMap creates a map filled with host and associated node.ID

type Identifier

type Identifier string

Identifier graph ID

func GenID

func GenID() Identifier

GenID helper generate a node Identifier

func GenIDNameBased added in v0.16.0

func GenIDNameBased(namespace, name string) Identifier

GenIDNameBased helper generate a node Identifier

type MemoryBackend

type MemoryBackend struct {
	GraphBackend
	// contains filtered or unexported fields
}

MemoryBackend describes the memory backend

func NewMemoryBackend

func NewMemoryBackend() (*MemoryBackend, error)

NewMemoryBackend creates a new graph memory backend

func (*MemoryBackend) EdgeAdded added in v0.16.0

func (m *MemoryBackend) EdgeAdded(e *Edge) bool

EdgeAdded event add an edge in the memory backend

func (*MemoryBackend) EdgeDeleted added in v0.16.0

func (m *MemoryBackend) EdgeDeleted(e *Edge) bool

EdgeDeleted in the graph backend

func (*MemoryBackend) GetEdge

func (m *MemoryBackend) GetEdge(i Identifier, t GraphContext) []*Edge

GetEdge in the graph backend

func (*MemoryBackend) GetEdgeNodes

func (m *MemoryBackend) GetEdgeNodes(e *Edge, t GraphContext, parentMetadata, childMetadata GraphElementMatcher) ([]*Node, []*Node)

GetEdgeNodes returns a list of nodes of an edge

func (MemoryBackend) GetEdges

func (m MemoryBackend) GetEdges(t GraphContext, metadata GraphElementMatcher) (edges []*Edge)

GetEdges from the graph backend

func (*MemoryBackend) GetNode

func (m *MemoryBackend) GetNode(i Identifier, t GraphContext) []*Node

GetNode from the graph backend

func (*MemoryBackend) GetNodeEdges

func (m *MemoryBackend) GetNodeEdges(n *Node, t GraphContext, meta GraphElementMatcher) []*Edge

GetNodeEdges returns a list of edges of a node

func (MemoryBackend) GetNodes

func (m MemoryBackend) GetNodes(t GraphContext, metadata GraphElementMatcher) (nodes []*Node)

GetNodes from the graph backend

func (*MemoryBackend) IsHistorySupported added in v0.18.0

func (m *MemoryBackend) IsHistorySupported() bool

IsHistorySupported returns that this backend doesn't support history

func (*MemoryBackend) MetadataUpdated added in v0.16.0

func (m *MemoryBackend) MetadataUpdated(i interface{}) bool

MetadataUpdated returns true

func (*MemoryBackend) NodeAdded added in v0.16.0

func (m *MemoryBackend) NodeAdded(n *Node) bool

NodeAdded in the graph backend

func (*MemoryBackend) NodeDeleted added in v0.16.0

func (m *MemoryBackend) NodeDeleted(n *Node) (removed bool)

NodeDeleted in the graph backend

type MemoryBackendEdge

type MemoryBackendEdge struct {
	*Edge
}

MemoryBackendEdge a memory backend edge

func (MemoryBackendEdge) GetField added in v0.16.0

func (e MemoryBackendEdge) GetField(name string) (interface{}, error)

func (MemoryBackendEdge) GetFieldInt64 added in v0.16.0

func (e MemoryBackendEdge) GetFieldInt64(field string) (_ int64, err error)

func (MemoryBackendEdge) GetFieldStringList added in v0.16.0

func (e MemoryBackendEdge) GetFieldStringList(name string) ([]string, error)

func (MemoryBackendEdge) GetFields added in v0.16.0

func (e MemoryBackendEdge) GetFields() ([]string, error)

func (MemoryBackendEdge) Host

func (e MemoryBackendEdge) Host() string

func (MemoryBackendEdge) MatchMetadata

func (e MemoryBackendEdge) MatchMetadata(f GraphElementMatcher) bool

func (MemoryBackendEdge) Metadata

func (e MemoryBackendEdge) Metadata() Metadata

Metadata returns a copy in order to avoid direct modification of metadata leading in loosing notification.

type MemoryBackendNode

type MemoryBackendNode struct {
	*Node
	// contains filtered or unexported fields
}

MemoryBackendNode a memory backend node

func (MemoryBackendNode) GetField added in v0.16.0

func (e MemoryBackendNode) GetField(name string) (interface{}, error)

func (MemoryBackendNode) GetFieldInt64 added in v0.16.0

func (e MemoryBackendNode) GetFieldInt64(field string) (_ int64, err error)

func (MemoryBackendNode) GetFieldString added in v0.16.0

func (e MemoryBackendNode) GetFieldString(field string) (_ string, err error)

func (MemoryBackendNode) GetFieldStringList added in v0.16.0

func (e MemoryBackendNode) GetFieldStringList(name string) ([]string, error)

func (MemoryBackendNode) GetFields added in v0.16.0

func (e MemoryBackendNode) GetFields() ([]string, error)

func (MemoryBackendNode) Host

func (e MemoryBackendNode) Host() string

func (MemoryBackendNode) MatchMetadata

func (e MemoryBackendNode) MatchMetadata(f GraphElementMatcher) bool

func (MemoryBackendNode) Metadata

func (e MemoryBackendNode) Metadata() Metadata

Metadata returns a copy in order to avoid direct modification of metadata leading in loosing notification.

type Metadata

type Metadata map[string]interface{}

Metadata describes the graph node metadata type. It implements GraphElementMatcher based only on Metadata.

func (Metadata) Clone added in v0.16.0

func (m Metadata) Clone() Metadata

Clone a metadata

func (Metadata) Filter added in v0.16.0

func (m Metadata) Filter() (*filters.Filter, error)

Filter returns a filter corresponding to the metadata

func (Metadata) Match added in v0.16.0

func (m Metadata) Match(e *graphElement) bool

Match returns true if the the given element matches the metadata.

func (*Metadata) SetField added in v0.16.0

func (m *Metadata) SetField(k string, v interface{}) bool

SetField set metadata value based on dot key ("a.b.c.d" = "ok")

func (Metadata) String

func (m Metadata) String() string

type MetadataIndexer added in v0.16.0

type MetadataIndexer struct {
	*GraphIndexer
	// contains filtered or unexported fields
}

MetadataIndexer describes a metadata based graph indexer

func NewMetadataIndexer added in v0.16.0

func NewMetadataIndexer(g *Graph, m GraphElementMatcher, indexes ...string) (indexer *MetadataIndexer)

NewMetadataIndexer returns a new metadata graph indexer for the nodes matching the graph filter `m`, indexing the metadata with `indexes`

func (*MetadataIndexer) Get added in v0.16.0

func (m *MetadataIndexer) Get(values ...interface{}) ([]*Node, []interface{})

Get computes the hash of the passed parameters and returns the matching nodes with their respective value

func (*MetadataIndexer) Hash added in v0.16.0

func (m *MetadataIndexer) Hash(values ...interface{}) string

Hash computes the hash of the passed parameters

type MetadataTransaction

type MetadataTransaction struct {
	Metadata Metadata
	// contains filtered or unexported fields
}

MetadataTransaction describes a metadata(s) transaction in the graph

func (*MetadataTransaction) AddMetadata

func (t *MetadataTransaction) AddMetadata(k string, v interface{})

AddMetadata in the current transaction

func (*MetadataTransaction) Commit

func (t *MetadataTransaction) Commit()

Commit the current transaction to the graph

type Node

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

Node of the graph

func (*Node) Decode

func (n *Node) Decode(i interface{}) error

Decode deserialize the node

func (*Node) GetField added in v0.16.0

func (e *Node) GetField(name string) (interface{}, error)

func (*Node) GetFieldInt64 added in v0.16.0

func (e *Node) GetFieldInt64(field string) (_ int64, err error)

func (*Node) GetFieldString added in v0.16.0

func (e *Node) GetFieldString(field string) (_ string, err error)

func (*Node) GetFieldStringList added in v0.16.0

func (e *Node) GetFieldStringList(name string) ([]string, error)

func (*Node) GetFields added in v0.16.0

func (e *Node) GetFields() ([]string, error)

func (*Node) Host

func (e *Node) Host() string

func (*Node) MarshalJSON

func (n *Node) MarshalJSON() ([]byte, error)

MarshalJSON serialize in JSON

func (*Node) MatchMetadata

func (e *Node) MatchMetadata(f GraphElementMatcher) bool

func (*Node) Metadata

func (e *Node) Metadata() Metadata

Metadata returns a copy in order to avoid direct modification of metadata leading in loosing notification.

func (*Node) String

func (n *Node) String() string

type NodeHasher added in v0.16.0

type NodeHasher func(n *Node) map[string]interface{}

NodeHasher describes a callback that is called to map a node to a set of hash,value pairs

type OrientDBBackend

type OrientDBBackend struct {
	GraphBackend
	// contains filtered or unexported fields
}

OrientDBBackend describes an OrientDB backend

func NewOrientDBBackend

func NewOrientDBBackend(addr string, database string, username string, password string) (*OrientDBBackend, error)

NewOrientDBBackend creates a new graph backend and connect to an OrientDB instance

func NewOrientDBBackendFromConfig

func NewOrientDBBackendFromConfig(backend string) (*OrientDBBackend, error)

NewOrientDBBackendFromConfig creates a new OrientDB database client based on configuration

func (*OrientDBBackend) EdgeAdded added in v0.16.0

func (o *OrientDBBackend) EdgeAdded(e *Edge) bool

EdgeAdded add a node in the database

func (*OrientDBBackend) EdgeDeleted added in v0.16.0

func (o *OrientDBBackend) EdgeDeleted(e *Edge) bool

EdgeDeleted delete a node in the database

func (*OrientDBBackend) GetEdge

func (o *OrientDBBackend) GetEdge(i Identifier, t GraphContext) []*Edge

GetEdge get an edge within a time slice

func (*OrientDBBackend) GetEdgeNodes

func (o *OrientDBBackend) GetEdgeNodes(e *Edge, t GraphContext, parentMetadata, childMetadata GraphElementMatcher) (parents []*Node, children []*Node)

GetEdgeNodes returns the parents and child nodes of an edge within time slice, matching metadata

func (*OrientDBBackend) GetEdges

func (o *OrientDBBackend) GetEdges(t GraphContext, m GraphElementMatcher) (edges []*Edge)

GetEdges returns a list of edges within time slice, matching metadata

func (*OrientDBBackend) GetNode

func (o *OrientDBBackend) GetNode(i Identifier, t GraphContext) (nodes []*Node)

GetNode get a node within a time slice

func (*OrientDBBackend) GetNodeEdges

func (o *OrientDBBackend) GetNodeEdges(n *Node, t GraphContext, m GraphElementMatcher) (edges []*Edge)

GetNodeEdges returns a list of a node edges within time slice

func (*OrientDBBackend) GetNodes

func (o *OrientDBBackend) GetNodes(t GraphContext, m GraphElementMatcher) (nodes []*Node)

GetNodes returns a list of nodes within time slice, matching metadata

func (*OrientDBBackend) IsHistorySupported added in v0.18.0

func (o *OrientDBBackend) IsHistorySupported() bool

IsHistorySupported returns that this backend does support history

func (*OrientDBBackend) MetadataUpdated added in v0.16.0

func (o *OrientDBBackend) MetadataUpdated(i interface{}) bool

MetadataUpdated returns true if a metadata has been updated in the database, based on ArchivedAt

func (*OrientDBBackend) NodeAdded added in v0.16.0

func (o *OrientDBBackend) NodeAdded(n *Node) bool

NodeAdded add a node in the database

func (*OrientDBBackend) NodeDeleted added in v0.16.0

func (o *OrientDBBackend) NodeDeleted(n *Node) bool

NodeDeleted delete a node in the database

type SyncMsg added in v0.16.0

type SyncMsg struct {
	Nodes []*Node
	Edges []*Edge
}

SyncMsg describes graph syncho message

type SyncRequestMsg added in v0.16.0

type SyncRequestMsg struct {
	GraphContext
	GremlinFilter string
}

type SyncRequestMsg describes a graph synchro request message

type TimedSearchQuery added in v0.16.0

type TimedSearchQuery struct {
	filters.SearchQuery
	TimeFilter     *filters.Filter
	MetadataFilter *filters.Filter
}

TimedSearchQuery describes a search query within a time slice and metadata filters

Source Files

  • cachedbackend.go
  • elasticsearch.go
  • filters.go
  • graph.go
  • indexer.go
  • memory.go
  • message.go
  • orientdb.go
  • sort.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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