db

package
v0.0.0-...-b0449d7 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init() error

Types

type CreateSandboxOptions

type CreateSandboxOptions struct {
	Name        string
	TemplateID  uint
	Placeholder string
	Editable    bool
}

type CreateTplOptions

type CreateTplOptions struct {
	Name              string
	Language          []string
	Timeout           int
	MaxCPUs           int64
	MaxMemory         int64
	InternetAccess    bool
	DNS               map[string]string
	MaxContainer      int64
	MaxContainerPerIP int64
}

type Sandbox

type Sandbox struct {
	gorm.Model

	UID         string `gorm:"NOT NULL" json:"uid"`
	Name        string `json:"name"`
	TemplateID  uint   `gorm:"NOT NULL" json:"template_id"`
	Template    *Tpl   `gorm:"ForeignKey:TemplateID" json:"template"`
	Placeholder string `json:"placeholder"`
	Editable    bool   `json:"editable"`
}

type SandboxStore

type SandboxStore interface {
	// GetByID returns a sandbox with the given id.
	GetByID(id uint) (*Sandbox, error)
	// GetByUID returns a sandbox with the given uid.
	GetByUID(uid string) (*Sandbox, error)
	// ListAll returns all the sandboxes.
	ListAll() ([]*Sandbox, error)
	// Create creates a new sandbox with the given options.
	Create(opts CreateSandboxOptions) error
	// Update edits a new sandbox with the given options.
	Update(opts UpdateSandboxOptions) error
	// Delete deletes a sandbox with the given id.
	Delete(id uint) error
}
var Sandboxes SandboxStore

type Tpl

type Tpl struct {
	gorm.Model

	Name     string           `json:"name"`
	Language pgtype.TextArray `gorm:"type:text[]" json:"language"`

	// Limit
	Timeout           int            `json:"timeout"`
	MaxCPUs           int64          `json:"max_cpus"`
	MaxMemory         int64          `json:"max_memory"`
	InternetAccess    bool           `json:"internet_access"`
	DNS               datatypes.JSON `gorm:"type:jsonb" json:"dns"`
	MaxContainer      int64          `json:"max_container"`
	MaxContainerPerIP int64          `json:"max_container_per_ip"`
}

type TplStore

type TplStore interface {
	// GetByID returns a template with the given id.
	GetByID(id uint) (*Tpl, error)
	// ListAll returns all the templates.
	ListAll() ([]*Tpl, error)
	// Create creates a new template with the given options.
	Create(opts CreateTplOptions) error
	// Update edits a new template with the given options.
	Update(opts UpdateTplOptions) error
	// Delete deletes a template with the given id.
	Delete(id uint) error
}
var Tpls TplStore

type UpdateSandboxOptions

type UpdateSandboxOptions struct {
	ID          uint
	Name        string
	TemplateID  uint
	Placeholder string
	Editable    bool
}

type UpdateTplOptions

type UpdateTplOptions struct {
	ID                uint
	Name              string
	Language          []string
	Timeout           int
	MaxCPUs           int64
	MaxMemory         int64
	InternetAccess    bool
	DNS               map[string]string
	MaxContainer      int64
	MaxContainerPerIP int64
}

Jump to

Keyboard shortcuts

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