graph

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Direct int64 = iota
	Shadowed
)
View Source
const (
	Namespace = "Graph"
)

Variables

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

Functions

func UnmarshalWSMessage

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

Types

type DefaultGraphListener added in v0.3.0

type DefaultGraphListener struct {
}

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)

func (*DefaultGraphListener) OnEdgeDeleted added in v0.3.0

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

func (*DefaultGraphListener) OnEdgeUpdated added in v0.3.0

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

func (*DefaultGraphListener) OnNodeAdded added in v0.3.0

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

func (*DefaultGraphListener) OnNodeDeleted added in v0.3.0

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

func (*DefaultGraphListener) OnNodeUpdated added in v0.3.0

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

type Edge

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

func (*Edge) Decode added in v0.4.0

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

func (*Edge) GetChild added in v0.4.0

func (e *Edge) GetChild() Identifier

func (*Edge) GetParent added in v0.4.0

func (e *Edge) GetParent() Identifier

func (*Edge) Host added in v0.4.0

func (e *Edge) Host() string

func (*Edge) JsonRawMessage added in v0.4.0

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

func (*Edge) MarshalJSON

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

func (*Edge) MatchMetadata added in v0.4.0

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

func (*Edge) Metadata added in v0.2.0

func (e *Edge) Metadata() Metadata

func (*Edge) String

func (e *Edge) String() string

type ElasticSearchBackend added in v0.6.0

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

func NewElasticSearchBackend added in v0.6.0

func NewElasticSearchBackend(addr string, port string, maxConns int, retrySeconds int, bulkMaxDocs int) (*ElasticSearchBackend, error)

func NewElasticSearchBackendFromConfig added in v0.6.0

func NewElasticSearchBackendFromConfig() (*ElasticSearchBackend, error)

func (*ElasticSearchBackend) AddEdge added in v0.6.0

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

func (*ElasticSearchBackend) AddMetadata added in v0.6.0

func (b *ElasticSearchBackend) AddMetadata(i interface{}, k string, v interface{}) bool

func (*ElasticSearchBackend) AddNode added in v0.6.0

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

func (*ElasticSearchBackend) DelEdge added in v0.6.0

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

func (*ElasticSearchBackend) DelNode added in v0.6.0

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

func (*ElasticSearchBackend) GetEdge added in v0.6.0

func (b *ElasticSearchBackend) GetEdge(i Identifier, t *time.Time) *Edge

func (*ElasticSearchBackend) GetEdgeNodes added in v0.6.0

func (b *ElasticSearchBackend) GetEdgeNodes(e *Edge, t *time.Time) (*Node, *Node)

func (*ElasticSearchBackend) GetEdges added in v0.6.0

func (b *ElasticSearchBackend) GetEdges(t *time.Time, m Metadata) (edges []*Edge)

func (*ElasticSearchBackend) GetNode added in v0.6.0

func (b *ElasticSearchBackend) GetNode(i Identifier, t *time.Time) *Node

func (*ElasticSearchBackend) GetNodeEdges added in v0.6.0

func (b *ElasticSearchBackend) GetNodeEdges(n *Node, t *time.Time) (edges []*Edge)

func (*ElasticSearchBackend) GetNodes added in v0.6.0

func (b *ElasticSearchBackend) GetNodes(t *time.Time, m Metadata) (nodes []*Node)

func (*ElasticSearchBackend) SetMetadata added in v0.6.0

func (b *ElasticSearchBackend) SetMetadata(i interface{}, m Metadata) bool

func (*ElasticSearchBackend) WithContext added in v0.8.0

func (b *ElasticSearchBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)

type Forwarder

type Forwarder struct {
	shttp.DefaultWSClientEventHandler
	Client *shttp.WSAsyncClient
	Graph  *Graph
	Host   string
}

func NewForwarder

func NewForwarder(c *shttp.WSAsyncClient, g *Graph, host string) *Forwarder

func (*Forwarder) OnConnected

func (c *Forwarder) OnConnected()

func (*Forwarder) OnEdgeAdded

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

func (*Forwarder) OnEdgeDeleted

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

func (*Forwarder) OnEdgeUpdated

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

func (*Forwarder) OnNodeAdded

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

func (*Forwarder) OnNodeDeleted

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

func (*Forwarder) OnNodeUpdated

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

type Graph

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

func NewGraph

func NewGraph(hostID string, backend GraphBackend) *Graph

func NewGraphFromConfig added in v0.4.0

func NewGraphFromConfig(backend GraphBackend) *Graph

func NewGraphWithContext added in v0.4.0

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

func (*Graph) AddEdge

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

func (*Graph) AddEventListener

