status

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Overview

Package status contains code for implementing status related commands like "weaver multi status" and "weaver single dashboard".

Index

Constants

This section is empty.

Variables

View Source
var File_internal_status_status_proto protoreflect.FileDescriptor

Functions

func DashboardCommand

func DashboardCommand(spec *DashboardSpec) *dtool.Command

DashboardCommand returns a "dashboard" subcommand that serves a dashboard with information about the active applications.

func DefaultRegistryDir

func DefaultRegistryDir() (string, error)

DefaultRegistryDir returns the default registry directory $XDG_DATA_HOME/serviceweaver, or ~/.local/share/serviceweaver if XDG_DATA_HOME is not set.

func MetricsCommand

func MetricsCommand(tool string, registry func(context.Context) (*Registry, error)) *dtool.Command

MetricsCommand returns a "metrics" subcommand that pretty prints the metrics of all active applications registered with the provided registry. tool is the name of the command-line tool the returned subcommand runs as (e.g., "weaver single").

func ProfileCommand

func ProfileCommand(toolName string, registry func(context.Context) (*Registry, error)) *tool.Command

ProfileCommand returns a "profile" subcommand that gathers pprof profiles.

func RegisterServer

func RegisterServer(mux *http.ServeMux, server Server, logger logtype.Logger)

RegisterServer registers a Server's methods with the provided mux under the /debug/serviceweaver/ prefix. You can use a Client to interact with a Status server.

func StatusCommand

func StatusCommand(tool string, registry func(context.Context) (*Registry, error)) *dtool.Command

StatusCommand returns a "status" subcommand that pretty prints the status of all active applications registered with the provided registry. tool is the name of the command-line tool the returned subcommand runs as (e.g., "weaver single").

Types

type Client

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

Client is an HTTP client to a status server. It's assumed the status server registered itself with RegisterServer.

func NewClient

func NewClient(addr string) *Client

NewClient returns a client to the status server on the provided address.

func (*Client) Metrics

func (c *Client) Metrics(ctx context.Context) (*Metrics, error)

Metrics implements the Server interface.

func (*Client) Profile

func (c *Client) Profile(ctx context.Context, req *protos.RunProfiling) (*protos.Profile, error)

Profile implements the Server interface.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*Status, error)

Status implements the Server interface.

type Command

type Command struct {
	Label   string // e.g., cat logs
	Command string // e.g., weaver single logs '--version=="12345678"'
}

A Command is a labeled terminal command that a user can run. We show these commands on the dashboard so that users can copy and run them.

type Component

type Component struct {
	Name    string    `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`         // component name (e.g., Cache)
	Group   string    `protobuf:"bytes,2,opt,name=group,proto3" json:"group,omitempty"`       // colocation group name (e.g., Cache)
	Pids    []int64   `protobuf:"varint,3,rep,packed,name=pids,proto3" json:"pids,omitempty"` // PIDs of component replicas
	Methods []*Method `protobuf:"bytes,4,rep,name=methods,proto3" json:"methods,omitempty"`   // methods
	// contains filtered or unexported fields
}

Component describes a Service Weaver component.

func (*Component) Descriptor deprecated

func (*Component) Descriptor() ([]byte, []int)

Deprecated: Use Component.ProtoReflect.Descriptor instead.

func (*Component) GetGroup added in v0.1.2

func (x *Component) GetGroup() string

func (*Component) GetMethods

func (x *Component) GetMethods() []*Method

func (*Component) GetName

func (x *Component) GetName() string

func (*Component) GetPids

func (x *Component) GetPids() []int64

func (*Component) ProtoMessage

func (*Component) ProtoMessage()

func (*Component) ProtoReflect

func (x *Component) ProtoReflect() protoreflect.Message

func (*Component) Reset

func (x *Component) Reset()

func (*Component) String

func (x *Component) String() string

type DashboardSpec

type DashboardSpec struct {
	Tool     string                                   // tool name (e.g., "weaver single")
	Registry func(context.Context) (*Registry, error) // registry of deployments
	Commands func(deploymentId string) []Command      // commands for a deployment
}

DashboardSpec configures the command returned by DashboardCommand.

type Listener

