graph

package
v0.0.67 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0, NCSA Imports: 10 Imported by: 0

Documentation

Overview

Package graph defines the graph Service interface and some useful utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllEdges

func AllEdges(ctx context.Context, es Service, req *gpb.EdgesRequest) (*gpb.EdgesReply, error)

AllEdges returns all edges for a particular EdgesRequest. This means that the returned reply will not have a next page token. WARNING: the paging API exists for a reason; using this can lead to very large memory consumption depending on the request.

func EdgesMap

func EdgesMap(edges map[string]*gpb.EdgeSet) map[string]map[string]map[string]map[int32]struct{}

EdgesMap returns a map from each node ticket to a map of its outward edge kinds.

func NodesMap

func NodesMap(nodes map[string]*cpb.NodeInfo) map[string]map[string][]byte

NodesMap returns a map from each node ticket to a map of its facts.

func RegisterHTTPHandlers

func RegisterHTTPHandlers(ctx context.Context, gs Service, mux *http.ServeMux)

RegisterHTTPHandlers registers JSON HTTP handlers with mux using the given graph Service. The following methods with be exposed:

GET /nodes
  Request: JSON encoded graph.NodesRequest
  Response: JSON encoded graph.NodesReply
GET /edges
  Request: JSON encoded graph.EdgesRequest
  Response: JSON encoded graph.EdgesReply

Note: /nodes, and /edges will return their responses as serialized protobufs if the "proto" query parameter is set.

Types

type BoundedRequests

type BoundedRequests struct {
	MaxTickets int
	Service
}

BoundedRequests guards against requests for more tickets than allowed per the MaxTickets configuration.

func (BoundedRequests) Edges

Edges implements part of the Service interface.

func (BoundedRequests) Nodes

Nodes implements part of the Service interface.

type ByOrdinal

type ByOrdinal []*gpb.EdgeSet_Group_Edge

ByOrdinal orders the edges in an edge group by their ordinals, with ties broken by ticket.

func (ByOrdinal) Len

func (s ByOrdinal) Len() int

func (ByOrdinal) Less

func (s ByOrdinal) Less(i, j int) bool

func (ByOrdinal) Swap

func (s ByOrdinal) Swap(i, j int)

type Service

type Service interface {
	Nodes(context.Context, *gpb.NodesRequest) (*gpb.NodesReply, error)
	Edges(context.Context, *gpb.EdgesRequest) (*gpb.EdgesReply, error)
}

Service exposes direct access to nodes and edges in a Kythe graph.

func WebClient

func WebClient(addr string) Service

WebClient returns a graph Service based on a remote web server.

Jump to

Keyboard shortcuts

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