func (g *Graph) AddEventListener(l GraphEventListener)

func (*Graph) AddMetadata added in v0.2.0

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

func (*Graph) AddNode

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

func (*Graph) AreLinked

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

func (*Graph) DelEdge

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

func (*Graph) DelHostGraph added in v0.7.0

func (g *Graph) DelHostGraph(host string)

func (*Graph) DelNode

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

func (*Graph) GetContext added in v0.4.0

func (g *Graph) GetContext() GraphContext

func (*Graph) GetEdge

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

func (*Graph) GetEdgeNodes added in v0.3.0

func (g *Graph) GetEdgeNodes(e *Edge) (*Node, *Node)

func (*Graph) GetEdges

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

func (*Graph) GetNode

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

func (*Graph) GetNodeEdges added in v0.4.0

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

func (*Graph) GetNodes

func (g *Graph) GetNodes(m Metadata) []*Node
func (g *Graph) Link(n1 *Node, n2 *Node, m ...Metadata) *Edge

func (*Graph) LookupChildren

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

func (*Graph) LookupEdges added in v0.8.0

func (g *Graph) LookupEdges(pm Metadata, cm Metadata, em Metadata) []*Edge

func (*Graph) LookupFirstChild added in v0.2.0

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

func (*Graph) LookupFirstNode

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

func (*Graph) LookupNodesFromKey

func (g *Graph) LookupNodesFromKey(key string) []*Node

func (*Graph) LookupParents added in v0.6.0

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

func (*Graph) LookupShortestPath added in v0.3.0

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

func (*Graph) MarshalJSON

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

func (*Graph) NewEdge

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

func (*Graph) NewNode

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

func (*Graph) NotifyEdgeAdded

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

func (*Graph) NotifyEdgeDeleted

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

func (*Graph) NotifyEdgeUpdated

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

func (*Graph) NotifyNodeAdded

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

func (*Graph) NotifyNodeDeleted

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

func (*Graph) NotifyNodeUpdated

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

func (*Graph) RemoveEventListener added in v0.3.0

func (g *Graph) RemoveEventListener(l GraphEventListener)

func (*Graph) Replace

func (g *Graph) Replace(o *Node, n *Node) *Node

func (*Graph) SetMetadata

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

func (*Graph) StartMetadataTransaction added in v0.3.0

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

func (*Graph) String

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

func (*Graph) WithContext added in v0.4.0

func (g *Graph) WithContext(c GraphContext) (*Graph, error)

type GraphBackend

type GraphBackend interface {
	AddNode(n *Node) bool
	DelNode(n *Node) bool
	GetNode(i Identifier, at *time.Time) *Node
	GetNodeEdges(n *Node, at *time.Time) []*Edge

	AddEdge(e *Edge) bool
	DelEdge(e *Edge) bool
	GetEdge(i Identifier, at *time.Time) *Edge
	GetEdgeNodes(e *Edge, at *time.Time) (*Node, *Node)

	AddMetadata(e interface{}, k string, v interface{}) bool
	SetMetadata(e interface{}, m Metadata) bool

	GetNodes(at *time.Time, m Metadata) []*Node
	GetEdges(at *time.Time, m Metadata) []*Edge

	WithContext(graph *Graph, context GraphContext) (*Graph, error)
}

func BackendFromConfig

func BackendFromConfig() (backend GraphBackend, err error)

type GraphContext added in v0.4.0

type GraphContext struct {
	Time *time.Time
}

func (*GraphContext) GetTime added in v0.4.0

func (c *GraphContext) GetTime() *time.Time

type GraphEventListener

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

type GraphServer added in v0.4.0

type GraphServer struct {
	shttp.DefaultWSServerEventHandler
	WSServer *shttp.WSServer
	Graph    *Graph
}

func NewServer

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

func (*GraphServer) OnEdgeAdded added in v0.4.0

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

func (*GraphServer) OnEdgeDeleted added in v0.4.0

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

func (*GraphServer) OnEdgeUpdated added in v0.4.0

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

func (*GraphServer) OnMessage added in v0.4.0

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

func (*GraphServer) OnNodeAdded added in v0.4.0

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

func (*GraphServer) OnNodeDeleted added in v0.4.0

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

func (*GraphServer) OnNodeUpdated added in v0.4.0

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

type GremlinBackend

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

func NewGremlinBackend

func NewGremlinBackend(endpoint string) (*GremlinBackend, error)

func (GremlinBackend) AddEdge

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

func (GremlinBackend) AddMetadata added in v0.2.0

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

func (GremlinBackend) AddNode

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

func (GremlinBackend) DelEdge

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

