models

package
v0.0.0-...-958ef34 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	gorm.Model

	State         AgentState
	UUID          uuid.UUID `gorm:"type:uuid;notnull;unique"`
	Hostname      string
	Address       string
	Version       string
	Gpus          datatypes.JSON
	VramAvailable uint64

	Labels   []KeyValue `gorm:"many2many:agent_labels;constraint:OnDelete:CASCADE;"`
	Taints   []KeyValue `gorm:"many2many:agent_taints;constraint:OnDelete:CASCADE;"`
	Sessions []Session

	PoolID uuid.UUID `gorm:"type:uuid;"`
	Pool   Pool      `gorm:"constraint:OnDelete:CASCADE;"`
}

type AgentState

type AgentState int
const (
	AgentStateUnknown AgentState = iota
	AgentStateActive
	AgentStateDisabled
	AgentStateMissing
	AgentStateClosed
)

func AgentStateFromString

func AgentStateFromString(value string) AgentState

func (AgentState) String

func (as AgentState) String() string

type Connection

type Connection struct {
	gorm.Model

	UUID        uuid.UUID `gorm:"type:uuid;notnull;unique"`
	SessionID   uint      `gorm:"constraint:OnDelete:CASCADE;"`
	Session     Session
	ExitCode    int
	Pid         string
	ProcessName string
}

type ExitStatus

type ExitStatus int
const (
	ExitStatusUnknown ExitStatus = iota
	ExitStatusSuccess
	ExitStatusFailure
	ExitStatusCanceled
)

func ExitStatusFromString

func ExitStatusFromString(value string) ExitStatus

func (ExitStatus) String

func (es ExitStatus) String() string

type KeyValue

type KeyValue struct {
	ID    uint
	Key   string `gorm:"notnull"`
	Value string `gorm:"notnull"`
}

type Permission

type Permission struct {
	ID         uuid.UUID      `gorm:"type:uuid;default:uuid_generate_v4();primaryKey"`
	UserID     string         `gorm:"type:text;not null;"`
	PoolID     uuid.UUID      `gorm:"type:uuid;not null;"`
	Pool       Pool           `gorm:"constraint:OnDelete:CASCADE;"`
	Permission PermissionType `gorm:"not null"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type PermissionType

type PermissionType int
const (
	CreateSession PermissionType = iota
	RegisterAgent
	Admin
)

func PermissionTypeFromString

func PermissionTypeFromString(value string) PermissionType

func (PermissionType) String

func (p PermissionType) String() string

type Pool

type Pool struct {
	ID        uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	PoolName  string    `gorm:"type:varchar(255);not null"`
	MaxAgents int       `gorm:"default:0"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`

	Permissions []Permission
	Sessions    []Session
	Agents      []Agent
}

type Session

type Session struct {
	gorm.Model

	UUID         uuid.UUID `gorm:"type:uuid;notnull;unique"`
	AgentID      *uint
	Agent        *Agent
	State        SessionState
	Address      string
	Version      string
	Persistent   bool
	GPUs         datatypes.JSON
	VramRequired uint64
	Requirements datatypes.JSON

	Connections []Connection

	Labels    []KeyValue `gorm:"many2many:session_labels;constraint:OnDelete:CASCADE;"`
	Tolerates []KeyValue `gorm:"many2many:session_tolerates;constraint:OnDelete:CASCADE;"`

	PoolID uuid.NullUUID `gorm:"type:uuid;"`
	Pool   Pool          `gorm:"constraint:OnDelete:CASCADE;"`
}

type SessionState

type SessionState int
const (
	SessionStateUnknown SessionState = iota
	SessionStateQueued
	SessionStateAssigned
	SessionStateActive
	SessionStateCanceling
	SessionStateClosed
)

func SessionStateFromString

func SessionStateFromString(value string) SessionState

func (SessionState) String

func (ss SessionState) String() string

Jump to

Keyboard shortcuts

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