core

package
v0.0.0-...-a2be96e Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SMOOTHING_FACTOR = 0.3

Functions

func CheckStop

func CheckStop(ctx context.Context) error

Types

type AppEvent

type AppEvent struct {
	ID              string
	State           AppState
	Path            string
	Branch          string
	Build           string
	AutoUpdate      bool
	UpdateAvailable bool
	UpdateBuild     string
	TotalPlayed     time.Duration
	LastPlayed      int64
}

type AppState

type AppState byte
const (
	READY AppState = iota
	INSTALLING
	UNINSTALLING
	NOT_INSTALLED
	UPDATING
	VERIFYING
	CHECKING_UPDATES
	LAUNCHING
	LAUNCHED
)

type Application

type Application struct {
	ID     string
	State  AppState
	Path   string
	Branch string
	Build  string

	AutoUpdate      bool
	UpdateAvailable bool
	UpdateBuild     string

	LastLaunched int64
	TotalPlayed  time.Duration
	LastPlayed   int64
	// contains filtered or unexported fields
}

func NewApp

func NewApp(id string) *Application

func (*Application) CheckUpdates

func (a *Application) CheckUpdates(ctx *Context) error

func (*Application) CompleteCheckUpdates

func (a *Application) CompleteCheckUpdates(ctx *Context, build string) error

func (*Application) Event

func (a *Application) Event() AppEvent

func (*Application) GetLastPlayed

func (a *Application) GetLastPlayed() int64

func (*Application) Install

func (a *Application) Install(ctx *Context, branch, build, path string, autoUpdate bool) error

func (*Application) Launch

func (a *Application) Launch(ctx *Context) error

func (*Application) Launched

func (a *Application) Launched(ctx *Context) error

func (*Application) NewBuild

func (a *Application) NewBuild(ctx *Context, branch, build string) error

func (*Application) Recover

func (a *Application) Recover(ctx *Context) error

func (*Application) SetAutoUpdate

func (a *Application) SetAutoUpdate(ctx *Context, value bool) error

func (*Application) Stopped

func (a *Application) Stopped(ctx *Context) error

func (*Application) SwitchBranch

func (a *Application) SwitchBranch(ctx *Context, branch, build string) error

func (*Application) Uninstall

func (a *Application) Uninstall(ctx *Context) error

func (*Application) Update

func (a *Application) Update(ctx *Context) error

func (*Application) Verify

func (a *Application) Verify(ctx *Context) error

type Apps

type Apps map[string]*Application

Apps is application registry

func (Apps) Add

func (s Apps) Add(app *Application) error

func (Apps) Find

func (s Apps) Find(id string) (*Application, error)

func (Apps) FindOrNew

func (s Apps) FindOrNew(id string) *Application

func (Apps) Remove

func (s Apps) Remove(id string) error

type Command

type Command interface {
	Apply(ctx *Context) error
}

type CommandFunc

type CommandFunc func(ctx *Context) error

func (CommandFunc) Apply

func (f CommandFunc) Apply(ctx *Context) error

type Context

type Context struct {
	DB       DB
	Apps     Apps
	Executor *Executor
	// contains filtered or unexported fields
}

func NewContext

func NewContext(db DB, f JobFactory) (*Context, error)

func (*Context) Notify

func (c *Context) Notify(event interface{})

func (*Context) Runner

func (c *Context) Runner() Runner

type DB

type DB interface {
	SaveApp(app *Application) error
	LoadApps() (Apps, error)
}

type Executor

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

func NewExecutor

func NewExecutor() *Executor

func (*Executor) Add

func (e *Executor) Add(ctx *Context, t *Task) error

func (*Executor) ChangePriority

func (e *Executor) ChangePriority(ctx *Context, id int64, priority int) error

func (*Executor) Find

func (e *Executor) Find(id int64) (*Task, error)

func (*Executor) GetAll

func (e *Executor) GetAll() []UpdateTaskEvent

func (*Executor) Remove

func (e *Executor) Remove(ctx *Context, id int64) error

func (*Executor) Run

func (e *Executor) Run(j SimpleJob)

type FakeJob

type FakeJob struct{}

func (*FakeJob) Run

func (f *FakeJob) Run(ctx process.Context) error

type IntIDProvider

type IntIDProvider int64

func (*IntIDProvider) NextID

func (p *IntIDProvider) NextID() int64

type Job

type Job interface {
	Run(ctx process.Context) error
}

type JobFactory

type JobFactory interface {
	NewJob(kind TaskType, app *Application, recover bool) Job
	NewCheckUpdate(ctx *Context, app *Application) SimpleJob
	NewLaunch(ctx *Context, app *Application) SimpleJob
}

type Listener

type Listener interface {
	Notify(event interface{})
}

type PerfStats

type PerfStats struct {
	Download int64
	Read     int64
	Write    int64
}

type PerfStatsEvent

type PerfStatsEvent struct {
	TaskID    int64
	AppID     string
	Timestamp time.Time
	Stats     PerfStats
}

type ProcessState

type ProcessState byte
const (
	PStopped ProcessState = iota
	PRunning
	PStopping
)

type QueueOrderEvent

type QueueOrderEvent struct {
	Tasks []int64
}

type Runner

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

func (Runner) Run

func (r Runner) Run(command interface{}) error

func (Runner) RunFunc

func (r Runner) RunFunc(f CommandFunc) error

func (Runner) Subscribe

func (r Runner) Subscribe(l Listener)

func (Runner) Unsubscribe

func (r Runner) Unsubscribe(l Listener)

type SimpleJob

type SimpleJob interface {
	Run() error
}

type Task

type Task struct {
	ID       int64
	App      *Application
	Type     TaskType
	State    TaskState
	Progress process.Progress
	Error    error
	// contains filtered or unexported fields
}

func NewTask

func NewTask(ctx *Context, app *Application, kind TaskType) *Task

func RecoverTask

func RecoverTask(ctx *Context, app *Application, kind TaskType) *Task

func (*Task) Pause

func (t *Task) Pause(ctx *Context) error

func (*Task) Resume

func (t *Task) Resume(ctx *Context) error

func (*Task) Run

func (t *Task) Run(ctx *Context) error

func (*Task) Stop

func (t *Task) Stop(ctx *Context) error

type TaskState

type TaskState byte
const (
	QUEUED TaskState = iota
	RUNNING
	PAUSED
	COMPLETED
)

type TaskType

type TaskType byte
const (
	NONE TaskType = iota
	INSTALL
	UNINSTALL
	UPDATE
	VERIFY
)

type TypeWriter

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

func (TypeWriter) String

func (t TypeWriter) String() string

type UpdateTaskEvent

type UpdateTaskEvent struct {
	TaskID   int64
	AppID    string
	Type     TaskType
	State    TaskState
	Progress process.Progress
	ETA      time.Duration
	Error    error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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