func (GremlinBackend) DelNode

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

func (GremlinBackend) GetEdge

func (g GremlinBackend) GetEdge(i Identifier, t *time.Time) *Edge

func (GremlinBackend) GetEdgeNodes

func (g GremlinBackend) GetEdgeNodes(e *Edge, t *time.Time) (*Node, *Node)

func (GremlinBackend) GetEdges

func (g GremlinBackend) GetEdges(t *time.Time, m Metadata) []*Edge

func (GremlinBackend) GetNode

func (g GremlinBackend) GetNode(i Identifier, t *time.Time) *Node

func (GremlinBackend) GetNodeEdges

func (g GremlinBackend) GetNodeEdges(n *Node, t *time.Time) []*Edge

func (GremlinBackend) GetNodes

func (g GremlinBackend) GetNodes(t *time.Time, m Metadata) []*Node

func (GremlinBackend) SetMetadata

func (g GremlinBackend) SetMetadata(i interface{}, meta Metadata) bool

func (GremlinBackend) WithContext added in v0.8.0

func (g GremlinBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)

type HostNodeIDMap added in v0.8.0

type HostNodeIDMap map[string][]string

func BuildHostNodeMap added in v0.8.0

func BuildHostNodeMap(nodes []*Node) HostNodeIDMap

type Identifier

type Identifier string

func GenID

func GenID() Identifier

type MemoryBackend

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

func NewMemoryBackend

func NewMemoryBackend() (*MemoryBackend, error)

func (MemoryBackend) AddEdge

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

func (MemoryBackend) AddMetadata added in v0.2.0

func (m MemoryBackend) AddMetadata(i interface{}, k string, v interface{}) bool

func (MemoryBackend) AddNode

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

func (MemoryBackend) DelEdge

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

func (MemoryBackend) DelNode

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

func (MemoryBackend) GetEdge

func (m MemoryBackend) GetEdge(i Identifier, t *time.Time) *Edge

func (MemoryBackend) GetEdgeNodes

func (m MemoryBackend) GetEdgeNodes(e *Edge, t *time.Time) (*Node, *Node)

func (MemoryBackend) GetEdges

func (m MemoryBackend) GetEdges(t *time.Time, metadata Metadata) []*Edge

func (MemoryBackend) GetNode

func (m MemoryBackend) GetNode(i Identifier, t *time.Time) *Node

func (MemoryBackend) GetNodeEdges

func (m MemoryBackend) GetNodeEdges(n *Node, t *time.Time) []*Edge

func (MemoryBackend) GetNodes

func (m MemoryBackend) GetNodes(t *time.Time, metadata Metadata) []*Node

func (MemoryBackend) SetMetadata

func (m MemoryBackend) SetMetadata(i interface{}, meta Metadata) bool

func (MemoryBackend) WithContext added in v0.8.0

func (m MemoryBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)

type MemoryBackendEdge

type MemoryBackendEdge struct {
	*Edge
}

func (MemoryBackendEdge) Host added in v0.4.0

func (e MemoryBackendEdge) Host() string

func (MemoryBackendEdge) MatchMetadata added in v0.4.0

func (e MemoryBackendEdge) MatchMetadata(f Metadata) bool

func (MemoryBackendEdge) Metadata added in v0.2.0

func (e MemoryBackendEdge) Metadata() Metadata

func (MemoryBackendEdge) String

func (e MemoryBackendEdge) String() string

type MemoryBackendNode

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

func (MemoryBackendNode) Host added in v0.4.0

func (e MemoryBackendNode) Host() string

func (MemoryBackendNode) MatchMetadata added in v0.4.0

func (e MemoryBackendNode) MatchMetadata(f Metadata) bool

func (MemoryBackendNode) Metadata added in v0.2.0

func (e MemoryBackendNode) Metadata() Metadata

func (MemoryBackendNode) String

func (e MemoryBackendNode) String() string

type Metadata added in v0.2.0

type Metadata map[string]interface{}

func (*Metadata) String added in v0.2.0

func (m *Metadata) String() string

type MetadataMatcher added in v0.4.0

type MetadataMatcher interface {
	Match(v interface{}) bool
}

type MetadataTransaction added in v0.3.0

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

func (*MetadataTransaction) AddMetadata added in v0.3.0

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

func (*MetadataTransaction) Commit added in v0.3.0

func (t *MetadataTransaction) Commit()

type Node

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

func (*Node) Decode added in v0.4.0

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

func (*Node) Host added in v0.4.0

func (e *Node) Host() string

func (*Node) JsonRawMessage added in v0.4.0

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

func (*Node) MarshalJSON

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

