Documentation
¶
Index ¶
- func DefaultBoltPath() string
- func GetBoltDb(file string) (*bolt.DB, error)
- func GetIndexNameFromQuery(query Query) string
- func GetIndexValueFromItem(keyParts Key, item *search.ExternalResultItem) []byte
- func GetIndexValueFromQuery(query Query) []byte
- func GetOlderThanHours(h int) []search.ExternalResultItem
- type BoltStorage
- func (b *BoltStorage) Create(keyParts Key, item *search.ExternalResultItem) error
- func (b *BoltStorage) Find(query Query, result *search.ExternalResultItem) error
- func (b *BoltStorage) ForChat(callback func(chat *Chat)) error
- func (b *BoltStorage) GetBucket(tx *bolt.Tx, children ...string) *bolt.Bucket
- func (b *BoltStorage) GetChat(id int) (*Chat, error)
- func (b *BoltStorage) GetSearchResults(categoryId int) ([]search.ExternalResultItem, error)
- func (b *BoltStorage) StoreChat(chat *Chat) error
- func (b *BoltStorage) StoreSearchResults(items []search.ExternalResultItem) error
- func (b *BoltStorage) Truncate() error
- func (b *BoltStorage) Update(query Query, item *search.ExternalResultItem) error
- type Chat
- type ChatMessage
- type Cursor
- type CursorOptions
- type DBStorage
- func (d *DBStorage) Create(keyParts Key, tr *search.ExternalResultItem) error
- func (d *DBStorage) Find(query Query, matchingItem *search.ExternalResultItem) error
- func (d *DBStorage) FindById(id string) *search.ExternalResultItem
- func (d *DBStorage) FindByNameAndIndex(title string, indexerSite string) *search.ExternalResultItem
- func (d *DBStorage) GetCategories() []db.TorrentCategory
- func (d *DBStorage) GetDb() *gorm.DB
- func (d *DBStorage) GetLatest(cnt int) []search.ExternalResultItem
- func (d *DBStorage) GetNewest(cnt int) []search.ExternalResultItem
- func (d *DBStorage) GetOlderThanHours(h int) []search.ExternalResultItem
- func (d *DBStorage) GetTorrentCount() int64
- func (d *DBStorage) GetTorrentsInCategories(ids []int) []search.ExternalResultItem
- func (d *DBStorage) Truncate()
- func (d *DBStorage) Update(query Query, item *search.ExternalResultItem) error
- func (d *DBStorage) UpdateResult(id uint, torrent *search.ExternalResultItem)
- type Index
- type ItemStorage
- type ItemStorageBacking
- type Key
- type KeyedStorage
- type ListIndex
- func (ix *ListIndex) Add(val []byte, id []byte) error
- func (ix *ListIndex) All(indexValue []byte, opts *CursorOptions) [][]byte
- func (ix *ListIndex) AllRecords(opts *CursorOptions) [][]byte
- func (ix *ListIndex) Get(indexValue []byte) []byte
- func (ix *ListIndex) Prefix(prefix []byte, opts *CursorOptions) [][]byte
- func (ix *ListIndex) Range(min []byte, max []byte, opts *CursorOptions) [][]byte
- func (ix *ListIndex) Remove(indexValue []byte) error
- func (ix *ListIndex) RemoveById(id []byte) error
- type PrefixCursor
- type Query
- type RangeCursor
- type ReversibleCursor
- type UniqueIndex
- func (ix *UniqueIndex) Add(indexValue []byte, id []byte) error
- func (ix *UniqueIndex) All(indexValue []byte, _ *CursorOptions) [][]byte
- func (ix *UniqueIndex) AllRecords(ops *CursorOptions) [][]byte
- func (ix *UniqueIndex) AllWithPrefix(prefix []byte, ops *CursorOptions) [][]byte
- func (ix *UniqueIndex) Get(indexValue []byte) []byte
- func (ix *UniqueIndex) Range(min []byte, max []byte, ops *CursorOptions) [][]byte
- func (ix *UniqueIndex) Remove(indexValue []byte) error
- func (ix *UniqueIndex) RemoveById(id []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBoltPath ¶
func DefaultBoltPath() string
func GetIndexNameFromQuery ¶
GetIndexNameFromQuery gets the name of an index from a query.
func GetIndexValueFromItem ¶
func GetIndexValueFromItem(keyParts Key, item *search.ExternalResultItem) []byte
GetIndexValueFromItem gets the index value from a key set and an item.
func GetIndexValueFromQuery ¶
GetIndexValueFromQuery get the value of an index by a query.
func GetOlderThanHours ¶
func GetOlderThanHours(h int) []search.ExternalResultItem
GetOlderThanHours gets items that are at least H hours old.
Types ¶
type BoltStorage ¶
func NewBoltStorage ¶
func NewBoltStorage(dbPath string) (*BoltStorage, error)
func (*BoltStorage) Create ¶
func (b *BoltStorage) Create(keyParts Key, item *search.ExternalResultItem) error
Create a new record for a result.
func (*BoltStorage) Find ¶
func (b *BoltStorage) Find(query Query, result *search.ExternalResultItem) error
Find something by it's index keys.
func (*BoltStorage) ForChat ¶
func (b *BoltStorage) ForChat(callback func(chat *Chat)) error
ForChat calls the callback for each chat, in an async way.
func (*BoltStorage) GetBucket ¶
GetBucket returns the given bucket. You can use an array of strings for sub-buckets.
func (*BoltStorage) GetSearchResults ¶
func (b *BoltStorage) GetSearchResults(categoryId int) ([]search.ExternalResultItem, error)
GetSearchResults by a given category id
func (*BoltStorage) StoreChat ¶
func (b *BoltStorage) StoreChat(chat *Chat) error
StoreChat stores a new chat. The chat id is used as a keyParts.
func (*BoltStorage) StoreSearchResults ¶
func (b *BoltStorage) StoreSearchResults(items []search.ExternalResultItem) error
StoreSearchResults stores the given results
func (*BoltStorage) Truncate ¶
func (b *BoltStorage) Truncate() error
func (*BoltStorage) Update ¶
func (b *BoltStorage) Update(query Query, item *search.ExternalResultItem) error
type ChatMessage ¶
type CursorOptions ¶
func NewCursorOptions ¶
func NewCursorOptions() *CursorOptions
func SingleItemCursor ¶
func SingleItemCursor() *CursorOptions
type DBStorage ¶
type DBStorage struct {
Path string
}
func DefaultStorageBacking ¶
func DefaultStorageBacking() *DBStorage
DefaultStorageBacking gets the default storage method for results.
func (*DBStorage) Create ¶
func (d *DBStorage) Create(keyParts Key, tr *search.ExternalResultItem) error
Create a new result record. In sqlite we're not using the key parts.
func (*DBStorage) Find ¶
func (d *DBStorage) Find(query Query, matchingItem *search.ExternalResultItem) error
func (*DBStorage) FindById ¶
func (d *DBStorage) FindById(id string) *search.ExternalResultItem
Find a result by it's id
func (*DBStorage) FindByNameAndIndex ¶
func (d *DBStorage) FindByNameAndIndex(title string, indexerSite string) *search.ExternalResultItem
FindByNameAndIndex finds an item by it's name and index.
func (*DBStorage) GetCategories ¶
func (d *DBStorage) GetCategories() []db.TorrentCategory
func (*DBStorage) GetNewest ¶
func (d *DBStorage) GetNewest(cnt int) []search.ExternalResultItem
GetNewest gets the CNT latest results.
func (*DBStorage) GetOlderThanHours ¶
func (d *DBStorage) GetOlderThanHours(h int) []search.ExternalResultItem
func (*DBStorage) GetTorrentCount ¶
func (*DBStorage) GetTorrentsInCategories ¶
func (d *DBStorage) GetTorrentsInCategories(ids []int) []search.ExternalResultItem
func (*DBStorage) Update ¶
func (d *DBStorage) Update(query Query, item *search.ExternalResultItem) error
Update a result with a matching keyParts.
func (*DBStorage) UpdateResult ¶
func (d *DBStorage) UpdateResult(id uint, torrent *search.ExternalResultItem)
type ItemStorage ¶
type ItemStorage interface { Add(item *search.ExternalResultItem) (bool, bool) NewWithKey(key Key) ItemStorage }
type ItemStorageBacking ¶
type ItemStorageBacking interface { //Tries to find a single record matching the query. Find(query Query, result *search.ExternalResultItem) error Update(query Query, item *search.ExternalResultItem) error Create(parts Key, item *search.ExternalResultItem) error }
type KeyedStorage ¶
type KeyedStorage struct {
// contains filtered or unexported fields
}
func NewKeyedStorage ¶
func NewKeyedStorage(keyFields Key) *KeyedStorage
NewKeyedStorage creates a new keyed storage with the default storage backing.
func NewKeyedStorageWithBacking ¶
func NewKeyedStorageWithBacking(key Key, storage ItemStorageBacking) *KeyedStorage
NewKeyedStorageWithBacking creates a new keyed storage with a custom storage backing.
func (*KeyedStorage) Add ¶
func (s *KeyedStorage) Add(item *search.ExternalResultItem) (bool, bool)
Add handles the discovery of the result, adding additional information like staleness state.
func (*KeyedStorage) NewWithKey ¶
func (s *KeyedStorage) NewWithKey(key Key) ItemStorage
NewWithKey gets a storage backed in the same way, with a different key.
type ListIndex ¶
type ListIndex struct { ParentBucket *bolt.Bucket //Bucket that contains all the index values, with values being the ID IndexBucket *bolt.Bucket //An index that contains all of our IDs, with values being the index values IDs *UniqueIndex }
ListIndex is an index that references values and the matching IDs
func NewListIndex ¶
NewListIndex creates a new list index with it's sub-buckets.
func (*ListIndex) All ¶
func (ix *ListIndex) All(indexValue []byte, opts *CursorOptions) [][]byte
All the IDs corresponding to the given value
func (*ListIndex) AllRecords ¶
func (ix *ListIndex) AllRecords(opts *CursorOptions) [][]byte
AllRecords returns all the IDs of this index
func (*ListIndex) Prefix ¶
func (ix *ListIndex) Prefix(prefix []byte, opts *CursorOptions) [][]byte
Prefix returns the ids whose values have the given prefix.
func (*ListIndex) Range ¶
func (ix *ListIndex) Range(min []byte, max []byte, opts *CursorOptions) [][]byte
Range returns the ids corresponding to the given range of values
func (*ListIndex) RemoveById ¶
RemoveById removes an index and the matching ID using an ID.
type PrefixCursor ¶
func (*PrefixCursor) CanContinue ¶
func (c *PrefixCursor) CanContinue(value []byte) bool
CanContinue figures out if the cursor can continue
func (*PrefixCursor) First ¶
func (c *PrefixCursor) First() ([]byte, []byte)
First item in the cursor that matches the prefix.
type Query ¶
type Query interface { Put(k, v interface{}) Size() int Keys() []interface{} Values() []interface{} Get(key interface{}) (value interface{}, found bool) }
func GetKeyQueryFromItem ¶
func GetKeyQueryFromItem(keyParts Key, item *search.ExternalResultItem) Query
GetKeyQueryFromItem gets the query that matches an item with the given keyParts.
type RangeCursor ¶
type RangeCursor struct { C *bolt.Cursor Reverse bool Min []byte Max []byte Comparator func(a []byte, b []byte) int }
func (*RangeCursor) CanContinue ¶
func (r *RangeCursor) CanContinue(value []byte) bool
CanContinue checks if the cursor can continue to the given value
func (*RangeCursor) First ¶
func (r *RangeCursor) First() ([]byte, []byte)
First gets the first element in the range.
func (*RangeCursor) Next ¶
func (r *RangeCursor) Next() ([]byte, []byte)
Next gets the next element in the cursor.
type ReversibleCursor ¶
func (*ReversibleCursor) CanContinue ¶
func (c *ReversibleCursor) CanContinue(val []byte) bool
func (*ReversibleCursor) First ¶
func (c *ReversibleCursor) First() ([]byte, []byte)
func (*ReversibleCursor) Next ¶
func (c *ReversibleCursor) Next() ([]byte, []byte)
type UniqueIndex ¶
UniqueIndex ensures the indexed values are all unique.
func NewUniqueIndex ¶
func NewUniqueIndex(parentBucket *bolt.Bucket, name []byte) (*UniqueIndex, error)
NewUniqueIndex creates a new unique index bucket
func (*UniqueIndex) Add ¶
func (ix *UniqueIndex) Add(indexValue []byte, id []byte) error
Add a value to the unique index. We're using the index value as a keyParts and we're storing the id in there.
func (*UniqueIndex) All ¶
func (ix *UniqueIndex) All(indexValue []byte, _ *CursorOptions) [][]byte
All returns all the IDs corresponding to the given index value. For unique indexes this should be a single ID.
func (*UniqueIndex) AllRecords ¶
func (ix *UniqueIndex) AllRecords(ops *CursorOptions) [][]byte
AllRecords returns all the IDs.
func (*UniqueIndex) AllWithPrefix ¶
func (ix *UniqueIndex) AllWithPrefix(prefix []byte, ops *CursorOptions) [][]byte
AllWithPrefix finds all the IDs that are prefixed with a given byte array
func (*UniqueIndex) Get ¶
func (ix *UniqueIndex) Get(indexValue []byte) []byte
Get the id behind an indexed value.
func (*UniqueIndex) Range ¶
func (ix *UniqueIndex) Range(min []byte, max []byte, ops *CursorOptions) [][]byte
Range gets the IDs in the given range.
func (*UniqueIndex) Remove ¶
func (ix *UniqueIndex) Remove(indexValue []byte) error
Remove a index value from the unique index.
func (*UniqueIndex) RemoveById ¶
func (ix *UniqueIndex) RemoveById(id []byte) error
RemoveById removes the first id from the index that matches the given id.