import "github.com/byte-mug/fastnntp-backend2/storage"
Storage methods, modeled after the venerable INN usenet server.
NOTE: All interfaces are WIP. Expect breaking changes.
var ENotInitialized = errors.New("SM not Initialized")
-
func Bzero(bs []byte)
-
func RegisterHisLoader(name string, ldr CfgHisLoader)
-
func RegisterOverviewLoader(name string, ldr CfgOverviewLoader)
-
func RegisterStorageLoader(name string, ldr CfgStorageLoader)
-
type Article_MD struct { Arrival time.Time }
-
type Article_R interface { Releaser io.WriterTo }
-
type Article_W interface { Releaser io.Reader io.WriterTo }
-
type CfgBaseInfo struct { Spool string `inn:"$spool"` }
-
type CfgHisLoader func(cfg *CfgMaster) (HisMethod, error)
-
type CfgMaster struct { OvMethod string `inn:"$ovmethod"` HisMethod string `inn:"$hismethod"` Spool string `inn:"$pathspool"` }
General-Config.
func (cfg *CfgMaster) BaseInfo() *CfgBaseInfo
-
type CfgOverviewLoader func(cfg *CfgMaster) (OverviewMethod, error)
-
type CfgStorage struct { Methods []*CfgStorageMethod `inn:"@method"` }
Storage-Config.
type CfgStorageLoader func(cfg *CfgStorageMethod, bi *CfgBaseInfo) (StorageMethod, error)
-
type CfgStorageMethod struct { Method string `inn:"$method"` Class int `inn:"$class"` Newsgroups string `inn:"$newsgroup"` Size int64 `inn:"$size"` MaxSize int64 `inn:"$max-size" json:"max-size"` Options string `inn:"$options"` ExactMatch bool `inn:"$exactmatch"` }
-
type Cursor interface { Releaser Next() bool }
-
type GroupElement struct { Group []byte Status byte Description []byte }
-
type GroupMethod interface { FetchGroups(status, descr bool, ge *GroupElement) (cur Cursor, err error) }
-
type HisMethod interface { HisWrite(msgid []byte, md *Article_MD, t *TOKEN) (err error) HisLookup(msgid []byte, t *TOKEN) (err error) HisCancel(msgid []byte) (err error) }
Inspired by INN's HIS(history) database. Maps message-ids to storage tokens.
func OpenHisMethod(cfg *CfgMaster) (HisMethod, error)
-
type OverviewElement struct { Num int64 Subject, From, Date, MsgId, Refs []byte Lng, Lines int64 }
-
func (ove *OverviewElement) Debug() string
-
type OverviewMethod interface { FetchOne(grp []byte, num int64, tk *TOKEN, ove *OverviewElement) (rel Releaser, err error) FetchAll(grp []byte, num, lastnum int64, tk *TOKEN, ove *OverviewElement) (cur Cursor, err error) SeekOne(grp []byte, num int64, back bool, tk *TOKEN, ove *OverviewElement) (rel Releaser, err error) GroupStat(grp []byte) (num, low, high int64, err error) // Writes a new Overview line into the database. GroupWriteOv(grp []byte, autonum bool, md *Article_MD, tk *TOKEN, ove *OverviewElement) (err error) // Initializes a group in the overview-database. InitGroup(grp []byte) (err error) }
-
func OpenOverviewMethod(cfg *CfgMaster) (OverviewMethod, error)
-
type Releaser interface { Release() }
-
type RiElement struct { Group []byte Num int64 }
-
type RiHistory struct { // IF Group != nil THEN expire a group. Group []byte Num int64 // IF MessageID != nil THEN expire an article. MessageId []byte }
-
type RiMethod interface { // Called for the first group/number-pair associated to the article RiWrite(msgid []byte, md *Article_MD, rie *RiElement) (err error) // Called for the remaining group/number-pair associated to the article RiWriteMore(msgid []byte, md *Article_MD, rie *RiElement) (err error) // Performs a reverse index lookup: message-id to the first group/number pair. RiLookup(msgid []byte, rie *RiElement) (rel Releaser, err error) // Query Expired articles. SHOULD return message-ids after their group/number counterparts. RiQueryExpired(ow *time.Time, rih *RiHistory) (cur Cursor, err error) // Expires an article using the message-id. RiExpire(msgid []byte) (err error) }
Reverse Index. Maps message-ids to group/number-pairs.
type SMFlags uint
-
const ( SM_Expensivestat SMFlags = 1 << iota SM_Selfexpire )
-
type SMLevel uint
-
const ( SM_Stat SMLevel = iota SM_Head SM_All )
-
type StorageManager struct { Classes [256]StorageMethod Methods [256]*CfgStorageMethod /* Used by the Posting backend. Will hold *fastnntp.WildMat objects. */ Wildmat [256]interface{} }
-
func (s *StorageManager) Open(bi *CfgBaseInfo) (err error)
-
func (s *StorageManager) Retrieve(t *TOKEN, sl SMLevel) (a Article_R, rs SMLevel, err error)
-
func (s *StorageManager) SetMethods(cfg *CfgStorage)
-
type StorageMethod interface { io.Closer Store(md *Article_MD, a Article_W, t *TOKEN) (err error) Retrieve(t *TOKEN, s SMLevel) (a Article_R, rs SMLevel, err error) Cancel(t *TOKEN) (err error) }
-
type TOKEN [34]byte
-
func (t *TOKEN) Bytes() []byte
-
func (t *TOKEN) Class() byte
-
func (t *TOKEN) Debug() string
-
import "errors"
import "fmt"
import "io"
import "strings"
import "time"
Path | Synopsis |
---|---|
hisldb/ | |
ovldb/ | Stores overview data into a LevelDB database. |
tradgroup/ | Implements a traditional newsgroup-listing solution. |
timehash/ | Implements a traditional storage method, where each article is stored in a separate file. |