Brijesh's Git Server — navigator-v2 @ 19f964e87980aeb2d2f6a016091d7bfe1bdb3732

api/internal/database/models.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
package database

import (
	"time"

	"github.com/google/uuid"
)

type SessionStatus string

const (
	StatusStarting SessionStatus = "starting"
	StatusRunning  SessionStatus = "running"
	StatusStopped  SessionStatus = "stopped"
	StatusFailed   SessionStatus = "failed"
)

type BrowserSession struct {
	ID            uuid.UUID     `json:"id"`
	DisplayNumber int           `json:"display_number"`
	VNCPort       int           `json:"vnc_port"`
	DebugPort     int           `json:"debug_port"`
	Status        SessionStatus `json:"status"`
	CreatedAt     time.Time     `json:"created_at"`
	UpdatedAt     time.Time     `json:"updated_at"`
	ErrorMessage  *string       `json:"error_message,omitempty"`
	XvfbPID       *int          `json:"xvfb_pid,omitempty"`
	ChromePID     *int          `json:"chrome_pid,omitempty"`
	VNCPID        *int          `json:"vnc_pid,omitempty"`
}

// Config holds the configuration for browser sessions
type Config struct {
	MaxSessions   int    `json:"max_sessions"`
	BaseVNCPort   int    `json:"base_vnc_port"`
	BaseDebugPort int    `json:"base_debug_port"`
	ChromePath    string `json:"chrome_path"`
	ScreenWidth   int    `json:"screen_width"`
	ScreenHeight  int    `json:"screen_height"`
	ScreenDepth   int    `json:"screen_depth"`
}

// DefaultConfig returns default configuration values
func DefaultConfig() Config {
	return Config{
		MaxSessions:   10,
		BaseVNCPort:   5900,
		BaseDebugPort: 9222,
		ChromePath:    "/usr/bin/chromium",
		ScreenWidth:   1280,
		ScreenHeight:  720,
		ScreenDepth:   24,
	}
}