envelope

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Overview

Package envelope implements a sidecar-like process that connects a weavelet to its environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

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

Envelope starts and manages a weavelet in a subprocess.

For more information, refer to runtime/protos/runtime.proto and https://serviceweaver.dev/blog/deployers.html.

func NewEnvelope

func NewEnvelope(ctx context.Context, wlet *protos.EnvelopeInfo, config *protos.AppConfig) (*Envelope, error)

NewEnvelope creates a new envelope, starting a weavelet subprocess and establishing a bidirectional connection with it. The weavelet process can be stopped at any time by canceling the passed-in context.

You can issue RPCs *to* the weavelet using the returned Envelope. To start receiving messages *from* the weavelet, call [Serve].

func (*Envelope) GetHealth added in v0.2.0

func (e *Envelope) GetHealth() protos.HealthStatus

GetHealth returns the health status of the weavelet.

func (*Envelope) GetLoad added in v0.2.0

func (e *Envelope) GetLoad() (*protos.LoadReport, error)

GetLoad gets a load report from the weavelet.

func (*Envelope) GetMetrics added in v0.2.0

func (e *Envelope) GetMetrics() ([]*metrics.MetricSnapshot, error)

GetMetrics returns a weavelet's metrics.

func (*Envelope) GetProfile added in v0.2.0

func (e *Envelope) GetProfile(req *protos.GetProfileRequest) ([]byte, error)

GetProfile gets a profile from the weavelet.

func (*Envelope) Serve added in v0.2.0

func (e *Envelope) Serve(h EnvelopeHandler) error

Serve accepts incoming messages from the weavelet. RPC requests are handled serially in the order they are received. Serve blocks until the connection terminates, returning the error that caused it to terminate. You can cancel the connection by cancelling the context passed to NewEnvelope. This method never returns a non-nil error.

func (*Envelope) UpdateComponents added in v0.2.0

func (e *Envelope) UpdateComponents(components []string) error

UpdateComponents updates the weavelet with the latest set of components it should be running.

func (*Envelope) UpdateRoutingInfo added in v0.2.0

func (e *Envelope) UpdateRoutingInfo(routing *protos.RoutingInfo) error

UpdateRoutingInfo updates the weavelet with a component's most recent routing info.

func (*Envelope) WeaveletInfo added in v0.2.0

func (e *Envelope) WeaveletInfo() *protos.WeaveletInfo

WeaveletInfo returns information about the started weavelet.

type EnvelopeHandler

type EnvelopeHandler interface {
	// ActivateComponent ensures that the provided component is running
	// somewhere. A call to ActivateComponent also implicitly signals that a
	// weavelet is interested in receiving routing info for the component.
	ActivateComponent(context.Context, *protos.ActivateComponentRequest) (*protos.ActivateComponentReply, error)

	// GetListenerAddress returns the address the weavelet should listen on for
	// a particular listener.
	GetListenerAddress(context.Context, *protos.GetListenerAddressRequest) (*protos.GetListenerAddressReply, error)

	// ExportListener exports the provided listener. Exporting a listener
	// typically, but not always, involves running a proxy that forwards
	// traffic to the provided address.
	ExportListener(context.Context, *protos.ExportListenerRequest) (*protos.ExportListenerReply, error)

	// HandleLogEntry handles a log entry.
	HandleLogEntry(context.Context, *protos.LogEntry) error

	// HandleTraceSpans handles a set of trace spans.
	HandleTraceSpans(context.Context, []trace.ReadOnlySpan) error
}

EnvelopeHandler handles messages from the weavelet. Values passed to the handlers are only valid for the duration of the handler's execution.

Jump to

Keyboard shortcuts

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