Skip to content

Commit

Permalink
Drop UpdateComponentsRPC. (#687)
Browse files Browse the repository at this point in the history
An earlier changed switched to using a controller component method call
to update the set of components served by a weavelet. This change finishes
that by dropping the UpdateComponentsRPC from the pipe protocol.

The weavertest multi deployer code had to be refactored a little bit
to give it access to the controller component (either local for
components hosted in the main process, or remote for components hosted
in other processes).

Also dropped the GetHealth method from the controller component since
it is currently not used. (The only user of GetHealth is an out of
tree deployer that has not yet been switched to using the controller
component.)
  • Loading branch information
ghemawat authored Dec 18, 2023
1 parent 90c6b0e commit d01bef8
Show file tree
Hide file tree
Showing 14 changed files with 579 additions and 768 deletions.
5 changes: 0 additions & 5 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ type noopController struct {

var _ controller = &noopController{}

// GetHealth implements controller interface.
func (*noopController) GetHealth(context.Context, *protos.GetHealthRequest) (*protos.GetHealthReply, error) {
return nil, fmt.Errorf("controller.GetHealth not implemented")
}

// UpdateComponents implements controller interface.
func (*noopController) UpdateComponents(context.Context, *protos.UpdateComponentsRequest) (*protos.UpdateComponentsReply, error) {
return nil, fmt.Errorf("controller.UpdateComponents not implemented")
Expand Down
1 change: 1 addition & 0 deletions godeps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ github.com/ServiceWeaver/weaver/weavertest
context
errors
fmt
github.com/ServiceWeaver/weaver/internal/control
github.com/ServiceWeaver/weaver/internal/envelope/conn
github.com/ServiceWeaver/weaver/internal/reflection
github.com/ServiceWeaver/weaver/internal/weaver
Expand Down
3 changes: 0 additions & 3 deletions internal/control/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import (
// Arguments and results are protobufs to allow deployers to evolve independently of
// application binaries.
type Controller interface {
// GetHealth returns the health of the weavelet.
GetHealth(context.Context, *protos.GetHealthRequest) (*protos.GetHealthReply, error)

// UpdateComponents updates the weavelet with the latest set of components it
// should be running.
UpdateComponents(context.Context, *protos.UpdateComponentsRequest) (*protos.UpdateComponentsReply, error)
Expand Down
18 changes: 0 additions & 18 deletions internal/envelope/conn/envelope_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,24 +304,6 @@ func (e *EnvelopeConn) GetProfileRPC(req *protos.GetProfileRequest) ([]byte, err
return reply.GetProfileReply.Data, nil
}

// UpdateComponentsRPC updates the weavelet with the latest set of components
// it should be running.
func (e *EnvelopeConn) UpdateComponentsRPC(components []string) error {
req := &protos.EnvelopeMsg{
UpdateComponentsRequest: &protos.UpdateComponentsRequest{
Components: components,
},
}
reply, err := e.rpc(req)
if err != nil {
return err
}
if reply.UpdateComponentsReply == nil {
return fmt.Errorf("nil UpdateComponentsReply received from weavelet")
}
return nil
}

// UpdateRoutingInfoRPC updates the weavelet with a component's most recent
// routing info.
func (e *EnvelopeConn) UpdateRoutingInfoRPC(routing *protos.RoutingInfo) error {
Expand Down
11 changes: 0 additions & 11 deletions internal/envelope/conn/weavelet_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ 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(context.Context, *protos.UpdateComponentsRequest) (*protos.UpdateComponentsReply, error)

// UpdateRoutingInfo updates a component's routing information.
UpdateRoutingInfo(*protos.UpdateRoutingInfoRequest) (*protos.UpdateRoutingInfoReply, error)
}
Expand Down Expand Up @@ -199,13 +195,6 @@ func (w *WeaveletConn) handleMessage(handler WeaveletHandler, msg *protos.Envelo
})
}()
return nil
case msg.UpdateComponentsRequest != nil:
reply, err := handler.UpdateComponents(context.Background(), msg.UpdateComponentsRequest)
return w.conn.send(&protos.WeaveletMsg{
Id: -msg.Id,
Error: errstring(err),
UpdateComponentsReply: reply,
})
case msg.UpdateRoutingInfoRequest != nil:
reply, err := handler.UpdateRoutingInfo(msg.UpdateRoutingInfoRequest)
return w.conn.send(&protos.WeaveletMsg{
Expand Down
5 changes: 0 additions & 5 deletions internal/weaver/remoteweavelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,6 @@ func (w *RemoteWeavelet) GetLoad(*protos.GetLoadRequest) (*protos.GetLoadReply,
return &protos.GetLoadReply{Load: report}, nil
}

// GetHealth implements the weaver.controller interface.
func (w *RemoteWeavelet) GetHealth(ctx context.Context, req *protos.GetHealthRequest) (*protos.GetHealthReply, error) {
return &protos.GetHealthReply{Status: protos.HealthStatus_HEALTHY}, nil
}

// UpdateComponents implements weaver.controller and conn.WeaverHandler interfaces.
func (w *RemoteWeavelet) UpdateComponents(ctx context.Context, req *protos.UpdateComponentsRequest) (*protos.UpdateComponentsReply, error) {
var errs []error
Expand Down
3 changes: 3 additions & 0 deletions runtime/envelope/envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ func NewEnvelope(ctx context.Context, wlet *protos.EnvelopeInfo, config *protos.
return e, nil
}

// Controller returns the controller component for the weavelet managed by this envelope.
func (e *Envelope) Controller() control.Controller { return e.controller }

// 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
Expand Down
Loading

0 comments on commit d01bef8

Please sign in to comment.