node

package
v0.0.0-...-02c76fb Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 3 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMetadataNotUnique = errors.New("metadata field is non-unique")

ErrMetadataNotUnique indicates that the user attempted to overwrite a node metadata field.

Functions

This section is empty.

Types

type Groupable

type Groupable interface {
	Group() string
}

Groupable returns a group

type Node

type Node struct {
	ID    string `json:"id"`
	Group string `json:"group"`
	// contains filtered or unexported fields
}

Node tracks the metadata associated with a node in the graph

func New

func New(id string, value interface{}) *Node

New creates a new node

func (*Node) AddMetadata

func (n *Node) AddMetadata(key string, value interface{}) error

AddMetadata will allow you to add metadata to the node. If the key already exists it will return ErrMetadataNotUnique to ensure immutability

func (*Node) LookupMetadata

func (n *Node) LookupMetadata(key string) (interface{}, bool)

LookupMetadata extracts a metdatadata field from the node. If the value is found, it returns (value, true), and (nil, false) otherwise.

func (*Node) ShowMetadata

func (n *Node) ShowMetadata() string

ShowMetadata will print out the existing metadata. Used for debugging

func (*Node) Value

func (n *Node) Value() interface{}

Value gets the inner value of this node

func (*Node) WithValue

func (n *Node) WithValue(value interface{}) *Node

WithValue returns a copy of the node with the new value set

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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