-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use component method calls for some of the envelope->weavelet calls.
Previously, all envelope initiated communicaton to the weavelet was carried over a pair of pipes. This change switches some of that communication to be based on component method calls. In particular, the signal to start components is now carried by a method call (UpdateComponents) to a component hosted by the weavelet. Main changes ------------ 1. Introduce a controller component that is hosted by every remoteweavelet. 2. The envelope picks the name of a Unix domain socket and passes it to the weavelet it creates. 3. The envelope creates a stub pointing at this socket and makes calls to it to control the weavelet. (Currently only UpdateComponents is handled this way.) 4. remoteweavelet creates a controller implementation to handle method calls received over this Unix domain socket. Other changes ------------- 1. envelope.NewEnvelope() now takes an Options struct as an argument. This struct can contain an optional Logger and an optional Tracer. The supplied Logger and Tracer are used for calls made to the controller component. 2. envelope.NewEnvelope() creates a temporary directory and allocates a Unix domain socket inside the directory. It also arranges to remove the directory when cleaning up (by catching termination signals for examples). 3. The socket name is passed in the EnvelopeInfo proto sent to the weavelet. 4. RemoteWeavelet creates a controller component and listens for calls to it on the supplied socket. 5. Added deployers.NewUnixSocketPath(), which allocates a new socket name inside a supplied directory. 6. weavertest multi deployer manages its own socket creation when it bypasses envelope.NewEnvelope(). 7. website/blog/deployers/deployers_test.go kills child processes using SIGTERM instead of SIGKILL. This allows the child process a chance to clean up its temporary directories. 8. deployers_test.go logs the stderr and stdout lines it receives instead of dropping them on the floor. This can be very helpful when things aren't working as expected. 9. The deployer examples in the blog import the weaver package so they have access to the controller component registration.
- Loading branch information
Showing
24 changed files
with
1,057 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package weaver | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ServiceWeaver/weaver/runtime/protos" | ||
) | ||
|
||
// controller is a component hosted in every weavelet. Deployers make calls to this component to | ||
// fetch information about the weavelet, and to make it do various things. | ||
// | ||
// 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) | ||
} | ||
|
||
// noopController is a no-op implementation of controller. It exists solely to cause | ||
// controller to be registered as a component. The actual implementation is provided | ||
// by internal/weaver/remoteweavelet.go | ||
type noopController struct { | ||
Implements[controller] | ||
} | ||
|
||
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.