web

package
v0.67.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: AGPL-3.0 Imports: 42 Imported by: 14

Documentation

Overview

Package web provides gRPC/REST/GUI APIs to control and monitor a robot.

Index

Constants

View Source
const (
	SubtypeName = "web"
	// TCPParentPort is the port of the parent socket when VIAM_TCP_MODE is set.
	TCPParentPort = 14998
	// TestTCPParentPort is the test suite version of TCPParentPort. It's different to avoid
	// collisions; it's listed here for documentation.
	TestTCPParentPort = 14999
)

SubtypeName is a constant that identifies the internal web resource subtype string.

Variables

API is the fully qualified API for the internal web service.

View Source
var InternalServiceName = resource.NewName(API, "builtin")

InternalServiceName is used to refer to/depend on this service internally.

Functions

func RunWeb

func RunWeb(ctx context.Context, r robot.LocalRobot, o weboptions.Options, logger logging.Logger) (err error)

RunWeb starts the web server on the robot with web options and blocks until we cancel the context.

func RunWebWithConfig

func RunWebWithConfig(ctx context.Context, r robot.LocalRobot, cfg *config.Config, logger logging.Logger) error

RunWebWithConfig starts the web server on the robot with a robot config and blocks until we cancel the context.

Types

type Namer added in v0.61.0

type Namer interface {
	GetName() string
}

Namer is used to get a resource name from incoming requests for countingfor request. Requests for resources are expected to be a gRPC object that includes a `GetName` method.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures how we set up the web service. Cribbed from https://github.com/grpc/grpc-go/blob/aff571cc86e6e7e740130dbbb32a9741558db805/dialoptions.go#L41

func WithStreamConfig

func WithStreamConfig(config gostream.StreamConfig) Option

WithStreamConfig returns an Option which sets the streamConfig used to enable audio/video streaming over WebRTC.

type RequestCounter added in v0.61.0

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

RequestCounter maps string keys to atomic ints that get bumped on every incoming gRPC request for components.

func (*RequestCounter) Stats added in v0.61.0

func (rc *RequestCounter) Stats() any

Stats satisfies the ftdc.Statser interface and will return a copy of the counters.

func (*RequestCounter) UnaryInterceptor added in v0.61.0

func (rc *RequestCounter) UnaryInterceptor(
	ctx context.Context, req any, info *googlegrpc.UnaryServerInfo, handler googlegrpc.UnaryHandler,
) (resp any, err error)

UnaryInterceptor returns an incoming server interceptor that will pull method information and optionally resource information to bump the request counters.

type RestartStatusResponse added in v0.51.0

type RestartStatusResponse struct {
	// RestartAllowed represents whether this instance of the viam-server can be
	// safely restarted.
	RestartAllowed bool `json:"restart_allowed"`
}

RestartStatusResponse is the JSON response of the `restart_status` HTTP endpoint.

type Service

type Service interface {
	resource.Resource

	// Start starts the web server
	Start(context.Context, weboptions.Options) error

	// Stop stops the main web service (but leaves module server socket running.)
	Stop()

	// StartModule starts the module server socket.
	StartModule(context.Context) error

	// Returns the address and port the web service listens on.
	Address() string

	// Returns the unix socket path the module server listens on.
	ModuleAddress() string

	Stats() any

	RequestCounter() *RequestCounter

	ModPeerConnTracker() *grpc.ModPeerConnTracker
}

A Service controls the web server for a robot.

func New

func New(r robot.Robot, logger logging.Logger, opts ...Option) Service

New returns a new web service for the given robot.

Directories

Path Synopsis
Package weboptions provides Options for configuring a web server
Package weboptions provides Options for configuring a web server
Package webstream provides controls for streaming from the web server.
Package webstream provides controls for streaming from the web server.
camera
Package camera provides utilities for working with camera resources in the context of streaming.
Package camera provides utilities for working with camera resources in the context of streaming.
state
Package state controls the source of the RTP packets being written to the stream's subscribers and ensures there is only one active at a time while there are peer connections to receive RTP packets.
Package state controls the source of the RTP packets being written to the stream's subscribers and ensures there is only one active at a time while there are peer connections to receive RTP packets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