graph

package
v0.0.0-...-056695e Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EINTERNAL       = "internal"
	EINVALID        = "invalid"
	ENOTFOUND       = "not_found"
	ENOTIMPLEMENTED = "not_implemented"
	EUNSUPPORTED    = "unsupported"
)

Application error codes.

NOTE: These are meant to be generic and they map well to HTTP error codes. Different applications can have very different error code requirements so these should be expanded as needed (or introduce subcodes).

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) string

ErrorCode unwraps an application error and returns its code. Non-application errors always return EINTERNAL.

func ErrorMessage

func ErrorMessage(err error) string

ErrorMessage unwraps an application error and returns its message. Non-application errors always return "Internal error".

Types

type Adder

type Adder interface {
	Graph
	graph.NodeAdder
	graph.WeightedEdgeAdder
}

Adder allows to add edges and nodes to graph.

type Builder

type Builder interface {
	// Build graph by adding nodes and edges from the data
	// received on the given channel.
	Build(context.Context, <-chan interface{}) error
}

Builder builds a graph.

type DOTEdge

type DOTEdge interface {
	Edge
	encoding.Attributer
}

DOTEdge is Graphviz DOT edge.

type DOTNode

type DOTNode interface {
	Node
	encoding.Attributer
	// DOTID returns DOT ID.
	DOTID() string
	// SetDOTID sets DOT ID.
	SetDOTID(dotid string)
}

DOTNode is Graphviz DOT node.

type Edge

type Edge interface {
	graph.WeightedEdge
	// UID returns edge UID.
	UID() string
	// Label returns edge label.
	Label() string
	// Attrs returns node attributes.
	Attrs() map[string]interface{}
}

Edge is a graph edge.

type EdgeUpdater

type EdgeUpdater interface {
	Graph
	graph.WeightedEdgeAdder
	graph.EdgeRemover
}

EdgeUpdater adds and removes edges.

type Error

type Error struct {
	// Machine-readable error code.
	Code string
	// Human-readable error message.
	Message string
}

Error represents an application-specific error. Application errors can be unwrapped by the caller to extract out the code & message.

Any non-application error (such as a disk error) should be reported as an EINTERNAL error and the human user should only see "Internal error" as the message. These low-level internal error details should only be logged and reported to the operator of the application (not the end user).

func Errorf

func Errorf(code string, format string, args ...interface{}) *Error

Errorf is a helper function to return an Error with a given code and formatted message.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

type Graph

type Graph interface {
	graph.Weighted
	// UID returns graph UID.
	UID() string
	// Edges returns graph edges iterator.
	Edges() graph.Edges
	// Type returns the type of graph.
	Type() string
	// Label returns graph label.
	Label() string
	// Attrs are graph attributes.
	Attrs() map[string]interface{}
}

Graph is weighted graph.

type LabelSetter

type LabelSetter interface {
	SetLabel(string)
}

LabelSetter sets label.

type Marshaler

type Marshaler interface {
	// Marshal marshals graph into bytes.
	Marshal(g Graph) ([]byte, error)
}

Marshaler is used for marshaling graphs.

type Node

type Node interface {
	graph.Node
	// UID returns node UID.
	UID() string
	// Label returns node label.
	Label() string
	// Attrs returns node attributes.
	Attrs() map[string]interface{}
}

Node is a graph node.

type NodeUpdater

type NodeUpdater interface {
	Graph
	graph.NodeAdder
	graph.NodeRemover
}

NodeUpdater adds and removes nodes.

type Remover

type Remover interface {
	Graph
	graph.NodeRemover
	graph.EdgeRemover
}

Remover allows to remove nodes and edges from graph.

type Styler

type Styler interface {
	// Type returns the type of style.
	Type() string
	// Shape returns style shape.
	Shape() string
	// Color returns style color.
	Color() color.RGBA
}

Styler is used for styling.

type UIDSetter

type UIDSetter interface {
	SetUID(string)
}

UIDSetter sets UID.

type Unmarshaler

type Unmarshaler interface {
	// Unmarshal unmarshals arbitrary bytes into graph.
	Unmarshal([]byte, Graph) error
}

Unmarshaler is used for unmarshaling graphs.

type Updater

type Updater interface {
	Adder
	Remover
}

Updater allows to update graph.

type WeightSetter

type WeightSetter interface {
	SetWeight(float64)
}

WeightSetter sets weight.

Directories

Path Synopsis
api
http/docs
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
builder
marshal
dot

Jump to

Keyboard shortcuts

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