Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use component method calls for some of the envelope->weavelet calls. #686

Merged
merged 3 commits into from
Dec 15, 2023

Conversation

ghemawat
Copy link
Collaborator

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.

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.
@ghemawat ghemawat requested a review from mwhittaker December 14, 2023 22:19
Copy link
Member

@mwhittaker mwhittaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome change, Sanjay! When I tried to imagine what it would like to transition from using the pipe to using component method calls, I didn't foresee the change being so elegant.

And very helpful CL description too, thanks! 🙏

internal/weaver/remoteweavelet.go Outdated Show resolved Hide resolved
internal/weaver/remoteweavelet.go Outdated Show resolved Hide resolved
internal/weaver/remoteweavelet.go Outdated Show resolved Hide resolved
runtime/envelope/envelope.go Show resolved Hide resolved
runtime/envelope/envelope.go Outdated Show resolved Hide resolved
runtime/envelope/envelope.go Show resolved Hide resolved
controller.go Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@ghemawat ghemawat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

runtime/envelope/envelope.go Show resolved Hide resolved
runtime/envelope/envelope.go Outdated Show resolved Hide resolved
runtime/envelope/envelope.go Show resolved Hide resolved
internal/weaver/remoteweavelet.go Outdated Show resolved Hide resolved
internal/weaver/remoteweavelet.go Outdated Show resolved Hide resolved
internal/weaver/remoteweavelet.go Outdated Show resolved Hide resolved
controller.go Outdated Show resolved Hide resolved
@ghemawat ghemawat merged commit 90c6b0e into ServiceWeaver:main Dec 15, 2023
7 checks passed
@ghemawat ghemawat deleted the wcomponent branch December 15, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants