Help us shape the future of Go! Take the 2026 Go Developer Survey

sandbox

package
v0.14.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EPOLLET        = 1 << 31
	MaxEpollEvents = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BwrapJsonStatus added in v0.10.0

type BwrapJsonStatus struct {
	// contains filtered or unexported fields
}

func (*BwrapJsonStatus) GetFile added in v0.10.0

func (b *BwrapJsonStatus) GetFile() *os.File

func (*BwrapJsonStatus) Stop added in v0.10.0

func (b *BwrapJsonStatus) Stop()

Stop waiting for changes and clean up everything

func (*BwrapJsonStatus) WaitPid added in v0.10.0

func (b *BwrapJsonStatus) WaitPid() (int, bool)

type BwrapStatusJsonI added in v0.10.0

type BwrapStatusJsonI interface {
	GetFile() *os.File
	WaitPid() (int, bool)
}

func NewBwrapJsonStatus added in v0.10.0

func NewBwrapJsonStatus(basePath string) (BwrapStatusJsonI, error)

type CGroups

type CGroups struct {
	Config *domain.RuntimeConfig `checkinject:"required"`
	// contains filtered or unexported fields
}

func (*CGroups) AddPid

func (c *CGroups) AddPid(cGroup string, pid int) error

func (*CGroups) CreateCGroup

func (c *CGroups) CreateCGroup(limits domain.CGroupLimits) (string, error)

CreateCGroup creates a cgroup for a sandbox

func (*CGroups) GetMetrics

func (c *CGroups) GetMetrics(cGroup string) (data domain.CGroupData, err error)

func (*CGroups) Init

func (c *CGroups) Init() error

Init creates a CGroup for the host and prepares to create cgroups for the sandboxes

func (*CGroups) RemoveCGroup

func (c *CGroups) RemoveCGroup(cGroup string) error

func (*CGroups) SetLimits added in v0.7.3

func (c *CGroups) SetLimits(cGroup string, limits domain.CGroupLimits) error

func (*CGroups) SetSandboxesMemoryHigh added in v0.7.3

func (c *CGroups) SetSandboxesMemoryHigh(memHigh int) error

SetSandboxesMemoryHigh sets memory.high for all sandbox parent cgroup memHigh is in bytes

type ImportPaths

type ImportPaths struct {
	Imports map[string]string `json:"imports"`
}

ImportPaths defines a type for creating imopsts.json for Deno

type Manager

type Manager struct {
	Config      *domain.RuntimeConfig `checkinject:"required"`
	SandboxRuns interface {
		Create(run domain.SandboxRunIDs, start time.Time) (int, error)
		End(sandboxID int, end time.Time, data domain.SandboxRunData) error
	} `checkinject:"required"`
	CGroups interface {
		CreateCGroup(domain.CGroupLimits) (string, error)
		AddPid(string, int) error
		SetLimits(string, domain.CGroupLimits) error
		GetMetrics(string) (domain.CGroupData, error)
		RemoveCGroup(string) error
	} `checkinject:"optional"`
	AppLogger interface {
		Get(string) domain.LoggerI
	} `checkinject:"required"`
	AppspaceLogger interface {
		Open(domain.AppspaceID) domain.LoggerI
	} `checkinject:"required"`
	ServiceMaker interface {
		Get(appspace *domain.Appspace) domain.ReverseServiceI
	} `checkinject:"required"`
	AppLocation2Path interface {
		Meta(string) string
		Files(string) string
		DenoDir(string) string
	} `checkinject:"required"`
	AppspaceLocation2Path interface {
		Base(string) string
		Data(string) string
		Files(string) string
		Avatars(string) string
		DenoDir(string) string
	} `checkinject:"required"`
	// contains filtered or unexported fields
}

Manager manages sandboxes

func (*Manager) ForApp

func (m *Manager) ForApp(appVersion *domain.AppVersion) (domain.SandboxI, error)

func (*Manager) ForMigration

func (m *Manager) ForMigration(appVersion domain.AppVersion, appspace *domain.Appspace) (domain.SandboxI, error)

func (*Manager) GetForAppspace

func (m *Manager) GetForAppspace(appVersion *domain.AppVersion, appspace *domain.Appspace) (domain.SandboxI, chan struct{})

GetForAppspace records the need for a sandbox and returns a channel I wonder if this should essentially tie up the sandbox such that it doesn't get cleaned out before the request gets passed to it.

func (*Manager) Init

func (m *Manager) Init()

Init creates maps

func (*Manager) PrintSandboxes

func (m *Manager) PrintSandboxes()

PrintSandboxes outputs containersa and status

