graph

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Namespace = "Graph"
)

Variables

This section is empty.

Functions

func UnmarshalWSMessage

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

Types

type DefaultGraphListener

type DefaultGraphListener struct {
}

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)

func (*DefaultGraphListener) OnEdgeDeleted

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

func (*DefaultGraphListener) OnEdgeUpdated

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

func (*DefaultGraphListener) OnNodeAdded

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

func (*DefaultGraphListener) OnNodeDeleted

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

func (*DefaultGraphListener) OnNodeUpdated

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

type Edge

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

func (*Edge) Decode

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

func (*Edge) GetChild

func (e *Edge) GetChild() Identifier

func (*Edge) GetParent

func (e *Edge) GetParent() Identifier

func (*Edge) Host

func (e *Edge) Host() string

func (*Edge) JsonRawMessage

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

func (*Edge) MarshalJSON

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

func (*Edge) MatchMetadata

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

func (*Edge) Metadata

func (e *Edge) Metadata() Metadata

func (*Edge) String

func (e *Edge) String() string

type Forwarder

type Forwarder struct {
	shttp.DefaultWSClientEventHandler
	Client *shttp.WSAsyncClient
	Graph  *Graph
	Root   *Node
}

func NewForwarder

func NewForwarder(c *shttp.WSAsyncClient, g *Graph, root *Node) *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, error)

func NewGraphFromConfig

func NewGraphFromConfig(backend GraphBackend) (*Graph, error)

func NewGraphWithContext

func NewGraphWithContext(hostID string, b GraphBackend, c 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

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

func (*Graph) DelEdge

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

func (*Graph) DelNode

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

func (*Graph) DelSubGraph

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

func (*Graph) GetContext

func (g *Graph) GetContext() GraphContext

func (*Graph) GetEdge

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

func (*Graph) GetEdgeNodes

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

func (*Graph) GetEdges

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

func (*Graph) GetNode

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

func (*Graph) GetNodeEdges

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

func (*Graph) GetNodes

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

func (*Graph) LookupChildren

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

func (*Graph) LookupFirstChild

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

func (*Graph) LookupFirstNode

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

func (*Graph) LookupNodes

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

func (*Graph) LookupNodesFromKey

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

func (*Graph) LookupParentNodes

func (g *Graph) LookupParentNodes(n *Node, f Metadata) []*Node

func (*Graph) LookupShortestPath

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

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

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

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

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) []*Node
	GetEdges(at time.Time) []*Edge
}

func BackendFromConfig

func BackendFromConfig() (GraphBackend, error)

type GraphContext

type GraphContext struct {
	Time *time.Time
}

func (*GraphContext) GetTime

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

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

func NewServer

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

func (*GraphServer) OnEdgeAdded

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

func (*GraphServer) OnEdgeDeleted

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

func (*GraphServer) OnEdgeUpdated

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

func (*GraphServer) OnMessage

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

func (*GraphServer) OnNodeAdded

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

func (*GraphServer) OnNodeDeleted

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

func (*GraphServer) OnNodeUpdated

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

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

func (GremlinBackend) SetMetadata

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

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

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

func (MemoryBackend) SetMetadata

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

type MemoryBackendEdge

type MemoryBackendEdge struct {
	*Edge
}

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

func (MemoryBackendEdge) String

func (e MemoryBackendEdge) String() string

type MemoryBackendNode

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

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

func (MemoryBackendNode) String

func (e MemoryBackendNode) String() string

type Metadata

type Metadata map[string]interface{}

func (*Metadata) String

func (m *Metadata) String() string

type MetadataMatcher

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

type MetadataTransaction

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

func (*MetadataTransaction) AddMetadata

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

func (*MetadataTransaction) Commit

func (t *MetadataTransaction) Commit()

type Node

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

func (*Node) Decode

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

func (*Node) Host

func (e *Node) Host() string

func (*Node) JsonRawMessage

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

func (*Node) MarshalJSON

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

func (*Node) MatchMetadata

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

func (*Node) Metadata

func (e *Node) Metadata() Metadata

func (*Node) String

func (e *Node) String() string

type OrientDBBackend

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

func NewOrientDBBackend

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

func NewOrientDBBackendFromConfig

func NewOrientDBBackendFromConfig() (*OrientDBBackend, error)

func (*OrientDBBackend) AddEdge

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

func (*OrientDBBackend) AddMetadata

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

func (*OrientDBBackend) AddNode

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

func (*OrientDBBackend) DelEdge

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

func (*OrientDBBackend) DelNode

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

func (*OrientDBBackend) GetEdge

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

func (*OrientDBBackend) GetEdgeNodes

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

func (*OrientDBBackend) GetEdges

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

func (*OrientDBBackend) GetNode

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

func (*OrientDBBackend) GetNodeEdges

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

func (*OrientDBBackend) GetNodes

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

func (*OrientDBBackend) SetMetadata

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

type TitangraphBackend

type TitangraphBackend struct {
	GremlinBackend
}

func NewTitangraphBackend

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

Source Files

  • forwarder.go
  • graph.go
  • gremlin.go
  • memory.go
  • orientdb.go
  • server.go
  • titangraph.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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