func (*Node) MatchMetadata added in v0.4.0

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

func (*Node) Metadata added in v0.2.0

func (e *Node) Metadata() Metadata

func (*Node) String

func (e *Node) String() string

type OrientDBBackend added in v0.4.0

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

func NewOrientDBBackend added in v0.4.0

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

func NewOrientDBBackendFromConfig added in v0.4.0

func NewOrientDBBackendFromConfig() (*OrientDBBackend, error)

func (*OrientDBBackend) AddEdge added in v0.4.0

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

func (*OrientDBBackend) AddMetadata added in v0.4.0

func (o *OrientDBBackend) AddMetadata(i interface{}, k string, v interface{}) bool

func (*OrientDBBackend) AddNode added in v0.4.0

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

func (*OrientDBBackend) DelEdge added in v0.4.0

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

func (*OrientDBBackend) DelNode added in v0.4.0

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

func (*OrientDBBackend) GetEdge added in v0.4.0

func (o *OrientDBBackend) GetEdge(i Identifier, t *time.Time) *Edge

func (*OrientDBBackend) GetEdgeNodes added in v0.4.0

func (o *OrientDBBackend) GetEdgeNodes(e *Edge, t *time.Time) (n1 *Node, n2 *Node)

func (*OrientDBBackend) GetEdges added in v0.4.0

func (o *OrientDBBackend) GetEdges(t *time.Time, m Metadata) (edges []*Edge)

func (*OrientDBBackend) GetNode added in v0.4.0

func (o *OrientDBBackend) GetNode(i Identifier, t *time.Time) *Node

func (*OrientDBBackend) GetNodeEdges added in v0.4.0

func (o *OrientDBBackend) GetNodeEdges(n *Node, t *time.Time) (edges []*Edge)

func (*OrientDBBackend) GetNodes added in v0.4.0

func (o *OrientDBBackend) GetNodes(t *time.Time, m Metadata) (nodes []*Node)

func (*OrientDBBackend) SetMetadata added in v0.4.0

func (o *OrientDBBackend) SetMetadata(i interface{}, m Metadata) bool

func (*OrientDBBackend) WithContext added in v0.8.0

func (o *OrientDBBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)

type ShadowedBackend added in v0.6.0

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

func NewShadowedBackend added in v0.6.0

func NewShadowedBackend(persistent GraphBackend) (*ShadowedBackend, error)

func (*ShadowedBackend) AddEdge added in v0.6.0

func (c *ShadowedBackend) AddEdge(e *Edge) bool

func (*ShadowedBackend) AddMetadata added in v0.6.0

func (c *ShadowedBackend) AddMetadata(i interface{}, k string, v interface{}) bool

func (*ShadowedBackend) AddNode added in v0.6.0

func (c *ShadowedBackend) AddNode(n *Node) bool

func (*ShadowedBackend) DelEdge added in v0.6.0

func (c *ShadowedBackend) DelEdge(e *Edge) bool

func (*ShadowedBackend) DelNode added in v0.6.0

func (c *ShadowedBackend) DelNode(n *Node) bool

func (*ShadowedBackend) GetEdge added in v0.6.0

func (c *ShadowedBackend) GetEdge(i Identifier, t *time.Time) *Edge

func (*ShadowedBackend) GetEdgeNodes added in v0.6.0

func (c *ShadowedBackend) GetEdgeNodes(e *Edge, t *time.Time) (*Node, *Node)

func (*ShadowedBackend) GetEdges added in v0.6.0

func (c *ShadowedBackend) GetEdges(t *time.Time, m Metadata) []*Edge

func (*ShadowedBackend) GetNode added in v0.6.0

func (c *ShadowedBackend) GetNode(i Identifier, t *time.Time) *Node

func (*ShadowedBackend) GetNodeEdges added in v0.6.0

func (c *ShadowedBackend) GetNodeEdges(n *Node, t *time.Time) (edges []*Edge)

func (*ShadowedBackend) GetNodes added in v0.6.0

func (c *ShadowedBackend) GetNodes(t *time.Time, m Metadata) []*Node

func (*ShadowedBackend) SetMetadata added in v0.6.0

func (c *ShadowedBackend) SetMetadata(i interface{}, metadata Metadata) bool

func (*ShadowedBackend) WithContext added in v0.8.0

func (c *ShadowedBackend) WithContext(graph *Graph, context GraphContext) (*Graph, error)

type TitangraphBackend added in v0.3.0

type TitangraphBackend struct {
	GremlinBackend
}

func NewTitangraphBackend added in v0.3.0

func NewTitangraphBackend(endpoint string) (*TitangraphBackend, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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