Something went wrong. Try again.
Social cloud hosting
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273package vm
import ( "encoding/json")
type Instance struct { ID string Runtime string
// TODO: Add Firecracker process handle, vsock connection, etc.}
type ExecuteRequest struct { BundlePath string `json:"bundlePath"` Endpoint string `json:"endpoint"` Args json.RawMessage `json:"args"` Env map[string]string `json:"env"` Permissions Permissions `json:"permissions"` TimeoutSecs int `json:"timeout"`}
type ExecuteResponse struct { Success bool `json:"success"` Data json.RawMessage `json:"data,omitempty"` Response *HTTPResponse `json:"response,omitempty"` Error string `json:"error,omitempty"` Metrics *Metrics `json:"metrics,omitempty"`}
type HTTPResponse struct { Status int `json:"status"` Headers map[string]string `json:"headers"` Body string `json:"body"` IsBase64 bool `json:"isBase64,omitempty"`}
type Permissions struct { Net []string `json:"net,omitempty"` Read []string `json:"read,omitempty"` Write []string `json:"write,omitempty"` Env []string `json:"env,omitempty"`}
type Metrics struct { MemoryUsedBytes uint64 `json:"memoryUsedBytes"` CPUPercent float64 `json:"cpuPercent"` ExecutionTimeMs int64 `json:"executionTimeMs"`}
func (i *Instance) Execute(req ExecuteRequest) (*ExecuteResponse, error) { // TODO: Send request over vsock to guest agent return &ExecuteResponse{ Success: false, Error: "not implemented", }, nil}
func (i *Instance) Stop() error { // TODO: Kill Firecracker process return nil}
func (i *Instance) MountBundle(bundlePath string) error { // TODO: Mount bundle via virtio-fs return nil}
func (i *Instance) UnmountBundle() error { // TODO: Unmount bundle return nil}