Add host agent with VM lifecycle, TAP networking, and envd client
Implements Phase 1: boot a Firecracker microVM, execute a command inside it via envd, and get the output back. Uses raw Firecracker HTTP API via Unix socket (not the Go SDK) for full control over the VM lifecycle. - internal/vm: VM manager with create/pause/resume/destroy, Firecracker HTTP client, process launcher with unshare + ip netns exec isolation - internal/network: per-sandbox network namespace with veth pair, TAP device, NAT rules, and IP forwarding - internal/envdclient: Connect RPC client for envd process/filesystem services with health check retry - cmd/host-agent: demo binary that boots a VM, runs "echo hello", prints output, and cleans up - proto/envd: canonical proto files with buf + protoc-gen-connect-go code generation - images/wrenn-init.sh: minimal PID 1 init script for guest VMs - CLAUDE.md: updated architecture to reflect TAP networking (not vsock) and Firecracker HTTP API (not Go SDK)
This commit is contained in:
1444
proto/envd/gen/filesystem.pb.go
Normal file
1444
proto/envd/gen/filesystem.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
337
proto/envd/gen/genconnect/filesystem.connect.go
Normal file
337
proto/envd/gen/genconnect/filesystem.connect.go
Normal file
@ -0,0 +1,337 @@
|
||||
// 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"))
|
||||
}
|
||||
310
proto/envd/gen/genconnect/process.connect.go
Normal file
310
proto/envd/gen/genconnect/process.connect.go
Normal file
@ -0,0 +1,310 @@
|
||||
// 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"))
|
||||
}
|
||||
1970
proto/envd/gen/process.pb.go
Normal file
1970
proto/envd/gen/process.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user