app

package
v0.0.0-...-06e0152 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UIEnd = iota
	ProbeEnd
)

Valid values of type End

View Source
const (
	DefaultHostname      = "scope.weave.local."
	DefaultWeaveURL      = "http://127.0.0.1:6784"
	DefaultContainerName = "weavescope"
)

Default values for weave app integration

View Source
const RequestCtxKey contextKey = contextKey("request")

RequestCtxKey is key used for request entry in context

Variables

View Source
var (
	// Version - set at buildtime.
	Version = "dev"

	// UniqueID - set at runtime.
	UniqueID = "0"
)

Functions

func AddContainerFilters

func AddContainerFilters(newFilters ...APITopologyOption)

AddContainerFilters adds to the default Registry (topologyRegistry)'s containerFilters

func NewVersion

func NewVersion(version, downloadURL string)

NewVersion is called to expose new version information to /api

func RegisterControlRoutes

func RegisterControlRoutes(router *mux.Router, cr ControlRouter)

RegisterControlRoutes registers the various control routes with a http mux.

func RegisterPipeRoutes

func RegisterPipeRoutes(router *mux.Router, pr PipeRouter)

RegisterPipeRoutes registers the pipe routes

func RegisterReportPostHandler

func RegisterReportPostHandler(a Adder, router *mux.Router)

RegisterReportPostHandler registers the handler for report submission

func RegisterTopologyRoutes

func RegisterTopologyRoutes(router *mux.Router, r Reporter, capabilities map[string]bool)

RegisterTopologyRoutes registers the various topology routes with a http mux.

func RenderContextForReporter

func RenderContextForReporter(rep Reporter, r report.Report) detailed.RenderContext

RenderContextForReporter creates the rendering context for the given reporter.

func URLMatcher

func URLMatcher(pattern string) mux.MatcherFunc

URLMatcher uses request.RequestURI (the raw, unparsed request) to attempt to match pattern. It does this as go's URL.Parse method is broken, and mistakenly unescapes the Path before parsing it. This breaks %2F (encoded forward slashes) in the paths.

Types

type APINode

type APINode struct {
	Node detailed.Node `json:"node"`
}

APINode is returned by the /api/topology/{name}/{id} handler.

type APITopology

type APITopology struct {
	Nodes detailed.NodeSummaries `json:"nodes"`
}

APITopology is returned by the /api/topology/{name} handler.

type APITopologyDesc

type APITopologyDesc struct {
	Name        string                   `json:"name"`
	Rank        int                      `json:"rank"`
	HideIfEmpty bool                     `json:"hide_if_empty"`
	Options     []APITopologyOptionGroup `json:"options"`

	URL           string            `json:"url"`
	SubTopologies []APITopologyDesc `json:"sub_topologies,omitempty"`
	Stats         topologyStats     `json:"stats,omitempty"`
	// contains filtered or unexported fields
}

APITopologyDesc is returned in a list by the /api/topology handler.

type APITopologyOption

type APITopologyOption struct {
	Value string `json:"value"`
	Label string `json:"label"`
	// contains filtered or unexported fields
}

APITopologyOption describes a &param=value to a given topology.

func MakeAPITopologyOption

func MakeAPITopologyOption(value string, label string, filterFunc render.FilterFunc, pseudo bool) APITopologyOption

MakeAPITopologyOption provides an external interface to the package for creating an APITopologyOption.

type APITopologyOptionGroup

type APITopologyOptionGroup struct {
	ID string `json:"id"`
	// Default value for the option. Used if the value is omitted; not used if the value is ""
	Default string              `json:"defaultValue"`
	Options []APITopologyOption `json:"options,omitempty"`
	// SelectType describes how options can be picked. Currently defined values:
	//   "one": Default if empty. Exactly one option may be picked from the list.
	//   "union": Any number of options may be picked. Nodes matching any option filter selected are displayed.
	//           Value and Default should be a ","-separated list.
	SelectType string `json:"selectType,omitempty"`
	// For "union" type, this is the label the UI should use to represent the case where nothing is selected
	NoneLabel string `json:"noneLabel,omitempty"`
}

APITopologyOptionGroup describes a group of APITopologyOptions

type Adder

type Adder interface {
	Add(context.Context, report.Report, []byte) error
}

Adder is something that can accept reports. It's a convenient interface for parts of the app, and several experimental components. It takes the following arguments: - context.Context: the request context - report.Report: the deserialised report - []byte: the serialised report (as gzip'd msgpack)

type Collector

type Collector interface {
	Reporter
	Adder
}

A Collector is a Reporter and an Adder

func NewCollector

func NewCollector(window time.Duration) Collector

NewCollector returns a collector ready for use.

func NewFileCollector

func NewFileCollector(path string, window time.Duration) (Collector, error)

NewFileCollector reads and parses the files at path (a file or directory) as reports. If there are multiple files, and they all have names representing "nanoseconds since epoch" timestamps, e.g. "1488557088545489008.msgpack.gz", then the collector will return merged reports resulting from replaying the file reports in a loop at a sequence and speed determined by the timestamps. Otherwise the collector always returns the merger of all reports.

