store

package
v0.0.0-...-27b812d Latest Latest
Warning

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

Go to latest
Published: May 29, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

nntp article storage

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type FilesystemStorage

type FilesystemStorage string

filesystem storage of nntp articles and attachments

func NewFilesytemStorage

func NewFilesytemStorage(dirname string) (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) HasArticle

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

check if we have the artilce with this message id

func (FilesystemStorage) StoreArticle

func (fs FilesystemStorage) StoreArticle(r io.Reader, msgid 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
	// 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 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

	// ensure the underlying storage backend is created
	Ensure() 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