Skip to content

Commit

Permalink
internal/runner: add ExecuteRequest.stop to runner.proto
Browse files Browse the repository at this point in the history
  • Loading branch information
adambabik committed Feb 17, 2023
1 parent 0529942 commit b802b95
Show file tree
Hide file tree
Showing 14 changed files with 479 additions and 235 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

[*.proto]
indent_style = space
indent_size = 2

# Tab indentation (no size specified)
[Makefile]
indent_style = tab
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ install/goreleaser:

.PHONY: proto/generate
proto/generate:
buf lint
buf format -w
buf generate

.PHONY: proto/clean
Expand Down
30 changes: 15 additions & 15 deletions internal/api/runme/parser/v1/parser.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@ package runme.parser.v1;
option go_package = "github.com/stateful/runme/internal/gen/proto/go/runme/parser/v1;parserv1";

message Notebook {
repeated Cell cells = 1;
map<string, string> metadata = 2;
repeated Cell cells = 1;
map<string, string> metadata = 2;
}

enum CellKind {
CELL_KIND_UNSPECIFIED = 0;
CELL_KIND_MARKUP = 1;
CELL_KIND_CODE = 2;
CELL_KIND_UNSPECIFIED = 0;
CELL_KIND_MARKUP = 1;
CELL_KIND_CODE = 2;
}

message Cell {
CellKind kind = 1;
string value = 2;
string language_id = 3;
map<string, string> metadata = 4;
CellKind kind = 1;
string value = 2;
string language_id = 3;
map<string, string> metadata = 4;
}

message DeserializeRequest {
bytes source = 1;
bytes source = 1;
}

message DeserializeResponse {
Notebook notebook = 1;
Notebook notebook = 1;
}

message SerializeRequest {
Notebook notebook = 1;
Notebook notebook = 1;
}

message SerializeResponse {
bytes result = 1;
bytes result = 1;
}

service ParserService {
rpc Deserialize(DeserializeRequest) returns (DeserializeResponse) {}
rpc Serialize(SerializeRequest) returns (SerializeResponse) {}
rpc Deserialize(DeserializeRequest) returns (DeserializeResponse) {}
rpc Serialize(SerializeRequest) returns (SerializeResponse) {}
}
160 changes: 84 additions & 76 deletions internal/api/runme/runner/v1/runner.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,120 +3,128 @@ syntax = "proto3";
package runme.runner.v1;

import "google/protobuf/wrappers.proto";
import "google/protobuf/duration.proto";

option go_package = "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v1;runnerv1";

message Session {
string id = 1;
string id = 1;

// envs keeps track of session environment variables.
// They can be modified by executing programs which
// alter them through "export" and "unset" commands.
repeated string envs = 2;
// envs keeps track of session environment variables.
// They can be modified by executing programs which
// alter them through "export" and "unset" commands.
repeated string envs = 2;

// metadata is a map of client specific metadata.
map<string, string> metadata = 3;
// metadata is a map of client specific metadata.
map<string, string> metadata = 3;
}

message CreateSessionRequest {
// metadata is a map of client specific metadata.
map<string, string> metadata = 1;
// metadata is a map of client specific metadata.
map<string, string> metadata = 1;

// envs field provides an initial set of environment variables
// for a newly created session.
repeated string envs = 2;
// envs field provides an initial set of environment variables
// for a newly created session.
repeated string envs = 2;
}

message CreateSessionResponse {
Session session = 1;
Session session = 1;
}

message GetSessionRequest {
string id = 1;
string id = 1;
}

message GetSessionResponse {
Session session = 1;
Session session = 1;
}

message ListSessionsRequest {}

message ListSessionsResponse {
repeated Session sessions = 1;
repeated Session sessions = 1;
}

message DeleteSessionRequest {
string id = 1;
string id = 1;
}

message DeleteSessionResponse {}

enum ExecuteStop {
EXECUTE_STOP_UNSPECIFIED = 0;
EXECUTE_STOP_INTERRUPT = 1;
EXECUTE_STOP_KILL = 2;
}

