Documentation ¶
Overview ¶
Package conn implements a bi-directional communication channel between an envelope and a weavelet.
Index ¶
- func Profile(req *protos.GetProfileRequest) ([]byte, error)
- type EnvelopeConn
- func (e *EnvelopeConn) GetHealthRPC() (protos.HealthStatus, error)
- func (e *EnvelopeConn) GetLoadRPC() (*protos.LoadReport, error)
- func (e *EnvelopeConn) GetMetricsRPC() ([]*metrics.MetricSnapshot, error)
- func (e *EnvelopeConn) GetProfileRPC(req *protos.GetProfileRequest) ([]byte, error)
- func (e *EnvelopeConn) Serve(h EnvelopeHandler) error
- func (e *EnvelopeConn) UpdateComponentsRPC(components []string) error
- func (e *EnvelopeConn) UpdateRoutingInfoRPC(routing *protos.RoutingInfo) error
- func (e *EnvelopeConn) WeaveletInfo() *protos.WeaveletInfo
- type EnvelopeHandler
- type WeaveletConn
- func (w *WeaveletConn) ActivateComponentRPC(req *protos.ActivateComponentRequest) error
- func (w *WeaveletConn) EnvelopeInfo() *protos.EnvelopeInfo
- func (w *WeaveletConn) ExportListenerRPC(req *protos.ExportListenerRequest) (*protos.ExportListenerReply, error)
- func (w *WeaveletConn) GetListenerAddressRPC(req *protos.GetListenerAddressRequest) (*protos.GetListenerAddressReply, error)
- func (w *WeaveletConn) Listener() net.Listener
- func (w *WeaveletConn) SendLogEntry(entry *protos.LogEntry) error
- func (w *WeaveletConn) SendTraceSpans(spans *protos.TraceSpans) error
- func (w *WeaveletConn) Serve() error
- func (w *WeaveletConn) VerifyClientCertificateRPC(req *protos.VerifyClientCertificateRequest) (*protos.VerifyClientCertificateReply, error)
- func (w *WeaveletConn) VerifyServerCertificateRPC(req *protos.VerifyServerCertificateRequest) error
- func (w *WeaveletConn) WeaveletInfo() *protos.WeaveletInfo
- type WeaveletHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 EnvelopeHandler ¶
type EnvelopeHandler interface { ActivateComponent(context.Context, *protos.ActivateComponentRequest) (*protos.ActivateComponentReply, error) GetListenerAddress(context.Context, *protos.GetListenerAddressRequest) (*protos.GetListenerAddressReply, error) ExportListener(context.Context, *protos.ExportListenerRequest) (*protos.ExportListenerReply, error) VerifyClientCertificate(context.Context, *protos.VerifyClientCertificateRequest) (*protos.VerifyClientCertificateReply, error) VerifyServerCertificate(context.Context, *protos.VerifyServerCertificateRequest) (*protos.VerifyServerCertificateReply, error) HandleLogEntry(context.Context, *protos.LogEntry) error HandleTraceSpans(context.Context, []trace.ReadOnlySpan) error }
See envelope.EnvelopeHandler
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 ¶
func (w *WeaveletConn) ExportListenerRPC(req *protos.ExportListenerRequest) (*protos.ExportListenerReply, error)
ExportListenerRPC exports the provided listener.
func (*WeaveletConn) GetListenerAddressRPC ¶ added in v0.2.0
func (w *WeaveletConn) GetListenerAddressRPC(req *protos.GetListenerAddressRequest) (*protos.GetListenerAddressReply, error)
GetListenerAddressRPC returns the address the weavelet should listen on for a particular listener.
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
func (w *WeaveletConn) VerifyClientCertificateRPC(req *protos.VerifyClientCertificateRequest) (*protos.VerifyClientCertificateReply, error)
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.