graph

package
v0.0.0-...-5b448de Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2017 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 (
	SyncRequestMsgType      = "SyncRequest"
	SyncReplyMsgType        = "SyncReply"
	HostGraphDeletedMsgType = "HostGraphDeleted"
	NodeUpdatedMsgType      = "NodeUpdated"
	NodeDeletedMsgType      = "NodeDeleted"
	NodeAddedMsgType        = "NodeAdded"
	EdgeUpdatedMsgType      = "EdgeUpdated"
	EdgeDeletedMsgType      = "EdgeDeleted"
	EdgeAddedMsgType        = "EdgeAdded"
)

Graph message type

View Source
const (
	Namespace = "Graph"
)

Namespace websocket message : Graph

Variables

View Source
var (
	ErrSyncRequestMalFormed  = errors.New("SyncRequestMsg malformed")
	ErrSyncReplyMsgMalFormed = errors.New("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

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

NewFilterForEdge creates a filter based on parent or child

func NewFilterForMetadata

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

NewFilterForMetadata creates a new filter based on metadata

func NewFilterForTime

func NewFilterForTime(t time.Time) *filters.Filter

NewFilterForTime creates a filter including time slice t

func NewFilterForTimeSlice

func NewFilterForTimeSlice(t *common.TimeSlice) *filters.Filter

NewFilterForTimeSlice creates a filter based on a time slice between CreatedAt and DeletedAt time.Now() is used as reference if t == nil

func UnmarshalWSMessage

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

UnmarshalWSMessage deserialize the websocket message

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

func (c *CachedBackend) GetNodeEdges(n *Node, t *common.TimeSlice, m Metadata) (edges []*Edge)

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) SetMode

func (c *CachedBackend) SetMode(mode int)

SetMode set cache mode

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) 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

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

func (*Edge) GetFieldInt64

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

func (*Edge) GetFieldString

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

GetFieldString returns the associated Field name

func (*Edge) GetFieldStringList

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

func (*Edge) GetParent

func (e *Edge) GetParent() Identifier

GetParent returns parent

func (*Edge) Host

func (e *Edge) Host() string

func (*Edge) JSONRawMessage

func (e *Edge) JSONRawMessage() *json.RawMessage

JSONRawMessage creates a JSON raw message

func (*Edge) MarshalJSON

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

MarshalJSON serialize in JSON

func (*Edge) MatchMetadata

func (e *Edge) MatchMetadata(f Metadata) 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

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

type Graph struct {
	sync.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 NewGraphWithContext

func NewGraphWithContext(hostID string, backend GraphBackend, context GraphContext) (*Graph, error)

NewGraphWithContext creates a new graph based on backedn within the context

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 Metadata) bool

AreLinked returns true if nodes n1, n2 are linked

func (*Graph) DelEdge

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

DelEdge delete an edge

func (*Graph) DelHostGraph

func (g *Graph) DelHostGraph(host string)

DelHostGraph delete the associated node with the hostname host

func (*Graph) DelMetadata

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)

DelNode delete the node n in the graph

func (*Graph) EdgeAdded

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

EdgeAdded add an edge

func (*Graph) EdgeDeleted

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

EdgeDeleted event

func (*Graph) EdgeUpdated

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 Metadata) ([]*Node, []*Node)

GetEdgeNodes returns a list of nodes of an edge

func (*Graph) GetEdges

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

GetEdges returns a list of edges

func (*Graph) GetHost

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 Metadata) []*Edge

GetNodeEdges returns a list of edges of a node

func (*Graph) GetNodes

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

GetNodes returns a list of nodes

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

Link the nodes n1, n2 with a new edge

func (*Graph) LookupChildren

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

LookupChildren returns a list of children nodes

func (*Graph) LookupFirstChild

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

LookupFirstChild returns the child

func (*Graph) LookupFirstNode

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

LookupFirstNode returns the fist node matching metadata

func (*Graph) LookupParents

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

LookupParents returns the associated parents edge of a node

func (*Graph) LookupShortestPath

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

LookupShortestPath returns the shortest path (list of node)

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) *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

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

NodeAdded in the graph

func (*Graph) NodeDeleted

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

NodeDeleted event

func (*Graph) NodeUpdated

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

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

type GraphContext struct {
	TimeSlice *common.TimeSlice
}

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

type HostNodeTIDMap map[string][]string

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 Identifier

type Identifier string

Identifier graph ID

func GenID

func GenID() Identifier

GenID helper generate a node Identifier

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

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

func (m *MemoryBackend) GetNodeEdges(n *Node, t *common.TimeSlice, meta Metadata) []*Edge

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) GetField

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

func (MemoryBackendEdge) GetFieldInt64

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

func (MemoryBackendEdge) GetFieldStringList

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

func (MemoryBackendEdge) Host

func (e MemoryBackendEdge) Host() string

func (MemoryBackendEdge) MatchMetadata

func (e MemoryBackendEdge) MatchMetadata(f Metadata) 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

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

func (MemoryBackendNode) GetFieldInt64

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

func (MemoryBackendNode) GetFieldString

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

func (MemoryBackendNode) GetFieldStringList

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

func (MemoryBackendNode) Host

func (e MemoryBackendNode) Host() string

func (MemoryBackendNode) MatchMetadata

func (e MemoryBackendNode) MatchMetadata(f Metadata) 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

func (Metadata) Clone

func (m Metadata) Clone() Metadata

Clone a metadata

func (*Metadata) String

func (m *Metadata) String() string

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

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

func (*Node) GetFieldInt64

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

func (*Node) GetFieldString

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

func (*Node) GetFieldStringList

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

func (*Node) Host

func (e *Node) Host() string

func (*Node) JSONRawMessage

func (n *Node) JSONRawMessage() *json.RawMessage

JSONRawMessage creates JSON raw message

func (*Node) MarshalJSON

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

MarshalJSON serialize in JSON

func (*Node) MatchMetadata

func (e *Node) MatchMetadata(f Metadata) 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 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

func (o *OrientDBBackend) GetNodeEdges(n *Node, t *common.TimeSlice, m Metadata) (edges []*Edge)

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 NewServer

func NewServer(g *Graph, server *shttp.WSServer) *Server

NewServer creates a new graph server based on a websocket server

func (*Server) AddEventHandler

func (s *Server) AddEventHandler(h ServerEventHandler)

AddEventHandler subscribe a new graph server event handler

func (*Server) OnEdgeAdded

func (s *Server) OnEdgeAdded(e *Edge)

OnEdgeAdded event

func (*Server) OnEdgeDeleted

func (s *Server) OnEdgeDeleted(e *Edge)

OnEdgeDeleted event

func (*Server) OnEdgeUpdated

func (s *Server) OnEdgeUpdated(e *Edge)

OnEdgeUpdated event

func (*Server) OnMessage

func (s *Server) OnMessage(c *shttp.WSClient, msg shttp.WSMessage)

OnMessage event

func (*Server) OnNodeAdded

func (s *Server) OnNodeAdded(n *Node)

OnNodeAdded event

func (*Server) OnNodeDeleted

func (s *Server) OnNodeDeleted(n *Node)

OnNodeDeleted event

func (*Server) OnNodeUpdated

func (s *Server) OnNodeUpdated(n *Node)

OnNodeUpdated event

type ServerEventHandler

type ServerEventHandler interface {
	OnGraphMessage(c *shttp.WSClient, m shttp.WSMessage, msgType string, obj interface{})
}

ServerEventHandler interface event

type SyncReplyMsg

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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