type ControlRouter

type ControlRouter interface {
	Handle(ctx context.Context, probeID string, req xfer.Request) (xfer.Response, error)
	Register(ctx context.Context, probeID string, handler xfer.ControlHandlerFunc) (int64, error)
	Deregister(ctx context.Context, probeID string, id int64) error
}

ControlRouter is a thing that can route control requests and responses between the UI and a probe.

func NewLocalControlRouter

func NewLocalControlRouter() ControlRouter

NewLocalControlRouter creates a new ControlRouter that does everything locally, in memory.

type CtxHandlerFunc

type CtxHandlerFunc func(context.Context, http.ResponseWriter, *http.Request)

CtxHandlerFunc is a http.HandlerFunc, with added contexts

type DockerClient

type DockerClient interface {
	ListContainers(fsouza.ListContainersOptions) ([]fsouza.APIContainers, error)
}

DockerClient is the little bit of the docker client we need.

type End

type End int

End is an enum for either end of the pipe.

func (End) String

func (e End) String() string

type Interface

type Interface struct {
	Name  string
	Addrs []net.Addr
}

Interface is because net.Interface isn't mockable.

func Interfaces

func Interfaces() ([]Interface, error)

Interfaces returns the list of Interfaces on the machine.

type InterfaceFunc

type InterfaceFunc func() ([]Interface, error)

InterfaceFunc is the type of Interfaces()

type Merger

type Merger interface {
	Merge([]report.Report) report.Report
}

Merger is the type for a thing that can merge reports.

func NewFastMerger

func NewFastMerger() Merger

NewFastMerger makes a Merger which merges together reports, mutating the one we are building up

type PipeRouter

type PipeRouter interface {
	Exists(context.Context, string) (bool, error)
	Get(context.Context, string, End) (xfer.Pipe, io.ReadWriter, error)
	Release(context.Context, string, End) error
	Delete(context.Context, string) error
	Stop()
}

PipeRouter stores pipes and allows you to connect to either end of them.

func NewLocalPipeRouter

func NewLocalPipeRouter() PipeRouter

NewLocalPipeRouter returns a new local (in-memory) pipe router.

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Registry is a threadsafe store of the available topologies

func MakeRegistry

func MakeRegistry() *Registry

MakeRegistry returns a new Registry

func (*Registry) Add

func (r *Registry) Add(ts ...APITopologyDesc)

Add inserts a topologyDesc to the Registry's items map

func (*Registry) AddContainerFilters

func (r *Registry) AddContainerFilters(newFilters ...APITopologyOption)

AddContainerFilters adds container filters to this Registry

func (*Registry) RendererForTopology

func (r *Registry) RendererForTopology(topologyID string, values url.Values, rpt report.Report) (render.Renderer, render.Transformer, error)

RendererForTopology ..

type Reporter

type Reporter interface {
	Report(context.Context, time.Time) (report.Report, error)
	HasReports(context.Context, time.Time) (bool, error)
	HasHistoricReports() bool
	WaitOn(context.Context, chan struct{})
	UnWait(context.Context, chan struct{})
}

Reporter is something that can produce reports on demand. It's a convenient interface for parts of the app, and several experimental components.

type StaticCollector

type StaticCollector report.Report

StaticCollector always returns the given report.

func (StaticCollector) Add

Add adds a report to the collector's internal state. It implements Adder.

func (StaticCollector) HasHistoricReports

func (c StaticCollector) HasHistoricReports() bool

HasHistoricReports indicates whether the collector contains reports older than now-app.window.

func (StaticCollector) HasReports

func (c StaticCollector) HasReports(context.Context, time.Time) (bool, error)

HasReports indicates whether the collector contains reports between timestamp-app.window and timestamp.

func (StaticCollector) Report

Report returns a merged report over all added reports. It implements Reporter.

func (StaticCollector) UnWait

func (c StaticCollector) UnWait(context.Context, chan struct{})

UnWait lets other components stop waiting on a new report being received. It implements Reporter.

func (StaticCollector) WaitOn

func (c StaticCollector) WaitOn(context.Context, chan struct{})

WaitOn lets other components wait on a new report being received. It implements Reporter.

type WeaveClient

type WeaveClient interface {
	AddDNSEntry(hostname, containerid string, ip net.IP) error
	Expose() error
}

WeaveClient is the little bit of the weave clent we need.

type WeavePublisher

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

WeavePublisher is a thing which periodically registers this app with WeaveDNS.

func NewWeavePublisher

func NewWeavePublisher(weaveClient WeaveClient, dockerClient DockerClient, interfaces InterfaceFunc, hostname, containerName string) *WeavePublisher

NewWeavePublisher makes a new Weave.

func (*WeavePublisher) Stop

func (w *WeavePublisher) Stop()

Stop the Weave.

type WebReporter

type WebReporter struct {
	Reporter
	MetricsGraphURL string
}

WebReporter is a reporter that creates reports whose data is eventually displayed on websites. It carries fields that will be forwarded to the detailed.RenderContext

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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