Skip to content

Commit

Permalink
Refactor gRPC API
Browse files Browse the repository at this point in the history
Split proto file in services + messages.

Rename package agent_api -> edgeless_api.
  • Loading branch information
ccicconetti committed Sep 20, 2023
1 parent 55948a1 commit 57191d0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 69 deletions.
2 changes: 1 addition & 1 deletion edgeless_api/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "grpc_impl")]
{
tonic_build::compile_protos("proto/agent_api.proto")?;
tonic_build::compile_protos("proto/services.proto")?;
}
Ok(())
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
syntax = "proto3";
import "google/protobuf/empty.proto";
package agent_api;

//////////////////////////////////////////////////////////////////////////
// Messages and data types
//////////////////////////////////////////////////////////////////////////
package edgeless_api;

// Function instance identifier.
message InstanceId {
Expand Down Expand Up @@ -180,65 +176,3 @@ message ResourceInstanceSpecification {
// Map between the callbacks and instances that will be called.
map<string, InstanceId> output_callback_definitions = 3;
}

//////////////////////////////////////////////////////////////////////////
// Services
//////////////////////////////////////////////////////////////////////////

// API to manage the lifecycle of function instances (s07).
service FunctionInstance {
// Start a new function instance.
// Input: request containing the description of the function to create.
// Output: the function instance identifier assigned
rpc Start (SpawnFunctionRequest) returns (InstanceId);

// Stop a running function instance.
// Input: the identifier of the function instance to tear down.
// Output: none.
rpc Stop (InstanceId) returns (google.protobuf.Empty );

// Update a running function instance by changing the mapping between the
// callback declarations and function instances.
// Input: the update mapping.
// Output: none.
rpc UpdateLinks (UpdateFunctionLinksRequest) returns (google.protobuf.Empty);
}

// API to manage the lifecycle of workflow instances (s04).
service WorkflowInstance {
// Start a new workflow.
// Input: request containing the description of the workflow to create.
// Output: the status of workflow instance newly created.
rpc Start (SpawnWorkflowRequest) returns (WorkflowInstanceStatus);

// Stop an active workflow.
// Input: the identifier of the workflow to tear down.
// Output: none.

rpc Stop (WorkflowId) returns (google.protobuf.Empty);
// List the active workflows or shows the status of a given active workflow.
// Input: the identifier of the active workflow or a special value indicating all workflows.
// Output: the list of status of the active workflow instances.
rpc List (WorkflowId) returns (WorkflowInstanceList);
}

// API to handle events (s01).
service FunctionInvocation {
// Handle an event.
// Input: event to be handled.
// Output: none.
rpc Handle (Event) returns (google.protobuf.Empty);
}

// API to handle the lifecycle of resources (s06).
service ResourceConfiguration {
// Create a new resource.
// Input: specification of the resource to be created.
// Output: the identifier of the newly created resource.
rpc Start (ResourceInstanceSpecification) returns (InstanceId);

// Terminate an existing resource.
// Input: the identifier of the resource to be terminated.
// Output: none.
rpc Stop (InstanceId) returns (google.protobuf.Empty);
}
64 changes: 64 additions & 0 deletions edgeless_api/proto/services.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
syntax = "proto3";

import "google/protobuf/empty.proto";
import "messages.proto";

package edgeless_api;

// API to manage the lifecycle of function instances (s07).
service FunctionInstance {
// Start a new function instance.
// Input: request containing the description of the function to create.
// Output: the function instance identifier assigned
rpc Start (SpawnFunctionRequest) returns (InstanceId);

// Stop a running function instance.
// Input: the identifier of the function instance to tear down.
// Output: none.
rpc Stop (InstanceId) returns (google.protobuf.Empty );

// Update a running function instance by changing the mapping between the
// callback declarations and function instances.
// Input: the update mapping.
// Output: none.
rpc UpdateLinks (UpdateFunctionLinksRequest) returns (google.protobuf.Empty);
}

// API to manage the lifecycle of workflow instances (s04).
service WorkflowInstance {
// Start a new workflow.
// Input: request containing the description of the workflow to create.
// Output: the status of workflow instance newly created.
rpc Start (SpawnWorkflowRequest) returns (WorkflowInstanceStatus);

// Stop an active workflow.
// Input: the identifier of the workflow to tear down.
// Output: none.

rpc Stop (WorkflowId) returns (google.protobuf.Empty);
// List the active workflows or shows the status of a given active workflow.
// Input: the identifier of the active workflow or a special value indicating all workflows.
// Output: the list of status of the active workflow instances.
rpc List (WorkflowId) returns (WorkflowInstanceList);
}

// API to handle events (s01).
service FunctionInvocation {
// Handle an event.
// Input: event to be handled.
// Output: none.
rpc Handle (Event) returns (google.protobuf.Empty);
}

// API to handle the lifecycle of resources (s06).
service ResourceConfiguration {
// Create a new resource.
// Input: specification of the resource to be created.
// Output: the identifier of the newly created resource.
rpc Start (ResourceInstanceSpecification) returns (InstanceId);

// Terminate an existing resource.
// Input: the identifier of the resource to be terminated.
// Output: none.
rpc Stop (InstanceId) returns (google.protobuf.Empty);
}
2 changes: 1 addition & 1 deletion edgeless_api/src/grpc_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ pub mod invocation;
pub mod resource_configuration;

pub mod api {
tonic::include_proto!("agent_api");
tonic::include_proto!("edgeless_api");
}

0 comments on commit 57191d0

Please sign in to comment.