server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAddress = "127.0.0.1:8787"
)

Variables

View Source
var (
	ErrJobNotFound    = errors.New("job not found")
	ErrJobNotReady    = errors.New("job is not ready")
	ErrJobActive      = errors.New("job is already queued or running")
	ErrQueueFull      = errors.New("job queue is full")
	ErrResumeRejected = errors.New("resume rejected")
)

Functions

func BytesFromMiB

func BytesFromMiB(value int64) (int64, error)

func DefaultDataDir

func DefaultDataDir() string

func DefaultMaxUploadBytes

func DefaultMaxUploadBytes() int64

func DefaultQueueSize

func DefaultQueueSize() int

func DefaultRetention

func DefaultRetention() time.Duration

Types

type Config

type Config struct {
	DataDir        string
	JobWorkers     int
	QueueSize      int
	MaxUploadBytes int64
	Retention      time.Duration
	AuthToken      string
	ServiceVersion string
	ReadOptions    read.Options
}

type HealthResponse

type HealthResponse struct {
	OK      bool   `json:"ok"`
	Service string `json:"service"`
	Version string `json:"version,omitempty"`
	Queued  int    `json:"queued"`
	Running int    `json:"running"`
}

type Job

type Job struct {
	ID         string      `json:"id"`
	Status     JobStatus   `json:"status"`
	InputName  string      `json:"input_name"`
	PromptName string      `json:"prompt_name"`
	Pages      string      `json:"pages,omitempty"`
	Resume     bool        `json:"resume,omitempty"`
	Merge      bool        `json:"merge"`
	CreatedAt  time.Time   `json:"created_at"`
	StartedAt  *time.Time  `json:"started_at,omitempty"`
	FinishedAt *time.Time  `json:"finished_at,omitempty"`
	Progress   JobProgress `json:"progress"`
	Result     *JobResult  `json:"result,omitempty"`
	Error      *JobError   `json:"error,omitempty"`
}

type JobError

type JobError struct {
	Kind      string `json:"kind"`
	Message   string `json:"message"`
	Retryable bool   `json:"retryable"`
}
type JobLinks struct {
	Status    string `json:"status"`
	Markdown  string `json:"markdown,omitempty"`
	Artifacts string `json:"artifacts,omitempty"`
	Resume    string `json:"resume,omitempty"`
}

type JobProgress

type JobProgress struct {
	PagesTotal       int `json:"pages_total,omitempty"`
	SourcePagesTotal int `json:"source_pages_total,omitempty"`
	PagesProcessed   int `json:"pages_processed,omitempty"`
	PagesRetained    int `json:"pages_retained,omitempty"`
	PagesCompleted   int `json:"pages_completed,omitempty"`
	PagesSuccess     int `json:"pages_success,omitempty"`
	PagesFailed      int `json:"pages_failed,omitempty"`
	PagesCached      int `json:"pages_cached,omitempty"`
	FilesTotal       int `json:"files_total,omitempty"`
	FilesCompleted   int `json:"files_completed,omitempty"`
	FilesFailed      int `json:"files_failed,omitempty"`
}

type JobResponse

type JobResponse struct {
	Job
	Links JobLinks `json:"links"`
}

type JobResult

type JobResult struct {
	Mode              string `json:"mode"`
	PagesTotal        int    `json:"pages_total,omitempty"`
	SourcePagesTotal  int    `json:"source_pages_total,omitempty"`
	PagesProcessed    int    `json:"pages_processed,omitempty"`
	PagesRetained     int    `json:"pages_retained,omitempty"`
	PagesSuccess      int    `json:"pages_success,omitempty"`
	PagesFailed       int    `json:"pages_failed,omitempty"`
	PagesCached       int    `json:"pages_cached,omitempty"`
	GroundingWarnings int    `json:"grounding_warnings,omitempty"`
	Resumed           bool   `json:"resumed,omitempty"`
	FilesTotal        int    `json:"files_total,omitempty"`
	FilesDone         int    `json:"files_done,omitempty"`
	FilesFailed       int    `json:"files_failed,omitempty"`
}

type JobStatus

type JobStatus string
const (
	StatusQueued    JobStatus = "queued"
	StatusRunning   JobStatus = "running"
	StatusSucceeded JobStatus = "succeeded"
	StatusFailed    JobStatus = "failed"
)

type ListResponse

type ListResponse struct {
	Jobs []JobResponse `json:"jobs"`
}

type Manager

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

func NewManager

func NewManager(config Config) (*Manager, error)

func (*Manager) Artifact

func (m *Manager) Artifact(id string) (*os.File, os.FileInfo, error)

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) CreateJob

func (m *Manager) CreateJob(inputName string, promptName string, pages string, merge bool, temporaryPath string, bytes int64) (Job, error)

func (*Manager) List

func (m *Manager) List(limit int) []Job

func (*Manager) ReadMarkdown

func (m *Manager) ReadMarkdown(id string) ([]byte, error)

func (*Manager) ResumeJob

func (m *Manager) ResumeJob(id string, pages string) (Job, error)

func (*Manager) Snapshot

func (m *Manager) Snapshot(id string) (Job, error)

func (*Manager) Stats

func (m *Manager) Stats() (int, int)

func (*Manager) TempDir

func (m *Manager) TempDir() string

type ResumeRequest

type ResumeRequest struct {
	Pages string `json:"pages,omitempty"`
}

type Server

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

func New

func New(config Config) (*Server, error)

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, address string) error

Jump to

Keyboard shortcuts

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