Documentation ¶
Index ¶
- Constants
- Variables
- func NewFilterForEdge(parent Identifier, child Identifier) *filters.Filter
- func NewFilterForMetadata(m Metadata) (*filters.Filter, error)
- func NewFilterForTime(t time.Time) *filters.Filter
- func NewFilterForTimeSlice(t *common.TimeSlice) *filters.Filter
- func UnmarshalWSMessage(msg shttp.WSMessage) (string, interface{}, error)
- type CachedBackend
- func (c *CachedBackend) EdgeAdded(e *Edge) bool
- func (c *CachedBackend) EdgeDeleted(e *Edge) bool
- func (c *CachedBackend) GetEdge(i Identifier, t *common.TimeSlice) []*Edge
- func (c *CachedBackend) GetEdgeNodes(e *Edge, t *common.TimeSlice, parentMetadata, childMetadata Metadata) ([]*Node, []*Node)
- func (c *CachedBackend) GetEdges(t *common.TimeSlice, m Metadata) []*Edge
- func (c *CachedBackend) GetNode(i Identifier, t *common.TimeSlice) []*Node
- func (c *CachedBackend) GetNodeEdges(n *Node, t *common.TimeSlice, m Metadata) (edges []*Edge)
- func (c *CachedBackend) GetNodes(t *common.TimeSlice, m Metadata) []*Node
- 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)
- func (c *CachedBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)
- 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 Edge
- func (e *Edge) Decode(i interface{}) error
- func (e *Edge) GetChild() Identifier
- func (e *Edge) GetField(name string) (interface{}, error)
- func (e *Edge) GetFieldInt64(field string) (_ int64, err error)
- func (e *Edge) GetFieldString(name string) (string, error)
- func (e *Edge) GetFieldStringList(name string) ([]string, error)
- func (e *Edge) GetParent() Identifier
- func (e *Edge) Host() string
- func (e *Edge) JSONRawMessage() *json.RawMessage
- func (e *Edge) MarshalJSON() ([]byte, error)
- func (e *Edge) MatchMetadata(f Metadata) bool
- func (e *Edge) Metadata() Metadata
- func (e *Edge) String() string
- type ElasticSearchBackend
- func (b *ElasticSearchBackend) EdgeAdded(e *Edge) bool
- func (b *ElasticSearchBackend) EdgeDeleted(e *Edge) bool
- func (b *ElasticSearchBackend) GetEdge(i Identifier, t *common.TimeSlice) []*Edge
- func (b *ElasticSearchBackend) GetEdgeNodes(e *Edge, t *common.TimeSlice, parentMetadata, childMetadata Metadata) (parents []*Node, children []*Node)
- func (b *ElasticSearchBackend) GetEdges(t *common.TimeSlice, m Metadata) []*Edge
- func (b *ElasticSearchBackend) GetNode(i Identifier, t *common.TimeSlice) []*Node
- func (b *ElasticSearchBackend) GetNodeEdges(n *Node, t *common.TimeSlice, m Metadata) (edges []*Edge)
- func (b *ElasticSearchBackend) GetNodes(t *common.TimeSlice, m Metadata) []*Node
- 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(obj string, tsq *TimedSearchQuery) (sr elastigo.SearchResult, _ error)
- func (b *ElasticSearchBackend) SearchEdges(tsq *TimedSearchQuery) (edges []*Edge)
- func (b *ElasticSearchBackend) SearchNodes(tsq *TimedSearchQuery) (nodes []*Node)
- func (b *ElasticSearchBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)
- type Graph
- func (g *Graph) AddEdge(e *Edge) bool
- func (g *Graph) AddEventListener(l GraphEventListener)
- 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 Metadata) bool
- func (g *Graph) DelEdge(e *Edge)
- func (g *Graph) DelHostGraph(host string)
- func (g *Graph) DelMetadata(i interface{}, k string) bool
- func (g *Graph) DelNode(n *Node)
- func (g *Graph) EdgeAdded(e *Edge) bool
- func (g *Graph) EdgeDeleted(e *Edge)
- func (g *Graph) EdgeUpdated(e *Edge) bool
- func (g *Graph) GetContext() GraphContext
- func (g *Graph) GetEdge(i Identifier) *Edge
- func (g *Graph) GetEdgeNodes(e *Edge, parentMetadata, childMetadata Metadata) ([]*Node, []*Node)
- func (g *Graph) GetEdges(m Metadata) []*Edge
- func (g *Graph) GetHost() string
- func (g *Graph) GetNode(i Identifier) *Node
- func (g *Graph) GetNodeEdges(n *Node, m Metadata) []*Edge
- func (g *Graph) GetNodes(m Metadata) []*Node
- func (g *Graph) Link(n1 *Node, n2 *Node, m Metadata) *Edge
- func (g *Graph) LookupChildren(n *Node, f Metadata, em Metadata) (nodes []*Node)
- func (g *Graph) LookupFirstChild(n *Node, f Metadata) *Node
- func (g *Graph) LookupFirstNode(m Metadata) *Node
- func (g *Graph) LookupParents(n *Node, f Metadata, em Metadata) (nodes []*Node)
- func (g *Graph) LookupShortestPath(n *Node, m Metadata, em Metadata) []*Node
- func (g *Graph) MarshalJSON() ([]byte, error)
- func (g *Graph) NewEdge(i Identifier, p *Node, c *Node, m Metadata) *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) RemoveEventListener(l GraphEventListener)
- 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)
- func (g *Graph) WithContext(c GraphContext) (*Graph, error)
- type GraphBackend
- type GraphContext
- type GraphEventListener
- type HostNodeTIDMap
- type Identifier
- type InterfaceMetric
- type MemoryBackend
- func (m *MemoryBackend) EdgeAdded(e *Edge) bool
- func (m *MemoryBackend) EdgeDeleted(e *Edge) bool
- func (m *MemoryBackend) GetEdge(i Identifier, t *common.TimeSlice) []*Edge
- func (m *MemoryBackend) GetEdgeNodes(e *Edge, t *common.TimeSlice, parentMetadata, childMetadata Metadata) ([]*Node, []*Node)
- func (m MemoryBackend) GetEdges(t *common.TimeSlice, metadata Metadata) (edges []*Edge)
- func (m *MemoryBackend) GetNode(i Identifier, t *common.TimeSlice) []*Node
- func (m *MemoryBackend) GetNodeEdges(n *Node, t *common.TimeSlice, meta Metadata) []*Edge
- func (m MemoryBackend) GetNodes(t *common.TimeSlice, metadata Metadata) (nodes []*Node)
- func (m *MemoryBackend) MetadataUpdated(i interface{}) bool
- func (m *MemoryBackend) NodeAdded(n *Node) bool
- func (m *MemoryBackend) NodeDeleted(n *Node) bool
- func (m *MemoryBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)
- type MemoryBackendEdge
- func (e MemoryBackendEdge) GetField(name string) (interface{}, error)
- func (e MemoryBackendEdge) GetFieldInt64(field string) (_ int64, err error)
- func (e MemoryBackendEdge) GetFieldStringList(name string) ([]string, error)
- func (e MemoryBackendEdge) Host() string
- func (e MemoryBackendEdge) MatchMetadata(f Metadata) bool
- func (e MemoryBackendEdge) Metadata() Metadata
- type MemoryBackendNode
- func (e MemoryBackendNode) GetField(name string) (interface{}, error)
- func (e MemoryBackendNode) GetFieldInt64(field string) (_ int64, err error)
- func (e MemoryBackendNode) GetFieldString(field string) (_ string, err error)
- func (e MemoryBackendNode) GetFieldStringList(name string) ([]string, error)
- func (e MemoryBackendNode) Host() string
- func (e MemoryBackendNode) MatchMetadata(f Metadata) bool
- func (e MemoryBackendNode) Metadata() Metadata
- type Metadata
- type MetadataTransaction
- type Node
- func (n *Node) Decode(i interface{}) error
- func (e *Node) GetField(name string) (interface{}, error)
- func (e *Node) GetFieldInt64(field string) (_ int64, err error)
- func (e *Node) GetFieldString(field string) (_ string, err error)
- func (e *Node) GetFieldStringList(name string) ([]string, error)
- func (e *Node) Host() string
- func (n *Node) JSONRawMessage() *json.RawMessage
- func (n *Node) MarshalJSON() ([]byte, error)
- func (e *Node) MatchMetadata(f Metadata) bool
- func (e *Node) Metadata() Metadata
- func (n *Node) String() string
- type OrientDBBackend
- func (o *OrientDBBackend) EdgeAdded(e *Edge) bool
- func (o *OrientDBBackend) EdgeDeleted(e *Edge) bool
- func (o *OrientDBBackend) GetEdge(i Identifier, t *common.TimeSlice) (edges []*Edge)
- func (o *OrientDBBackend) GetEdgeNodes(e *Edge, t *common.TimeSlice, parentMetadata, childMetadata Metadata) (parents []*Node, children []*Node)
- func (o *OrientDBBackend) GetEdges(t *common.TimeSlice, m Metadata) (edges []*Edge)
- func (o *OrientDBBackend) GetNode(i Identifier, t *common.TimeSlice) (nodes []*Node)
- func (o *OrientDBBackend) GetNodeEdges(n *Node, t *common.TimeSlice, m Metadata) (edges []*Edge)
- func (o *OrientDBBackend) GetNodes(t *common.TimeSlice, m Metadata) (nodes []*Node)
- func (o *OrientDBBackend) MetadataUpdated(i interface{}) bool
- func (o *OrientDBBackend) NodeAdded(n *Node) bool
- func (o *OrientDBBackend) NodeDeleted(n *Node) bool
- func (o *OrientDBBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)
- type Server
- func (s *Server) AddEventHandler(h ServerEventHandler)
- func (s *Server) OnEdgeAdded(e *Edge)
- func (s *Server) OnEdgeDeleted(e *Edge)
- func (s *Server) OnEdgeUpdated(e *Edge)
- func (s *Server) OnMessage(c *shttp.WSClient, msg shttp.WSMessage)
- func (s *Server) OnNodeAdded(n *Node)
- func (s *Server) OnNodeDeleted(n *Node)
- func (s *Server) OnNodeUpdated(n *Node)
- type ServerEventHandler
- type SyncReplyMsg
- type TimedSearchQuery
Constants ¶
const ( CacheOnlyMode int = iota PersistentOnlyMode DefaultMode )
Define the running cache mode, memory and/or persisent
const ( SyncRequestMsgType = "SyncRequest" SyncReplyMsgType = "SyncReply" HostGraphDeletedMsgType = "HostGraphDeleted" NodeUpdatedMsgType = "NodeUpdated" NodeDeletedMsgType = "NodeDeleted" NodeAddedMsgType = "NodeAdded" EdgeUpdatedMsgType = "EdgeUpdated" EdgeDeletedMsgType = "EdgeDeleted" EdgeAddedMsgType = "EdgeAdded" )
Graph message type
const (
Namespace = "Graph"
)
Namespace websocket message : Graph
Variables ¶
var ( ErrSyncRequestMalFormed = errors.New("SyncRequestMsg malformed") ErrSyncReplyMsgMalFormed = errors.New("SyncReplyMsg malformed") )
Graph error message
var ErrBadConfig = errors.New("elasticsearch : Config file is misconfigured, check elasticsearch key format")
ErrBadConfig elasticsearch configuration file is incorrect
Functions ¶
func NewFilterForEdge ¶
func NewFilterForEdge(parent Identifier, child Identifier) *filters.Filter
NewFilterForEdge creates a filter based on parent or child
func NewFilterForMetadata ¶
NewFilterForMetadata creates a new filter based on metadata
func NewFilterForTime ¶
NewFilterForTime creates a filter including time slice t
func NewFilterForTimeSlice ¶
NewFilterForTimeSlice creates a filter based on a time slice between CreatedAt and DeletedAt time.Now() is used as reference if t == nil
Types ¶
type CachedBackend ¶
type CachedBackend struct {
// contains filtered or unexported fields
}
CachedBackend describes a cache mechanism in memory and/or persistent database
func NewCachedBackend ¶
func NewCachedBackend(persistent GraphBackend) (*CachedBackend, error)
NewCachedBackend creates new graph cache mechanism
func (*CachedBackend) EdgeAdded ¶
func (c *CachedBackend) EdgeAdded(e *Edge) bool
EdgeAdded add an edge in the cache
func (*CachedBackend) EdgeDeleted ¶
func (c *CachedBackend) EdgeDeleted(e *Edge) bool
EdgeDeleted delete an edge in the cache
func (*CachedBackend) GetEdge ¶
func (c *CachedBackend) GetEdge(i Identifier, t *common.TimeSlice) []*Edge
GetEdge retrieve an edge within a time slice
func (*CachedBackend) GetEdgeNodes ¶
func (c *CachedBackend) GetEdgeNodes(e *Edge, t *common.TimeSlice, parentMetadata, childMetadata Metadata) ([]*Node, []*Node)
GetEdgeNodes retrieve a list of nodes from an edge within a time slice, matching metadata
func (*CachedBackend) GetEdges ¶
func (c *CachedBackend) GetEdges(t *common.TimeSlice, m Metadata) []*Edge
GetEdges returns a list of edges with a time slice, matching metadata
func (*CachedBackend) GetNode ¶
func (c *CachedBackend) GetNode(i Identifier, t *common.TimeSlice) []*Node
GetNode retrieve a node from the cache within a time slice
func (*CachedBackend) GetNodeEdges ¶
GetNodeEdges retrieve a list of edges from a node within a time slice, matching metadata
func (*CachedBackend) GetNodes ¶
func (c *CachedBackend) GetNodes(t *common.TimeSlice, m Metadata) []*Node
GetNodes returns a list of nodes with a time slice, matching metadata
func (*CachedBackend) MetadataUpdated ¶
func (c *CachedBackend) MetadataUpdated(i interface{}) bool
MetadataUpdated updates metadata
func (*CachedBackend) NodeAdded ¶
func (c *CachedBackend) NodeAdded(n *Node) bool
NodeAdded same the node in the cache
func (*CachedBackend) NodeDeleted ¶
func (c *CachedBackend) NodeDeleted(n *Node) bool
NodeDeleted Delete the node in the cache
func (*CachedBackend) WithContext ¶
func (c *CachedBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)
WithContext returns a graph matching the context, usually within time slice
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) GetFieldInt64 ¶
func (*Edge) GetFieldString ¶
GetFieldString returns the associated Field name
func (*Edge) GetFieldStringList ¶
func (*Edge) JSONRawMessage ¶
func (e *Edge) JSONRawMessage() *json.RawMessage
JSONRawMessage creates a JSON raw message
func (*Edge) MarshalJSON ¶
MarshalJSON serialize in JSON
func (*Edge) MatchMetadata ¶
type ElasticSearchBackend ¶
type ElasticSearchBackend struct { GraphBackend // contains filtered or unexported fields }
ElasticSearchBackend describes a presisent backend based on ElasticSearch
func NewElasticSearchBackend ¶
func NewElasticSearchBackend(addr string, port string, maxConns int, retrySeconds int, bulkMaxDocs int, bulkMaxDelay int) (*ElasticSearchBackend, error)
NewElasticSearchBackend creates a new graph backend and connect to an ElasticSearch database
func NewElasticSearchBackendFromConfig ¶
func NewElasticSearchBackendFromConfig() (*ElasticSearchBackend, error)
NewElasticSearchBackendFromConfig creates a new graph backend based on configuration file parameters
func (*ElasticSearchBackend) EdgeAdded ¶
func (b *ElasticSearchBackend) EdgeAdded(e *Edge) bool
EdgeAdded add an edge in the database
func (*ElasticSearchBackend) EdgeDeleted ¶
func (b *ElasticSearchBackend) EdgeDeleted(e *Edge) bool
EdgeDeleted delete an edge in the database
func (*ElasticSearchBackend) GetEdge ¶
func (b *ElasticSearchBackend) GetEdge(i Identifier, t *common.TimeSlice) []*Edge
GetEdge get an edge within a time slice
func (*ElasticSearchBackend) GetEdgeNodes ¶
func (b *ElasticSearchBackend) GetEdgeNodes(e *Edge, t *common.TimeSlice, parentMetadata, childMetadata Metadata) (parents []*Node, children []*Node)
GetEdgeNodes returns the parents and child nodes of an edge within time slice, matching metadatas
func (*ElasticSearchBackend) GetEdges ¶
func (b *ElasticSearchBackend) GetEdges(t *common.TimeSlice, m Metadata) []*Edge
GetEdges returns a list of edges within time slice, matching metadata
func (*ElasticSearchBackend) GetNode ¶
func (b *ElasticSearchBackend) GetNode(i Identifier, t *common.TimeSlice) []*Node
GetNode get a node within a time slice
func (*ElasticSearchBackend) GetNodeEdges ¶
func (b *ElasticSearchBackend) GetNodeEdges(n *Node, t *common.TimeSlice, m Metadata) (edges []*Edge)
GetNodeEdges returns a list of a node edges within time slice
func (*ElasticSearchBackend) GetNodes ¶
func (b *ElasticSearchBackend) GetNodes(t *common.TimeSlice, m Metadata) []*Node
GetNodes returns a list of nodes within time slice, matching metadata
func (*ElasticSearchBackend) MetadataUpdated ¶
func (b *ElasticSearchBackend) MetadataUpdated(i interface{}) bool
MetadataUpdated updates a node metadata in the database
func (*ElasticSearchBackend) NodeAdded ¶
func (b *ElasticSearchBackend) NodeAdded(n *Node) bool
NodeAdded add a node
func (*ElasticSearchBackend) NodeDeleted ¶
func (b *ElasticSearchBackend) NodeDeleted(n *Node) bool
NodeDeleted delete a node
func (*ElasticSearchBackend) Query ¶
func (b *ElasticSearchBackend) Query(obj string, tsq *TimedSearchQuery) (sr elastigo.SearchResult, _ error)
Query the database for a "node" or "edge"
func (*ElasticSearchBackend) SearchEdges ¶
func (b *ElasticSearchBackend) SearchEdges(tsq *TimedSearchQuery) (edges []*Edge)
SearchEdges search edges matching the query
func (*ElasticSearchBackend) SearchNodes ¶
func (b *ElasticSearchBackend) SearchNodes(tsq *TimedSearchQuery) (nodes []*Node)
SearchNodes search nodes matching the query
func (*ElasticSearchBackend) WithContext ¶
func (b *ElasticSearchBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)
WithContext step
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 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 NewGraphWithContext ¶
func NewGraphWithContext(hostID string, backend GraphBackend, context GraphContext) (*Graph, error)
NewGraphWithContext creates a new graph based on backedn within the context
func (*Graph) AddEventListener ¶
func (g *Graph) AddEventListener(l GraphEventListener)
AddEventListener subscibe a new graph listener
func (*Graph) AddMetadata ¶
AddMetadata add a metadata to an associated edge or node
func (*Graph) DelHostGraph ¶
DelHostGraph delete the associated node with the hostname host
func (*Graph) DelMetadata ¶
DelMetadata delete a metadata to an associated edge or node
func (*Graph) GetContext ¶
func (g *Graph) GetContext() GraphContext
GetContext returns the current context
func (*Graph) GetEdgeNodes ¶
GetEdgeNodes returns a list of nodes of an edge
func (*Graph) GetNodeEdges ¶
GetNodeEdges returns a list of edges of a node
func (*Graph) LookupChildren ¶
LookupChildren returns a list of children nodes
func (*Graph) LookupFirstChild ¶
LookupFirstChild returns the child
func (*Graph) LookupFirstNode ¶
LookupFirstNode returns the fist node matching metadata
func (*Graph) LookupParents ¶
LookupParents returns the associated parents edge of a node
func (*Graph) LookupShortestPath ¶
LookupShortestPath returns the shortest path (list of node)
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) RemoveEventListener ¶
func (g *Graph) RemoveEventListener(l GraphEventListener)
RemoveEventListener unsubscribe a graph listener
func (*Graph) SetMetadata ¶
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) WithContext ¶
func (g *Graph) WithContext(c GraphContext) (*Graph, error)
WithContext select a graph within a context
type GraphBackend ¶
type GraphBackend interface { NodeAdded(n *Node) bool NodeDeleted(n *Node) bool GetNode(i Identifier, at *common.TimeSlice) []*Node GetNodeEdges(n *Node, at *common.TimeSlice, m Metadata) []*Edge EdgeAdded(e *Edge) bool EdgeDeleted(e *Edge) bool GetEdge(i Identifier, at *common.TimeSlice) []*Edge GetEdgeNodes(e *Edge, at *common.TimeSlice, parentMetadata, childMetadata Metadata) ([]*Node, []*Node) MetadataUpdated(e interface{}) bool GetNodes(t *common.TimeSlice, m Metadata) []*Node GetEdges(t *common.TimeSlice, m Metadata) []*Edge WithContext(graph *Graph, context GraphContext) (*Graph, error) }
GraphBackend interface mechanism used as storage
func BackendFromConfig ¶
func BackendFromConfig() (backend GraphBackend, err error)
BackendFromConfig creates a new graph backend based on configuration memory, orientdb, elasticsearch backend are supported
type GraphContext ¶
GraphContext describes within time slice
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 HostNodeTIDMap ¶
HostNodeTIDMap a map of host and node ID
func BuildHostNodeTIDMap ¶
func BuildHostNodeTIDMap(nodes []*Node) HostNodeTIDMap
BuildHostNodeTIDMap creates a map filled with host and associated node.ID
type InterfaceMetric ¶
type InterfaceMetric struct { RxPackets int64 TxPackets int64 RxBytes int64 TxBytes int64 RxErrors int64 TxErrors int64 RxDropped int64 TxDropped int64 Multicast int64 Collisions int64 RxLengthErrors int64 RxOverErrors int64 RxCrcErrors int64 RxFrameErrors int64 RxFifoErrors int64 RxMissedErrors int64 TxAbortedErrors int64 TxCarrierErrors int64 TxFifoErrors int64 TxHeartbeatErrors int64 TxWindowErrors int64 RxCompressed int64 TxCompressed int64 }
InterfaceMetric the interface packets counters
func (*InterfaceMetric) Add ¶
func (im *InterfaceMetric) Add(m common.Metric) common.Metric
Add do a sum operation on interface metric
func (*InterfaceMetric) GetFieldInt64 ¶
func (im *InterfaceMetric) GetFieldInt64(field string) (int64, error)
GetFieldInt64 returns field by name
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 ¶
func (m *MemoryBackend) EdgeAdded(e *Edge) bool
EdgeAdded event add an edge in the memory backend
func (*MemoryBackend) EdgeDeleted ¶
func (m *MemoryBackend) EdgeDeleted(e *Edge) bool
EdgeDeleted in the graph backend
func (*MemoryBackend) GetEdge ¶
func (m *MemoryBackend) GetEdge(i Identifier, t *common.TimeSlice) []*Edge
GetEdge in the graph backend
func (*MemoryBackend) GetEdgeNodes ¶
func (m *MemoryBackend) GetEdgeNodes(e *Edge, t *common.TimeSlice, parentMetadata, childMetadata Metadata) ([]*Node, []*Node)
GetEdgeNodes returns a list of nodes of an edge
func (MemoryBackend) GetEdges ¶
func (m MemoryBackend) GetEdges(t *common.TimeSlice, metadata Metadata) (edges []*Edge)
GetEdges from the graph backend
func (*MemoryBackend) GetNode ¶
func (m *MemoryBackend) GetNode(i Identifier, t *common.TimeSlice) []*Node
GetNode from the graph backend
func (*MemoryBackend) GetNodeEdges ¶
GetNodeEdges returns a list of edges of a node
func (MemoryBackend) GetNodes ¶
func (m MemoryBackend) GetNodes(t *common.TimeSlice, metadata Metadata) (nodes []*Node)
GetNodes from the graph backend
func (*MemoryBackend) MetadataUpdated ¶
func (m *MemoryBackend) MetadataUpdated(i interface{}) bool
MetadataUpdated returns true
func (*MemoryBackend) NodeAdded ¶
func (m *MemoryBackend) NodeAdded(n *Node) bool
NodeAdded in the graph backend
func (*MemoryBackend) NodeDeleted ¶
func (m *MemoryBackend) NodeDeleted(n *Node) bool
NodeDeleted in the graph backend
func (*MemoryBackend) WithContext ¶
func (m *MemoryBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)
WithContext returns a graph based on context
type MemoryBackendEdge ¶
type MemoryBackendEdge struct {
*Edge
}
MemoryBackendEdge a memory backend edge
func (MemoryBackendEdge) GetFieldInt64 ¶
func (MemoryBackendEdge) GetFieldStringList ¶
func (MemoryBackendEdge) MatchMetadata ¶
type MemoryBackendNode ¶
type MemoryBackendNode struct { *Node // contains filtered or unexported fields }
MemoryBackendNode a memory backend node
func (MemoryBackendNode) GetFieldInt64 ¶
func (MemoryBackendNode) GetFieldString ¶
func (MemoryBackendNode) GetFieldStringList ¶
func (MemoryBackendNode) MatchMetadata ¶
type Metadata ¶
type Metadata map[string]interface{}
Metadata describes the graph node metadata type
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) GetFieldInt64 ¶
func (*Node) GetFieldString ¶
func (*Node) GetFieldStringList ¶
func (*Node) JSONRawMessage ¶
func (n *Node) JSONRawMessage() *json.RawMessage
JSONRawMessage creates JSON raw message
func (*Node) MarshalJSON ¶
MarshalJSON serialize in JSON
func (*Node) MatchMetadata ¶
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() (*OrientDBBackend, error)
NewOrientDBBackendFromConfig creates a new OrientDB database client based on configuration
func (*OrientDBBackend) EdgeAdded ¶
func (o *OrientDBBackend) EdgeAdded(e *Edge) bool
EdgeAdded add a node in the database
func (*OrientDBBackend) EdgeDeleted ¶
func (o *OrientDBBackend) EdgeDeleted(e *Edge) bool
EdgeDeleted delete a node in the database
func (*OrientDBBackend) GetEdge ¶
func (o *OrientDBBackend) GetEdge(i Identifier, t *common.TimeSlice) (edges []*Edge)
GetEdge get an edge within a time slice
func (*OrientDBBackend) GetEdgeNodes ¶
func (o *OrientDBBackend) GetEdgeNodes(e *Edge, t *common.TimeSlice, parentMetadata, childMetadata Metadata) (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 *common.TimeSlice, m Metadata) (edges []*Edge)
GetEdges returns a list of edges within time slice, matching metadata
func (*OrientDBBackend) GetNode ¶
func (o *OrientDBBackend) GetNode(i Identifier, t *common.TimeSlice) (nodes []*Node)
GetNode get a node within a time slice
func (*OrientDBBackend) GetNodeEdges ¶
GetNodeEdges returns a list of a node edges within time slice
func (*OrientDBBackend) GetNodes ¶
func (o *OrientDBBackend) GetNodes(t *common.TimeSlice, m Metadata) (nodes []*Node)
GetNodes returns a list of nodes within time slice, matching metadata
func (*OrientDBBackend) MetadataUpdated ¶
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 ¶
func (o *OrientDBBackend) NodeAdded(n *Node) bool
NodeAdded add a node in the database
func (*OrientDBBackend) NodeDeleted ¶
func (o *OrientDBBackend) NodeDeleted(n *Node) bool
NodeDeleted delete a node in the database
func (*OrientDBBackend) WithContext ¶
func (o *OrientDBBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)
WithContext step
type Server ¶
type Server struct { shttp.DefaultWSServerEventHandler WSServer *shttp.WSServer Graph *Graph // contains filtered or unexported fields }
Server describes a graph server based on websocket
func (*Server) AddEventHandler ¶
func (s *Server) AddEventHandler(h ServerEventHandler)
AddEventHandler subscribe a new graph server event handler
type ServerEventHandler ¶
type ServerEventHandler interface {
OnGraphMessage(c *shttp.WSClient, m shttp.WSMessage, msgType string, obj interface{})
}
ServerEventHandler interface event
type SyncReplyMsg ¶
SyncReplyMsg describes graph syncho message
type TimedSearchQuery ¶
type TimedSearchQuery struct { filters.SearchQuery TimeFilter *filters.Filter MetadataFilter *filters.Filter }
TimedSearchQuery describes a search query within a time slice and metadata filters