vm

package
v0.0.0-...-0186d81 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: AGPL-3.0 Imports: 49 Imported by: 0

Documentation

Overview

Package vm owns persistent VM identities and reuses sandbox scheduling and durable disks for each cold boot.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, opts ServiceOpts) error

Types

type Gateway

type Gateway interface {
	GetOrCreateStub(context.Context, *pb.GetOrCreateStubRequest) (*pb.GetOrCreateStubResponse, error)
	StopContainer(context.Context, *pb.StopContainerRequest) (*pb.StopContainerResponse, error)
	ResolveCPUTier(ctx context.Context, workspace *types.Workspace, requested types.CPUTier, pool string, eligible bool) (types.CPUTier, error)
	IsHostedCPUPool(string) bool
}

type ICESession

type ICESession struct {
	VMID        string
	ContainerID string
	TokenHash   string
	Password    string
	WorkspaceID uint
	Generation  int64
}

type ImageVerifier

type ImageVerifier interface {
	VerifyImageBuild(context.Context, *pb.VerifyImageBuildRequest) (*pb.VerifyImageBuildResponse, error)
}

type Runtime

type Runtime interface {
	pb.PodServiceServer
	RunVM(context.Context, *auth.AuthInfo, string, string, types.VMSpec, string, map[string]string) error
	VMPortReady(context.Context, string, string, uint32) (bool, error)
	ForwardVM(echo.Context, string, string) error
	TunnelVM(echo.Context, string, uint32) error
	SetVMICEHandler(func(net.Conn))
}

type Service

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

type ServiceOpts

type ServiceOpts struct {
	StateRepo     VMRepository
	Config        types.VMConfig
	BackendRepo   repository.BackendRepository
	ContainerRepo repository.ContainerRepository
	Runtime       Runtime
	Gateway       Gateway
	Images        ImageVerifier
	RouteGroup    *echo.Group
	Server        *echo.Echo
	BackendDialer *network.BackendDialer
	TCPConfig     types.PodTCPConfig // Shared raw TCP listener used by ICE-TCP media.
}

type VMRedisRepository

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

func (*VMRedisRepository) AcquireICELease

func (r *VMRedisRepository) AcquireICELease(ctx context.Context, fragment, lease string, ttl time.Duration) (int, error)

func (*VMRedisRepository) GetICESession

func (r *VMRedisRepository) GetICESession(ctx context.Context, fragment string) (*ICESession, error)

func (*VMRedisRepository) HasActivity

func (r *VMRedisRepository) HasActivity(ctx context.Context, id string) (bool, error)

func (*VMRedisRepository) IncrementICERegistrations

func (r *VMRedisRepository) IncrementICERegistrations(ctx context.Context, id string) (int, error)

func (*VMRedisRepository) RegisterICESession

func (r *VMRedisRepository) RegisterICESession(ctx context.Context, fragment string, session ICESession, ttl time.Duration) (bool, error)

func (*VMRedisRepository) ReleaseActivity

func (r *VMRedisRepository) ReleaseActivity(ctx context.Context, id, lease string) error

func (*VMRedisRepository) ReleaseICELease

func (r *VMRedisRepository) ReleaseICELease(ctx context.Context, fragment, lease string) error

func (*VMRedisRepository) RenewActivity

func (r *VMRedisRepository) RenewActivity(ctx context.Context, id, lease string) error

func (*VMRedisRepository) RenewICELease

func (r *VMRedisRepository) RenewICELease(ctx context.Context, fragment, lease string, ttl time.Duration) error

type VMRepository

type VMRepository interface {
	RenewActivity(ctx context.Context, id, lease string) error
	HasActivity(ctx context.Context, id string) (bool, error)
	ReleaseActivity(ctx context.Context, id, lease string) error
	IncrementICERegistrations(ctx context.Context, id string) (int, error)
	// RegisterICESession returns false for a colliding registration.
	RegisterICESession(ctx context.Context, fragment string, session ICESession, ttl time.Duration) (bool, error)
	// GetICESession returns nil for an absent or expired registration.
	GetICESession(ctx context.Context, fragment string) (*ICESession, error)
	AcquireICELease(ctx context.Context, fragment, lease string, ttl time.Duration) (int, error)
	RenewICELease(ctx context.Context, fragment, lease string, ttl time.Duration) error
	ReleaseICELease(ctx context.Context, fragment, lease string) error
}

VMRepository owns ephemeral activity and media coordination.

func NewVMRedisRepository

func NewVMRedisRepository(rdb *common.RedisClient) VMRepository

Jump to

Keyboard shortcuts

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