Documentation ¶
Index ¶
- Variables
- type BoltDBStorage
- func (s *BoltDBStorage) Close() error
- func (s *BoltDBStorage) Finalize() error
- func (s *BoltDBStorage) FindByPath(path string) (*model.Post, error)
- func (s *BoltDBStorage) ListAll(page int) ([]*model.Post, error)
- func (s *BoltDBStorage) ListTag(tag string, page int) ([]*model.Post, error)
- func (s *BoltDBStorage) Meta() *model.Meta
- func (s *BoltDBStorage) Save(post *model.Post) error
- func (s *BoltDBStorage) TagMeta(tag string) *model.Meta
- type MemoryStorage
- func (s *MemoryStorage) Close() error
- func (s *MemoryStorage) Finalize() error
- func (s *MemoryStorage) FindByPath(path string) (*model.Post, error)
- func (s *MemoryStorage) ListAll(page int) ([]*model.Post, error)
- func (s *MemoryStorage) ListTag(tag string, page int) ([]*model.Post, error)
- func (s *MemoryStorage) Meta() *model.Meta
- func (s *MemoryStorage) Save(post *model.Post) error
- func (s *MemoryStorage) TagMeta(tag string) *model.Meta
- type Storage
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorUnknownStorageType is the error returned when trying to instantiate a storage of unknown type ErrorUnknownStorageType = errors.New("unknown storage type") // ErrorNotFound is the error returned when trying to find a post by non-existent path ErrorNotFound = errors.New("record not found") )
Functions ¶
This section is empty.
Types ¶
type BoltDBStorage ¶
type BoltDBStorage struct {
// contains filtered or unexported fields
}
BoltDBStorage is the Storage implementation on top of BoltDB
func NewBoltDBStorage ¶
func NewBoltDBStorage(path string, postsPerPage int) (*BoltDBStorage, error)
NewBoltDBStorage creates new BoltDBStorage instance
func (*BoltDBStorage) Close ¶
func (s *BoltDBStorage) Close() error
Close closes the storage and frees all resources
func (*BoltDBStorage) Finalize ¶
func (s *BoltDBStorage) Finalize() error
Finalize is called after all posts are persisted in the storage
func (*BoltDBStorage) FindByPath ¶
func (s *BoltDBStorage) FindByPath(path string) (*model.Post, error)
FindByPath searches for a post by path
func (*BoltDBStorage) ListAll ¶
func (s *BoltDBStorage) ListAll(page int) ([]*model.Post, error)
ListAll returns ordered by date posts page
func (*BoltDBStorage) Meta ¶
func (s *BoltDBStorage) Meta() *model.Meta
Meta returns metadata for all persisted posts
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage is the in memory Storage implementation
func NewMemoryStorage ¶
func NewMemoryStorage(postsPerPage int) (*MemoryStorage, error)
NewMemoryStorage creates new MemoryStorage instance
func (*MemoryStorage) Close ¶
func (s *MemoryStorage) Close() error
Close closes the storage and frees all resources
func (*MemoryStorage) Finalize ¶
func (s *MemoryStorage) Finalize() error
Finalize is called after all posts are persisted in the storage
func (*MemoryStorage) FindByPath ¶
func (s *MemoryStorage) FindByPath(path string) (*model.Post, error)
FindByPath searches for a post by path
func (*MemoryStorage) ListAll ¶
func (s *MemoryStorage) ListAll(page int) ([]*model.Post, error)
ListAll returns ordered by date posts page
func (*MemoryStorage) Meta ¶
func (s *MemoryStorage) Meta() *model.Meta
Meta returns metadata for all persisted posts
type Storage ¶
type Storage interface { io.Closer // Save persists new post in the storage Save(post *model.Post) error // Finalize is called after all posts are persisted in the storage Finalize() error // FindByPath searches for a post by path FindByPath(path string) (*model.Post, error) // ListAll returns ordered by date posts page ListAll(page int) ([]*model.Post, error) // ListTag returns ordered by date posts page for a tag ListTag(tag string, page int) ([]*model.Post, error) // Meta returns metadata for all persisted posts Meta() *model.Meta // TagMeta returns metadata for all persisted posts for a tag TagMeta(tag string) *model.Meta }
Storage is the interface for posts storage