display

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UpdateQueueSize = 100
	LogLines        = 10
)

Constants

View Source
const (
	StatusLength       = 40
	EmojiColumnWidth   = 2
	TickerInterval     = 100 * time.Millisecond
	ProgressBarPadding = 2

	MillisecondsPerTenth = 100
	TenthsPerSecond      = 10
)

Constants for rendering

Variables

View Source
var DisplayColumns = []DisplayColumn{
	{Title: "Name", Width: 10},
	{Title: "Type", Width: 6},
	{Title: "Location", Width: 16},
	{Title: "Status", Width: StatusLength},
	{Title: "Progress", Width: 20},
	{Title: "Time", Width: 10},
	{Title: "Pub IP", Width: 20},
	{Title: "Priv IP", Width: 20},
	{Title: models.DisplayTextOrchestrator, Width: EmojiColumnWidth, EmojiColumn: true},
	{Title: models.DisplayTextSSH, Width: EmojiColumnWidth, EmojiColumn: true},
	{Title: models.DisplayTextDocker, Width: EmojiColumnWidth, EmojiColumn: true},
	{Title: models.DisplayTextBacalhau, Width: EmojiColumnWidth, EmojiColumn: true},
	{Title: models.DisplayTextCustomScript, Width: EmojiColumnWidth, EmojiColumn: true},
	{Title: "", Width: 1},
}

DisplayColumns defines the structure of the display table

View Source
var GetGlobalModelFunc func() *DisplayModel = GetGlobalModel
View Source
var GetGlobalProgramFunc = GetGlobalProgram

Functions

func AggregateColumnWidths

func AggregateColumnWidths() int

AggregateColumnWidths calculates the total width of all columns

func ConvertOrchestratorToEmoji

func ConvertOrchestratorToEmoji(orchestrator bool) string

ConvertOrchestratorToEmoji converts orchestrator status to an emoji

func ConvertStateToEmoji

func ConvertStateToEmoji(serviceState models.ServiceState) string

ConvertStateToEmoji converts a service state to an emoji

func SetGlobalModel

func SetGlobalModel(m *DisplayModel)

SetGlobalModel sets the global DisplayModel instance

Types

type DisplayColumn

type DisplayColumn struct {
	Title       string
	Width       int
	Height      int
	EmojiColumn bool
}

DisplayColumn represents a column in the display table

type DisplayModel

type DisplayModel struct {
	Deployment       *models.Deployment
	TextBox          []string
	Quitting         bool
	LastUpdate       time.Time
	DebugMode        bool
	UpdateTimes      []time.Duration
	UpdateTimesIndex int
	UpdateTimesSize  int
	LastUpdateStart  time.Time
	CPUUsage         float64
	MemoryUsage      uint64
	BatchedUpdates   []models.StatusUpdateMsg
	BatchUpdateTimer *time.Timer

	UpdateMutex         sync.Mutex
	UpdateQueue         chan UpdateAction
	UpdateProcessorDone chan bool
	// contains filtered or unexported fields
}

DisplayModel represents the main display model

func GetGlobalModel

func GetGlobalModel() *DisplayModel

GetGlobalModel returns the singleton instance of DisplayModel

func NewDisplayModel

func NewDisplayModel(deployment *models.Deployment) *DisplayModel

NewDisplayModel creates and returns a new DisplayModel

func (*DisplayModel) DeregisterGoroutine

func (m *DisplayModel) DeregisterGoroutine(id int64)

DeregisterGoroutine deregisters a goroutine by its ID

func (*DisplayModel) Init

func (m *DisplayModel) Init() tea.Cmd

Init initializes the DisplayModel

func (*DisplayModel) ProcessUpdate

func (m *DisplayModel) ProcessUpdate(update UpdateAction)

ProcessUpdate processes a single update action

func (*DisplayModel) QueueUpdate

func (m *DisplayModel) QueueUpdate(update UpdateAction)

QueueUpdate queues an update to be processed

func (*DisplayModel) RegisterGoroutine

func (m *DisplayModel) RegisterGoroutine(label string) int64

RegisterGoroutine registers a new goroutine with a label

func (*DisplayModel) RenderFinalTable

func (m *DisplayModel) RenderFinalTable() string

RenderFinalTable renders the final table with additional summary information

func (*DisplayModel) StartUpdateProcessor

func (m *DisplayModel) StartUpdateProcessor(ctx context.Context)

StartUpdateProcessor begins processing updates

func (*DisplayModel) StopUpdateProcessor

func (m *DisplayModel) StopUpdateProcessor()

StopUpdateProcessor halts the update processor

func (*DisplayModel) Update

func (m *DisplayModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles updates to the DisplayModel

func (*DisplayModel) UpdateStatus

func (m *DisplayModel) UpdateStatus(status *models.DisplayStatus)

UpdateStatus updates the status of a machine

func (*DisplayModel) View

func (m *DisplayModel) View() string

View renders the DisplayModel

type GlobalProgammer

type GlobalProgammer interface {
	InitProgram(m *DisplayModel)
	GetProgram() *GlobalProgram
	Quit()
	Run() (tea.Model, error)
}

func GetGlobalProgram

func GetGlobalProgram() GlobalProgammer

GetGlobalProgram returns the singleton instance of GlobalProgram

type GlobalProgram

type GlobalProgram struct {
	Program *tea.Program
}

GlobalProgram represents the singleton instance

func (*GlobalProgram) GetProgram

func (gp *GlobalProgram) GetProgram() *GlobalProgram

GetProgram returns the tea.Program instance

func (*GlobalProgram) InitProgram

func (gp *GlobalProgram) InitProgram(m *DisplayModel)

InitProgram initializes the tea.Program

func (*GlobalProgram) Quit

func (gp *GlobalProgram) Quit()

func (*GlobalProgram) Run

func (gp *GlobalProgram) Run() (tea.Model, error)

type MockProgram

type MockProgram struct{}

func (*MockProgram) GetProgram

func (m *MockProgram) GetProgram() *GlobalProgram

func (*MockProgram) InitProgram

func (m *MockProgram) InitProgram(model *DisplayModel)

func (*MockProgram) Quit

func (m *MockProgram) Quit()

func (*MockProgram) Run

func (m *MockProgram) Run() (tea.Model, error)

type ResourceType

type ResourceType string

Type definitions

type ServiceType

type ServiceType string

Type definitions

type UpdateAction

type UpdateAction struct {
	MachineName string
	UpdateData  UpdateData
	UpdateFunc  func(models.Machiner, UpdateData)
}

UpdateAction represents an action to update the display

func NewUpdateAction

func NewUpdateAction(machineName string, updateData UpdateData) UpdateAction

NewUpdateAction creates a new UpdateAction instance.

type UpdateData

type UpdateData struct {
	UpdateType    UpdateType
	ResourceType  ResourceType
	ResourceState models.MachineResourceState
	ServiceType   ServiceType
	ServiceState  models.ServiceState
	Complete      bool
}

UpdateData contains data for an update action

func (*UpdateData) String

func (u *UpdateData) String() string

String returns a string representation of the UpdatePayload.

type UpdateType

type UpdateType string

Type definitions

const (
	UpdateTypeComplete UpdateType = "Complete"
	UpdateTypeResource UpdateType = "Resource"
	UpdateTypeService  UpdateType = "Service"
)

Constants for update types

Jump to

Keyboard shortcuts

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