52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
|
package boltbackend
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
|
||
|
"github.com/boltdb/bolt"
|
||
|
"github.com/gorilla/feeds"
|
||
|
)
|
||
|
|
||
|
// BoltBackend is a Bolt-powered storage backend for bacheca
|
||
|
type BoltBackend struct {
|
||
|
db *bolt.DB
|
||
|
}
|
||
|
|
||
|
// MakeBoltBackend returns a BoltBackend instance
|
||
|
func MakeBoltBackend(path string) (*BoltBackend, error) {
|
||
|
db, err := bolt.Open(path, 0600, nil)
|
||
|
return &BoltBackend{
|
||
|
db: db,
|
||
|
}, err
|
||
|
}
|
||
|
|
||
|
// Close closes the underlying bolt handler
|
||
|
func (b *BoltBackend) Close() error {
|
||
|
return b.db.Close()
|
||
|
}
|
||
|
|
||
|
// GetFeed returns the whole feed
|
||
|
func (b *BoltBackend) GetFeed() (*feeds.Feed, error) {
|
||
|
return nil, errors.New("not implemented")
|
||
|
}
|
||
|
|
||
|
// AddItem adds an item to the feed
|
||
|
func (b *BoltBackend) AddItem(item feeds.Item) (string, error) {
|
||
|
return "", errors.New("not implemented")
|
||
|
}
|
||
|
|
||
|
// RemoveItem removes an item by ID
|
||
|
func (b *BoltBackend) RemoveItem(id string) error {
|
||
|
return errors.New("not implemented")
|
||
|
}
|
||
|
|
||
|
// ReplaceItem replaces the item at a specified ID with the data provided
|
||
|
func (b *BoltBackend) ReplaceItem(id string, item feeds.Item) error {
|
||
|
return errors.New("not implemented")
|
||
|
}
|
||
|
|
||
|
// SetInfo sets the feed metadata (like title and description)
|
||
|
func (b *BoltBackend) SetInfo(info feeds.Feed) error {
|
||
|
return errors.New("not implemented")
|
||
|
}
|