poster

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPosterClosed is returned when attempting to post after the poster has been closed
	ErrPosterClosed = errors.New("poster is closed")
)

Functions

This section is empty.

Types

type DeferredCheckError added in v0.0.29

type DeferredCheckError struct {
	FailedArticles []FailedArticleInfo
	TotalArticles  int
}

DeferredCheckError is a non-fatal error indicating some articles need deferred verification. The upload itself succeeded, but article verification (STAT check) failed after all immediate retries.

func (*DeferredCheckError) Error added in v0.0.29

func (e *DeferredCheckError) Error() string

type FailedArticleInfo added in v0.0.29

type FailedArticleInfo struct {
	MessageID string
	Groups    []string
}

FailedArticleInfo contains information about an article that failed verification and should be deferred for later checking.

type Post

type Post struct {
	FilePath string
	Articles []*article.Article
	Status   PostStatus
	Error    error
	Retries  int
	// contains filtered or unexported fields
}

Post represents a file to be posted

type PostStatus

type PostStatus int

PostStatus represents the status of a post

const (
	PostStatusPending PostStatus = iota
	PostStatusPosted
	PostStatusVerified
	PostStatusFailed
	PostStatusCancelled
	PostStatusPosting
)

type Poster

type Poster interface {
	// Post posts files from a directory to Usenet
	Post(ctx context.Context, files []string, rootDir string, nzbGen nzb.NZBGenerator) error
	// PostWithRelativePaths posts files with custom display names (relative paths) for subjects
	// relativePaths maps absolute file path to the display name to use in the subject
	PostWithRelativePaths(ctx context.Context, files []string, rootDir string, nzbGen nzb.NZBGenerator, relativePaths map[string]string) error
	// Stats returns posting statistics
	Stats() Stats
	// Close closes the poster
	Close()
}

Poster defines the interface for posting articles to Usenet

func New

func New(ctx context.Context, cfg config.Config, poolManager pool.PoolManager, jobProgress progress.JobProgress) (Poster, error)

New creates a new poster using dependency injection for the connection pool manager

type Stats

type Stats struct {
	ArticlesPosted  int64
	ArticlesChecked int64
	BytesPosted     int64
	ArticleErrors   int64
	StartTime       time.Time
	// contains filtered or unexported fields
}

Stats tracks posting statistics

type Throttle

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

Throttle handles rate limiting using lock-free atomic operations for better performance under high concurrency.

func NewThrottle added in v0.0.6

func NewThrottle(rate int64, interval time.Duration) *Throttle

NewThrottle creates a new throttle with the given rate and interval

func (*Throttle) Wait

func (t *Throttle) Wait(bytes int64)

Wait waits until enough tokens are available for the given bytes. Uses a token bucket algorithm with atomic operations for lock-free rate limiting.

Jump to

Keyboard shortcuts

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