Documentation
¶
Index ¶
- type Postie
- func (p *Postie) CleanupPar2Files(ctx context.Context, sourceFile fileinfo.FileInfo)
- func (p *Postie) Close()
- func (p *Postie) ExecutePostUploadScript(ctx context.Context, nzbPath string, sourcePath string, itemID string) error
- func (p *Postie) Post(ctx context.Context, files []fileinfo.FileInfo, rootDir string, ...) (nzbPath string, retErr error)
- func (p *Postie) SetDeleteOriginal(v bool)
- type QueueInterface
- type Runtime
- func (r *Runtime) Close() error
- func (r *Runtime) DurableVerificationEnabled() bool
- func (r *Runtime) Metrics() RuntimeMetrics
- func (r *Runtime) NewManifestRecorder(transferID string) *transferwriter.Recorder
- func (r *Runtime) Par2Scheduler() *par2.Scheduler
- func (r *Runtime) RunVerification(ctx context.Context)
- func (r *Runtime) TransferStore() *transferstore.Store
- func (r *Runtime) UploadEngine() *poster.Engine
- type RuntimeMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Postie ¶
type Postie struct {
// contains filtered or unexported fields
}
func New ¶
func New( ctx context.Context, cfg config.Config, poolManager *pool.Manager, jobProgress progress.JobProgress, queue QueueInterface, ) (*Postie, error)
New creates a Postie that owns a private transfer runtime. It is retained as a compatibility entry point for the CLI and external package users; the processor path uses NewWithRuntime to share one process-wide runtime across all jobs.
func NewWithRuntime ¶ added in v0.0.30
func NewWithRuntime( ctx context.Context, cfg config.Config, poolManager *pool.Manager, jobProgress progress.JobProgress, queue QueueInterface, rt *Runtime, transferID string, ) (*Postie, error)
NewWithRuntime creates a Postie that borrows shared resources from rt. When rt is nil a private PAR2 scheduler is created honouring the configured par2.max_concurrent_jobs, preserving standalone behaviour. transferID binds this job's durable manifests; when empty (or rt has no store) manifest recording is disabled.
func (*Postie) CleanupPar2Files ¶ added in v0.0.29
CleanupPar2Files removes PAR2 files for the given source file This method can be called when a job fails permanently to clean up orphaned PAR2 files
func (*Postie) ExecutePostUploadScript ¶ added in v0.0.29
func (p *Postie) ExecutePostUploadScript(ctx context.Context, nzbPath string, sourcePath string, itemID string) error
ExecutePostUploadScript executes the post-upload script for a completed item This should be called after the file has been marked as completed in the database
func (*Postie) SetDeleteOriginal ¶ added in v0.0.30
SetDeleteOriginal records whether the job's original files should be deleted after the durable verification service confirms the upload. Must be called before Post. No effect in standalone mode (deletion is handled inline there).
type QueueInterface ¶ added in v0.0.29
type QueueInterface interface {
UpdateScriptStatus(ctx context.Context, itemID string, status string, retryCount int, lastError string, nextRetryAt *time.Time, firstFailureAt *time.Time) error
MarkScriptCompleted(ctx context.Context, itemID string) error
}
QueueInterface defines the queue methods needed by Postie
type Runtime ¶ added in v0.0.30
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns the process-wide transfer resources shared across all upload jobs. Today it holds the PAR2 scheduler; later phases extend it with the upload engine, durable verification service, shared throttle, and global upload-buffer budget.
The Processor creates one Runtime during initialization and closes it during shutdown. Each per-job Postie borrows these shared resources (via NewWithRuntime) instead of creating its own, which is what makes the limits process-wide rather than per queue job.
func NewRuntime ¶ added in v0.0.30
func NewRuntime(ctx context.Context, cfg config.Config, poolManager *pool.Manager, store *transferstore.Store, manifestDir string, scriptQueue QueueInterface) (*Runtime, error)
NewRuntime builds the shared transfer runtime from cfg. poolManager may be nil; when it is (or when no upload connections are advertised) the upload engine is left unset and jobs fall back to standalone, unbounded behaviour. store and manifestDir enable durable manifest recording; when store is nil jobs run without manifests (standalone). It is safe to call with a cfg whose PAR2 settings are unset; the PAR2 scheduler then defaults to a single job.
func (*Runtime) Close ¶ added in v0.0.30
Close releases runtime-owned resources. It is safe to call on a nil Runtime and safe to call more than once.
func (*Runtime) DurableVerificationEnabled ¶ added in v0.0.30
DurableVerificationEnabled reports whether durable verification is active (a verification service was created). When true, callers should defer destructive cleanup (delete_original, post-upload script) until the durable service marks the transfer verified, rather than acting at upload completion.
func (*Runtime) Metrics ¶ added in v0.0.30
func (r *Runtime) Metrics() RuntimeMetrics
Metrics returns a snapshot of current runtime resource usage. Safe on a nil Runtime (returns the zero value).
func (*Runtime) NewManifestRecorder ¶ added in v0.0.30
func (r *Runtime) NewManifestRecorder(transferID string) *transferwriter.Recorder
NewManifestRecorder returns a per-job manifest recorder bound to transferID, or nil when the runtime has no store or transferID is empty (so the poster runs without manifest recording). The concrete type lets the caller both use it as a poster.ManifestSink and call CompleteUpload after posting.
func (*Runtime) Par2Scheduler ¶ added in v0.0.30
Par2Scheduler returns the shared PAR2 scheduler, or nil if r is nil.
func (*Runtime) RunVerification ¶ added in v0.0.30
RunVerification runs the durable verification service until ctx is cancelled. It is a no-op (returns immediately) when no service was created (standalone mode or missing store/pool). Intended to be started once as a goroutine.
func (*Runtime) TransferStore ¶ added in v0.0.30
func (r *Runtime) TransferStore() *transferstore.Store
TransferStore returns the shared durable transfer store, or nil if none.
func (*Runtime) UploadEngine ¶ added in v0.0.30
UploadEngine returns the shared upload engine, or nil if r is nil or no engine was created.
type RuntimeMetrics ¶ added in v0.0.30
type RuntimeMetrics struct {
UploadActiveWorkers int64 `json:"uploadActiveWorkers"`
UploadQueuedWorkers int64 `json:"uploadQueuedWorkers"`
UploadWorkerCount int64 `json:"uploadWorkerCount"`
UploadReservedBytes int64 `json:"uploadReservedBytes"`
UploadBudgetBytes int64 `json:"uploadBudgetBytes"`
Par2ActiveJobs int64 `json:"par2ActiveJobs"`
Par2QueuedJobs int64 `json:"par2QueuedJobs"`
Par2Capacity int `json:"par2Capacity"`
}
RuntimeMetrics is a point-in-time snapshot of process-wide transfer resource usage, suitable for surfacing in the UI or logs so memory growth can be attributed to a subsystem.