/
store.go
50 lines (38 loc) · 1.64 KB
/
store.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package store
import (
"errors"
"io"
"os"
)
var ErrNoSuchArticle = errors.New("no such article")
// storage for nntp articles and attachments
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)
}