store

package
v0.0.0-...-7277db8 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

nntp article storage

Index

Constants

View Source
const HighWaterHeader = "X-High-Water"
View Source
const LowWaterHeader = "X-Low-Water"

Variables

View Source
var ErrNoSuchArticle = errors.New("no such article")

Functions

This section is empty.

Types

type FilesystemStorage

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

filesystem storage of nntp articles and attachments

func NewFilesytemStorage

func NewFilesytemStorage(dirname string, unpackAttachments bool) (fs FilesystemStorage, err error)

create a new filesystem storage directory ensure directory and subdirectories

func (FilesystemStorage) ArticleDir

func (fs FilesystemStorage) ArticleDir() string

get the directory path for articles

func (FilesystemStorage) AttachmentDir

func (fs FilesystemStorage) AttachmentDir() string

get the directory path for attachments

func (FilesystemStorage) DeleteArticle

func (fs FilesystemStorage) DeleteArticle(msgid string) (err error)

func (FilesystemStorage) Ensure

func (fs FilesystemStorage) Ensure() (err error)

ensure the filesystem storage exists and is well formed and read/writable

func (FilesystemStorage) ForEachInGroup

func (fs FilesystemStorage) ForEachInGroup(group string, chnl chan string)

func (FilesystemStorage) GetAllNewsgroups

func (fs FilesystemStorage) GetAllNewsgroups() (newsgroups []string, err error)

func (FilesystemStorage) GetWatermark

func (fs FilesystemStorage) GetWatermark(newsgroup string) (hi, lo uint64, err error)

func (FilesystemStorage) HasArticle

func (fs FilesystemStorage) HasArticle(msgid string) (err error)

check if we have the artilce with this message id

func (FilesystemStorage) HasNewsgroup

func (fs FilesystemStorage) HasNewsgroup(newsgroup string) (has bool, err error)

func (FilesystemStorage) NewsgroupsDir

func (fs FilesystemStorage) NewsgroupsDir() string

func (FilesystemStorage) OpenArticle

func (fs FilesystemStorage) OpenArticle(msgid string) (r *os.File, err error)

open article given message-id does not check validity

func (FilesystemStorage) StoreArticle

func (fs FilesystemStorage) StoreArticle(r io.Reader, msgid, newsgroup string) (fpath string, err error)

store an article from a reader to disk

func (FilesystemStorage) StoreAttachment

func (fs FilesystemStorage) StoreAttachment(r io.Reader, filename string) (fpath string, err error)

store attachment onto filesystem

func (FilesystemStorage) String

func (fs FilesystemStorage) String() string

func (FilesystemStorage) TempDir

func (fs FilesystemStorage) TempDir() string

get the temp file directory

type Storage

type Storage interface {
	// store an attachment that we read from an io.Reader
	// filename is used to hint to store what extension to store it as
	// returns absolute filepath where attachment was stored and nil on success
	// returns emtpy string and error if an error ocurred while storing
	StoreAttachment(r io.Reader, filename string) (string, error)

	// store an article that we read from an io.Reader
	// message id is used to hint where the article is stored as well as newsgroup
	// returns absolute filepath to where the article was stored and nil on success
	// returns empty string and error if an error ocurred while storing
	StoreArticle(r io.Reader, msgid, newsgroup string) (string, error)

	// return nil if the article with the given message id exists in this storage
	// return ErrNoSuchArticle if it does not exist or an error if another error occured while checking
	HasArticle(msgid string) error

	// delete article from underlying storage
	DeleteArticle(msgid string) error

	// open article for reading
	OpenArticle(msgid string) (*os.File, error)

	// ensure the underlying storage backend is created
	Ensure() error

	// iterate over all messages in a newsgroup
	// send results down a channel
	ForEachInGroup(newsgroup string, cnhl chan string)

	// get a list of all newsgroups
	GetAllNewsgroups() ([]string, error)

	// determine if we have a newsgroup
	HasNewsgroup(newsgroup string) (bool, error)

	// get hi/lo watermark for newsgroup
	GetWatermark(newsgroup string) (uint64, uint64, error)
}

storage for nntp articles and attachments

func NewNullStorage

func NewNullStorage() Storage

create a storage backend that does nothing

Jump to

Keyboard shortcuts

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