Documentation
¶
Index ¶
- Constants
- func IsLoopbackHost(host string) bool
- func TaskParamBool(params map[string]any, key string) bool
- func TaskParamInt(params map[string]any, key string) int
- func TaskParamString(params map[string]any, key string) string
- func TaskParamStrings(params map[string]any, key string) []string
- type CacheProvider
- type ConfigProvider
- type Deps
- type Engine
- func (e *Engine) Cancel(id string) error
- func (e *Engine) Close()
- func (e *Engine) Counts() (running int, queued int)
- func (e *Engine) Get(id string) (Task, bool)
- func (e *Engine) Hub() *sse.Hub
- func (e *Engine) List(limit int) []Task
- func (e *Engine) Submit(kind string, params map[string]any) (string, error)
- type ExtProvider
- type ListProvider
- type LogLine
- type Options
- type QueryProvider
- type SearchProvider
- type Server
- type ShowProvider
- type Task
- type TaskProgress
- type TaskReporter
- func (r *TaskReporter) Error(format string, args ...any)
- func (r *TaskReporter) Info(format string, args ...any)
- func (r *TaskReporter) Logf(level, format string, args ...any)
- func (r *TaskReporter) Progress(percent float64, phase string)
- func (r *TaskReporter) ProgressBytes(current, total int64, phase string)
- type TaskRunner
- type TaskStatus
Constants ¶
const DefaultPort = 8787
DefaultPort is the eget web default listen port.
Variables ¶
This section is empty.
Functions ¶
func IsLoopbackHost ¶
IsLoopbackHost reports whether host only accepts local connections.
func TaskParamBool ¶
TaskParamBool reads a boolean parameter that arrived as JSON.
func TaskParamInt ¶
TaskParamInt reads a numeric parameter that arrived as JSON (json numbers decode into float64).
func TaskParamString ¶
TaskParamString reads a string parameter that arrived as JSON.
Types ¶
type CacheProvider ¶
type CacheProvider interface {
ResolveCacheDir() (string, error)
List(cacheDir string, opts appcache.ListOptions) (appcache.ListResult, error)
Status(cacheDir string) (appcache.StatusResult, error)
}
CacheProvider is the subset of appcache.Service the console needs.
type ConfigProvider ¶
type ConfigProvider interface {
ConfigInfo() (app.ConfigInfoResult, error)
ConfigExport(out io.Writer, withGlobal bool) error
ConfigGet(key string) (any, error)
ConfigSet(key, value string) error
}
ConfigProvider is the subset of app.ConfigService the console needs.
type Deps ¶
type Deps struct {
List ListProvider
Show ShowProvider
Query QueryProvider
Search SearchProvider
Config ConfigProvider
Cache CacheProvider
Ext ExtProvider
// Machine handlers serve the cache mirror protocol on its original paths
// (/manifest.json, /download/*, /files/*).
Manifest http.HandlerFunc
Download http.HandlerFunc
File http.HandlerFunc
// AssetCandidates lists the assets matching a target without downloading,
// so the install form can offer an explicit choice.
AssetCandidates func(ctx context.Context, target string) ([]string, error)
// ListWithManagers returns the list provider scoped to a manager selection,
// which is how /api/outdated filters to eget-only or one external manager
// without rebuilding the service.
ListWithManagers func(app.ManagersSelection) ListProvider
}
Deps are the application services the console calls.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine runs one task at a time — the store and external managers do not tolerate concurrent writers — and publishes every state change to SSE subscribers through a keyed hub.
func NewEngine ¶
func NewEngine(storePath string, runners map[string]TaskRunner) *Engine
NewEngine restores persisted task history and starts the single worker.
func (*Engine) Close ¶
func (e *Engine) Close()
Close cancels running tasks and stops the worker. Queued tasks are dropped.
type ExtProvider ¶
type ExtProvider interface {
Names() []string
Manager(name string) (extpkg.Manager, bool)
Path(manager extpkg.Manager) (string, bool)
List(ctx context.Context, only ...string) ([]extpkg.Package, []extpkg.Failure, error)
Outdated(ctx context.Context, only ...string) ([]extpkg.Package, []extpkg.Failure, error)
}
ExtProvider is the subset of extpkg.Service the console needs.
type ListProvider ¶
type ListProvider interface {
ListPackages() ([]app.ListItem, error)
ListInstalledPackages() ([]app.ListItem, error)
ListOutdatedPackages() ([]app.OutdatedItem, []app.OutdatedCheckFailure, int, error)
FindPackage(name string) (*app.ListItem, error)
}
ListProvider is the subset of app.ListService the console needs.
type Options ¶
type Options struct {
Host string
Port int
Token string
ReadOnly bool
AllowMutations bool
Version string
CacheRoot string
NoCacheIndex bool
// AllowHosts adds names to the Host header allow list.
AllowHosts []string
JSONLog bool
LogWriter io.Writer
// TaskStore is the tasks.json path (empty disables persistence).
TaskStore string
// TaskRunners maps a task kind to its implementation. Write endpoints are
// unavailable when it is empty.
TaskRunners map[string]TaskRunner
}
Options configures the eget web console.
type QueryProvider ¶
type QueryProvider interface {
Query(opts app.QueryOptions) (app.QueryResult, error)
}
QueryProvider is the subset of app.QueryService the console needs.
type SearchProvider ¶
type SearchProvider interface {
Search(opts app.SearchOptions) (app.SearchResult, error)
}
SearchProvider is the subset of app.SearchService the console needs.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server hosts the eget web console over HTTP.
func (*Server) MutationsEnabled ¶
MutationsEnabled reports whether write endpoints may run.
func (*Server) Router ¶
Router exposes the underlying router, for tests that register extra routes before the first request freezes the routing table.
type ShowProvider ¶
type ShowProvider interface {
ShowPackage(target string) (app.ShowResult, error)
}
ShowProvider is the subset of app.ShowService the console needs.
type Task ¶
type Task struct {
ID string `json:"id"`
Kind string `json:"kind"`
Params map[string]any `json:"params,omitempty"`
Status TaskStatus `json:"status"`
CreatedAt time.Time `json:"createdAt"`
StartedAt *time.Time `json:"startedAt,omitempty"`
FinishedAt *time.Time `json:"finishedAt,omitempty"`
Progress TaskProgress `json:"progress"`
Logs []LogLine `json:"logs,omitempty"`
Result any `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
type TaskProgress ¶
type TaskReporter ¶
type TaskReporter struct {
// contains filtered or unexported fields
}
TaskReporter is how a running task pushes log lines and progress.
func (*TaskReporter) Error ¶
func (r *TaskReporter) Error(format string, args ...any)
func (*TaskReporter) Info ¶
func (r *TaskReporter) Info(format string, args ...any)
func (*TaskReporter) Logf ¶
func (r *TaskReporter) Logf(level, format string, args ...any)
func (*TaskReporter) Progress ¶
func (r *TaskReporter) Progress(percent float64, phase string)
func (*TaskReporter) ProgressBytes ¶
func (r *TaskReporter) ProgressBytes(current, total int64, phase string)
type TaskRunner ¶
TaskRunner performs one queued task. It must honor ctx cancellation and return a JSON-serializable result.
type TaskStatus ¶
type TaskStatus string
TaskStatus is the lifecycle state of a console task.
const ( StatusQueued TaskStatus = "queued" StatusRunning TaskStatus = "running" StatusSucceeded TaskStatus = "succeeded" StatusFailed TaskStatus = "failed" StatusCanceled TaskStatus = "canceled" // StatusInterrupted marks a task that was still running when the process // exited; the engine cannot resume it after a restart. StatusInterrupted TaskStatus = "interrupted" )