Documentation ¶
Index ¶
- Constants
- type BarePackage
- type DatabaseConfig
- type DatabaseStats
- type PocketBase
- func (pb *PocketBase) Check()
- func (pb *PocketBase) Close()
- func (pb *PocketBase) DeletePackage(name string)
- func (pb *PocketBase) GetAllFiles() map[string][]*url.URL
- func (pb *PocketBase) GetCountOfMarks(cond bool) int
- func (pb *PocketBase) GetDocument(id string, withfiles bool) (document string, filelist []*url.URL, err error)
- func (pb *PocketBase) GetIncompletePackages() []*BarePackage
- func (pb *PocketBase) GetItemCount(name string) (count int)
- func (pb *PocketBase) GetRevision(id string) (rev string)
- func (pb *PocketBase) GetSequence() (sequence int)
- func (pb *PocketBase) GetStats() (stats *DatabaseStats)
- func (pb *PocketBase) Init()
- func (pb *PocketBase) IsInitialized() bool
- func (pb *PocketBase) LogStats()
- func (pb *PocketBase) Migrate(boltPath string)
- func (pb *PocketBase) PutCompleted(pack *BarePackage, document string, rev string, downloads []*url.URL) (succeed bool)
- func (pb *PocketBase) PutPackage(tx transactionable, id string, rev string, mark bool, overwrite bool) error
- func (pb *PocketBase) PutPackages(allDocs []*BarePackage)
- func (pb *PocketBase) SetSequence(seq int)
- type PocketStore
- type StoreType
Constants ¶
const ( MarkIncomplete = "0" MarkComplete = "1" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BarePackage ¶
BarePackage represents the basis elements for package
type DatabaseConfig ¶
type DatabaseConfig struct { Type string `toml:"type"` Path interface{} `toml:"path"` MaxCacheSize int `toml:"max_cache_size"` CacheLifetime int `toml:"cache_lifetime"` }
DatabaseConfig defines config for database
type DatabaseStats ¶
DatabaseStats represents the count of each bucket
type PocketBase ¶
type PocketBase struct {
// contains filtered or unexported fields
}
PocketBase type is a frontend for BoltDB
func NewPocketBase ¶
func NewPocketBase(config *DatabaseConfig) *PocketBase
NewPocketBase creates a new PocketBase object
func (*PocketBase) Check ¶
func (pb *PocketBase) Check()
Check method checks redundancy for the buckets
func (*PocketBase) DeletePackage ¶
func (pb *PocketBase) DeletePackage(name string)
DeletePackage method deletes a package
func (*PocketBase) GetAllFiles ¶
func (pb *PocketBase) GetAllFiles() map[string][]*url.URL
GetAllFiles method returns {name: files} map
func (*PocketBase) GetCountOfMarks ¶
func (pb *PocketBase) GetCountOfMarks(cond bool) int
GetCountOfMarks method returns a count of marked items
func (*PocketBase) GetDocument ¶
func (pb *PocketBase) GetDocument(id string, withfiles bool) (document string, filelist []*url.URL, err error)
GetDocument method returns a document by given name
func (*PocketBase) GetIncompletePackages ¶
func (pb *PocketBase) GetIncompletePackages() []*BarePackage
GetIncompletePackages method returns a list of packages that are ready for queueing
func (*PocketBase) GetItemCount ¶
func (pb *PocketBase) GetItemCount(name string) (count int)
GetItemCount method returns the count of items in the bucket
func (*PocketBase) GetRevision ¶
func (pb *PocketBase) GetRevision(id string) (rev string)
GetRevision method returns a revision of document
func (*PocketBase) GetSequence ¶
func (pb *PocketBase) GetSequence() (sequence int)
GetSequence method returns current sequence of registry
func (*PocketBase) GetStats ¶
func (pb *PocketBase) GetStats() (stats *DatabaseStats)
GetStats method returns status of various buckets
func (*PocketBase) Init ¶
func (pb *PocketBase) Init()
Init method initializes scheme
Globals bucket contains global variables such as "sequence" Packages bucket contains the map of "id": "revision" hash Marks bucket contains the state to determine whether package currently downloaded or not Documents bucket contains full document of the package Files bucket con
func (*PocketBase) IsInitialized ¶
func (pb *PocketBase) IsInitialized() bool
IsInitialized method returns whether the database has initialized
func (*PocketBase) LogStats ¶
func (pb *PocketBase) LogStats()
LogStats method logs database stats every 10 seconds
func (*PocketBase) Migrate ¶
func (pb *PocketBase) Migrate(boltPath string)
func (*PocketBase) PutCompleted ¶
func (pb *PocketBase) PutCompleted(pack *BarePackage, document string, rev string, downloads []*url.URL) (succeed bool)
PutCompleted method inserts a completed package into the appropriate buckets
func (*PocketBase) PutPackage ¶
func (pb *PocketBase) PutPackage(tx transactionable, id string, rev string, mark bool, overwrite bool) error
PutPackage method inserts a package into the appropriate buckets
func (*PocketBase) PutPackages ¶
func (pb *PocketBase) PutPackages(allDocs []*BarePackage)
PutPackages method is a bulk method of PutPackage
func (*PocketBase) SetSequence ¶
func (pb *PocketBase) SetSequence(seq int)
SetSequence method sets current sequence of registry
type PocketStore ¶
type PocketStore interface { Connect() error Close() Init() IsInitialized() bool GetItemCount(string) int GetSequence() int SetSequence(int) GetCountOfMarks(string) int GetIncompletePackages() []*BarePackage GetRevision(string) string GetDocument(string, bool) (string, []byte, error) GetAllFiles() map[string][]*url.URL AcquireTx() transactionable PutPackage(transactionable, string, string, bool, bool) error DeletePackage(string) PutCompleted(transactionable, *BarePackage, string, string, []*url.URL) bool }
PocketStore represents the database factory interface