conn

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package conn implements a bi-directional communication channel between an envelope and a weavelet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Profile

func Profile(req *protos.GetProfileRequest) ([]byte, error)

Profile collects profiles for the weavelet.

Types

type EnvelopeConn

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

EnvelopeConn is the envelope side of the connection between a weavelet and an envelope. For more information, refer to runtime/protos/runtime.proto and https://serviceweaver.dev/blog/deployers.html.

func NewEnvelopeConn

func NewEnvelopeConn(ctx context.Context, r io.ReadCloser, w io.WriteCloser, info *protos.EnvelopeInfo) (*EnvelopeConn, error)

NewEnvelopeConn returns a connection to an already started weavelet. The connection sends messages to and receives messages from the weavelet using r and w. The provided EnvelopeInfo is sent to the weavelet as part of the handshake.

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

The connection stops on error or when the provided context is canceled.

func (*EnvelopeConn) GetHealthRPC added in v0.2.0

func (e *EnvelopeConn) GetHealthRPC() (protos.HealthStatus, error)

GetHealthRPC gets a weavelet's health.

func (*EnvelopeConn) GetLoadRPC added in v0.2.0

func (e *EnvelopeConn) GetLoadRPC() (*protos.LoadReport, error)

GetLoadRPC gets a load report from the weavelet.

func (*EnvelopeConn) GetMetricsRPC

func (e *EnvelopeConn) GetMetricsRPC() ([]*metrics.MetricSnapshot, error)

GetMetricsRPC gets a weavelet's metrics. There can only be one outstanding GetMetricsRPC at a time.

func (*EnvelopeConn) GetProfileRPC added in v0.2.0

func (e *EnvelopeConn) GetProfileRPC(req *protos.GetProfileRequest) ([]byte, error)

GetProfileRPC gets a profile from the weavelet. There can only be one outstanding GetProfileRPC at a time.

func (*EnvelopeConn) Serve added in v0.2.0

func (e *EnvelopeConn) 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 NewEnvelopeConn. This method never returns a non-nil error.

func (*EnvelopeConn) UpdateComponentsRPC added in v0.2.0

func (e *EnvelopeConn) UpdateComponentsRPC(components []string) error

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

func (*EnvelopeConn) UpdateRoutingInfoRPC added in v0.2.0

func (e *EnvelopeConn) UpdateRoutingInfoRPC(routing *protos.RoutingInfo) error

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

func (*EnvelopeConn) WeaveletInfo added in v0.2.0

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

WeaveletInfo returns information about the weavelet.

type WeaveletConn

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

WeaveletConn is the weavelet side of the connection between a weavelet and an envelope. For more information, refer to runtime/protos/runtime.proto and https://serviceweaver.dev/blog/deployers.html.

func NewWeaveletConn

func NewWeaveletConn(r io.ReadCloser, w io.WriteCloser, h WeaveletHandler) (*WeaveletConn, error)

NewWeaveletConn returns a connection to an envelope. The connection sends messages to and receives messages from the envelope using r and w. Note that all RPCs will block until [Serve] is called.

TODO(mwhittaker): Pass in a context.Context?

func (*WeaveletConn) ActivateComponentRPC added in v0.2.0

func (w *WeaveletConn) ActivateComponentRPC(req *protos.ActivateComponentRequest) error

ActivateComponentRPC ensures that the provided component is running somewhere. A call to ActivateComponentRPC also implicitly signals that a weavelet is interested in receiving routing info for the component.

func (*WeaveletConn) EnvelopeInfo added in v0.2.0

func (w *WeaveletConn) EnvelopeInfo() *protos.EnvelopeInfo

EnvelopeInfo returns the EnvelopeInfo received from the envelope.

func (*WeaveletConn) ExportListenerRPC

ExportListenerRPC exports the provided listener.

func (*WeaveletConn) GetListenerAddressRPC added in v0.2.0

GetListenerAddressRPC returns the address the weavelet should listen on for a particular listener.

func (*WeaveletConn) GetSelfCertificateRPC added in v0.12.0

GetSelfCertificateRPC returns the certificate and the private key the weavelet should use for network connection establishment.

func (*WeaveletConn) Listener added in v0.2.0

func (w *WeaveletConn) Listener() net.Listener

Listener returns the internal network listener for the weavelet.

func (*WeaveletConn) SendLogEntry

func (w *WeaveletConn) SendLogEntry(entry *protos.LogEntry) error

SendLogEntry sends a log entry to the envelope, without waiting for a reply.

func (*WeaveletConn) SendTraceSpans

func (w *WeaveletConn) SendTraceSpans(spans *protos.TraceSpans) error

SendTraceSpans sends a set of trace spans to the envelope, without waiting for a reply.

func (*WeaveletConn) Serve added in v0.2.0

func (w *WeaveletConn) Serve() error

Serve accepts RPC requests from the envelope. Requests are handled serially in the order they are received.

func (*WeaveletConn) VerifyClientCertificateRPC added in v0.6.0

VerifyClientCertificateRPC verifies the identity of a client that is attempting to connect to the weavelet.

func (*WeaveletConn) VerifyServerCertificateRPC added in v0.6.0

func (w *WeaveletConn) VerifyServerCertificateRPC(req *protos.VerifyServerCertificateRequest) error

VerifyServerCertificateRPC verifies the identity of the server the weavelet is attempting to connect to.

func (*WeaveletConn) WeaveletInfo added in v0.6.0

func (w *WeaveletConn) WeaveletInfo() *protos.WeaveletInfo

WeaveletInfo returns the WeaveletInfo sent to the envelope.

type WeaveletHandler added in v0.2.0

type WeaveletHandler interface {

	// GetLoad returns a load report.
	GetLoad(*protos.GetLoadRequest) (*protos.GetLoadReply, error)

	// UpdateComponents updates the set of components the weavelet should be
	// running. Currently, the set of components only increases over time.
	UpdateComponents(*protos.UpdateComponentsRequest) (*protos.UpdateComponentsReply, error)

	// UpdateRoutingInfo updates a component's routing information.
	UpdateRoutingInfo(*protos.UpdateRoutingInfoRequest) (*protos.UpdateRoutingInfoReply, error)
}

WeaveletHandler handles messages from the envelope. A handler should not block and should not perform RPCs over the pipe. 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