forked from wrenn/wrenn
Prototype with single host server and no admin panel (#2)
Reviewed-on: wrenn/sandbox#2 Co-authored-by: pptx704 <rafeed@omukk.dev> Co-committed-by: pptx704 <rafeed@omukk.dev>
This commit is contained in:
13
proto/envd/buf.gen.yaml
Normal file
13
proto/envd/buf.gen.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
version: v2
|
||||
plugins:
|
||||
- protoc_builtin: go
|
||||
out: gen
|
||||
opt: paths=source_relative
|
||||
- local: protoc-gen-connect-go
|
||||
out: gen
|
||||
opt: paths=source_relative
|
||||
managed:
|
||||
enabled: true
|
||||
override:
|
||||
- file_option: go_package_prefix
|
||||
value: git.omukk.dev/wrenn/sandbox/proto/envd/gen
|
||||
3
proto/envd/buf.yaml
Normal file
3
proto/envd/buf.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
version: v2
|
||||
modules:
|
||||
- path: .
|
||||
@ -0,0 +1,137 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package filesystem;
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
service Filesystem {
|
||||
rpc Stat(StatRequest) returns (StatResponse);
|
||||
rpc MakeDir(MakeDirRequest) returns (MakeDirResponse);
|
||||
rpc Move(MoveRequest) returns (MoveResponse);
|
||||
rpc ListDir(ListDirRequest) returns (ListDirResponse);
|
||||
rpc Remove(RemoveRequest) returns (RemoveResponse);
|
||||
|
||||
rpc WatchDir(WatchDirRequest) returns (stream WatchDirResponse);
|
||||
|
||||
// Non-streaming versions of WatchDir
|
||||
rpc CreateWatcher(CreateWatcherRequest) returns (CreateWatcherResponse);
|
||||
rpc GetWatcherEvents(GetWatcherEventsRequest) returns (GetWatcherEventsResponse);
|
||||
rpc RemoveWatcher(RemoveWatcherRequest) returns (RemoveWatcherResponse);
|
||||
}
|
||||
|
||||
message MoveRequest {
|
||||
string source = 1;
|
||||
string destination = 2;
|
||||
}
|
||||
|
||||
message MoveResponse {
|
||||
EntryInfo entry = 1;
|
||||
}
|
||||
|
||||
message MakeDirRequest {
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
message MakeDirResponse {
|
||||
EntryInfo entry = 1;
|
||||
}
|
||||
|
||||
message RemoveRequest {
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
message RemoveResponse {}
|
||||
|
||||
message StatRequest {
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
message StatResponse {
|
||||
EntryInfo entry = 1;
|
||||
}
|
||||
|
||||
message EntryInfo {
|
||||
string name = 1;
|
||||
FileType type = 2;
|
||||
string path = 3;
|
||||
int64 size = 4;
|
||||
uint32 mode = 5;
|
||||
string permissions = 6;
|
||||
string owner = 7;
|
||||
string group = 8;
|
||||
google.protobuf.Timestamp modified_time = 9;
|
||||
// If the entry is a symlink, this field contains the target of the symlink.
|
||||
optional string symlink_target = 10;
|
||||
}
|
||||
|
||||
enum FileType {
|
||||
FILE_TYPE_UNSPECIFIED = 0;
|
||||
FILE_TYPE_FILE = 1;
|
||||
FILE_TYPE_DIRECTORY = 2;
|
||||
FILE_TYPE_SYMLINK = 3;
|
||||
}
|
||||
|
||||
message ListDirRequest {
|
||||
string path = 1;
|
||||
uint32 depth = 2;
|
||||
}
|
||||
|
||||
message ListDirResponse {
|
||||
repeated EntryInfo entries = 1;
|
||||
}
|
||||
|
||||
message WatchDirRequest {
|
||||
string path = 1;
|
||||
bool recursive = 2;
|
||||
}
|
||||
|
||||
message FilesystemEvent {
|
||||
string name = 1;
|
||||
EventType type = 2;
|
||||
}
|
||||
|
||||
message WatchDirResponse {
|
||||
oneof event {
|
||||
StartEvent start = 1;
|
||||
FilesystemEvent filesystem = 2;
|
||||
KeepAlive keepalive = 3;
|
||||
}
|
||||
|
||||
message StartEvent {}
|
||||
|
||||
message KeepAlive {}
|
||||
}
|
||||
|
||||
message CreateWatcherRequest {
|
||||
string path = 1;
|
||||
bool recursive = 2;
|
||||
}
|
||||
|
||||
message CreateWatcherResponse {
|
||||
string watcher_id = 1;
|
||||
}
|
||||
|
||||
message GetWatcherEventsRequest {
|
||||
string watcher_id = 1;
|
||||
}
|
||||
|
||||
message GetWatcherEventsResponse {
|
||||
repeated FilesystemEvent events = 1;
|
||||
}
|
||||
|
||||
message RemoveWatcherRequest {
|
||||
string watcher_id = 1;
|
||||
}
|
||||
|
||||
message RemoveWatcherResponse {}
|
||||
|
||||
enum EventType {
|
||||
EVENT_TYPE_UNSPECIFIED = 0;
|
||||
EVENT_TYPE_CREATE = 1;
|
||||
EVENT_TYPE_WRITE = 2;
|
||||
EVENT_TYPE_REMOVE = 3;
|
||||
EVENT_TYPE_RENAME = 4;
|
||||
EVENT_TYPE_CHMOD = 5;
|
||||
}
|
||||
|
||||
1446
proto/envd/gen/filesystem.pb.go
Normal file
1446
proto/envd/gen/filesystem.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
339
proto/envd/gen/genconnect/filesystem.connect.go
Normal file
339
proto/envd/gen/genconnect/filesystem.connect.go
Normal file
@ -0,0 +1,339 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: filesystem.proto
|
||||
|
||||
package genconnect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
gen "git.omukk.dev/wrenn/sandbox/proto/envd/gen"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file and the connect package are
|
||||
// compatible. If you get a compiler error that this constant is not defined, this code was
|
||||
// generated with a version of connect newer than the one compiled into your binary. You can fix the
|
||||
// problem by either regenerating this code with an older version of connect or updating the connect
|
||||
// version compiled into your binary.
|
||||
const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// FilesystemName is the fully-qualified name of the Filesystem service.
|
||||
FilesystemName = "filesystem.Filesystem"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
|
||||
//
|
||||
// Note that these are different from the fully-qualified method names used by
|
||||
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
|
||||
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
|
||||
// period.
|
||||
const (
|
||||
// FilesystemStatProcedure is the fully-qualified name of the Filesystem's Stat RPC.
|
||||
FilesystemStatProcedure = "/filesystem.Filesystem/Stat"
|
||||
// FilesystemMakeDirProcedure is the fully-qualified name of the Filesystem's MakeDir RPC.
|
||||
FilesystemMakeDirProcedure = "/filesystem.Filesystem/MakeDir"
|
||||
// FilesystemMoveProcedure is the fully-qualified name of the Filesystem's Move RPC.
|
||||
FilesystemMoveProcedure = "/filesystem.Filesystem/Move"
|
||||
// FilesystemListDirProcedure is the fully-qualified name of the Filesystem's ListDir RPC.
|
||||
FilesystemListDirProcedure = "/filesystem.Filesystem/ListDir"
|
||||
// FilesystemRemoveProcedure is the fully-qualified name of the Filesystem's Remove RPC.
|
||||
FilesystemRemoveProcedure = "/filesystem.Filesystem/Remove"
|
||||
// FilesystemWatchDirProcedure is the fully-qualified name of the Filesystem's WatchDir RPC.
|
||||
FilesystemWatchDirProcedure = "/filesystem.Filesystem/WatchDir"
|
||||
// FilesystemCreateWatcherProcedure is the fully-qualified name of the Filesystem's CreateWatcher
|
||||
// RPC.
|
||||
FilesystemCreateWatcherProcedure = "/filesystem.Filesystem/CreateWatcher"
|
||||
// FilesystemGetWatcherEventsProcedure is the fully-qualified name of the Filesystem's
|
||||
// GetWatcherEvents RPC.
|
||||
FilesystemGetWatcherEventsProcedure = "/filesystem.Filesystem/GetWatcherEvents"
|
||||
// FilesystemRemoveWatcherProcedure is the fully-qualified name of the Filesystem's RemoveWatcher
|
||||
// RPC.
|
||||
FilesystemRemoveWatcherProcedure = "/filesystem.Filesystem/RemoveWatcher"
|
||||
)
|
||||
|
||||
// FilesystemClient is a client for the filesystem.Filesystem service.
|
||||
type FilesystemClient interface {
|
||||
Stat(context.Context, *connect.Request[gen.StatRequest]) (*connect.Response[gen.StatResponse], error)
|
||||
MakeDir(context.Context, *connect.Request[gen.MakeDirRequest]) (*connect.Response[gen.MakeDirResponse], error)
|
||||
Move(context.Context, *connect.Request[gen.MoveRequest]) (*connect.Response[gen.MoveResponse], error)
|
||||
ListDir(context.Context, *connect.Request[gen.ListDirRequest]) (*connect.Response[gen.ListDirResponse], error)
|
||||
Remove(context.Context, *connect.Request[gen.RemoveRequest]) (*connect.Response[gen.RemoveResponse], error)
|
||||
WatchDir(context.Context, *connect.Request[gen.WatchDirRequest]) (*connect.ServerStreamForClient[gen.WatchDirResponse], error)
|
||||
// Non-streaming versions of WatchDir
|
||||
CreateWatcher(context.Context, *connect.Request[gen.CreateWatcherRequest]) (*connect.Response[gen.CreateWatcherResponse], error)
|
||||
GetWatcherEvents(context.Context, *connect.Request[gen.GetWatcherEventsRequest]) (*connect.Response[gen.GetWatcherEventsResponse], error)
|
||||
RemoveWatcher(context.Context, *connect.Request[gen.RemoveWatcherRequest]) (*connect.Response[gen.RemoveWatcherResponse], error)
|
||||
}
|
||||
|
||||
// NewFilesystemClient constructs a client for the filesystem.Filesystem service. By default, it
|
||||
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
|
||||
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
|
||||
// connect.WithGRPCWeb() options.
|
||||
//
|
||||
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewFilesystemClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) FilesystemClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
filesystemMethods := gen.File_filesystem_proto.Services().ByName("Filesystem").Methods()
|
||||
return &filesystemClient{
|
||||
stat: connect.NewClient[gen.StatRequest, gen.StatResponse](
|
||||
httpClient,
|
||||
baseURL+FilesystemStatProcedure,
|
||||
connect.WithSchema(filesystemMethods.ByName("Stat")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
makeDir: connect.NewClient[gen.MakeDirRequest, gen.MakeDirResponse](
|
||||
httpClient,
|
||||
baseURL+FilesystemMakeDirProcedure,
|
||||
connect.WithSchema(filesystemMethods.ByName("MakeDir")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
move: connect.NewClient[gen.MoveRequest, gen.MoveResponse](
|
||||
httpClient,
|
||||
baseURL+FilesystemMoveProcedure,
|
||||
connect.WithSchema(filesystemMethods.ByName("Move")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listDir: connect.NewClient[gen.ListDirRequest, gen.ListDirResponse](
|
||||
httpClient,
|
||||
baseURL+FilesystemListDirProcedure,
|
||||
connect.WithSchema(filesystemMethods.ByName("ListDir")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
remove: connect.NewClient[gen.RemoveRequest, gen.RemoveResponse](
|
||||
httpClient,
|
||||
baseURL+FilesystemRemoveProcedure,
|
||||
connect.WithSchema(filesystemMethods.ByName("Remove")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
watchDir: connect.NewClient[gen.WatchDirRequest, gen.WatchDirResponse](
|
||||
httpClient,
|
||||
baseURL+FilesystemWatchDirProcedure,
|
||||
connect.WithSchema(filesystemMethods.ByName("WatchDir")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
createWatcher: connect.NewClient[gen.CreateWatcherRequest, gen.CreateWatcherResponse](
|
||||
httpClient,
|
||||
baseURL+FilesystemCreateWatcherProcedure,
|
||||
connect.WithSchema(filesystemMethods.ByName("CreateWatcher")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getWatcherEvents: connect.NewClient[gen.GetWatcherEventsRequest, gen.GetWatcherEventsResponse](
|
||||
httpClient,
|
||||
baseURL+FilesystemGetWatcherEventsProcedure,
|
||||
connect.WithSchema(filesystemMethods.ByName("GetWatcherEvents")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
removeWatcher: connect.NewClient[gen.RemoveWatcherRequest, gen.RemoveWatcherResponse](
|
||||
httpClient,
|
||||
baseURL+FilesystemRemoveWatcherProcedure,
|
||||
connect.WithSchema(filesystemMethods.ByName("RemoveWatcher")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// filesystemClient implements FilesystemClient.
|
||||
type filesystemClient struct {
|
||||
stat *connect.Client[gen.StatRequest, gen.StatResponse]
|
||||
makeDir *connect.Client[gen.MakeDirRequest, gen.MakeDirResponse]
|
||||
move *connect.Client[gen.MoveRequest, gen.MoveResponse]
|
||||
listDir *connect.Client[gen.ListDirRequest, gen.ListDirResponse]
|
||||
remove *connect.Client[gen.RemoveRequest, gen.RemoveResponse]
|
||||
watchDir *connect.Client[gen.WatchDirRequest, gen.WatchDirResponse]
|
||||
createWatcher *connect.Client[gen.CreateWatcherRequest, gen.CreateWatcherResponse]
|
||||
getWatcherEvents *connect.Client[gen.GetWatcherEventsRequest, gen.GetWatcherEventsResponse]
|
||||
removeWatcher *connect.Client[gen.RemoveWatcherRequest, gen.RemoveWatcherResponse]
|
||||
}
|
||||
|
||||
// Stat calls filesystem.Filesystem.Stat.
|
||||
func (c *filesystemClient) Stat(ctx context.Context, req *connect.Request[gen.StatRequest]) (*connect.Response[gen.StatResponse], error) {
|
||||
return c.stat.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// MakeDir calls filesystem.Filesystem.MakeDir.
|
||||
func (c *filesystemClient) MakeDir(ctx context.Context, req *connect.Request[gen.MakeDirRequest]) (*connect.Response[gen.MakeDirResponse], error) {
|
||||
return c.makeDir.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// Move calls filesystem.Filesystem.Move.
|
||||
func (c *filesystemClient) Move(ctx context.Context, req *connect.Request[gen.MoveRequest]) (*connect.Response[gen.MoveResponse], error) {
|
||||
return c.move.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListDir calls filesystem.Filesystem.ListDir.
|
||||
func (c *filesystemClient) ListDir(ctx context.Context, req *connect.Request[gen.ListDirRequest]) (*connect.Response[gen.ListDirResponse], error) {
|
||||
return c.listDir.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// Remove calls filesystem.Filesystem.Remove.
|
||||
func (c *filesystemClient) Remove(ctx context.Context, req *connect.Request[gen.RemoveRequest]) (*connect.Response[gen.RemoveResponse], error) {
|
||||
return c.remove.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// WatchDir calls filesystem.Filesystem.WatchDir.
|
||||
func (c *filesystemClient) WatchDir(ctx context.Context, req *connect.Request[gen.WatchDirRequest]) (*connect.ServerStreamForClient[gen.WatchDirResponse], error) {
|
||||
return c.watchDir.CallServerStream(ctx, req)
|
||||
}
|
||||
|
||||
// CreateWatcher calls filesystem.Filesystem.CreateWatcher.
|
||||
func (c *filesystemClient) CreateWatcher(ctx context.Context, req *connect.Request[gen.CreateWatcherRequest]) (*connect.Response[gen.CreateWatcherResponse], error) {
|
||||
return c.createWatcher.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetWatcherEvents calls filesystem.Filesystem.GetWatcherEvents.
|
||||
func (c *filesystemClient) GetWatcherEvents(ctx context.Context, req *connect.Request[gen.GetWatcherEventsRequest]) (*connect.Response[gen.GetWatcherEventsResponse], error) {
|
||||
return c.getWatcherEvents.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// RemoveWatcher calls filesystem.Filesystem.RemoveWatcher.
|
||||
func (c *filesystemClient) RemoveWatcher(ctx context.Context, req *connect.Request[gen.RemoveWatcherRequest]) (*connect.Response[gen.RemoveWatcherResponse], error) {
|
||||
return c.removeWatcher.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// FilesystemHandler is an implementation of the filesystem.Filesystem service.
|
||||
type FilesystemHandler interface {
|
||||
Stat(context.Context, *connect.Request[gen.StatRequest]) (*connect.Response[gen.StatResponse], error)
|
||||
MakeDir(context.Context, *connect.Request[gen.MakeDirRequest]) (*connect.Response[gen.MakeDirResponse], error)
|
||||
Move(context.Context, *connect.Request[gen.MoveRequest]) (*connect.Response[gen.MoveResponse], error)
|
||||
ListDir(context.Context, *connect.Request[gen.ListDirRequest]) (*connect.Response[gen.ListDirResponse], error)
|
||||
Remove(context.Context, *connect.Request[gen.RemoveRequest]) (*connect.Response[gen.RemoveResponse], error)
|
||||
WatchDir(context.Context, *connect.Request[gen.WatchDirRequest], *connect.ServerStream[gen.WatchDirResponse]) error
|
||||
// Non-streaming versions of WatchDir
|
||||
CreateWatcher(context.Context, *connect.Request[gen.CreateWatcherRequest]) (*connect.Response[gen.CreateWatcherResponse], error)
|
||||
GetWatcherEvents(context.Context, *connect.Request[gen.GetWatcherEventsRequest]) (*connect.Response[gen.GetWatcherEventsResponse], error)
|
||||
RemoveWatcher(context.Context, *connect.Request[gen.RemoveWatcherRequest]) (*connect.Response[gen.RemoveWatcherResponse], error)
|
||||
}
|
||||
|
||||
// NewFilesystemHandler builds an HTTP handler from the service implementation. It returns the path
|
||||
// on which to mount the handler and the handler itself.
|
||||
//
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewFilesystemHandler(svc FilesystemHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
filesystemMethods := gen.File_filesystem_proto.Services().ByName("Filesystem").Methods()
|
||||
filesystemStatHandler := connect.NewUnaryHandler(
|
||||
FilesystemStatProcedure,
|
||||
svc.Stat,
|
||||
connect.WithSchema(filesystemMethods.ByName("Stat")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
filesystemMakeDirHandler := connect.NewUnaryHandler(
|
||||
FilesystemMakeDirProcedure,
|
||||
svc.MakeDir,
|
||||
connect.WithSchema(filesystemMethods.ByName("MakeDir")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
filesystemMoveHandler := connect.NewUnaryHandler(
|
||||
FilesystemMoveProcedure,
|
||||
svc.Move,
|
||||
connect.WithSchema(filesystemMethods.ByName("Move")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
filesystemListDirHandler := connect.NewUnaryHandler(
|
||||
FilesystemListDirProcedure,
|
||||
svc.ListDir,
|
||||
connect.WithSchema(filesystemMethods.ByName("ListDir")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
filesystemRemoveHandler := connect.NewUnaryHandler(
|
||||
FilesystemRemoveProcedure,
|
||||
svc.Remove,
|
||||
connect.WithSchema(filesystemMethods.ByName("Remove")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
filesystemWatchDirHandler := connect.NewServerStreamHandler(
|
||||
FilesystemWatchDirProcedure,
|
||||
svc.WatchDir,
|
||||
connect.WithSchema(filesystemMethods.ByName("WatchDir")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
filesystemCreateWatcherHandler := connect.NewUnaryHandler(
|
||||
FilesystemCreateWatcherProcedure,
|
||||
svc.CreateWatcher,
|
||||
connect.WithSchema(filesystemMethods.ByName("CreateWatcher")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
filesystemGetWatcherEventsHandler := connect.NewUnaryHandler(
|
||||
FilesystemGetWatcherEventsProcedure,
|
||||
svc.GetWatcherEvents,
|
||||
connect.WithSchema(filesystemMethods.ByName("GetWatcherEvents")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
filesystemRemoveWatcherHandler := connect.NewUnaryHandler(
|
||||
FilesystemRemoveWatcherProcedure,
|
||||
svc.RemoveWatcher,
|
||||
connect.WithSchema(filesystemMethods.ByName("RemoveWatcher")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/filesystem.Filesystem/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case FilesystemStatProcedure:
|
||||
filesystemStatHandler.ServeHTTP(w, r)
|
||||
case FilesystemMakeDirProcedure:
|
||||
filesystemMakeDirHandler.ServeHTTP(w, r)
|
||||
case FilesystemMoveProcedure:
|
||||
filesystemMoveHandler.ServeHTTP(w, r)
|
||||
case FilesystemListDirProcedure:
|
||||
filesystemListDirHandler.ServeHTTP(w, r)
|
||||
case FilesystemRemoveProcedure:
|
||||
filesystemRemoveHandler.ServeHTTP(w, r)
|
||||
case FilesystemWatchDirProcedure:
|
||||
filesystemWatchDirHandler.ServeHTTP(w, r)
|
||||
case FilesystemCreateWatcherProcedure:
|
||||
filesystemCreateWatcherHandler.ServeHTTP(w, r)
|
||||
case FilesystemGetWatcherEventsProcedure:
|
||||
filesystemGetWatcherEventsHandler.ServeHTTP(w, r)
|
||||
case FilesystemRemoveWatcherProcedure:
|
||||
filesystemRemoveWatcherHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedFilesystemHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedFilesystemHandler struct{}
|
||||
|
||||
func (UnimplementedFilesystemHandler) Stat(context.Context, *connect.Request[gen.StatRequest]) (*connect.Response[gen.StatResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.Stat is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedFilesystemHandler) MakeDir(context.Context, *connect.Request[gen.MakeDirRequest]) (*connect.Response[gen.MakeDirResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.MakeDir is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedFilesystemHandler) Move(context.Context, *connect.Request[gen.MoveRequest]) (*connect.Response[gen.MoveResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.Move is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedFilesystemHandler) ListDir(context.Context, *connect.Request[gen.ListDirRequest]) (*connect.Response[gen.ListDirResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.ListDir is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedFilesystemHandler) Remove(context.Context, *connect.Request[gen.RemoveRequest]) (*connect.Response[gen.RemoveResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.Remove is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedFilesystemHandler) WatchDir(context.Context, *connect.Request[gen.WatchDirRequest], *connect.ServerStream[gen.WatchDirResponse]) error {
|
||||
return connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.WatchDir is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedFilesystemHandler) CreateWatcher(context.Context, *connect.Request[gen.CreateWatcherRequest]) (*connect.Response[gen.CreateWatcherResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.CreateWatcher is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedFilesystemHandler) GetWatcherEvents(context.Context, *connect.Request[gen.GetWatcherEventsRequest]) (*connect.Response[gen.GetWatcherEventsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.GetWatcherEvents is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedFilesystemHandler) RemoveWatcher(context.Context, *connect.Request[gen.RemoveWatcherRequest]) (*connect.Response[gen.RemoveWatcherResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("filesystem.Filesystem.RemoveWatcher is not implemented"))
|
||||
}
|
||||
312
proto/envd/gen/genconnect/process.connect.go
Normal file
312
proto/envd/gen/genconnect/process.connect.go
Normal file
@ -0,0 +1,312 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: process.proto
|
||||
|
||||
package genconnect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
gen "git.omukk.dev/wrenn/sandbox/proto/envd/gen"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file and the connect package are
|
||||
// compatible. If you get a compiler error that this constant is not defined, this code was
|
||||
// generated with a version of connect newer than the one compiled into your binary. You can fix the
|
||||
// problem by either regenerating this code with an older version of connect or updating the connect
|
||||
// version compiled into your binary.
|
||||
const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// ProcessName is the fully-qualified name of the Process service.
|
||||
ProcessName = "process.Process"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
|
||||
//
|
||||
// Note that these are different from the fully-qualified method names used by
|
||||
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
|
||||
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
|
||||
// period.
|
||||
const (
|
||||
// ProcessListProcedure is the fully-qualified name of the Process's List RPC.
|
||||
ProcessListProcedure = "/process.Process/List"
|
||||
// ProcessConnectProcedure is the fully-qualified name of the Process's Connect RPC.
|
||||
ProcessConnectProcedure = "/process.Process/Connect"
|
||||
// ProcessStartProcedure is the fully-qualified name of the Process's Start RPC.
|
||||
ProcessStartProcedure = "/process.Process/Start"
|
||||
// ProcessUpdateProcedure is the fully-qualified name of the Process's Update RPC.
|
||||
ProcessUpdateProcedure = "/process.Process/Update"
|
||||
// ProcessStreamInputProcedure is the fully-qualified name of the Process's StreamInput RPC.
|
||||
ProcessStreamInputProcedure = "/process.Process/StreamInput"
|
||||
// ProcessSendInputProcedure is the fully-qualified name of the Process's SendInput RPC.
|
||||
ProcessSendInputProcedure = "/process.Process/SendInput"
|
||||
// ProcessSendSignalProcedure is the fully-qualified name of the Process's SendSignal RPC.
|
||||
ProcessSendSignalProcedure = "/process.Process/SendSignal"
|
||||
// ProcessCloseStdinProcedure is the fully-qualified name of the Process's CloseStdin RPC.
|
||||
ProcessCloseStdinProcedure = "/process.Process/CloseStdin"
|
||||
)
|
||||
|
||||
// ProcessClient is a client for the process.Process service.
|
||||
type ProcessClient interface {
|
||||
List(context.Context, *connect.Request[gen.ListRequest]) (*connect.Response[gen.ListResponse], error)
|
||||
Connect(context.Context, *connect.Request[gen.ConnectRequest]) (*connect.ServerStreamForClient[gen.ConnectResponse], error)
|
||||
Start(context.Context, *connect.Request[gen.StartRequest]) (*connect.ServerStreamForClient[gen.StartResponse], error)
|
||||
Update(context.Context, *connect.Request[gen.UpdateRequest]) (*connect.Response[gen.UpdateResponse], error)
|
||||
// Client input stream ensures ordering of messages
|
||||
StreamInput(context.Context) *connect.ClientStreamForClient[gen.StreamInputRequest, gen.StreamInputResponse]
|
||||
SendInput(context.Context, *connect.Request[gen.SendInputRequest]) (*connect.Response[gen.SendInputResponse], error)
|
||||
SendSignal(context.Context, *connect.Request[gen.SendSignalRequest]) (*connect.Response[gen.SendSignalResponse], error)
|
||||
// Close stdin to signal EOF to the process.
|
||||
// Only works for non-PTY processes. For PTY, send Ctrl+D (0x04) instead.
|
||||
CloseStdin(context.Context, *connect.Request[gen.CloseStdinRequest]) (*connect.Response[gen.CloseStdinResponse], error)
|
||||
}
|
||||
|
||||
// NewProcessClient constructs a client for the process.Process service. By default, it uses the
|
||||
// Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
|
||||
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
|
||||
// connect.WithGRPCWeb() options.
|
||||
//
|
||||
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewProcessClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ProcessClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
processMethods := gen.File_process_proto.Services().ByName("Process").Methods()
|
||||
return &processClient{
|
||||
list: connect.NewClient[gen.ListRequest, gen.ListResponse](
|
||||
httpClient,
|
||||
baseURL+ProcessListProcedure,
|
||||
connect.WithSchema(processMethods.ByName("List")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
connect: connect.NewClient[gen.ConnectRequest, gen.ConnectResponse](
|
||||
httpClient,
|
||||
baseURL+ProcessConnectProcedure,
|
||||
connect.WithSchema(processMethods.ByName("Connect")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
start: connect.NewClient[gen.StartRequest, gen.StartResponse](
|
||||
httpClient,
|
||||
baseURL+ProcessStartProcedure,
|
||||
connect.WithSchema(processMethods.ByName("Start")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
update: connect.NewClient[gen.UpdateRequest, gen.UpdateResponse](
|
||||
httpClient,
|
||||
baseURL+ProcessUpdateProcedure,
|
||||
connect.WithSchema(processMethods.ByName("Update")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
streamInput: connect.NewClient[gen.StreamInputRequest, gen.StreamInputResponse](
|
||||
httpClient,
|
||||
baseURL+ProcessStreamInputProcedure,
|
||||
connect.WithSchema(processMethods.ByName("StreamInput")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
sendInput: connect.NewClient[gen.SendInputRequest, gen.SendInputResponse](
|
||||
httpClient,
|
||||
baseURL+ProcessSendInputProcedure,
|
||||
connect.WithSchema(processMethods.ByName("SendInput")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
sendSignal: connect.NewClient[gen.SendSignalRequest, gen.SendSignalResponse](
|
||||
httpClient,
|
||||
baseURL+ProcessSendSignalProcedure,
|
||||
connect.WithSchema(processMethods.ByName("SendSignal")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
closeStdin: connect.NewClient[gen.CloseStdinRequest, gen.CloseStdinResponse](
|
||||
httpClient,
|
||||
baseURL+ProcessCloseStdinProcedure,
|
||||
connect.WithSchema(processMethods.ByName("CloseStdin")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// processClient implements ProcessClient.
|
||||
type processClient struct {
|
||||
list *connect.Client[gen.ListRequest, gen.ListResponse]
|
||||
connect *connect.Client[gen.ConnectRequest, gen.ConnectResponse]
|
||||
start *connect.Client[gen.StartRequest, gen.StartResponse]
|
||||
update *connect.Client[gen.UpdateRequest, gen.UpdateResponse]
|
||||
streamInput *connect.Client[gen.StreamInputRequest, gen.StreamInputResponse]
|
||||
sendInput *connect.Client[gen.SendInputRequest, gen.SendInputResponse]
|
||||
sendSignal *connect.Client[gen.SendSignalRequest, gen.SendSignalResponse]
|
||||
closeStdin *connect.Client[gen.CloseStdinRequest, gen.CloseStdinResponse]
|
||||
}
|
||||
|
||||
// List calls process.Process.List.
|
||||
func (c *processClient) List(ctx context.Context, req *connect.Request[gen.ListRequest]) (*connect.Response[gen.ListResponse], error) {
|
||||
return c.list.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// Connect calls process.Process.Connect.
|
||||
func (c *processClient) Connect(ctx context.Context, req *connect.Request[gen.ConnectRequest]) (*connect.ServerStreamForClient[gen.ConnectResponse], error) {
|
||||
return c.connect.CallServerStream(ctx, req)
|
||||
}
|
||||
|
||||
// Start calls process.Process.Start.
|
||||
func (c *processClient) Start(ctx context.Context, req *connect.Request[gen.StartRequest]) (*connect.ServerStreamForClient[gen.StartResponse], error) {
|
||||
return c.start.CallServerStream(ctx, req)
|
||||
}
|
||||
|
||||
// Update calls process.Process.Update.
|
||||
func (c *processClient) Update(ctx context.Context, req *connect.Request[gen.UpdateRequest]) (*connect.Response[gen.UpdateResponse], error) {
|
||||
return c.update.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// StreamInput calls process.Process.StreamInput.
|
||||
func (c *processClient) StreamInput(ctx context.Context) *connect.ClientStreamForClient[gen.StreamInputRequest, gen.StreamInputResponse] {
|
||||
return c.streamInput.CallClientStream(ctx)
|
||||
}
|
||||
|
||||
// SendInput calls process.Process.SendInput.
|
||||
func (c *processClient) SendInput(ctx context.Context, req *connect.Request[gen.SendInputRequest]) (*connect.Response[gen.SendInputResponse], error) {
|
||||
return c.sendInput.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SendSignal calls process.Process.SendSignal.
|
||||
func (c *processClient) SendSignal(ctx context.Context, req *connect.Request[gen.SendSignalRequest]) (*connect.Response[gen.SendSignalResponse], error) {
|
||||
return c.sendSignal.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// CloseStdin calls process.Process.CloseStdin.
|
||||
func (c *processClient) CloseStdin(ctx context.Context, req *connect.Request[gen.CloseStdinRequest]) (*connect.Response[gen.CloseStdinResponse], error) {
|
||||
return c.closeStdin.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ProcessHandler is an implementation of the process.Process service.
|
||||
type ProcessHandler interface {
|
||||
List(context.Context, *connect.Request[gen.ListRequest]) (*connect.Response[gen.ListResponse], error)
|
||||
Connect(context.Context, *connect.Request[gen.ConnectRequest], *connect.ServerStream[gen.ConnectResponse]) error
|
||||
Start(context.Context, *connect.Request[gen.StartRequest], *connect.ServerStream[gen.StartResponse]) error
|
||||
Update(context.Context, *connect.Request[gen.UpdateRequest]) (*connect.Response[gen.UpdateResponse], error)
|
||||
// Client input stream ensures ordering of messages
|
||||
StreamInput(context.Context, *connect.ClientStream[gen.StreamInputRequest]) (*connect.Response[gen.StreamInputResponse], error)
|
||||
SendInput(context.Context, *connect.Request[gen.SendInputRequest]) (*connect.Response[gen.SendInputResponse], error)
|
||||
SendSignal(context.Context, *connect.Request[gen.SendSignalRequest]) (*connect.Response[gen.SendSignalResponse], error)
|
||||
// Close stdin to signal EOF to the process.
|
||||
// Only works for non-PTY processes. For PTY, send Ctrl+D (0x04) instead.
|
||||
CloseStdin(context.Context, *connect.Request[gen.CloseStdinRequest]) (*connect.Response[gen.CloseStdinResponse], error)
|
||||
}
|
||||
|
||||
// NewProcessHandler builds an HTTP handler from the service implementation. It returns the path on
|
||||
// which to mount the handler and the handler itself.
|
||||
//
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewProcessHandler(svc ProcessHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
processMethods := gen.File_process_proto.Services().ByName("Process").Methods()
|
||||
processListHandler := connect.NewUnaryHandler(
|
||||
ProcessListProcedure,
|
||||
svc.List,
|
||||
connect.WithSchema(processMethods.ByName("List")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
processConnectHandler := connect.NewServerStreamHandler(
|
||||
ProcessConnectProcedure,
|
||||
svc.Connect,
|
||||
connect.WithSchema(processMethods.ByName("Connect")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
processStartHandler := connect.NewServerStreamHandler(
|
||||
ProcessStartProcedure,
|
||||
svc.Start,
|
||||
connect.WithSchema(processMethods.ByName("Start")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
processUpdateHandler := connect.NewUnaryHandler(
|
||||
ProcessUpdateProcedure,
|
||||
svc.Update,
|
||||
connect.WithSchema(processMethods.ByName("Update")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
processStreamInputHandler := connect.NewClientStreamHandler(
|
||||
ProcessStreamInputProcedure,
|
||||
svc.StreamInput,
|
||||
connect.WithSchema(processMethods.ByName("StreamInput")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
processSendInputHandler := connect.NewUnaryHandler(
|
||||
ProcessSendInputProcedure,
|
||||
svc.SendInput,
|
||||
connect.WithSchema(processMethods.ByName("SendInput")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
processSendSignalHandler := connect.NewUnaryHandler(
|
||||
ProcessSendSignalProcedure,
|
||||
svc.SendSignal,
|
||||
connect.WithSchema(processMethods.ByName("SendSignal")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
processCloseStdinHandler := connect.NewUnaryHandler(
|
||||
ProcessCloseStdinProcedure,
|
||||
svc.CloseStdin,
|
||||
connect.WithSchema(processMethods.ByName("CloseStdin")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/process.Process/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case ProcessListProcedure:
|
||||
processListHandler.ServeHTTP(w, r)
|
||||
case ProcessConnectProcedure:
|
||||
processConnectHandler.ServeHTTP(w, r)
|
||||
case ProcessStartProcedure:
|
||||
processStartHandler.ServeHTTP(w, r)
|
||||
case ProcessUpdateProcedure:
|
||||
processUpdateHandler.ServeHTTP(w, r)
|
||||
case ProcessStreamInputProcedure:
|
||||
processStreamInputHandler.ServeHTTP(w, r)
|
||||
case ProcessSendInputProcedure:
|
||||
processSendInputHandler.ServeHTTP(w, r)
|
||||
case ProcessSendSignalProcedure:
|
||||
processSendSignalHandler.ServeHTTP(w, r)
|
||||
case ProcessCloseStdinProcedure:
|
||||
processCloseStdinHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedProcessHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedProcessHandler struct{}
|
||||
|
||||
func (UnimplementedProcessHandler) List(context.Context, *connect.Request[gen.ListRequest]) (*connect.Response[gen.ListResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("process.Process.List is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedProcessHandler) Connect(context.Context, *connect.Request[gen.ConnectRequest], *connect.ServerStream[gen.ConnectResponse]) error {
|
||||
return connect.NewError(connect.CodeUnimplemented, errors.New("process.Process.Connect is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedProcessHandler) Start(context.Context, *connect.Request[gen.StartRequest], *connect.ServerStream[gen.StartResponse]) error {
|
||||
return connect.NewError(connect.CodeUnimplemented, errors.New("process.Process.Start is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedProcessHandler) Update(context.Context, *connect.Request[gen.UpdateRequest]) (*connect.Response[gen.UpdateResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("process.Process.Update is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedProcessHandler) StreamInput(context.Context, *connect.ClientStream[gen.StreamInputRequest]) (*connect.Response[gen.StreamInputResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("process.Process.StreamInput is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedProcessHandler) SendInput(context.Context, *connect.Request[gen.SendInputRequest]) (*connect.Response[gen.SendInputResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("process.Process.SendInput is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedProcessHandler) SendSignal(context.Context, *connect.Request[gen.SendSignalRequest]) (*connect.Response[gen.SendSignalResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("process.Process.SendSignal is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedProcessHandler) CloseStdin(context.Context, *connect.Request[gen.CloseStdinRequest]) (*connect.Response[gen.CloseStdinResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("process.Process.CloseStdin is not implemented"))
|
||||
}
|
||||
1972
proto/envd/gen/process.pb.go
Normal file
1972
proto/envd/gen/process.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,173 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package process;
|
||||
|
||||
service Process {
|
||||
rpc List(ListRequest) returns (ListResponse);
|
||||
|
||||
rpc Connect(ConnectRequest) returns (stream ConnectResponse);
|
||||
rpc Start(StartRequest) returns (stream StartResponse);
|
||||
|
||||
rpc Update(UpdateRequest) returns (UpdateResponse);
|
||||
|
||||
// Client input stream ensures ordering of messages
|
||||
rpc StreamInput(stream StreamInputRequest) returns (StreamInputResponse);
|
||||
rpc SendInput(SendInputRequest) returns (SendInputResponse);
|
||||
rpc SendSignal(SendSignalRequest) returns (SendSignalResponse);
|
||||
|
||||
// Close stdin to signal EOF to the process.
|
||||
// Only works for non-PTY processes. For PTY, send Ctrl+D (0x04) instead.
|
||||
rpc CloseStdin(CloseStdinRequest) returns (CloseStdinResponse);
|
||||
}
|
||||
|
||||
message PTY {
|
||||
Size size = 1;
|
||||
|
||||
message Size {
|
||||
uint32 cols = 1;
|
||||
uint32 rows = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message ProcessConfig {
|
||||
string cmd = 1;
|
||||
repeated string args = 2;
|
||||
|
||||
map<string, string> envs = 3;
|
||||
optional string cwd = 4;
|
||||
}
|
||||
|
||||
message ListRequest {}
|
||||
|
||||
message ProcessInfo {
|
||||
ProcessConfig config = 1;
|
||||
uint32 pid = 2;
|
||||
optional string tag = 3;
|
||||
}
|
||||
|
||||
message ListResponse {
|
||||
repeated ProcessInfo processes = 1;
|
||||
}
|
||||
|
||||
message StartRequest {
|
||||
ProcessConfig process = 1;
|
||||
optional PTY pty = 2;
|
||||
optional string tag = 3;
|
||||
// This is optional for backwards compatibility.
|
||||
// We default to true. New SDK versions will set this to false by default.
|
||||
optional bool stdin = 4;
|
||||
}
|
||||
|
||||
message UpdateRequest {
|
||||
ProcessSelector process = 1;
|
||||
|
||||
optional PTY pty = 2;
|
||||
}
|
||||
|
||||
message UpdateResponse {}
|
||||
|
||||
message ProcessEvent {
|
||||
oneof event {
|
||||
StartEvent start = 1;
|
||||
DataEvent data = 2;
|
||||
EndEvent end = 3;
|
||||
KeepAlive keepalive = 4;
|
||||
}
|
||||
|
||||
message StartEvent {
|
||||
uint32 pid = 1;
|
||||
}
|
||||
|
||||
message DataEvent {
|
||||
oneof output {
|
||||
bytes stdout = 1;
|
||||
bytes stderr = 2;
|
||||
bytes pty = 3;
|
||||
}
|
||||
}
|
||||
|
||||
message EndEvent {
|
||||
sint32 exit_code = 1;
|
||||
bool exited = 2;
|
||||
string status = 3;
|
||||
optional string error = 4;
|
||||
}
|
||||
|
||||
message KeepAlive {}
|
||||
}
|
||||
|
||||
message StartResponse {
|
||||
ProcessEvent event = 1;
|
||||
}
|
||||
|
||||
message ConnectResponse {
|
||||
ProcessEvent event = 1;
|
||||
}
|
||||
|
||||
message SendInputRequest {
|
||||
ProcessSelector process = 1;
|
||||
|
||||
ProcessInput input = 2;
|
||||
}
|
||||
|
||||
message SendInputResponse {}
|
||||
|
||||
message ProcessInput {
|
||||
oneof input {
|
||||
bytes stdin = 1;
|
||||
bytes pty = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message StreamInputRequest {
|
||||
oneof event {
|
||||
StartEvent start = 1;
|
||||
DataEvent data = 2;
|
||||
KeepAlive keepalive = 3;
|
||||
}
|
||||
|
||||
message StartEvent {
|
||||
ProcessSelector process = 1;
|
||||
}
|
||||
|
||||
message DataEvent {
|
||||
ProcessInput input = 2;
|
||||
}
|
||||
|
||||
message KeepAlive {}
|
||||
}
|
||||
|
||||
message StreamInputResponse {}
|
||||
|
||||
enum Signal {
|
||||
SIGNAL_UNSPECIFIED = 0;
|
||||
SIGNAL_SIGTERM = 15;
|
||||
SIGNAL_SIGKILL = 9;
|
||||
}
|
||||
|
||||
message SendSignalRequest {
|
||||
ProcessSelector process = 1;
|
||||
|
||||
Signal signal = 2;
|
||||
}
|
||||
|
||||
message SendSignalResponse {}
|
||||
|
||||
message CloseStdinRequest {
|
||||
ProcessSelector process = 1;
|
||||
}
|
||||
|
||||
message CloseStdinResponse {}
|
||||
|
||||
message ConnectRequest {
|
||||
ProcessSelector process = 1;
|
||||
}
|
||||
|
||||
message ProcessSelector {
|
||||
oneof selector {
|
||||
uint32 pid = 1;
|
||||
string tag = 2;
|
||||
}
|
||||
}
|
||||
|
||||
13
proto/hostagent/buf.gen.yaml
Normal file
13
proto/hostagent/buf.gen.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
version: v2
|
||||
plugins:
|
||||
- protoc_builtin: go
|
||||
out: gen
|
||||
opt: paths=source_relative
|
||||
- local: protoc-gen-connect-go
|
||||
out: gen
|
||||
opt: paths=source_relative
|
||||
managed:
|
||||
enabled: true
|
||||
override:
|
||||
- file_option: go_package_prefix
|
||||
value: git.omukk.dev/wrenn/sandbox/proto/hostagent/gen
|
||||
3
proto/hostagent/buf.yaml
Normal file
3
proto/hostagent/buf.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
version: v2
|
||||
modules:
|
||||
- path: .
|
||||
2101
proto/hostagent/gen/hostagent.pb.go
Normal file
2101
proto/hostagent/gen/hostagent.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
517
proto/hostagent/gen/hostagentv1connect/hostagent.connect.go
Normal file
517
proto/hostagent/gen/hostagentv1connect/hostagent.connect.go
Normal file
@ -0,0 +1,517 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: hostagent.proto
|
||||
|
||||
package hostagentv1connect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
gen "git.omukk.dev/wrenn/sandbox/proto/hostagent/gen"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file and the connect package are
|
||||
// compatible. If you get a compiler error that this constant is not defined, this code was
|
||||
// generated with a version of connect newer than the one compiled into your binary. You can fix the
|
||||
// problem by either regenerating this code with an older version of connect or updating the connect
|
||||
// version compiled into your binary.
|
||||
const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// HostAgentServiceName is the fully-qualified name of the HostAgentService service.
|
||||
HostAgentServiceName = "hostagent.v1.HostAgentService"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
|
||||
//
|
||||
// Note that these are different from the fully-qualified method names used by
|
||||
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
|
||||
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
|
||||
// period.
|
||||
const (
|
||||
// HostAgentServiceCreateSandboxProcedure is the fully-qualified name of the HostAgentService's
|
||||
// CreateSandbox RPC.
|
||||
HostAgentServiceCreateSandboxProcedure = "/hostagent.v1.HostAgentService/CreateSandbox"
|
||||
// HostAgentServiceDestroySandboxProcedure is the fully-qualified name of the HostAgentService's
|
||||
// DestroySandbox RPC.
|
||||
HostAgentServiceDestroySandboxProcedure = "/hostagent.v1.HostAgentService/DestroySandbox"
|
||||
// HostAgentServicePauseSandboxProcedure is the fully-qualified name of the HostAgentService's
|
||||
// PauseSandbox RPC.
|
||||
HostAgentServicePauseSandboxProcedure = "/hostagent.v1.HostAgentService/PauseSandbox"
|
||||
// HostAgentServiceResumeSandboxProcedure is the fully-qualified name of the HostAgentService's
|
||||
// ResumeSandbox RPC.
|
||||
HostAgentServiceResumeSandboxProcedure = "/hostagent.v1.HostAgentService/ResumeSandbox"
|
||||
// HostAgentServiceExecProcedure is the fully-qualified name of the HostAgentService's Exec RPC.
|
||||
HostAgentServiceExecProcedure = "/hostagent.v1.HostAgentService/Exec"
|
||||
// HostAgentServiceListSandboxesProcedure is the fully-qualified name of the HostAgentService's
|
||||
// ListSandboxes RPC.
|
||||
HostAgentServiceListSandboxesProcedure = "/hostagent.v1.HostAgentService/ListSandboxes"
|
||||
// HostAgentServiceWriteFileProcedure is the fully-qualified name of the HostAgentService's
|
||||
// WriteFile RPC.
|
||||
HostAgentServiceWriteFileProcedure = "/hostagent.v1.HostAgentService/WriteFile"
|
||||
// HostAgentServiceReadFileProcedure is the fully-qualified name of the HostAgentService's ReadFile
|
||||
// RPC.
|
||||
HostAgentServiceReadFileProcedure = "/hostagent.v1.HostAgentService/ReadFile"
|
||||
// HostAgentServiceCreateSnapshotProcedure is the fully-qualified name of the HostAgentService's
|
||||
// CreateSnapshot RPC.
|
||||
HostAgentServiceCreateSnapshotProcedure = "/hostagent.v1.HostAgentService/CreateSnapshot"
|
||||
// HostAgentServiceDeleteSnapshotProcedure is the fully-qualified name of the HostAgentService's
|
||||
// DeleteSnapshot RPC.
|
||||
HostAgentServiceDeleteSnapshotProcedure = "/hostagent.v1.HostAgentService/DeleteSnapshot"
|
||||
// HostAgentServiceExecStreamProcedure is the fully-qualified name of the HostAgentService's
|
||||
// ExecStream RPC.
|
||||
HostAgentServiceExecStreamProcedure = "/hostagent.v1.HostAgentService/ExecStream"
|
||||
// HostAgentServiceWriteFileStreamProcedure is the fully-qualified name of the HostAgentService's
|
||||
// WriteFileStream RPC.
|
||||
HostAgentServiceWriteFileStreamProcedure = "/hostagent.v1.HostAgentService/WriteFileStream"
|
||||
// HostAgentServiceReadFileStreamProcedure is the fully-qualified name of the HostAgentService's
|
||||
// ReadFileStream RPC.
|
||||
HostAgentServiceReadFileStreamProcedure = "/hostagent.v1.HostAgentService/ReadFileStream"
|
||||
// HostAgentServicePingSandboxProcedure is the fully-qualified name of the HostAgentService's
|
||||
// PingSandbox RPC.
|
||||
HostAgentServicePingSandboxProcedure = "/hostagent.v1.HostAgentService/PingSandbox"
|
||||
)
|
||||
|
||||
// HostAgentServiceClient is a client for the hostagent.v1.HostAgentService service.
|
||||
type HostAgentServiceClient interface {
|
||||
// CreateSandbox boots a new microVM with the given configuration.
|
||||
CreateSandbox(context.Context, *connect.Request[gen.CreateSandboxRequest]) (*connect.Response[gen.CreateSandboxResponse], error)
|
||||
// DestroySandbox stops and cleans up a sandbox (VM, network, rootfs).
|
||||
DestroySandbox(context.Context, *connect.Request[gen.DestroySandboxRequest]) (*connect.Response[gen.DestroySandboxResponse], error)
|
||||
// PauseSandbox pauses a running sandbox's VM.
|
||||
PauseSandbox(context.Context, *connect.Request[gen.PauseSandboxRequest]) (*connect.Response[gen.PauseSandboxResponse], error)
|
||||
// ResumeSandbox resumes a paused sandbox's VM.
|
||||
ResumeSandbox(context.Context, *connect.Request[gen.ResumeSandboxRequest]) (*connect.Response[gen.ResumeSandboxResponse], error)
|
||||
// Exec runs a command inside a sandbox and returns the collected output.
|
||||
Exec(context.Context, *connect.Request[gen.ExecRequest]) (*connect.Response[gen.ExecResponse], error)
|
||||
// ListSandboxes returns all sandboxes managed by this host agent.
|
||||
ListSandboxes(context.Context, *connect.Request[gen.ListSandboxesRequest]) (*connect.Response[gen.ListSandboxesResponse], error)
|
||||
// WriteFile writes content to a file inside a sandbox.
|
||||
WriteFile(context.Context, *connect.Request[gen.WriteFileRequest]) (*connect.Response[gen.WriteFileResponse], error)
|
||||
// ReadFile reads a file from inside a sandbox.
|
||||
ReadFile(context.Context, *connect.Request[gen.ReadFileRequest]) (*connect.Response[gen.ReadFileResponse], error)
|
||||
// CreateSnapshot pauses a sandbox, takes a snapshot, stores it as a reusable
|
||||
// template, and destroys the sandbox.
|
||||
CreateSnapshot(context.Context, *connect.Request[gen.CreateSnapshotRequest]) (*connect.Response[gen.CreateSnapshotResponse], error)
|
||||
// DeleteSnapshot removes a snapshot template from disk.
|
||||
DeleteSnapshot(context.Context, *connect.Request[gen.DeleteSnapshotRequest]) (*connect.Response[gen.DeleteSnapshotResponse], error)
|
||||
// ExecStream runs a command inside a sandbox and streams output events as they arrive.
|
||||
ExecStream(context.Context, *connect.Request[gen.ExecStreamRequest]) (*connect.ServerStreamForClient[gen.ExecStreamResponse], error)
|
||||
// WriteFileStream writes a file to a sandbox using chunked streaming.
|
||||
// First message must contain metadata (sandbox_id, path). Subsequent messages contain data chunks.
|
||||
WriteFileStream(context.Context) *connect.ClientStreamForClient[gen.WriteFileStreamRequest, gen.WriteFileStreamResponse]
|
||||
// ReadFileStream reads a file from a sandbox and streams it back in chunks.
|
||||
ReadFileStream(context.Context, *connect.Request[gen.ReadFileStreamRequest]) (*connect.ServerStreamForClient[gen.ReadFileStreamResponse], error)
|
||||
// PingSandbox resets the inactivity timer for a running sandbox.
|
||||
PingSandbox(context.Context, *connect.Request[gen.PingSandboxRequest]) (*connect.Response[gen.PingSandboxResponse], error)
|
||||
}
|
||||
|
||||
// NewHostAgentServiceClient constructs a client for the hostagent.v1.HostAgentService service. By
|
||||
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
|
||||
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
|
||||
// connect.WithGRPC() or connect.WithGRPCWeb() options.
|
||||
//
|
||||
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewHostAgentServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) HostAgentServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
hostAgentServiceMethods := gen.File_hostagent_proto.Services().ByName("HostAgentService").Methods()
|
||||
return &hostAgentServiceClient{
|
||||
createSandbox: connect.NewClient[gen.CreateSandboxRequest, gen.CreateSandboxResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceCreateSandboxProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("CreateSandbox")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
destroySandbox: connect.NewClient[gen.DestroySandboxRequest, gen.DestroySandboxResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceDestroySandboxProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("DestroySandbox")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
pauseSandbox: connect.NewClient[gen.PauseSandboxRequest, gen.PauseSandboxResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServicePauseSandboxProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("PauseSandbox")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
resumeSandbox: connect.NewClient[gen.ResumeSandboxRequest, gen.ResumeSandboxResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceResumeSandboxProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ResumeSandbox")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
exec: connect.NewClient[gen.ExecRequest, gen.ExecResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceExecProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("Exec")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listSandboxes: connect.NewClient[gen.ListSandboxesRequest, gen.ListSandboxesResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceListSandboxesProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ListSandboxes")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
writeFile: connect.NewClient[gen.WriteFileRequest, gen.WriteFileResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceWriteFileProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("WriteFile")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
readFile: connect.NewClient[gen.ReadFileRequest, gen.ReadFileResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceReadFileProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ReadFile")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
createSnapshot: connect.NewClient[gen.CreateSnapshotRequest, gen.CreateSnapshotResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceCreateSnapshotProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("CreateSnapshot")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
deleteSnapshot: connect.NewClient[gen.DeleteSnapshotRequest, gen.DeleteSnapshotResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceDeleteSnapshotProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("DeleteSnapshot")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
execStream: connect.NewClient[gen.ExecStreamRequest, gen.ExecStreamResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceExecStreamProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ExecStream")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
writeFileStream: connect.NewClient[gen.WriteFileStreamRequest, gen.WriteFileStreamResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceWriteFileStreamProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("WriteFileStream")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
readFileStream: connect.NewClient[gen.ReadFileStreamRequest, gen.ReadFileStreamResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServiceReadFileStreamProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ReadFileStream")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
pingSandbox: connect.NewClient[gen.PingSandboxRequest, gen.PingSandboxResponse](
|
||||
httpClient,
|
||||
baseURL+HostAgentServicePingSandboxProcedure,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("PingSandbox")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// hostAgentServiceClient implements HostAgentServiceClient.
|
||||
type hostAgentServiceClient struct {
|
||||
createSandbox *connect.Client[gen.CreateSandboxRequest, gen.CreateSandboxResponse]
|
||||
destroySandbox *connect.Client[gen.DestroySandboxRequest, gen.DestroySandboxResponse]
|
||||
pauseSandbox *connect.Client[gen.PauseSandboxRequest, gen.PauseSandboxResponse]
|
||||
resumeSandbox *connect.Client[gen.ResumeSandboxRequest, gen.ResumeSandboxResponse]
|
||||
exec *connect.Client[gen.ExecRequest, gen.ExecResponse]
|
||||
listSandboxes *connect.Client[gen.ListSandboxesRequest, gen.ListSandboxesResponse]
|
||||
writeFile *connect.Client[gen.WriteFileRequest, gen.WriteFileResponse]
|
||||
readFile *connect.Client[gen.ReadFileRequest, gen.ReadFileResponse]
|
||||
createSnapshot *connect.Client[gen.CreateSnapshotRequest, gen.CreateSnapshotResponse]
|
||||
deleteSnapshot *connect.Client[gen.DeleteSnapshotRequest, gen.DeleteSnapshotResponse]
|
||||
execStream *connect.Client[gen.ExecStreamRequest, gen.ExecStreamResponse]
|
||||
writeFileStream *connect.Client[gen.WriteFileStreamRequest, gen.WriteFileStreamResponse]
|
||||
readFileStream *connect.Client[gen.ReadFileStreamRequest, gen.ReadFileStreamResponse]
|
||||
pingSandbox *connect.Client[gen.PingSandboxRequest, gen.PingSandboxResponse]
|
||||
}
|
||||
|
||||
// CreateSandbox calls hostagent.v1.HostAgentService.CreateSandbox.
|
||||
func (c *hostAgentServiceClient) CreateSandbox(ctx context.Context, req *connect.Request[gen.CreateSandboxRequest]) (*connect.Response[gen.CreateSandboxResponse], error) {
|
||||
return c.createSandbox.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DestroySandbox calls hostagent.v1.HostAgentService.DestroySandbox.
|
||||
func (c *hostAgentServiceClient) DestroySandbox(ctx context.Context, req *connect.Request[gen.DestroySandboxRequest]) (*connect.Response[gen.DestroySandboxResponse], error) {
|
||||
return c.destroySandbox.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// PauseSandbox calls hostagent.v1.HostAgentService.PauseSandbox.
|
||||
func (c *hostAgentServiceClient) PauseSandbox(ctx context.Context, req *connect.Request[gen.PauseSandboxRequest]) (*connect.Response[gen.PauseSandboxResponse], error) {
|
||||
return c.pauseSandbox.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ResumeSandbox calls hostagent.v1.HostAgentService.ResumeSandbox.
|
||||
func (c *hostAgentServiceClient) ResumeSandbox(ctx context.Context, req *connect.Request[gen.ResumeSandboxRequest]) (*connect.Response[gen.ResumeSandboxResponse], error) {
|
||||
return c.resumeSandbox.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// Exec calls hostagent.v1.HostAgentService.Exec.
|
||||
func (c *hostAgentServiceClient) Exec(ctx context.Context, req *connect.Request[gen.ExecRequest]) (*connect.Response[gen.ExecResponse], error) {
|
||||
return c.exec.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListSandboxes calls hostagent.v1.HostAgentService.ListSandboxes.
|
||||
func (c *hostAgentServiceClient) ListSandboxes(ctx context.Context, req *connect.Request[gen.ListSandboxesRequest]) (*connect.Response[gen.ListSandboxesResponse], error) {
|
||||
return c.listSandboxes.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// WriteFile calls hostagent.v1.HostAgentService.WriteFile.
|
||||
func (c *hostAgentServiceClient) WriteFile(ctx context.Context, req *connect.Request[gen.WriteFileRequest]) (*connect.Response[gen.WriteFileResponse], error) {
|
||||
return c.writeFile.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ReadFile calls hostagent.v1.HostAgentService.ReadFile.
|
||||
func (c *hostAgentServiceClient) ReadFile(ctx context.Context, req *connect.Request[gen.ReadFileRequest]) (*connect.Response[gen.ReadFileResponse], error) {
|
||||
return c.readFile.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// CreateSnapshot calls hostagent.v1.HostAgentService.CreateSnapshot.
|
||||
func (c *hostAgentServiceClient) CreateSnapshot(ctx context.Context, req *connect.Request[gen.CreateSnapshotRequest]) (*connect.Response[gen.CreateSnapshotResponse], error) {
|
||||
return c.createSnapshot.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeleteSnapshot calls hostagent.v1.HostAgentService.DeleteSnapshot.
|
||||
func (c *hostAgentServiceClient) DeleteSnapshot(ctx context.Context, req *connect.Request[gen.DeleteSnapshotRequest]) (*connect.Response[gen.DeleteSnapshotResponse], error) {
|
||||
return c.deleteSnapshot.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ExecStream calls hostagent.v1.HostAgentService.ExecStream.
|
||||
func (c *hostAgentServiceClient) ExecStream(ctx context.Context, req *connect.Request[gen.ExecStreamRequest]) (*connect.ServerStreamForClient[gen.ExecStreamResponse], error) {
|
||||
return c.execStream.CallServerStream(ctx, req)
|
||||
}
|
||||
|
||||
// WriteFileStream calls hostagent.v1.HostAgentService.WriteFileStream.
|
||||
func (c *hostAgentServiceClient) WriteFileStream(ctx context.Context) *connect.ClientStreamForClient[gen.WriteFileStreamRequest, gen.WriteFileStreamResponse] {
|
||||
return c.writeFileStream.CallClientStream(ctx)
|
||||
}
|
||||
|
||||
// ReadFileStream calls hostagent.v1.HostAgentService.ReadFileStream.
|
||||
func (c *hostAgentServiceClient) ReadFileStream(ctx context.Context, req *connect.Request[gen.ReadFileStreamRequest]) (*connect.ServerStreamForClient[gen.ReadFileStreamResponse], error) {
|
||||
return c.readFileStream.CallServerStream(ctx, req)
|
||||
}
|
||||
|
||||
// PingSandbox calls hostagent.v1.HostAgentService.PingSandbox.
|
||||
func (c *hostAgentServiceClient) PingSandbox(ctx context.Context, req *connect.Request[gen.PingSandboxRequest]) (*connect.Response[gen.PingSandboxResponse], error) {
|
||||
return c.pingSandbox.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// HostAgentServiceHandler is an implementation of the hostagent.v1.HostAgentService service.
|
||||
type HostAgentServiceHandler interface {
|
||||
// CreateSandbox boots a new microVM with the given configuration.
|
||||
CreateSandbox(context.Context, *connect.Request[gen.CreateSandboxRequest]) (*connect.Response[gen.CreateSandboxResponse], error)
|
||||
// DestroySandbox stops and cleans up a sandbox (VM, network, rootfs).
|
||||
DestroySandbox(context.Context, *connect.Request[gen.DestroySandboxRequest]) (*connect.Response[gen.DestroySandboxResponse], error)
|
||||
// PauseSandbox pauses a running sandbox's VM.
|
||||
PauseSandbox(context.Context, *connect.Request[gen.PauseSandboxRequest]) (*connect.Response[gen.PauseSandboxResponse], error)
|
||||
// ResumeSandbox resumes a paused sandbox's VM.
|
||||
ResumeSandbox(context.Context, *connect.Request[gen.ResumeSandboxRequest]) (*connect.Response[gen.ResumeSandboxResponse], error)
|
||||
// Exec runs a command inside a sandbox and returns the collected output.
|
||||
Exec(context.Context, *connect.Request[gen.ExecRequest]) (*connect.Response[gen.ExecResponse], error)
|
||||
// ListSandboxes returns all sandboxes managed by this host agent.
|
||||
ListSandboxes(context.Context, *connect.Request[gen.ListSandboxesRequest]) (*connect.Response[gen.ListSandboxesResponse], error)
|
||||
// WriteFile writes content to a file inside a sandbox.
|
||||
WriteFile(context.Context, *connect.Request[gen.WriteFileRequest]) (*connect.Response[gen.WriteFileResponse], error)
|
||||
// ReadFile reads a file from inside a sandbox.
|
||||
ReadFile(context.Context, *connect.Request[gen.ReadFileRequest]) (*connect.Response[gen.ReadFileResponse], error)
|
||||
// CreateSnapshot pauses a sandbox, takes a snapshot, stores it as a reusable
|
||||
// template, and destroys the sandbox.
|
||||
CreateSnapshot(context.Context, *connect.Request[gen.CreateSnapshotRequest]) (*connect.Response[gen.CreateSnapshotResponse], error)
|
||||
// DeleteSnapshot removes a snapshot template from disk.
|
||||
DeleteSnapshot(context.Context, *connect.Request[gen.DeleteSnapshotRequest]) (*connect.Response[gen.DeleteSnapshotResponse], error)
|
||||
// ExecStream runs a command inside a sandbox and streams output events as they arrive.
|
||||
ExecStream(context.Context, *connect.Request[gen.ExecStreamRequest], *connect.ServerStream[gen.ExecStreamResponse]) error
|
||||
// WriteFileStream writes a file to a sandbox using chunked streaming.
|
||||
// First message must contain metadata (sandbox_id, path). Subsequent messages contain data chunks.
|
||||
WriteFileStream(context.Context, *connect.ClientStream[gen.WriteFileStreamRequest]) (*connect.Response[gen.WriteFileStreamResponse], error)
|
||||
// ReadFileStream reads a file from a sandbox and streams it back in chunks.
|
||||
ReadFileStream(context.Context, *connect.Request[gen.ReadFileStreamRequest], *connect.ServerStream[gen.ReadFileStreamResponse]) error
|
||||
// PingSandbox resets the inactivity timer for a running sandbox.
|
||||
PingSandbox(context.Context, *connect.Request[gen.PingSandboxRequest]) (*connect.Response[gen.PingSandboxResponse], error)
|
||||
}
|
||||
|
||||
// NewHostAgentServiceHandler builds an HTTP handler from the service implementation. It returns the
|
||||
// path on which to mount the handler and the handler itself.
|
||||
//
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewHostAgentServiceHandler(svc HostAgentServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
hostAgentServiceMethods := gen.File_hostagent_proto.Services().ByName("HostAgentService").Methods()
|
||||
hostAgentServiceCreateSandboxHandler := connect.NewUnaryHandler(
|
||||
HostAgentServiceCreateSandboxProcedure,
|
||||
svc.CreateSandbox,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("CreateSandbox")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceDestroySandboxHandler := connect.NewUnaryHandler(
|
||||
HostAgentServiceDestroySandboxProcedure,
|
||||
svc.DestroySandbox,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("DestroySandbox")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServicePauseSandboxHandler := connect.NewUnaryHandler(
|
||||
HostAgentServicePauseSandboxProcedure,
|
||||
svc.PauseSandbox,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("PauseSandbox")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceResumeSandboxHandler := connect.NewUnaryHandler(
|
||||
HostAgentServiceResumeSandboxProcedure,
|
||||
svc.ResumeSandbox,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ResumeSandbox")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceExecHandler := connect.NewUnaryHandler(
|
||||
HostAgentServiceExecProcedure,
|
||||
svc.Exec,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("Exec")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceListSandboxesHandler := connect.NewUnaryHandler(
|
||||
HostAgentServiceListSandboxesProcedure,
|
||||
svc.ListSandboxes,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ListSandboxes")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceWriteFileHandler := connect.NewUnaryHandler(
|
||||
HostAgentServiceWriteFileProcedure,
|
||||
svc.WriteFile,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("WriteFile")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceReadFileHandler := connect.NewUnaryHandler(
|
||||
HostAgentServiceReadFileProcedure,
|
||||
svc.ReadFile,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ReadFile")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceCreateSnapshotHandler := connect.NewUnaryHandler(
|
||||
HostAgentServiceCreateSnapshotProcedure,
|
||||
svc.CreateSnapshot,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("CreateSnapshot")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceDeleteSnapshotHandler := connect.NewUnaryHandler(
|
||||
HostAgentServiceDeleteSnapshotProcedure,
|
||||
svc.DeleteSnapshot,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("DeleteSnapshot")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceExecStreamHandler := connect.NewServerStreamHandler(
|
||||
HostAgentServiceExecStreamProcedure,
|
||||
svc.ExecStream,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ExecStream")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceWriteFileStreamHandler := connect.NewClientStreamHandler(
|
||||
HostAgentServiceWriteFileStreamProcedure,
|
||||
svc.WriteFileStream,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("WriteFileStream")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServiceReadFileStreamHandler := connect.NewServerStreamHandler(
|
||||
HostAgentServiceReadFileStreamProcedure,
|
||||
svc.ReadFileStream,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("ReadFileStream")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
hostAgentServicePingSandboxHandler := connect.NewUnaryHandler(
|
||||
HostAgentServicePingSandboxProcedure,
|
||||
svc.PingSandbox,
|
||||
connect.WithSchema(hostAgentServiceMethods.ByName("PingSandbox")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/hostagent.v1.HostAgentService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case HostAgentServiceCreateSandboxProcedure:
|
||||
hostAgentServiceCreateSandboxHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceDestroySandboxProcedure:
|
||||
hostAgentServiceDestroySandboxHandler.ServeHTTP(w, r)
|
||||
case HostAgentServicePauseSandboxProcedure:
|
||||
hostAgentServicePauseSandboxHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceResumeSandboxProcedure:
|
||||
hostAgentServiceResumeSandboxHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceExecProcedure:
|
||||
hostAgentServiceExecHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceListSandboxesProcedure:
|
||||
hostAgentServiceListSandboxesHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceWriteFileProcedure:
|
||||
hostAgentServiceWriteFileHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceReadFileProcedure:
|
||||
hostAgentServiceReadFileHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceCreateSnapshotProcedure:
|
||||
hostAgentServiceCreateSnapshotHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceDeleteSnapshotProcedure:
|
||||
hostAgentServiceDeleteSnapshotHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceExecStreamProcedure:
|
||||
hostAgentServiceExecStreamHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceWriteFileStreamProcedure:
|
||||
hostAgentServiceWriteFileStreamHandler.ServeHTTP(w, r)
|
||||
case HostAgentServiceReadFileStreamProcedure:
|
||||
hostAgentServiceReadFileStreamHandler.ServeHTTP(w, r)
|
||||
case HostAgentServicePingSandboxProcedure:
|
||||
hostAgentServicePingSandboxHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedHostAgentServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedHostAgentServiceHandler struct{}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) CreateSandbox(context.Context, *connect.Request[gen.CreateSandboxRequest]) (*connect.Response[gen.CreateSandboxResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.CreateSandbox is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) DestroySandbox(context.Context, *connect.Request[gen.DestroySandboxRequest]) (*connect.Response[gen.DestroySandboxResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.DestroySandbox is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) PauseSandbox(context.Context, *connect.Request[gen.PauseSandboxRequest]) (*connect.Response[gen.PauseSandboxResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.PauseSandbox is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) ResumeSandbox(context.Context, *connect.Request[gen.ResumeSandboxRequest]) (*connect.Response[gen.ResumeSandboxResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.ResumeSandbox is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) Exec(context.Context, *connect.Request[gen.ExecRequest]) (*connect.Response[gen.ExecResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.Exec is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) ListSandboxes(context.Context, *connect.Request[gen.ListSandboxesRequest]) (*connect.Response[gen.ListSandboxesResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.ListSandboxes is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) WriteFile(context.Context, *connect.Request[gen.WriteFileRequest]) (*connect.Response[gen.WriteFileResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.WriteFile is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) ReadFile(context.Context, *connect.Request[gen.ReadFileRequest]) (*connect.Response[gen.ReadFileResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.ReadFile is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) CreateSnapshot(context.Context, *connect.Request[gen.CreateSnapshotRequest]) (*connect.Response[gen.CreateSnapshotResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.CreateSnapshot is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) DeleteSnapshot(context.Context, *connect.Request[gen.DeleteSnapshotRequest]) (*connect.Response[gen.DeleteSnapshotResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.DeleteSnapshot is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) ExecStream(context.Context, *connect.Request[gen.ExecStreamRequest], *connect.ServerStream[gen.ExecStreamResponse]) error {
|
||||
return connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.ExecStream is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) WriteFileStream(context.Context, *connect.ClientStream[gen.WriteFileStreamRequest]) (*connect.Response[gen.WriteFileStreamResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.WriteFileStream is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) ReadFileStream(context.Context, *connect.Request[gen.ReadFileStreamRequest], *connect.ServerStream[gen.ReadFileStreamResponse]) error {
|
||||
return connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.ReadFileStream is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedHostAgentServiceHandler) PingSandbox(context.Context, *connect.Request[gen.PingSandboxRequest]) (*connect.Response[gen.PingSandboxResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.PingSandbox is not implemented"))
|
||||
}
|
||||
@ -0,0 +1,238 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package hostagent.v1;
|
||||
|
||||
// HostAgentService manages sandbox VMs on a single physical host.
|
||||
// The control plane calls these RPCs to orchestrate sandbox lifecycle.
|
||||
service HostAgentService {
|
||||
// CreateSandbox boots a new microVM with the given configuration.
|
||||
rpc CreateSandbox(CreateSandboxRequest) returns (CreateSandboxResponse);
|
||||
|
||||
// DestroySandbox stops and cleans up a sandbox (VM, network, rootfs).
|
||||
rpc DestroySandbox(DestroySandboxRequest) returns (DestroySandboxResponse);
|
||||
|
||||
// PauseSandbox pauses a running sandbox's VM.
|
||||
rpc PauseSandbox(PauseSandboxRequest) returns (PauseSandboxResponse);
|
||||
|
||||
// ResumeSandbox resumes a paused sandbox's VM.
|
||||
rpc ResumeSandbox(ResumeSandboxRequest) returns (ResumeSandboxResponse);
|
||||
|
||||
// Exec runs a command inside a sandbox and returns the collected output.
|
||||
rpc Exec(ExecRequest) returns (ExecResponse);
|
||||
|
||||
// ListSandboxes returns all sandboxes managed by this host agent.
|
||||
rpc ListSandboxes(ListSandboxesRequest) returns (ListSandboxesResponse);
|
||||
|
||||
// WriteFile writes content to a file inside a sandbox.
|
||||
rpc WriteFile(WriteFileRequest) returns (WriteFileResponse);
|
||||
|
||||
// ReadFile reads a file from inside a sandbox.
|
||||
rpc ReadFile(ReadFileRequest) returns (ReadFileResponse);
|
||||
|
||||
// CreateSnapshot pauses a sandbox, takes a snapshot, stores it as a reusable
|
||||
// template, and destroys the sandbox.
|
||||
rpc CreateSnapshot(CreateSnapshotRequest) returns (CreateSnapshotResponse);
|
||||
|
||||
// DeleteSnapshot removes a snapshot template from disk.
|
||||
rpc DeleteSnapshot(DeleteSnapshotRequest) returns (DeleteSnapshotResponse);
|
||||
|
||||
// ExecStream runs a command inside a sandbox and streams output events as they arrive.
|
||||
rpc ExecStream(ExecStreamRequest) returns (stream ExecStreamResponse);
|
||||
|
||||
// WriteFileStream writes a file to a sandbox using chunked streaming.
|
||||
// First message must contain metadata (sandbox_id, path). Subsequent messages contain data chunks.
|
||||
rpc WriteFileStream(stream WriteFileStreamRequest) returns (WriteFileStreamResponse);
|
||||
|
||||
// ReadFileStream reads a file from a sandbox and streams it back in chunks.
|
||||
rpc ReadFileStream(ReadFileStreamRequest) returns (stream ReadFileStreamResponse);
|
||||
|
||||
// PingSandbox resets the inactivity timer for a running sandbox.
|
||||
rpc PingSandbox(PingSandboxRequest) returns (PingSandboxResponse);
|
||||
|
||||
}
|
||||
|
||||
message CreateSandboxRequest {
|
||||
// Sandbox ID assigned by the control plane. If empty, the host agent generates one.
|
||||
string sandbox_id = 5;
|
||||
|
||||
// Template name (e.g., "minimal", "python311"). Determines base rootfs.
|
||||
string template = 1;
|
||||
|
||||
// Number of virtual CPUs (default: 1).
|
||||
int32 vcpus = 2;
|
||||
|
||||
// Memory in MB (default: 512).
|
||||
int32 memory_mb = 3;
|
||||
|
||||
// TTL in seconds. Sandbox is auto-paused after this duration of
|
||||
// inactivity. 0 means no auto-pause.
|
||||
int32 timeout_sec = 4;
|
||||
}
|
||||
|
||||
message CreateSandboxResponse {
|
||||
string sandbox_id = 1;
|
||||
string status = 2;
|
||||
string host_ip = 3;
|
||||
}
|
||||
|
||||
message DestroySandboxRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message DestroySandboxResponse {}
|
||||
|
||||
message PauseSandboxRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message PauseSandboxResponse {}
|
||||
|
||||
message ResumeSandboxRequest {
|
||||
string sandbox_id = 1;
|
||||
|
||||
// TTL in seconds restored from the DB so the reaper can auto-pause
|
||||
// the sandbox again after inactivity. 0 means no auto-pause.
|
||||
int32 timeout_sec = 2;
|
||||
}
|
||||
|
||||
message ResumeSandboxResponse {
|
||||
string sandbox_id = 1;
|
||||
string status = 2;
|
||||
string host_ip = 3;
|
||||
}
|
||||
|
||||
message CreateSnapshotRequest {
|
||||
string sandbox_id = 1;
|
||||
string name = 2;
|
||||
}
|
||||
|
||||
message CreateSnapshotResponse {
|
||||
string name = 1;
|
||||
int64 size_bytes = 2;
|
||||
}
|
||||
|
||||
message DeleteSnapshotRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message DeleteSnapshotResponse {}
|
||||
|
||||
message ExecRequest {
|
||||
string sandbox_id = 1;
|
||||
string cmd = 2;
|
||||
repeated string args = 3;
|
||||
// Timeout for the command in seconds (default: 30).
|
||||
int32 timeout_sec = 4;
|
||||
}
|
||||
|
||||
message ExecResponse {
|
||||
bytes stdout = 1;
|
||||
bytes stderr = 2;
|
||||
int32 exit_code = 3;
|
||||
}
|
||||
|
||||
message ListSandboxesRequest {}
|
||||
|
||||
message ListSandboxesResponse {
|
||||
repeated SandboxInfo sandboxes = 1;
|
||||
|
||||
// IDs of sandboxes that were automatically paused by the TTL reaper
|
||||
// since the last call. Drained on read.
|
||||
repeated string auto_paused_sandbox_ids = 2;
|
||||
}
|
||||
|
||||
message SandboxInfo {
|
||||
string sandbox_id = 1;
|
||||
string status = 2;
|
||||
string template = 3;
|
||||
int32 vcpus = 4;
|
||||
int32 memory_mb = 5;
|
||||
string host_ip = 6;
|
||||
int64 created_at_unix = 7;
|
||||
int64 last_active_at_unix = 8;
|
||||
int32 timeout_sec = 9;
|
||||
}
|
||||
|
||||
message WriteFileRequest {
|
||||
string sandbox_id = 1;
|
||||
string path = 2;
|
||||
bytes content = 3;
|
||||
}
|
||||
|
||||
message WriteFileResponse {}
|
||||
|
||||
message ReadFileRequest {
|
||||
string sandbox_id = 1;
|
||||
string path = 2;
|
||||
}
|
||||
|
||||
message ReadFileResponse {
|
||||
bytes content = 1;
|
||||
}
|
||||
|
||||
// ── Streaming Exec ──────────────────────────────────────────────────
|
||||
|
||||
message ExecStreamRequest {
|
||||
string sandbox_id = 1;
|
||||
string cmd = 2;
|
||||
repeated string args = 3;
|
||||
int32 timeout_sec = 4;
|
||||
}
|
||||
|
||||
message ExecStreamResponse {
|
||||
oneof event {
|
||||
ExecStreamStart start = 1;
|
||||
ExecStreamData data = 2;
|
||||
ExecStreamEnd end = 3;
|
||||
}
|
||||
}
|
||||
|
||||
message ExecStreamStart {
|
||||
uint32 pid = 1;
|
||||
}
|
||||
|
||||
message ExecStreamData {
|
||||
oneof output {
|
||||
bytes stdout = 1;
|
||||
bytes stderr = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message ExecStreamEnd {
|
||||
int32 exit_code = 1;
|
||||
string error = 2;
|
||||
}
|
||||
|
||||
// ── Streaming File Transfer ─────────────────────────────────────────
|
||||
|
||||
message WriteFileStreamRequest {
|
||||
oneof content {
|
||||
WriteFileStreamMeta meta = 1;
|
||||
bytes chunk = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message WriteFileStreamMeta {
|
||||
string sandbox_id = 1;
|
||||
string path = 2;
|
||||
}
|
||||
|
||||
message WriteFileStreamResponse {}
|
||||
|
||||
message ReadFileStreamRequest {
|
||||
string sandbox_id = 1;
|
||||
string path = 2;
|
||||
}
|
||||
|
||||
message ReadFileStreamResponse {
|
||||
bytes chunk = 1;
|
||||
}
|
||||
|
||||
// ── Ping ────────────────────────────────────────────────────────────
|
||||
|
||||
message PingSandboxRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message PingSandboxResponse {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user