message ExecuteRequest {
// program_name is a name of the program to execute.
// If it's not a path (relative or absolute), the runner
// will try to resolve the name.
// For example: "sh", "/bin/bash".
string program_name = 1;

// arguments is a list of arguments passed to the program.
repeated string arguments = 2;

// directory to execute the program in.
string directory = 3;

// envs is a list of additional environment variables
// that will be injected to the executed program.
repeated string envs = 4;

// commands are commands to be executed by the program.
// The commands are joined and executed as a script.
// For example: "echo 'Hello, World'", "ls -l /etc".
// This is mutually exclusive with the script field.
repeated string commands = 5;

// script is code to be executed by the program.
// Individual lines are joined with the new line character.
// This is mutually exclusive with the commands field.
string script = 6;

// tty when true allocates a pseudo-TTY.
bool tty = 7;

// input_data is a byte array that will be send as input
// to the program.
// It is allowed in the consecutive calls only.
bytes input_data = 8;

// session_id indicates in which Session the program should execute.
// Executing in a Session might provide additional context like
// environment variables.
string session_id = 20;
// program_name is a name of the program to execute.
// If it's not a path (relative or absolute), the runner
// will try to resolve the name.
// For example: "sh", "/bin/bash".
string program_name = 1;

// arguments is a list of arguments passed to the program.
repeated string arguments = 2;

// directory to execute the program in.
string directory = 3;

// envs is a list of additional environment variables
// that will be injected to the executed program.
repeated string envs = 4;

// commands are commands to be executed by the program.
// The commands are joined and executed as a script.
// For example: "echo 'Hello, World'", "ls -l /etc".
// This is mutually exclusive with the script field.
repeated string commands = 5;

// script is code to be executed by the program.
// Individual lines are joined with the new line character.
// This is mutually exclusive with the commands field.
string script = 6;

// tty when true allocates a pseudo-TTY.
bool tty = 7;

// input_data is a byte array that will be send as input
// to the program.
bytes input_data = 8;

// stop requests the running process to be stopped.
// It is allowed only in the consecutive calls.
ExecuteStop stop = 9;

// session_id indicates in which Session the program should execute.
// Executing in a Session might provide additional context like
// environment variables.
string session_id = 20;
}

message ExecuteResponse {
// exit_code is sent only in the final message.
google.protobuf.UInt32Value exit_code = 1;
// exit_code is sent only in the final message.
google.protobuf.UInt32Value exit_code = 1;

// stdout_data contains bytes from stdout since the last response.
bytes stdout_data = 2;
// stdout_data contains bytes from stdout since the last response.
bytes stdout_data = 2;

// stderr_data contains bytes from stderr since the last response.
bytes stderr_data = 3;
// stderr_data contains bytes from stderr since the last response.
bytes stderr_data = 3;
}

service RunnerService {
rpc CreateSession(CreateSessionRequest) returns (CreateSessionResponse) {};
rpc GetSession(GetSessionRequest) returns (GetSessionResponse) {};
rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) {};
rpc DeleteSession(DeleteSessionRequest) returns (DeleteSessionResponse) {};

// Execute executes a program. Examine "ExecuteRequest" to explore
// configuration options.
//
// It's a bidirectional stream RPC method. It expects the first
// "ExecuteRequest" to contain details of a program to execute.
// Subsequent "ExecuteRequest" should only contain "input_data" as
// other fields will be ignored.
rpc Execute(stream ExecuteRequest) returns (stream ExecuteResponse) {};
rpc CreateSession(CreateSessionRequest) returns (CreateSessionResponse) {}
rpc GetSession(GetSessionRequest) returns (GetSessionResponse) {}
rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) {}
rpc DeleteSession(DeleteSessionRequest) returns (DeleteSessionResponse) {}

// Execute executes a program. Examine "ExecuteRequest" to explore
// configuration options.
//
// It's a bidirectional stream RPC method. It expects the first
// "ExecuteRequest" to contain details of a program to execute.
// Subsequent "ExecuteRequest" should only contain "input_data" as
// other fields will be ignored.
rpc Execute(stream ExecuteRequest) returns (stream ExecuteResponse) {}
}
Loading

0 comments on commit b802b95

Please sign in to comment.