envelope

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 18 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, i.e., an OS process running inside a colocation group replica, hosting Service Weaver components. It also captures the weavelet's tracing, logging, and metrics information.

func NewEnvelope

func NewEnvelope(wlet *protos.Weavelet, h EnvelopeHandler, opts Options) (*Envelope, error)

func (*Envelope) HealthStatus

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

HealthStatus returns the health status of the weavelet.

func (*Envelope) ReadMetrics

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

ReadMetrics returns the set of all captured metrics.

func (*Envelope) Run

func (e *Envelope) Run(ctx context.Context) error

Run runs the application, restarting it when necessary.

func (*Envelope) RunProfiling

func (e *Envelope) RunProfiling(_ context.Context, req *protos.RunProfiling) (*protos.Profile, error)

RunProfiling returns weavelet profiling information.

func (*Envelope) Stop

func (e *Envelope) Stop() error

Stop permanently terminates the weavelet process managed by the envelope.

func (*Envelope) Weavelet

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

type EnvelopeHandler

type EnvelopeHandler interface {
	// StartComponent starts the given component.
	StartComponent(entry *protos.ComponentToStart) error

	// StartColocationGroup starts the given colocation group.
	StartColocationGroup(entry *protos.ColocationGroup) error

	// RegisterReplica registers the given weavelet replica.
	RegisterReplica(entry *protos.ReplicaToRegister) error

	// ReportLoad reports the given weavelet load information.
	ReportLoad(entry *protos.WeaveletLoadReport) error

	// ExportListener exports the given listener, returning the export
	// information (e.g,. any port assigned).
	ExportListener(request *protos.ListenerToExport) (*protos.ExportListenerReply, error)

	// GetRoutingInfo returns the latest routing information for the weavelet.
	//
	// This is a blocking method that can be processed out-of-order w.r.t.
	// the other methods.
	GetRoutingInfo(request *protos.GetRoutingInfo) (*protos.RoutingInfo, error)

	// GetComponentsToStart is a blocking call that returns the latest set of
	// components that should be started by the weavelet.
	//
	// This is a blocking method that can be processed out-of-order w.r.t.
	// the other methods.
	GetComponentsToStart(request *protos.GetComponentsToStart) (*protos.ComponentsToStart, error)

	// RecvLogEntry enables the envelope to receive a log entry.
	RecvLogEntry(entry *protos.LogEntry)

	// RecvTraceSpans enables the envelope to receive a sequence of trace spans.
	RecvTraceSpans(spans []trace.ReadOnlySpan) error
}

EnvelopeHandler implements the envelope side processing of messages exchanged with the managed weavelet.

type Options

type Options struct {
	// Restart dictates when a weavelet is restarted. Defaults to Never.
	Restart RestartPolicy

	// Retry configures the exponential backoff performed when restarting the
	// weavelet. Defaults to retry.DefaultOptions.
	Retry retry.Options

	// GetEnvelopeConn returns a connection between a pre-started weavelet and
	// its Envelope.
	//
	// Note that setting this option implies that the weavelet has already been
	// started, in which case the Envelope will not restart it (i.e., the
	// Restart policy is assumed to be Never).
	//
	// TODO: conn.EnvelopeConn is internal. This is only used right now for
	// weavertest. If we remove the weavertest use case, we can remove this
	// option.
	//
	// TODO: Set this only in weavertest.
	GetEnvelopeConn func() *conn.EnvelopeConn
}

Options to configure the weavelet managed by the Envelope.

type RestartPolicy

type RestartPolicy int

RestartPolicy governs when a weavelet is restarted.

const (
	Never     RestartPolicy = iota // Never restart
	Always                         // Always restart
	OnFailure                      // Restart iff weavelet exits with non-zero exit code
)

func (RestartPolicy) String

func (r RestartPolicy) String() string

Jump to

Keyboard shortcuts

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