Documentation
¶
Index ¶
- Constants
- Variables
- func ConcurrencyLimitMiddleware(maxConcurrent int) func(http.Handler) http.Handler
- func SizeLimitMiddleware(maxBytes int64) func(http.Handler) http.Handler
- type CleanupManager
- type Job
- type JobCompleteEvent
- type JobErrorEvent
- type JobManager
- func (m *JobManager) CreateJob(uploadID, from, to string) (*Job, error)
- func (m *JobManager) DeleteJob(id string) bool
- func (m *JobManager) GetJob(id string) (*Job, error)
- func (m *JobManager) ListJobs() []*Job
- func (m *JobManager) PruneJobs(before time.Time) int
- func (m *JobManager) UpdateStatus(id, status, resultPath, errMsg string)
- func (m *JobManager) UpdateStatusWithWarnings(id, status, resultPath, errMsg string, warnings []string)
- type JobProgressEvent
- type JobStore
- type SSEWriter
- type Server
- type ServerMode
- type ServerOption
- func WithCORSOrigin(origin string) ServerOption
- func WithLogger(logger *slog.Logger) ServerOption
- func WithMaxRunningJobs(n int) ServerOption
- func WithMaxUploadSize(size int64) ServerOption
- func WithRequestTimeout(timeout time.Duration) ServerOption
- func WithServerMode(mode ServerMode) ServerOption
- func WithUI(enabled bool) ServerOption
- func WithVersion(version string) ServerOption
Constants ¶
const ( JobStatusQueued = "queued" JobStatusRunning = "running" JobStatusDone = "done" JobStatusFailed = "failed" JobStatusCanceled = "canceled" )
Variables ¶
var ErrJobNotFound = errors.New("job not found")
var Version = "dev"
Version is the API version value. It can be overridden with -ldflags.
Functions ¶
func ConcurrencyLimitMiddleware ¶
ConcurrencyLimitMiddleware bounds concurrent conversion work with a semaphore.
Types ¶
type CleanupManager ¶
type CleanupManager struct {
// contains filtered or unexported fields
}
CleanupManager removes stale temporary files from uploads/downloads storage.
func NewCleanupManager ¶
func (*CleanupManager) CleanupOnce ¶
func (c *CleanupManager) CleanupOnce() error
func (*CleanupManager) Start ¶
func (c *CleanupManager) Start()
Start launches cleanup in the background. Missing tempDir never blocks startup.
func (*CleanupManager) Stop ¶
func (c *CleanupManager) Stop()
Stop signals the background cleanup goroutine to stop.
type Job ¶
type Job struct {
ID string `json:"id"`
Status string `json:"status"`
UploadID string `json:"upload_id"`
From string `json:"from"`
To string `json:"to"`
CreatedAt time.Time `json:"created_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ResultPath string `json:"-"`
Error string `json:"error,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
type JobCompleteEvent ¶
type JobErrorEvent ¶
type JobManager ¶
type JobManager struct {
// contains filtered or unexported fields
}
func NewJobManager ¶
func NewJobManager() *JobManager
func (*JobManager) CreateJob ¶
func (m *JobManager) CreateJob(uploadID, from, to string) (*Job, error)
func (*JobManager) DeleteJob ¶
func (m *JobManager) DeleteJob(id string) bool
func (*JobManager) ListJobs ¶
func (m *JobManager) ListJobs() []*Job
func (*JobManager) UpdateStatus ¶
func (m *JobManager) UpdateStatus(id, status, resultPath, errMsg string)
func (*JobManager) UpdateStatusWithWarnings ¶ added in v0.1.2
func (m *JobManager) UpdateStatusWithWarnings(id, status, resultPath, errMsg string, warnings []string)
type JobProgressEvent ¶
type SSEWriter ¶
type SSEWriter struct {
// contains filtered or unexported fields
}
SSEWriter writes Server-Sent Events using the standard event/data format.
func NewSSEWriter ¶
func NewSSEWriter(w http.ResponseWriter) (*SSEWriter, error)
NewSSEWriter configures the response for Server-Sent Events.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the conversion engine and HTTP server.
func NewServer ¶
func NewServer(engine *core.Engine, addr string, opts ...ServerOption) *Server
NewServer constructs a server with all API routes registered.
func (*Server) ListenAndServe ¶
ListenAndServe starts the HTTP server.
type ServerMode ¶
type ServerMode int
ServerMode controls whether the server exposes the web UI or runs as a public API only. The zero value defaults to ServerModeLocalUI.
const ( // ServerModeLocalUI serves both the web UI and the API (default). ServerModeLocalUI ServerMode = iota // ServerModePublicAPI serves only the API; UI routes return 404. ServerModePublicAPI )
type ServerOption ¶
type ServerOption func(*Server)
ServerOption configures Server construction.
func WithCORSOrigin ¶
func WithCORSOrigin(origin string) ServerOption
WithCORSOrigin sets the Access-Control-Allow-Origin value.
func WithLogger ¶
func WithLogger(logger *slog.Logger) ServerOption
WithLogger sets the logger used by middleware.
func WithMaxRunningJobs ¶
func WithMaxRunningJobs(n int) ServerOption
WithMaxRunningJobs sets the maximum number of concurrently running conversion jobs. Jobs beyond the limit remain queued until a slot opens.
func WithMaxUploadSize ¶
func WithMaxUploadSize(size int64) ServerOption
WithMaxUploadSize sets the maximum request body size reserved for future endpoints.
func WithRequestTimeout ¶
func WithRequestTimeout(timeout time.Duration) ServerOption
WithRequestTimeout sets the per-request timeout.
func WithServerMode ¶
func WithServerMode(mode ServerMode) ServerOption
WithServerMode sets the server mode which controls UI availability. ServerModeLocalUI enables the web UI; ServerModePublicAPI disables it.
func WithVersion ¶
func WithVersion(version string) ServerOption
WithVersion sets the version returned by /api/v1/version.