Documentation
¶
Overview ¶
Package web provides the toga web UI for browsing cached modules and viewing logs.
templ: version: v0.3.1001
Index ¶
- Constants
- func StaticFS() http.FileSystem
- type AzureLister
- func (a *AzureLister) DeleteModule(ctx context.Context, modulePath, version string) error
- func (a *AzureLister) GetFile(ctx context.Context, name string) (io.ReadCloser, error)
- func (a *AzureLister) ListFiles(ctx context.Context, modulePath string) ([]FileEntry, error)
- func (a *AzureLister) ListModules(ctx context.Context, cursor, query string, limit int) (*ModulePage, error)
- type DiskLister
- func (d *DiskLister) DeleteModule(_ context.Context, modulePath, version string) error
- func (d *DiskLister) GetFile(_ context.Context, name string) (io.ReadCloser, error)
- func (d *DiskLister) ListFiles(_ context.Context, modulePath string) ([]FileEntry, error)
- func (d *DiskLister) ListModules(ctx context.Context, cursor, query string, limit int) (*ModulePage, error)
- type FetchResult
- type FileEntry
- type GCSLister
- func (g *GCSLister) DeleteModule(ctx context.Context, modulePath, version string) error
- func (g *GCSLister) GetFile(ctx context.Context, name string) (io.ReadCloser, error)
- func (g *GCSLister) ListFiles(ctx context.Context, modulePath string) ([]FileEntry, error)
- func (g *GCSLister) ListModules(ctx context.Context, cursor, query string, limit int) (*ModulePage, error)
- type Handler
- type Lister
- type Module
- type ModulePage
- type ObjectStoreLister
- func (o *ObjectStoreLister) DeleteModule(ctx context.Context, modulePath, version string) error
- func (o *ObjectStoreLister) GetFile(ctx context.Context, name string) (io.ReadCloser, error)
- func (o *ObjectStoreLister) ListFiles(ctx context.Context, modulePath string) ([]FileEntry, error)
- func (o *ObjectStoreLister) ListModules(ctx context.Context, cursor, query string, limit int) (*ModulePage, error)
- type ProgressFunc
- type Version
Constants ¶
const DefaultPageSize = 50
DefaultPageSize is the number of modules per page.
Variables ¶
This section is empty.
Functions ¶
func StaticFS ¶
func StaticFS() http.FileSystem
StaticFS returns an http.FileSystem serving the embedded static assets.
Types ¶
type AzureLister ¶
AzureLister implements Lister for Azure Blob Storage backends.
func (*AzureLister) DeleteModule ¶
func (a *AzureLister) DeleteModule(ctx context.Context, modulePath, version string) error
DeleteModule removes cached files for a module and optional version.
func (*AzureLister) GetFile ¶
func (a *AzureLister) GetFile(ctx context.Context, name string) (io.ReadCloser, error)
GetFile retrieves a single cached file by name.
func (*AzureLister) ListModules ¶
func (a *AzureLister) ListModules(ctx context.Context, cursor, query string, limit int) (*ModulePage, error)
ListModules returns a paginated list of cached modules from the backend.
type DiskLister ¶
type DiskLister struct {
Root string
}
DiskLister implements Lister for filesystem-based caches.
func (*DiskLister) DeleteModule ¶
func (d *DiskLister) DeleteModule(_ context.Context, modulePath, version string) error
DeleteModule removes cached files for a module path and optional version.
func (*DiskLister) GetFile ¶
func (d *DiskLister) GetFile(_ context.Context, name string) (io.ReadCloser, error)
GetFile returns a cached file by its cache-relative name.
func (*DiskLister) ListModules ¶
func (d *DiskLister) ListModules(ctx context.Context, cursor, query string, limit int) (*ModulePage, error)
ListModules walks the cache directory with efficient pagination. Instead of walking the entire tree, it:
- Collects only module paths (directories containing @v/).
- Skips directory subtrees that sort before the cursor.
- Stops walking once limit+1 modules are found (for hasMore detection).
- Only stats files for the modules in the returned page.
type FetchResult ¶
FetchResult holds the outcome of fetching a single module.
type GCSLister ¶
GCSLister implements Lister for Google Cloud Storage backends.
func (*GCSLister) DeleteModule ¶
DeleteModule removes cached files for a module and optional version.
func (*GCSLister) ListModules ¶
func (g *GCSLister) ListModules(ctx context.Context, cursor, query string, limit int) (*ModulePage, error)
ListModules returns a paginated list of cached modules from the backend.
type Handler ¶
type Handler struct {
Lister Lister
Fetcher *goproxy.GoFetcher
Cacher goproxy.Cacher
Logger *slog.Logger
Prefix string // URL prefix, e.g. "/-/ui"
}
Handler serves the toga web UI.
type Lister ¶
type Lister interface {
// ListModules returns a paginated list of cached modules.
// cursor is the module path to start after (empty for first page).
// query filters by substring match (empty for all).
// limit is max results to return.
ListModules(ctx context.Context, cursor, query string, limit int) (*ModulePage, error)
ListFiles(ctx context.Context, modulePath string) ([]FileEntry, error)
GetFile(ctx context.Context, name string) (io.ReadCloser, error)
DeleteModule(ctx context.Context, modulePath, version string) error
}
Lister can enumerate cached modules. Implemented per storage backend.
type ModulePage ¶
type ModulePage struct {
Modules []Module
NextCursor string // empty if no more results
Total int // total matching modules (-1 if unknown)
}
ModulePage is a paginated result set of modules.
type ObjectStoreLister ¶
ObjectStoreLister implements Lister for S3/MinIO backends using the minio-go client. It uses ListObjects with delimiter to paginate efficiently server-side.
func (*ObjectStoreLister) DeleteModule ¶
func (o *ObjectStoreLister) DeleteModule(ctx context.Context, modulePath, version string) error
DeleteModule removes cached files for a module from the object store.
func (*ObjectStoreLister) GetFile ¶
func (o *ObjectStoreLister) GetFile(ctx context.Context, name string) (io.ReadCloser, error)
GetFile retrieves a single object from the store.
func (*ObjectStoreLister) ListFiles ¶
ListFiles lists all objects under module/@v/. ListFiles lists all objects under a module's version prefix.
func (*ObjectStoreLister) ListModules ¶
func (o *ObjectStoreLister) ListModules(ctx context.Context, cursor, query string, limit int) (*ModulePage, error)
ListModules uses S3 ListObjects to enumerate module paths. Since S3 keys are flat (module/@v/version.ext), we list with prefix="" and look for keys containing versionPrefix to extract module paths. For large buckets, this streams results instead of loading all keys into memory. ListModules returns a paginated list of cached modules from the object store.
type ProgressFunc ¶
type ProgressFunc func(FetchResult)
ProgressFunc is called after each module is fetched during recursive fetch.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Command fetch-assets downloads htmx, Alpine.js, Pico CSS, and highlight.js into internal/web/static/ for embedding into the toga binary.
|
Command fetch-assets downloads htmx, Alpine.js, Pico CSS, and highlight.js into internal/web/static/ for embedding into the toga binary. |