type Listener struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // exported listener name
	Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` // dialable listener address
	// contains filtered or unexported fields
}

Listener describes a Service Weaver listener.

func (*Listener) Descriptor deprecated

func (*Listener) Descriptor() ([]byte, []int)

Deprecated: Use Listener.ProtoReflect.Descriptor instead.

func (*Listener) GetAddr

func (x *Listener) GetAddr() string

func (*Listener) GetName

func (x *Listener) GetName() string

func (*Listener) ProtoMessage

func (*Listener) ProtoMessage()

func (*Listener) ProtoReflect

func (x *Listener) ProtoReflect() protoreflect.Message

func (*Listener) Reset

func (x *Listener) Reset()

func (*Listener) String

func (x *Listener) String() string

type Method

type Method struct {
	Name   string       `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`     // method name
	Minute *MethodStats `protobuf:"bytes,2,opt,name=minute,proto3" json:"minute,omitempty"` // stats from the last minute
	Hour   *MethodStats `protobuf:"bytes,3,opt,name=hour,proto3" json:"hour,omitempty"`     // stats from the last hour
	Total  *MethodStats `protobuf:"bytes,4,opt,name=total,proto3" json:"total,omitempty"`   // lifetime stats
	// contains filtered or unexported fields
}

Method describes a Component method.

func (*Method) Descriptor deprecated

func (*Method) Descriptor() ([]byte, []int)

Deprecated: Use Method.ProtoReflect.Descriptor instead.

func (*Method) GetHour

func (x *Method) GetHour() *MethodStats

func (*Method) GetMinute

func (x *Method) GetMinute() *MethodStats

func (*Method) GetName

func (x *Method) GetName() string

func (*Method) GetTotal

func (x *Method) GetTotal() *MethodStats

func (*Method) ProtoMessage

func (*Method) ProtoMessage()

func (*Method) ProtoReflect

func (x *Method) ProtoReflect() protoreflect.Message

func (*Method) Reset

func (x *Method) Reset()

func (*Method) String

func (x *Method) String() string

type MethodStats

type MethodStats struct {
	NumCalls     float64 `protobuf:"fixed64,1,opt,name=num_calls,json=numCalls,proto3" json:"num_calls,omitempty"`                 // number of times the method was called
	AvgLatencyMs float64 `protobuf:"fixed64,2,opt,name=avg_latency_ms,json=avgLatencyMs,proto3" json:"avg_latency_ms,omitempty"`   // average latency, in ms, of method execution
	RecvKbPerSec float64 `protobuf:"fixed64,3,opt,name=recv_kb_per_sec,json=recvKbPerSec,proto3" json:"recv_kb_per_sec,omitempty"` // KB/s received by method
	SentKbPerSec float64 `protobuf:"fixed64,4,opt,name=sent_kb_per_sec,json=sentKbPerSec,proto3" json:"sent_kb_per_sec,omitempty"` // KB/s returned by method
	// contains filtered or unexported fields
}

MethodStats summarizes a method's metrics.

func (*MethodStats) Descriptor deprecated

func (*MethodStats) Descriptor() ([]byte, []int)

Deprecated: Use MethodStats.ProtoReflect.Descriptor instead.

func (*MethodStats) GetAvgLatencyMs

func (x *MethodStats) GetAvgLatencyMs() float64

func (*MethodStats) GetNumCalls

func (x *MethodStats) GetNumCalls() float64

func (*MethodStats) GetRecvKbPerSec

func (x *MethodStats) GetRecvKbPerSec() float64

func (*MethodStats) GetSentKbPerSec

func (x *MethodStats) GetSentKbPerSec() float64

func (*MethodStats) ProtoMessage

func (*MethodStats) ProtoMessage()

func (*MethodStats) ProtoReflect

func (x *MethodStats) ProtoReflect() protoreflect.Message

func (*MethodStats) Reset

func (x *MethodStats) Reset()

func (*MethodStats) String

func (x *MethodStats) String() string

type Metrics

type Metrics struct {
	Metrics []*protos.MetricSnapshot `protobuf:"bytes,1,rep,name=metrics,proto3" json:"metrics,omitempty"`
	// contains filtered or unexported fields
}

Metrics is a snapshot of a deployment's metrics.

func (*Metrics) Descriptor deprecated

func (*Metrics) Descriptor() ([]byte, []int)

Deprecated: Use Metrics.ProtoReflect.Descriptor instead.

func (*Metrics) GetMetrics

func (x *Metrics) GetMetrics() []*protos.MetricSnapshot

func (*Metrics) ProtoMessage

func (*Metrics) ProtoMessage()

func (*Metrics) ProtoReflect

func (x *Metrics) ProtoReflect() protoreflect.Message

func (*Metrics) Reset

func (x *Metrics) Reset()

func (*Metrics) String

func (x *Metrics) String() string

type Registration

type Registration struct {
	DeploymentId string // deployment id (e.g, "eba18295")
	App          string // app name (e.g., "todo")
	Addr         string // status server (e.g., "localhost:12345")
}

A Registration contains basic metadata about a Service Weaver application.

func (Registration) Rolodex

func (r Registration) Rolodex() string

Rolodex returns a pretty-printed rolodex displaying the registration.

╭───────────────────────────────────────────────────╮
│ app        : collatz                              │
│ deployment : fdeeb059-825b-4606-9e99-e22e63e10552 │
╰───────────────────────────────────────────────────╯

type Registry

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

A Registry is a persistent collection of Service Weaver application metadata.

Tools like "weaver multi status" and "weaver multi dashboard" use the registry to know which applications are running and to fetch the status of the running applications.

func NewRegistry

func NewRegistry(_ context.Context, dir string) (*Registry, error)

NewRegistry returns a registry that persists data to the provided directory.

func (*Registry) Get

func (r *Registry) Get(ctx context.Context, deploymentId string) (Registration, error)

Get returns the Registration for the provided deployment. If the deployment doesn't exist or is not active, a non-nil error is returned.

func (*Registry) List

func (r *Registry) List(ctx context.Context) ([]Registration, error)

List returns all active Registrations.

func (*Registry) Register

func (r *Registry) Register(ctx context.Context, reg Registration) error

Register adds a registration to the registry.

func (*Registry) Unregister

func (r *Registry) Unregister(_ context.Context, deploymentId string) error

Unregister removes a registration from the registry.

type Server

type Server interface {
	// Status returns the status of the deployment.
	Status(context.Context) (*Status, error)

	// Metrics returns a snapshot of the deployment's metrics.
	Metrics(context.Context) (*Metrics, error)

	// Profile returns a profile of the deployment.
	Profile(context.Context, *protos.RunProfiling) (*protos.Profile, error)
}

A Server returns information about a Service Weaver deployment.

type Status

type Status struct {
	App            string                 `protobuf:"bytes,1,opt,name=app,proto3" json:"app,omitempty"`                                             // application name
	DeploymentId   string                 `protobuf:"bytes,2,opt,name=deployment_id,json=deploymentId,proto3" json:"deployment_id,omitempty"`       // deployment id
	SubmissionTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=submission_time,json=submissionTime,proto3" json:"submission_time,omitempty"` // when the app was submitted
	StatusAddr     string                 `protobuf:"bytes,4,opt,name=status_addr,json=statusAddr,proto3" json:"status_addr,omitempty"`             // status server address
	Components     []*Component           `protobuf:"bytes,5,rep,name=components,proto3" json:"components,omitempty"`                               // active components
	Listeners      []*Listener            `protobuf:"bytes,6,rep,name=listeners,proto3" json:"listeners,omitempty"`                                 // exported listeners
	Config         *protos.AppConfig      `protobuf:"bytes,7,opt,name=config,proto3" json:"config,omitempty"`                                       // application config
	// contains filtered or unexported fields
}

Status describes the status of a Service Weaver application deployment.

func (*Status) Descriptor deprecated

func (*Status) Descriptor() ([]byte, []int)

Deprecated: Use Status.ProtoReflect.Descriptor instead.

func (*Status) GetApp

func (x *Status) GetApp() string

func (*Status) GetComponents

func (x *Status) GetComponents() []*Component

func (*Status) GetConfig

func (x *Status) GetConfig() *protos.AppConfig

func (*Status) GetDeploymentId

func (x *Status) GetDeploymentId() string

func (*Status) GetListeners

func (x *Status) GetListeners() []*Listener

func (*Status) GetStatusAddr

func (x *Status) GetStatusAddr() string

func (*Status) GetSubmissionTime

func (x *Status) GetSubmissionTime() *timestamppb.Timestamp

func (*Status) ProtoMessage

func (*Status) ProtoMessage()

func (*Status) ProtoReflect

func (x *Status) ProtoReflect() protoreflect.Message

func (*Status) Reset

func (x *Status) Reset()

func (*Status) String

func (x *Status) String() string

Jump to

Keyboard shortcuts

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