texera
texera copied to clipboard
Migrate scala control messages to protobuf
This PR migrates all Scala control messages and their corresponding handlers to use gRPC.
Main Changes
-
Rewrote
AsyncRPCServer
andAsyncRPCClient
- Adjusted both to fit into the generated gRPC interface, while keeping RPCs sent and received through actor messages.
-
Centralized RPC Definitions
- All RPC messages and method definitions are now located in:
src/main/protobuf/edu/uci/ics/amber/engine/architecture/rpc
- All RPC messages and method definitions are now located in:
-
Preserved Existing Handler Definitions
- The previous way of defining RPC handlers has been retained for compatibility.
-
Removed Unused RPCs
- Deleted obsolete RPCs:
-
QueryCurrentInputTuple
-
ShutdownDPThread
-
- Deleted obsolete RPCs:
-
Unified Logic Modification RPCs
- Merged Fries/Python logic modification RPCs into one:
-
Before:
-
Reconfigure
(Fries) -
UpdateExecutor
(Python code update)
-
-
After:
-
ModifyLogic
(Unified)
-
-
Before:
- Merged Fries/Python logic modification RPCs into one:
Steps to Create New RPCs
-
Create a request proto message in
controlcommands.proto
with all necessary inputs. -
Create a response proto message in
controlreturns.proto
. -
Define the RPC:
- For controller-handled RPCs, add the definition to
controllerservice.proto
. - For worker-handled RPCs, add it to
workerservice.proto
.
- For controller-handled RPCs, add the definition to
-
Generate Scala code by running
protocGenerate
in the SBT shell. -
Implement the RPC handler in either
ControllerAsyncRPCHandlerInitializer
orWorkerAsyncRPCHandlerInitializer
, and move it to thepromisehandlers
folder for better organization.
Changes in Sending RPCs
Example: Using the StartWorkflow
RPC, which is handled by the controller.
-
Before this PR:
send(StartWorkflow(), CONTROLLER).map { ret => // handle the return value }
-
After this PR:
controllerInterface.startWorkflow(EmptyRequest(), mkContext(CONTROLLER)).map { resp => // handle the response }
Advanced Usage: Direct Control Invocation
To create a control invocation directly (advanced use case):
import edu.uci.ics.amber.engine.common.rpc.AsyncRPCClient.ControlInvocation
ControlInvocation(
METHOD_RPC_NAME,
PayloadRequest(),
AsyncRPCContext(senderID, receiverID),
commandID
)