func (*Manager) StopAll

func (m *Manager) StopAll()

StopAll takes all known sandboxes and stops them. It also stops the ticker

func (*Manager) StopAppspace

func (m *Manager) StopAppspace(appspaceID domain.AppspaceID)

StopAppspace is used to stop an appspace sandbox from running if there is one it returns if/when no sanboxes are running for that appspace

type OutProxy added in v0.13.2

type OutProxy struct {
	Log func(string)
	// contains filtered or unexported fields
}

func (*OutProxy) Port added in v0.13.2

func (o *OutProxy) Port() int

func (*OutProxy) Start added in v0.13.2

func (o *OutProxy) Start(config domain.RuntimeConfig, mitm bool) error

func (*OutProxy) Stop added in v0.13.2

func (o *OutProxy) Stop()

type Sandbox

type Sandbox struct {
	SandboxRuns interface {
		Create(run domain.SandboxRunIDs, start time.Time) (int, error)
		End(int, time.Time, domain.SandboxRunData) error
	}
	CGroups interface {
		CreateCGroup(domain.CGroupLimits) (string, error)
		AddPid(string, int) error
		SetLimits(string, domain.CGroupLimits) error
		GetMetrics(string) (domain.CGroupData, error)
		RemoveCGroup(string) error
	}
	Logger interface{ Log(string, string) }

	Services domain.ReverseServiceI

	AppLocation2Path interface {
		Meta(string) string
		Files(string) string
		DenoDir(string) string
	}
	AppspaceLocation2Path interface {
		Base(string) string
		Data(string) string
		Files(string) string
		Avatars(string) string
		DenoDir(string) string
	}
	Config *domain.RuntimeConfig
	// contains filtered or unexported fields
}

Sandbox holds the data necessary to interact with the container

func NewSandbox

func NewSandbox(id int, operation string, ownerID domain.UserID, appVersion *domain.AppVersion, appspace *domain.Appspace) *Sandbox

func (*Sandbox) AppVersion

func (s *Sandbox) AppVersion() *domain.AppVersion

func (*Sandbox) AppspaceID

func (s *Sandbox) AppspaceID() (a domain.NullAppspaceID)

func (*Sandbox) ExecFn

func (s *Sandbox) ExecFn(handler domain.AppspaceRouteHandler) error

ExecFn executes a function in athesandbox, based on the params of AppspaceRouteHandler

func (*Sandbox) GetTransport

func (s *Sandbox) GetTransport() http.RoundTripper

GetTransport gets the http transport of the sandbox

func (*Sandbox) Graceful

func (s *Sandbox) Graceful()

Graceful politely asks the sandbox to shut itself down

func (*Sandbox) Kill

func (s *Sandbox) Kill()

Kill the sandbox. No mercy.

func (*Sandbox) LastActive

func (s *Sandbox) LastActive() time.Time

LastActive returns the last used time

func (*Sandbox) NewTask

func (s *Sandbox) NewTask() chan struct{}

NewTask returns a channel used to signal the beginning and end of a task. Pass a struct to indicate the task has started, close to indicate it has ended.

func (*Sandbox) Operation

func (s *Sandbox) Operation() string

func (*Sandbox) OwnerID

func (s *Sandbox) OwnerID() domain.UserID

func (*Sandbox) SendMessage

func (s *Sandbox) SendMessage(serviceID int, commandID int, payload []byte) (twine.SentMessageI, error)

SendMessage sends to sandbox via twine

func (*Sandbox) SetImportMapExtras added in v0.7.3

func (s *Sandbox) SetImportMapExtras(extras map[string]string)

SetImportMap sets items to include in the generated import map

func (*Sandbox) SetInspect

func (s *Sandbox) SetInspect(inspect bool)

SetInspect sets the inspect flag which will cause the sandbox to start with --inspect-brk

func (*Sandbox) Start

func (s *Sandbox) Start()

Start sets the status to starting and begins the start process in a goroutine.

func (*Sandbox) Status

func (s *Sandbox) Status() domain.SandboxStatus

Status returns the status of the Sandbox

func (*Sandbox) SubscribeStatus

func (s *Sandbox) SubscribeStatus() chan domain.SandboxStatus

SubscribeStatus returns a channel that will receive status for this sandbox It automatically closes the channel after sending sandbox dead

func (*Sandbox) TiedUp

func (s *Sandbox) TiedUp() bool

TiedUp indicates whether the sandbox has unfinished tasks

func (*Sandbox) WaitFor

func (s *Sandbox) WaitFor(status domain.SandboxStatus)

WaitFor blocks until status is met, or greater status is met

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL