graph

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: Apache-2.0 Imports: 15 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

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 ElasticSearchBackend added in v0.9.0

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

func NewElasticSearchBackend added in v0.9.0

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

func NewElasticSearchBackendFromConfig added in v0.9.0

func NewElasticSearchBackendFromConfig() (*ElasticSearchBackend, error)

func (*ElasticSearchBackend) AddEdge added in v0.9.0

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

func (*ElasticSearchBackend) AddMetadata added in v0.9.0

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

func (*ElasticSearchBackend) AddNode added in v0.9.0

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

func (*ElasticSearchBackend) DelEdge added in v0.9.0

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

func (*ElasticSearchBackend) DelNode added in v0.9.0

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

func (*ElasticSearchBackend) GetEdge added in v0.9.0

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

func (*ElasticSearchBackend) GetEdgeNodes added in v0.9.0

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

func (*ElasticSearchBackend) GetEdges added in v0.9.0

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

func (*ElasticSearchBackend) GetNode added in v0.9.0

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

func (*ElasticSearchBackend) GetNodeEdges added in v0.9.0

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

func (*ElasticSearchBackend) GetNodes added in v0.9.0

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

func (*ElasticSearchBackend) SetMetadata added in v0.9.0

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

func (*ElasticSearchBackend) WithContext added in v0.9.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

func NewGraphFromConfig(backend GraphBackend) *Graph

func NewGraphWithContext

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

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.9.0

func (g *Graph) DelHostGraph(host string)

func (*Graph) DelNode

func (g *Graph) DelNode(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(m Metadata) []*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(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.9.0

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

func (*Graph) LookupFirstChild

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.9.0

func (g *Graph) LookupParents(n *Node, f Metadata, em ...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, h ...string) *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, 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

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)

func (*GraphServer) OnUnregisterClient added in v0.9.0

func (s *GraphServer) OnUnregisterClient(c *shttp.WSClient)

type HostNodeTIDMap added in v0.9.0

type HostNodeTIDMap map[string][]string

func BuildHostNodeTIDMap added in v0.9.0

func BuildHostNodeTIDMap(nodes []*Node) HostNodeTIDMap

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, 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.9.0

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

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

func (*OrientDBBackend) SetMetadata

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

func (*OrientDBBackend) WithContext added in v0.9.0

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

type ShadowedBackend added in v0.9.0

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

func NewShadowedBackend added in v0.9.0

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

func (*ShadowedBackend) AddEdge added in v0.9.0

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

func (*ShadowedBackend) AddMetadata added in v0.9.0

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

func (*ShadowedBackend) AddNode added in v0.9.0

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

func (*ShadowedBackend) DelEdge added in v0.9.0

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

func (*ShadowedBackend) DelNode added in v0.9.0

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

func (*ShadowedBackend) GetEdge added in v0.9.0

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

func (*ShadowedBackend) GetEdgeNodes added in v0.9.0

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

func (*ShadowedBackend) GetEdges added in v0.9.0

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

func (*ShadowedBackend) GetNode added in v0.9.0

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

func (*ShadowedBackend) GetNodeEdges added in v0.9.0

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

func (*ShadowedBackend) GetNodes added in v0.9.0

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

func (*ShadowedBackend) SetMetadata added in v0.9.0

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

func (*ShadowedBackend) WithContext added in v0.9.0

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

Source Files

  • elasticsearch.go
  • forwarder.go
  • graph.go
  • memory.go
  • orientdb.go
  • server.go
  • shadowedbackend.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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