Documentation
¶
Overview ¶
Package interfaces holds shared contracts consumed by both the server orchestrator (App) and the handlers package. These interfaces live here to avoid circular dependencies while keeping the contracts in a neutral, stable location.
Package interfaces holds shared contracts consumed by both the server orchestrator (App) and the handlers package. These interfaces live here to avoid circular dependencies while keeping the contracts in a neutral, stable location.
Package interfaces holds shared contracts consumed by both the server orchestrator (App) and the handlers package. These interfaces live here to avoid circular dependencies while keeping the contracts in a neutral, stable location.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigOps ¶ added in v0.9.0
type ConfigOps interface {
UpdateConfigWithPrecedence(cfg *config.Config, changedFields []string)
ApplyConfig()
InvalidateHTTPCache()
SetPreloadEnabled(enabled bool)
SetRestartRequired(b bool)
TriggerRestart()
}
ConfigOps provides configuration update operations for applying config changes, managing restart flags, and invalidating caches. Extracted as a narrow interface from ServerDeps.
type CredentialStore ¶ added in v0.9.0
type CredentialStore interface {
CheckAccountLockout(ctx context.Context, username string) (bool, error)
GetUser(ctx context.Context, username string) (*session.User, error)
RecordFailedLoginAttempt(ctx context.Context, username string) error
ClearLoginAttempts(ctx context.Context, username string) error
UpdateUsername(ctx context.Context, username string) error
UpdatePassword(ctx context.Context, passwordHash string) error
}
CredentialStore provides credential-related operations for authentication and user management. Extracted as a narrow interface from ServerDeps.
type GalleryOps ¶ added in v0.9.0
type GalleryOps interface {
GetHandlerQueries(cpc *dbconnpool.CpConn) HandlerQueries
GetMetadataQueries(cpc *dbconnpool.CpConn) MetadataQueries
GetConfigQueries(cpc *dbconnpool.CpConn) config.ConfigQueries
GetETagVersion() string
ImagesDir() string
}
GalleryOps provides gallery query operations — handler queries, metadata, config queries, ETag versioning, and the images directory path. Extracted as a narrow interface from ServerDeps.
type HandlerQueries ¶
type HandlerQueries interface {
GetFolderViewByID(ctx context.Context, id int64) (gallerydb.FolderView, error)
GetFoldersViewsByParentIDOrderByName(ctx context.Context, parent sql.NullInt64) ([]gallerydb.FolderView, error)
GetFileViewsByFolderIDOrderByFileName(ctx context.Context, folderID sql.NullInt64) ([]gallerydb.FileView, error)
GetFileViewByID(ctx context.Context, id int64) (gallerydb.FileView, error)
GetFolderByID(ctx context.Context, id int64) (gallerydb.Folder, error)
GetThumbnailsByFileID(ctx context.Context, fileID int64) (gallerydb.Thumbnail, error)
GetThumbnailBlobDataByID(ctx context.Context, id int64) ([]byte, error)
// GetPreloadRoutesByFolderID returns routes to preload for a folder (source of truth: direct children only).
// Returns *sql.Rows; each row contains a route string to scan.
GetPreloadRoutesByFolderID(ctx context.Context, parentID sql.NullInt64) (*sql.Rows, error)
GetFileFolderIndexByID(ctx context.Context, id int64) (gallerydb.GetFileFolderIndexByIDRow, error)
GetFolderInfoCountsByID(ctx context.Context, id int64) (gallerydb.GetFolderInfoCountsByIDRow, error)
GetGalleryFileThumbRowsByFolderID(ctx context.Context, folderID sql.NullInt64) ([]gallerydb.GetGalleryFileThumbRowsByFolderIDRow, error)
GetGalleryFolderThumbRowsByParentID(ctx context.Context, parentID sql.NullInt64) ([]gallerydb.GetGalleryFolderThumbRowsByParentIDRow, error)
}
HandlerQueries abstracts the subset of DB queries used by HTTP handlers. Shared by server and handlers packages.
type MetadataQueries ¶ added in v0.8.0
type MetadataQueries interface {
GetExifByFile(ctx context.Context, fileID int64) (gallerydb.ExifMetadatum, error)
GetIPTCByFile(ctx context.Context, fileID int64) (gallerydb.IptcMetadatum, error)
}
MetadataQueries abstracts EXIF and IPTC reads for a file. Used by GalleryHandlers (InfoBoxImage).
type ServerControl ¶ added in v0.9.0
type ServerControl interface {
Shutdown()
TriggerDiscovery(ctx context.Context) error
ResetStats()
StartCacheBatchLoad() (StartCacheBatchLoadResult, error)
// ManualDiscoveryError returns the in-memory error from a manual
// POST /server/discovery rebuild failure, or "" when none. Cleared on
// restart.
ManualDiscoveryError() string
// SetManualDiscoveryError sets or clears the manual discovery rebuild
// error. An empty msg clears it (acknowledged by the operator).
SetManualDiscoveryError(msg string)
}
ServerControl provides server lifecycle operations — shutdown, discovery, stats reset, and cache batch loading. Extracted as a narrow interface from ServerDeps.
type ServerDeps ¶ added in v0.8.0
type ServerDeps interface {
CredentialStore
ConfigOps
GalleryOps
ServerControl
// --- Config access ---
GetConfig() *config.Config
// --- Template helpers ---
AddCommonTemplateData(w http.ResponseWriter, r *http.Request, data map[string]any, fullPage bool) map[string]any
ServerError(w http.ResponseWriter, r *http.Request, err error)
}
ServerDeps provides all server-level dependencies consumed by handler groups. Implemented by *server.App, it replaces the previous callback-field wiring pattern with a single compile-time-checked interface.
CredentialStore, ConfigOps, GalleryOps, and ServerControl are embedded for backward compatibility — handler groups that need only narrow interfaces can accept them directly instead of the full ServerDeps.
type StartCacheBatchLoadResult ¶ added in v0.8.0
type StartCacheBatchLoadResult struct {
Blocked bool // true if discovery is active
Message string // toast message
}
StartCacheBatchLoadResult describes the result of attempting to start cache batch load.