Documentation ¶
Index ¶
- Constants
- Variables
- func NewFilterForEdge(parent Identifier, child Identifier) *filters.Filter
- func SortEdges(edges []*Edge, sortBy string, sortOrder common.SortOrder)
- func SortNodes(nodes []*Node, sortBy string, sortOrder common.SortOrder)
- func UnmarshalMessage(msg *ws.StructMessage) (string, interface{}, error)
- type Backend
- type CachedBackend
- func (c *CachedBackend) EdgeAdded(e *Edge) bool
- func (c *CachedBackend) EdgeDeleted(e *Edge) bool
- func (c *CachedBackend) GetEdge(i Identifier, t Context) []*Edge
- func (c *CachedBackend) GetEdgeNodes(e *Edge, t Context, parentMetadata, childMetadata ElementMatcher) ([]*Node, []*Node)
- func (c *CachedBackend) GetEdges(t Context, m ElementMatcher) []*Edge
- func (c *CachedBackend) GetNode(i Identifier, t Context) []*Node
- func (c *CachedBackend) GetNodeEdges(n *Node, t Context, m ElementMatcher) (edges []*Edge)
- func (c *CachedBackend) GetNodes(t Context, m ElementMatcher) []*Node
- func (c *CachedBackend) IsHistorySupported() bool
- func (c *CachedBackend) MetadataUpdated(i interface{}) bool
- func (c *CachedBackend) NodeAdded(n *Node) bool
- func (c *CachedBackend) NodeDeleted(n *Node) bool
- func (c *CachedBackend) SetMode(mode int)
- type Context
- type DefaultGraphListener
- func (c *DefaultGraphListener) OnEdgeAdded(e *Edge)
- func (c *DefaultGraphListener) OnEdgeDeleted(e *Edge)
- func (c *DefaultGraphListener) OnEdgeUpdated(e *Edge)
- func (c *DefaultGraphListener) OnNodeAdded(n *Node)
- func (c *DefaultGraphListener) OnNodeDeleted(n *Node)
- func (c *DefaultGraphListener) OnNodeUpdated(n *Node)
- type DefaultLinker
- type Edge
- func (e *Edge) GetField(name string) (interface{}, error)
- func (e *Edge) GetFieldInt64(field string) (_ int64, err error)
- func (e *Edge) GetFieldKeys() []string
- func (e *Edge) GetFieldString(field string) (_ string, err error)
- func (e *Edge) GetFieldStringList(name string) ([]string, error)
- func (e *Edge) MatchMetadata(f ElementMatcher) bool
- func (e *Edge) String() string
- func (e *Edge) UnmarshalJSON(b []byte) error
- type ElasticSearchBackend
- func (b *ElasticSearchBackend) EdgeAdded(e *Edge) bool
- func (b *ElasticSearchBackend) EdgeDeleted(e *Edge) bool
- func (b *ElasticSearchBackend) GetEdge(i Identifier, t Context) []*Edge
- func (b *ElasticSearchBackend) GetEdgeNodes(e *Edge, t Context, parentMetadata, childMetadata ElementMatcher) (parents []*Node, children []*Node)
- func (b *ElasticSearchBackend) GetEdges(t Context, m ElementMatcher) []*Edge
- func (b *ElasticSearchBackend) GetNode(i Identifier, t Context) []*Node
- func (b *ElasticSearchBackend) GetNodeEdges(n *Node, t Context, m ElementMatcher) (edges []*Edge)
- func (b *ElasticSearchBackend) GetNodes(t Context, m ElementMatcher) []*Node
- func (b *ElasticSearchBackend) IsHistorySupported() bool
- func (b *ElasticSearchBackend) MetadataUpdated(i interface{}) bool
- func (b *ElasticSearchBackend) NodeAdded(n *Node) bool
- func (b *ElasticSearchBackend) NodeDeleted(n *Node) bool
- func (b *ElasticSearchBackend) Query(typ string, tsq *TimedSearchQuery) (sr *elastic.SearchResult, _ error)
- type ElementFilter
- type ElementMatcher
- type EventHandler
- type EventListener
- type Graph
- func (g *Graph) AddEdge(e *Edge) bool
- func (g *Graph) AddEventListener(l EventListener)
- func (g *Graph) AddMetadata(i interface{}, k string, v interface{}) bool
- func (g *Graph) AddNode(n *Node) bool
- func (g *Graph) AreLinked(n1 *Node, n2 *Node, m ElementMatcher) bool
- func (g *Graph) CloneWithContext(context Context) (*Graph, error)
- func (g *Graph) CreateEdge(i Identifier, p *Node, c *Node, m Metadata, t Time, h ...string) *Edge
- func (g *Graph) CreateNode(i Identifier, m Metadata, t Time, h ...string) *Node
- func (g *Graph) DelEdge(e *Edge) bool
- func (g *Graph) DelMetadata(i interface{}, k string) bool
- func (g *Graph) DelNode(n *Node) bool
- func (g *Graph) DelOriginGraph(origin string)
- func (g *Graph) Diff(newGraph *Graph) (addedNodes []*Node, removedNodes []*Node, addedEdges []*Edge, ...)
- func (g *Graph) EdgeAdded(e *Edge) bool
- func (g *Graph) EdgeDeleted(e *Edge)
- func (g *Graph) EdgeUpdated(e *Edge) bool
- func (g *Graph) GetContext() Context
- func (g *Graph) GetEdge(i Identifier) *Edge
- func (g *Graph) GetEdgeNodes(e *Edge, parentMetadata, childMetadata ElementMatcher) ([]*Node, []*Node)
- func (g *Graph) GetEdges(m ElementMatcher) []*Edge
- func (g *Graph) GetFirstLink(parent, child *Node, metadata Metadata) *Edge
- func (g *Graph) GetHost() string
- func (g *Graph) GetNode(i Identifier) *Node
- func (g *Graph) GetNodeEdges(n *Node, m ElementMatcher) []*Edge
- func (g *Graph) GetNodes(m ElementMatcher) []*Node
- func (g *Graph) GetNodesMap(t Context) map[Identifier]*Node
- func (g *Graph) Link(n1 *Node, n2 *Node, m Metadata, h ...string) *Edge
- func (g *Graph) LookupChildren(n *Node, f ElementMatcher, em ElementMatcher) (nodes []*Node)
- func (g *Graph) LookupFirstChild(n *Node, f ElementMatcher) *Node
- func (g *Graph) LookupFirstNode(m ElementMatcher) *Node
- func (g *Graph) LookupParents(n *Node, f ElementMatcher, em ElementMatcher) (nodes []*Node)
- func (g *Graph) LookupShortestPath(n *Node, m ElementMatcher, em ElementMatcher) []*Node
- func (g *Graph) MarshalJSON() ([]byte, error)
- func (g *Graph) NewEdge(i Identifier, p *Node, c *Node, m Metadata, h ...string) *Edge
- func (g *Graph) NewNode(i Identifier, m Metadata, h ...string) *Node
- func (g *Graph) NodeAdded(n *Node) bool
- func (g *Graph) NodeDeleted(n *Node)
- func (g *Graph) NodeUpdated(n *Node) bool
- func (g *Graph) Origin() string
- func (g *Graph) RemoveEventListener(l EventListener)
- func (g *Graph) SetMetadata(i interface{}, m Metadata) bool
- func (g *Graph) StartMetadataTransaction(i interface{}) *MetadataTransaction
- func (g *Graph) String() string
- func (g *Graph) Unlink(n1 *Node, n2 *Node)
- type Identifier
- type Indexer
- func (i *Indexer) AddEventListener(l EventListener)
- func (i *Indexer) FromHash(hash string) (nodes []*Node, values []interface{})
- func (i *Indexer) OnNodeAdded(n *Node)
- func (i *Indexer) OnNodeDeleted(n *Node)
- func (i *Indexer) OnNodeUpdated(n *Node)
- func (i *Indexer) RemoveEventListener(l EventListener)
- func (i *Indexer) Start()
- func (i *Indexer) Stop()
- type Linker
- type ListenerHandler
- type MemoryBackend
- func (m *MemoryBackend) EdgeAdded(e *Edge) bool
- func (m *MemoryBackend) EdgeDeleted(e *Edge) bool
- func (m *MemoryBackend) GetEdge(i Identifier, t Context) []*Edge
- func (m *MemoryBackend) GetEdgeNodes(e *Edge, t Context, parentMetadata, childMetadata ElementMatcher) ([]*Node, []*Node)
- func (m MemoryBackend) GetEdges(t Context, metadata ElementMatcher) (edges []*Edge)
- func (m *MemoryBackend) GetNode(i Identifier, t Context) []*Node
- func (m *MemoryBackend) GetNodeEdges(n *Node, t Context, meta ElementMatcher) []*Edge
- func (m MemoryBackend) GetNodes(t Context, metadata ElementMatcher) (nodes []*Node)
- func (m *MemoryBackend) IsHistorySupported() bool
- func (m *MemoryBackend) MetadataUpdated(i interface{}) bool
- func (m *MemoryBackend) NodeAdded(n *Node) bool
- func (m *MemoryBackend) NodeDeleted(n *Node) (removed bool)
- type MemoryBackendEdge
- type MemoryBackendNode
- func (e MemoryBackendNode) GetField(name string) (interface{}, error)
- func (e MemoryBackendNode) GetFieldInt64(field string) (_ int64, err error)
- func (e MemoryBackendNode) GetFieldKeys() []string
- func (e MemoryBackendNode) GetFieldString(field string) (_ string, err error)
- func (e MemoryBackendNode) GetFieldStringList(name string) ([]string, error)
- func (e MemoryBackendNode) MatchMetadata(f ElementMatcher) bool
- type Metadata
- type MetadataDecoder
- type MetadataIndexer
- type MetadataIndexerLinker
- type MetadataTransaction
- type Node
- func (e *Node) GetField(name string) (interface{}, error)
- func (e *Node) GetFieldInt64(field string) (_ int64, err error)
- func (e *Node) GetFieldKeys() []string
- func (e *Node) GetFieldString(field string) (_ string, err error)
- func (e *Node) GetFieldStringList(name string) ([]string, error)
- func (e *Node) MatchMetadata(f ElementMatcher) bool
- func (n *Node) String() string
- func (n *Node) UnmarshalJSON(b []byte) error
- type NodeAction
- type NodeHasher
- type OrientDBBackend
- func (o *OrientDBBackend) EdgeAdded(e *Edge) bool
- func (o *OrientDBBackend) EdgeDeleted(e *Edge) bool
- func (o *OrientDBBackend) GetEdge(i Identifier, t Context) []*Edge
- func (o *OrientDBBackend) GetEdgeNodes(e *Edge, t Context, parentMetadata, childMetadata ElementMatcher) (parents []*Node, children []*Node)
- func (o *OrientDBBackend) GetEdges(t Context, m ElementMatcher) (edges []*Edge)
- func (o *OrientDBBackend) GetNode(i Identifier, t Context) (nodes []*Node)
- func (o *OrientDBBackend) GetNodeEdges(n *Node, t Context, m ElementMatcher) (edges []*Edge)
- func (o *OrientDBBackend) GetNodes(t Context, m ElementMatcher) (nodes []*Node)
- func (o *OrientDBBackend) IsHistorySupported() bool
- func (o *OrientDBBackend) MetadataUpdated(i interface{}) bool
- func (o *OrientDBBackend) NodeAdded(n *Node) bool
- func (o *OrientDBBackend) NodeDeleted(n *Node) bool
- type Processor
- type ResourceLinker
- type SyncMsg
- type SyncRequestMsg
- type Time
- type TimedSearchQuery
Constants ¶
const ( CacheOnlyMode int = iota PersistentOnlyMode DefaultMode )
Define the running cache mode, memory and/or persistent
const ( NodeUpdated graphEventType = iota + 1 NodeAdded NodeDeleted EdgeUpdated EdgeAdded EdgeDeleted )
Graph events
const ( SyncMsgType = "Sync" SyncRequestMsgType = "SyncRequest" SyncReplyMsgType = "SyncReply" OriginGraphDeletedMsgType = "OriginGraphDeleted" NodeUpdatedMsgType = "NodeUpdated" NodeDeletedMsgType = "NodeDeleted" NodeAddedMsgType = "NodeAdded" EdgeUpdatedMsgType = "EdgeUpdated" EdgeDeletedMsgType = "EdgeDeleted" EdgeAddedMsgType = "EdgeAdded" )
Graph message type
const ( SortByInt64 int = iota + 1 SortByString )
Sort criterias
const (
// Namespace used for WebSocket message
Namespace = "Graph"
)
Variables ¶
var ( // NodeMetadataDecoders is a map that owns special type metadata decoder NodeMetadataDecoders = make(map[string]MetadataDecoder) // EdgeMetadataDecoders is a map that owns special type metadata decoder EdgeMetadataDecoders = make(map[string]MetadataDecoder) )
var ( ErrSyncRequestMalFormed = errors.New("SyncRequestMsg malformed") ErrSyncMsgMalFormed = errors.New("SyncMsg/SyncReplyMsg malformed") )
Graph error message
Functions ¶
func NewFilterForEdge ¶ added in v0.10.0
func NewFilterForEdge(parent Identifier, child Identifier) *filters.Filter
NewFilterForEdge creates a filter based on parent or child
func UnmarshalMessage ¶ added in v0.19.1
func UnmarshalMessage(msg *ws.StructMessage) (string, interface{}, error)
UnmarshalMessage unmarshal graph message
Types ¶
type Backend ¶ added in v0.21.0
type Backend interface { NodeAdded(n *Node) bool NodeDeleted(n *Node) bool GetNode(i Identifier, at Context) []*Node GetNodeEdges(n *Node, at Context, m ElementMatcher) []*Edge EdgeAdded(e *Edge) bool EdgeDeleted(e *Edge) bool GetEdge(i Identifier, at Context) []*Edge GetEdgeNodes(e *Edge, at Context, parentMetadata, childMetadata ElementMatcher) ([]*Node, []*Node) MetadataUpdated(e interface{}) bool GetNodes(t Context, m ElementMatcher) []*Node GetEdges(t Context, m ElementMatcher) []*Edge IsHistorySupported() bool }
Backend interface mechanism used as storage
type CachedBackend ¶ added in v0.10.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.10.0
func NewCachedBackend(persistent Backend) (*CachedBackend, error)
NewCachedBackend creates new graph cache mechanism
func (*CachedBackend) EdgeAdded ¶ added in v0.12.0
func (c *CachedBackend) EdgeAdded(e *Edge) bool
EdgeAdded add an edge in the cache
func (*CachedBackend) EdgeDeleted ¶ added in v0.12.0
func (c *CachedBackend) EdgeDeleted(e *Edge) bool
EdgeDeleted delete an edge in the cache
func (*CachedBackend) GetEdge ¶ added in v0.10.0
func (c *CachedBackend) GetEdge(i Identifier, t Context) []*Edge
GetEdge retrieve an edge within a time slice
func (*CachedBackend) GetEdgeNodes ¶ added in v0.10.0
func (c *CachedBackend) GetEdgeNodes(e *Edge, t Context, parentMetadata, childMetadata ElementMatcher) ([]*Node, []*Node)
GetEdgeNodes retrieve a list of nodes from an edge within a time slice, matching metadata
func (*CachedBackend) GetEdges ¶ added in v0.10.0
func (c *CachedBackend) GetEdges(t Context, m ElementMatcher) []*Edge
GetEdges returns a list of edges with a time slice, matching metadata
func (*CachedBackend) GetNode ¶ added in v0.10.0
func (c *CachedBackend) GetNode(i Identifier, t Context) []*Node
GetNode retrieve a node from the cache within a time slice
func (*CachedBackend) GetNodeEdges ¶ added in v0.10.0
func (c *CachedBackend) GetNodeEdges(n *Node, t Context, m ElementMatcher) (edges []*Edge)
GetNodeEdges retrieve a list of edges from a node within a time slice, matching metadata
func (*CachedBackend) GetNodes ¶ added in v0.10.0
func (c *CachedBackend) GetNodes(t Context, m ElementMatcher) []*Node
GetNodes returns a list of nodes with a time slice, matching metadata
func (*CachedBackend) IsHistorySupported ¶ added in v0.17.0
func (c *CachedBackend) IsHistorySupported() bool
IsHistorySupported returns whether the persistent backend supports history
func (*CachedBackend) MetadataUpdated ¶ added in v0.12.0
func (c *CachedBackend) MetadataUpdated(i interface{}) bool
MetadataUpdated updates metadata
func (*CachedBackend) NodeAdded ¶ added in v0.12.0
func (c *CachedBackend) NodeAdded(n *Node) bool
NodeAdded same the node in the cache
func (*CachedBackend) NodeDeleted ¶ added in v0.12.0
func (c *CachedBackend) NodeDeleted(n *Node) bool
NodeDeleted Delete the node in the cache
func (*CachedBackend) SetMode ¶ added in v0.10.0
func (c *CachedBackend) SetMode(mode int)
SetMode set cache mode
type DefaultGraphListener ¶ added in v0.3.0
type DefaultGraphListener struct { }
DefaultGraphListener default implementation of a graph listener, can be used when not implementing the whole set of callbacks
func (*DefaultGraphListener) OnEdgeAdded ¶ added in v0.3.0
func (c *DefaultGraphListener) OnEdgeAdded(e *Edge)
OnEdgeAdded event
func (*DefaultGraphListener) OnEdgeDeleted ¶ added in v0.3.0
func (c *DefaultGraphListener) OnEdgeDeleted(e *Edge)
OnEdgeDeleted event
func (*DefaultGraphListener) OnEdgeUpdated ¶ added in v0.3.0
func (c *DefaultGraphListener) OnEdgeUpdated(e *Edge)
OnEdgeUpdated event
func (*DefaultGraphListener) OnNodeAdded ¶ added in v0.3.0
func (c *DefaultGraphListener) OnNodeAdded(n *Node)
OnNodeAdded event
func (*DefaultGraphListener) OnNodeDeleted ¶ added in v0.3.0
func (c *DefaultGraphListener) OnNodeDeleted(n *Node)
OnNodeDeleted event
func (*DefaultGraphListener) OnNodeUpdated ¶ added in v0.3.0
func (c *DefaultGraphListener) OnNodeUpdated(n *Node)
OnNodeUpdated event
type DefaultLinker ¶ added in v0.20.0
type DefaultLinker struct { }
DefaultLinker returns a linker that does nothing
func (*DefaultLinker) GetABLinks ¶ added in v0.20.0
func (dl *DefaultLinker) GetABLinks(node *Node) []*Edge
GetABLinks returns all the outgoing links for a node
func (*DefaultLinker) GetBALinks ¶ added in v0.20.0
func (dl *DefaultLinker) GetBALinks(node *Node) []*Edge
GetBALinks returns all the incoming links for a node
type Edge ¶
type Edge struct { Parent Identifier Child Identifier // contains filtered or unexported fields }
Edge of the graph linked by a parent and a child
func CreateEdge ¶ added in v0.20.0
func CreateEdge(i Identifier, p *Node, c *Node, m Metadata, t Time, h string, s common.ServiceType) *Edge
CreateEdge returns a new edge not bound to any graph
func (*Edge) GetFieldInt64 ¶ added in v0.10.0
func (*Edge) GetFieldKeys ¶ added in v0.21.0
func (e *Edge) GetFieldKeys() []string
func (*Edge) GetFieldString ¶ added in v0.10.0
func (*Edge) GetFieldStringList ¶ added in v0.12.0
GetFieldStringList returns a list a string for the given field name
func (*Edge) MatchMetadata ¶ added in v0.4.0
func (e *Edge) MatchMetadata(f ElementMatcher) bool
MatchMetadata returns when an edge matches a specified filter or metadata
func (*Edge) UnmarshalJSON ¶ added in v0.21.0
UnmarshalJSON custom unmarshal function
type ElasticSearchBackend ¶ added in v0.6.0
type ElasticSearchBackend struct { Backend // contains filtered or unexported fields }
ElasticSearchBackend describes a presisent backend based on ElasticSearch
func NewElasticSearchBackendFromClient ¶ added in v0.18.0
func NewElasticSearchBackendFromClient(client es.ClientInterface) (*ElasticSearchBackend, error)
NewElasticSearchBackendFromClient creates a new graph backend using the given elasticsearch client connection
func NewElasticSearchBackendFromConfig ¶ added in v0.6.0
func NewElasticSearchBackendFromConfig(backend string, etcdClient *etcd.Client) (*ElasticSearchBackend, error)
NewElasticSearchBackendFromConfig creates a new graph backend based on configuration file parameters
func (*ElasticSearchBackend) EdgeAdded ¶ added in v0.12.0
func (b *ElasticSearchBackend) EdgeAdded(e *Edge) bool
EdgeAdded add an edge in the database
func (*ElasticSearchBackend) EdgeDeleted ¶ added in v0.12.0
func (b *ElasticSearchBackend) EdgeDeleted(e *Edge) bool
EdgeDeleted delete an edge in the database
func (*ElasticSearchBackend) GetEdge ¶ added in v0.6.0
func (b *ElasticSearchBackend) GetEdge(i Identifier, t Context) []*Edge
GetEdge get an edge within a time slice
func (*ElasticSearchBackend) GetEdgeNodes ¶ added in v0.6.0
func (b *ElasticSearchBackend) GetEdgeNodes(e *Edge, t Context, parentMetadata, childMetadata ElementMatcher) (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.6.0
func (b *ElasticSearchBackend) GetEdges(t Context, m ElementMatcher) []*Edge
GetEdges returns a list of edges within time slice, matching metadata
func (*ElasticSearchBackend) GetNode ¶ added in v0.6.0
func (b *ElasticSearchBackend) GetNode(i Identifier, t Context) []*Node
GetNode get a node within a time slice
func (*ElasticSearchBackend) GetNodeEdges ¶ added in v0.6.0
func (b *ElasticSearchBackend) GetNodeEdges(n *Node, t Context, m ElementMatcher) (edges []*Edge)
GetNodeEdges returns a list of a node edges within time slice
func (*ElasticSearchBackend) GetNodes ¶ added in v0.6.0
func (b *ElasticSearchBackend) GetNodes(t Context, m ElementMatcher) []*Node
GetNodes returns a list of nodes within time slice, matching metadata
func (*ElasticSearchBackend) IsHistorySupported ¶ added in v0.17.0
func (b *ElasticSearchBackend) IsHistorySupported() bool
IsHistorySupported returns that this backend does support history
func (*ElasticSearchBackend) MetadataUpdated ¶ added in v0.12.0
func (b *ElasticSearchBackend) MetadataUpdated(i interface{}) bool
MetadataUpdated updates a node metadata in the database
func (*ElasticSearchBackend) NodeAdded ¶ added in v0.12.0
func (b *ElasticSearchBackend) NodeAdded(n *Node) bool
NodeAdded add a node
func (*ElasticSearchBackend) NodeDeleted ¶ added in v0.12.0
func (b *ElasticSearchBackend) NodeDeleted(n *Node) bool
NodeDeleted delete a node
func (*ElasticSearchBackend) Query ¶ added in v0.10.0
func (b *ElasticSearchBackend) Query(typ string, tsq *TimedSearchQuery) (sr *elastic.SearchResult, _ error)
Query the database for a "node" or "edge"
type ElementFilter ¶ added in v0.21.0
type ElementFilter struct {
// contains filtered or unexported fields
}
ElementFilter implements ElementMatcher interface based on filter
func NewElementFilter ¶ added in v0.21.0
func NewElementFilter(f *filters.Filter) *ElementFilter
NewElementFilter returns a new ElementFilter
type ElementMatcher ¶ added in v0.21.0
ElementMatcher defines an interface used to match an element
type EventHandler ¶ added in v0.21.0
EventHandler describes an object that notifies listeners with graph events
func NewEventHandler ¶ added in v0.21.0
func NewEventHandler(maxEvents int) *EventHandler
NewEventHandler instanciate a new event handler
func (*EventHandler) AddEventListener ¶ added in v0.21.0
func (g *EventHandler) AddEventListener(l EventListener)
AddEventListener subscribe a new graph listener
func (*EventHandler) NotifyEvent ¶ added in v0.21.0
func (g *EventHandler) NotifyEvent(kind graphEventType, element interface{})
NotifyEvent notifies all the listeners of an event. NotifyEvent makes sure that we don't enter a notify endless loop.
func (*EventHandler) RemoveEventListener ¶ added in v0.21.0
func (g *EventHandler) RemoveEventListener(l EventListener)
RemoveEventListener unsubscribe a graph listener
type EventListener ¶
type EventListener interface { OnNodeUpdated(n *Node) OnNodeAdded(n *Node) OnNodeDeleted(n *Node) OnEdgeUpdated(e *Edge) OnEdgeAdded(e *Edge) OnEdgeDeleted(e *Edge) }
EventListener describes the graph events interface mechanism
type Graph ¶
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 Backend, service common.ServiceType) *Graph
NewGraph creates a new graph based on the backend
func NewGraphFromConfig ¶ added in v0.4.0
func NewGraphFromConfig(backend Backend, service common.ServiceType) *Graph
NewGraphFromConfig creates a new graph based on configuration
func (*Graph) AddEventListener ¶
func (g *Graph) AddEventListener(l EventListener)
AddEventListener subscibe a new graph listener
func (*Graph) AddMetadata ¶ added in v0.2.0
AddMetadata add a metadata to an associated edge or node
func (*Graph) AreLinked ¶
func (g *Graph) AreLinked(n1 *Node, n2 *Node, m ElementMatcher) bool
AreLinked returns true if nodes n1, n2 are linked
func (*Graph) CloneWithContext ¶ added in v0.17.0
CloneWithContext creates a new graph based on the given one and the given context
func (*Graph) CreateEdge ¶ added in v0.20.0
CreateEdge creates a new edge and adds it to the graph
func (*Graph) CreateNode ¶ added in v0.20.0
CreateNode creates a new node and adds it to the graph
func (*Graph) DelMetadata ¶ added in v0.10.0
DelMetadata delete a metadata to an associated edge or node
func (*Graph) DelOriginGraph ¶ added in v0.20.0
DelOriginGraph delete the associated node with the origin
func (*Graph) Diff ¶ added in v0.14.0
func (g *Graph) Diff(newGraph *Graph) (addedNodes []*Node, removedNodes []*Node, addedEdges []*Edge, removedEdges []*Edge)
Diff computes the difference between two graphs
func (*Graph) EdgeUpdated ¶ added in v0.12.0
EdgeUpdated updates an edge
func (*Graph) GetContext ¶ added in v0.4.0
GetContext returns the current context
func (*Graph) GetEdgeNodes ¶ added in v0.3.0
func (g *Graph) GetEdgeNodes(e *Edge, parentMetadata, childMetadata ElementMatcher) ([]*Node, []*Node)
GetEdgeNodes returns a list of nodes of an edge
func (*Graph) GetEdges ¶
func (g *Graph) GetEdges(m ElementMatcher) []*Edge
GetEdges returns a list of edges
func (*Graph) GetFirstLink ¶ added in v0.17.0
GetFirstLink get Link between the parent and the child node
func (*Graph) GetNodeEdges ¶ added in v0.4.0
func (g *Graph) GetNodeEdges(n *Node, m ElementMatcher) []*Edge
GetNodeEdges returns a list of edges of a node
func (*Graph) GetNodes ¶
func (g *Graph) GetNodes(m ElementMatcher) []*Node
GetNodes returns a list of nodes
func (*Graph) GetNodesMap ¶ added in v0.15.0
func (g *Graph) GetNodesMap(t Context) map[Identifier]*Node
GetNodesMap returns a map of nodes within a time slice
func (*Graph) LookupChildren ¶
func (g *Graph) LookupChildren(n *Node, f ElementMatcher, em ElementMatcher) (nodes []*Node)
LookupChildren returns a list of children nodes
func (*Graph) LookupFirstChild ¶ added in v0.2.0
func (g *Graph) LookupFirstChild(n *Node, f ElementMatcher) *Node
LookupFirstChild returns the child
func (*Graph) LookupFirstNode ¶
func (g *Graph) LookupFirstNode(m ElementMatcher) *Node
LookupFirstNode returns the fist node matching metadata
func (*Graph) LookupParents ¶ added in v0.6.0
func (g *Graph) LookupParents(n *Node, f ElementMatcher, em ElementMatcher) (nodes []*Node)
LookupParents returns the associated parents edge of a node
func (*Graph) LookupShortestPath ¶ added in v0.3.0
func (g *Graph) LookupShortestPath(n *Node, m ElementMatcher, em ElementMatcher) []*Node
LookupShortestPath based on Dijkstra algorithm
func (*Graph) MarshalJSON ¶
MarshalJSON serialize the graph in JSON
func (*Graph) NewEdge ¶
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) NodeUpdated ¶ added in v0.12.0
NodeUpdated updates a node
func (*Graph) RemoveEventListener ¶ added in v0.3.0
func (g *Graph) RemoveEventListener(l EventListener)
RemoveEventListener unsubscribe a graph listener
func (*Graph) SetMetadata ¶
SetMetadata associate metadata to an edge or node
func (*Graph) StartMetadataTransaction ¶ added in v0.3.0
func (g *Graph) StartMetadataTransaction(i interface{}) *MetadataTransaction
StartMetadataTransaction start a new transaction
type Indexer ¶ added in v0.21.0
type Indexer struct { common.RWMutex DefaultGraphListener // contains filtered or unexported fields }
Indexer 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 NewIndexer ¶ added in v0.21.0
func NewIndexer(g *Graph, listenerHandler ListenerHandler, hashNode NodeHasher, appendOnly bool) *Indexer
NewIndexer returns a new graph indexer with the associated hashing callback
func (*Indexer) AddEventListener ¶ added in v0.21.0
func (i *Indexer) AddEventListener(l EventListener)
AddEventListener subscibe a new graph listener
func (*Indexer) FromHash ¶ added in v0.21.0
FromHash returns the nodes mapped by a hash along with their associated values
func (*Indexer) OnNodeAdded ¶ added in v0.21.0
OnNodeAdded event
func (*Indexer) OnNodeDeleted ¶ added in v0.21.0
OnNodeDeleted event
func (*Indexer) OnNodeUpdated ¶ added in v0.21.0
OnNodeUpdated event
func (*Indexer) RemoveEventListener ¶ added in v0.21.0
func (i *Indexer) RemoveEventListener(l EventListener)
RemoveEventListener unsubscribe a graph listener
type Linker ¶ added in v0.20.0
Linker describes an object that returns incoming edges to a node and outgoing edges from that node
type ListenerHandler ¶ added in v0.21.0
type ListenerHandler interface { AddEventListener(l EventListener) RemoveEventListener(l EventListener) }
ListenerHandler describes an other that manages a set of event listeners
type MemoryBackend ¶
type MemoryBackend struct { Backend // 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.12.0
func (m *MemoryBackend) EdgeAdded(e *Edge) bool
EdgeAdded event add an edge in the memory backend
func (*MemoryBackend) EdgeDeleted ¶ added in v0.12.0
func (m *MemoryBackend) EdgeDeleted(e *Edge) bool
EdgeDeleted in the graph backend
func (*MemoryBackend) GetEdge ¶
func (m *MemoryBackend) GetEdge(i Identifier, t Context) []*Edge
GetEdge in the graph backend
func (*MemoryBackend) GetEdgeNodes ¶
func (m *MemoryBackend) GetEdgeNodes(e *Edge, t Context, parentMetadata, childMetadata ElementMatcher) ([]*Node, []*Node)
GetEdgeNodes returns a list of nodes of an edge
func (MemoryBackend) GetEdges ¶
func (m MemoryBackend) GetEdges(t Context, metadata ElementMatcher) (edges []*Edge)
GetEdges from the graph backend
func (*MemoryBackend) GetNode ¶
func (m *MemoryBackend) GetNode(i Identifier, t Context) []*Node
GetNode from the graph backend
func (*MemoryBackend) GetNodeEdges ¶
func (m *MemoryBackend) GetNodeEdges(n *Node, t Context, meta ElementMatcher) []*Edge
GetNodeEdges returns a list of edges of a node
func (MemoryBackend) GetNodes ¶
func (m MemoryBackend) GetNodes(t Context, metadata ElementMatcher) (nodes []*Node)
GetNodes from the graph backend
func (*MemoryBackend) IsHistorySupported ¶ added in v0.17.0
func (m *MemoryBackend) IsHistorySupported() bool
IsHistorySupported returns that this backend doesn't support history
func (*MemoryBackend) MetadataUpdated ¶ added in v0.12.0
func (m *MemoryBackend) MetadataUpdated(i interface{}) bool
MetadataUpdated returns true
func (*MemoryBackend) NodeAdded ¶ added in v0.12.0
func (m *MemoryBackend) NodeAdded(n *Node) bool
NodeAdded in the graph backend
func (*MemoryBackend) NodeDeleted ¶ added in v0.12.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) GetFieldInt64 ¶ added in v0.10.0
func (MemoryBackendEdge) GetFieldKeys ¶ added in v0.21.0
func (e MemoryBackendEdge) GetFieldKeys() []string
func (MemoryBackendEdge) GetFieldString ¶ added in v0.20.0
func (MemoryBackendEdge) GetFieldStringList ¶ added in v0.12.0
GetFieldStringList returns a list a string for the given field name
type MemoryBackendNode ¶
type MemoryBackendNode struct { *Node // contains filtered or unexported fields }
MemoryBackendNode a memory backend node
func (MemoryBackendNode) GetFieldInt64 ¶ added in v0.10.0
func (MemoryBackendNode) GetFieldKeys ¶ added in v0.21.0
func (e MemoryBackendNode) GetFieldKeys() []string
func (MemoryBackendNode) GetFieldString ¶ added in v0.10.0
func (MemoryBackendNode) GetFieldStringList ¶ added in v0.12.0
GetFieldStringList returns a list a string for the given field name
func (MemoryBackendNode) MatchMetadata ¶ added in v0.4.0
func (e MemoryBackendNode) MatchMetadata(f ElementMatcher) bool
MatchMetadata returns whether a graph element matches with the provided filter or metadata
type Metadata ¶ added in v0.2.0
type Metadata map[string]interface{}
Metadata describes the graph node metadata type. It implements ElementMatcher based only on Metadata. easyjson:json
func (Metadata) Match ¶ added in v0.16.0
Match returns true if the the given element matches the metadata.
func (*Metadata) SetField ¶ added in v0.16.0
SetField set metadata value based on dot key ("a.b.c.d" = "ok")
func (*Metadata) SetFieldAndNormalize ¶ added in v0.19.0
SetFieldAndNormalize set metadata value after normalization (and deepcopy)
type MetadataDecoder ¶ added in v0.21.0
type MetadataDecoder func(raw json.RawMessage) (common.Getter, error)
MetadataDecoder defines a json rawmessage decoder which has to return a object implementing the getter interface
type MetadataIndexer ¶ added in v0.16.0
type MetadataIndexer struct { *Indexer // contains filtered or unexported fields }
MetadataIndexer describes a metadata based graph indexer
func NewMetadataIndexer ¶ added in v0.16.0
func NewMetadataIndexer(g *Graph, listenerHandler ListenerHandler, m ElementMatcher, 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 MetadataIndexerLinker ¶ added in v0.20.0
type MetadataIndexerLinker struct { *ResourceLinker // contains filtered or unexported fields }
MetadataIndexerLinker describes an object that links resources from one indexer to resources from an other indexer.
func NewMetadataIndexerLinker ¶ added in v0.20.0
func NewMetadataIndexerLinker(g *Graph, indexer1, indexer2 *MetadataIndexer, edgeMetadata Metadata) *MetadataIndexerLinker
NewMetadataIndexerLinker returns a new metadata based linker
func (*MetadataIndexerLinker) GetABLinks ¶ added in v0.20.0
func (mil *MetadataIndexerLinker) GetABLinks(node *Node) (edges []*Edge)
GetABLinks returns all the outgoing links for a node
func (*MetadataIndexerLinker) GetBALinks ¶ added in v0.20.0
func (mil *MetadataIndexerLinker) GetBALinks(node *Node) (edges []*Edge)
GetBALinks returns all the incoming links for a node
type MetadataTransaction ¶ added in v0.3.0
type MetadataTransaction struct {
// contains filtered or unexported fields
}
MetadataTransaction describes a metadata transaction in the graph
func (*MetadataTransaction) AddMetadata ¶ added in v0.3.0
func (t *MetadataTransaction) AddMetadata(k string, v interface{})
AddMetadata in the current transaction
func (*MetadataTransaction) Commit ¶ added in v0.3.0
func (t *MetadataTransaction) Commit()
Commit the current transaction to the graph
func (*MetadataTransaction) DelMetadata ¶ added in v0.19.1
func (t *MetadataTransaction) DelMetadata(k string)
DelMetadata in the current transaction
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node of the graph
func CreateNode ¶ added in v0.20.0
func CreateNode(i Identifier, m Metadata, t Time, h string, s common.ServiceType) *Node
CreateNode returns a new node not bound to a graph
func (*Node) GetFieldInt64 ¶ added in v0.10.0
func (*Node) GetFieldKeys ¶ added in v0.21.0
func (e *Node) GetFieldKeys() []string
func (*Node) GetFieldString ¶ added in v0.10.0
func (*Node) GetFieldStringList ¶ added in v0.12.0
GetFieldStringList returns a list a string for the given field name
func (*Node) MatchMetadata ¶ added in v0.4.0
func (e *Node) MatchMetadata(f ElementMatcher) bool
MatchMetadata returns whether a graph element matches with the provided filter or metadata
func (*Node) UnmarshalJSON ¶ added in v0.21.0
UnmarshalJSON custom unmarshal function
type NodeAction ¶ added in v0.21.0
NodeAction is a callback to perform on a node. The action is kept active as long as it returns true.
type NodeHasher ¶ added in v0.16.0
NodeHasher describes a callback that is called to map a node to a set of hash,value pairs
type OrientDBBackend ¶ added in v0.4.0
type OrientDBBackend struct { Backend // contains filtered or unexported fields }
OrientDBBackend describes an OrientDB backend
func NewOrientDBBackend ¶ added in v0.4.0
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 ¶ added in v0.4.0
func NewOrientDBBackendFromConfig(backend string) (*OrientDBBackend, error)
NewOrientDBBackendFromConfig creates a new OrientDB database client based on configuration
func (*OrientDBBackend) EdgeAdded ¶ added in v0.12.0
func (o *OrientDBBackend) EdgeAdded(e *Edge) bool
EdgeAdded add a node in the database
func (*OrientDBBackend) EdgeDeleted ¶ added in v0.12.0
func (o *OrientDBBackend) EdgeDeleted(e *Edge) bool
EdgeDeleted delete a node in the database
func (*OrientDBBackend) GetEdge ¶ added in v0.4.0
func (o *OrientDBBackend) GetEdge(i Identifier, t Context) []*Edge
GetEdge get an edge within a time slice
func (*OrientDBBackend) GetEdgeNodes ¶ added in v0.4.0
func (o *OrientDBBackend) GetEdgeNodes(e *Edge, t Context, parentMetadata, childMetadata ElementMatcher) (parents []*Node, children []*Node)
GetEdgeNodes returns the parents and child nodes of an edge within time slice, matching metadata
func (*OrientDBBackend) GetEdges ¶ added in v0.4.0
func (o *OrientDBBackend) GetEdges(t Context, m ElementMatcher) (edges []*Edge)
GetEdges returns a list of edges within time slice, matching metadata
func (*OrientDBBackend) GetNode ¶ added in v0.4.0
func (o *OrientDBBackend) GetNode(i Identifier, t Context) (nodes []*Node)
GetNode get a node within a time slice
func (*OrientDBBackend) GetNodeEdges ¶ added in v0.4.0
func (o *OrientDBBackend) GetNodeEdges(n *Node, t Context, m ElementMatcher) (edges []*Edge)
GetNodeEdges returns a list of a node edges within time slice
func (*OrientDBBackend) GetNodes ¶ added in v0.4.0
func (o *OrientDBBackend) GetNodes(t Context, m ElementMatcher) (nodes []*Node)
GetNodes returns a list of nodes within time slice, matching metadata
func (*OrientDBBackend) IsHistorySupported ¶ added in v0.17.0
func (o *OrientDBBackend) IsHistorySupported() bool
IsHistorySupported returns that this backend does support history
func (*OrientDBBackend) MetadataUpdated ¶ added in v0.12.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.12.0
func (o *OrientDBBackend) NodeAdded(n *Node) bool
NodeAdded add a node in the database
func (*OrientDBBackend) NodeDeleted ¶ added in v0.12.0
func (o *OrientDBBackend) NodeDeleted(n *Node) bool
NodeDeleted delete a node in the database
type Processor ¶ added in v0.21.0
type Processor struct { common.RWMutex DefaultGraphListener MetadataIndexer *MetadataIndexer // contains filtered or unexported fields }
Processor encapsulates an indexer that will process NodeActions on the nodes that filter
func NewProcessor ¶ added in v0.21.0
func NewProcessor(g *Graph, listenerHandler ListenerHandler, m ElementMatcher, indexes ...string) (processor *Processor)
NewProcessor creates a Processor on the graph g, a stream of events controlled by listenerHandler, that match a first set of metadata m. Actions will be associated to a given set of values for indexes.
func (*Processor) Cancel ¶ added in v0.21.0
func (processor *Processor) Cancel(values ...interface{})
Cancel the actions attached to a given set of values.
func (*Processor) DoAction ¶ added in v0.21.0
func (processor *Processor) DoAction(action NodeAction, values ...interface{})
DoAction will perform the action for nodes matching values.
func (*Processor) OnNodeAdded ¶ added in v0.21.0
OnNodeAdded event
type ResourceLinker ¶ added in v0.20.0
type ResourceLinker struct {
// contains filtered or unexported fields
}
ResourceLinker returns a resource linker. It listens for events from 2 graph events sources to determine if resources from one source should be linked with resources of the other source.
func NewResourceLinker ¶ added in v0.20.0
func NewResourceLinker(g *Graph, glh1 ListenerHandler, glh2 ListenerHandler, linker Linker, m Metadata) *ResourceLinker
NewResourceLinker returns a new resource linker
func (*ResourceLinker) Start ¶ added in v0.20.0
func (rl *ResourceLinker) Start()
Start linking resources by listening for graph events
func (*ResourceLinker) Stop ¶ added in v0.20.0
func (rl *ResourceLinker) Stop()
Stop linking resources
type SyncRequestMsg ¶ added in v0.14.0
SyncRequestMsg describes a graph synchro request message
func (*SyncRequestMsg) UnmarshalJSON ¶ added in v0.21.0
func (s *SyncRequestMsg) UnmarshalJSON(b []byte) error
UnmarshalJSON custom unmarshal function
type Time ¶ added in v0.21.0
Time describes time type used in the graph
func (*Time) MarshalJSON ¶ added in v0.21.0
MarshalJSON custom marshalling function
func (*Time) UnmarshalJSON ¶ added in v0.21.0
UnmarshalJSON custom unmarshalling function
type TimedSearchQuery ¶ added in v0.10.0
type TimedSearchQuery struct { filters.SearchQuery TimeFilter *filters.Filter MetadataFilter *filters.Filter }
TimedSearchQuery describes a search query within a time slice and metadata filters