const maxMmapStep … const version … const magic … const pgidNoFreelist … const IgnoreNoSync … const DefaultMaxBatchSize … const DefaultMaxBatchDelay … const DefaultAllocSize … var defaultPageSize … const flockRetryTimeout … type FreelistType … const FreelistArrayType … const FreelistMapType … type DB … // Path returns the path to currently open database file. func (db *DB) Path() string { … } // GoString returns the Go string representation of the database. func (db *DB) GoString() string { … } // String returns the string representation of the database. func (db *DB) String() string { … } // Open creates and opens a database at the given path. // If the file does not exist then it will be created automatically. // Passing in nil options will cause Bolt to open the database with the default options. func Open(path string, mode os.FileMode, options *Options) (*DB, error) { … } // getPageSize reads the pageSize from the meta pages. It tries // to read the first meta page firstly. If the first page is invalid, // then it tries to read the second page using the default page size. func (db *DB) getPageSize() (int, error) { … } // getPageSizeFromFirstMeta reads the pageSize from the first meta page func (db *DB) getPageSizeFromFirstMeta() (int, bool, error) { … } // getPageSizeFromSecondMeta reads the pageSize from the second meta page func (db *DB) getPageSizeFromSecondMeta() (int, bool, error) { … } // loadFreelist reads the freelist if it is synced, or reconstructs it // by scanning the DB if it is not synced. It assumes there are no // concurrent accesses being made to the freelist. func (db *DB) loadFreelist() { … } func (db *DB) hasSyncedFreelist() bool { … } // mmap opens the underlying memory-mapped file and initializes the meta references. // minsz is the minimum size that the new mmap can be. func (db *DB) mmap(minsz int) (err error) { … } func (db *DB) invalidate() { … } // munmap unmaps the data file from memory. func (db *DB) munmap() error { … } // mmapSize determines the appropriate size for the mmap given the current size // of the database. The minimum size is 32KB and doubles until it reaches 1GB. // Returns an error if the new mmap size is greater than the max allowed. func (db *DB) mmapSize(size int) (int, error) { … } func (db *DB) munlock(fileSize int) error { … } func (db *DB) mlock(fileSize int) error { … } func (db *DB) mrelock(fileSizeFrom, fileSizeTo int) error { … } // init creates a new database file and initializes its meta pages. func (db *DB) init() error { … } // Close releases all database resources. // It will block waiting for any open transactions to finish // before closing the database and returning. func (db *DB) Close() error { … } func (db *DB) close() error { … } // Begin starts a new transaction. // Multiple read-only transactions can be used concurrently but only one // write transaction can be used at a time. Starting multiple write transactions // will cause the calls to block and be serialized until the current write // transaction finishes. // // Transactions should not be dependent on one another. Opening a read // transaction and a write transaction in the same goroutine can cause the // writer to deadlock because the database periodically needs to re-mmap itself // as it grows and it cannot do that while a read transaction is open. // // If a long running read transaction (for example, a snapshot transaction) is // needed, you might want to set DB.InitialMmapSize to a large enough value // to avoid potential blocking of write transaction. // // IMPORTANT: You must close read-only transactions after you are finished or // else the database will not reclaim old pages. func (db *DB) Begin(writable bool) (*Tx, error) { … } func (db *DB) beginTx() (*Tx, error) { … } func (db *DB) beginRWTx() (*Tx, error) { … } // freePages releases any pages associated with closed read-only transactions. func (db *DB) freePages() { … } type txsById … func (t txsById) Len() int { … } func (t txsById) Swap(i, j int) { … } func (t txsById) Less(i, j int) bool { … } // removeTx removes a transaction from the database. func (db *DB) removeTx(tx *Tx) { … } // Update executes a function within the context of a read-write managed transaction. // If no error is returned from the function then the transaction is committed. // If an error is returned then the entire transaction is rolled back. // Any error that is returned from the function or returned from the commit is // returned from the Update() method. // // Attempting to manually commit or rollback within the function will cause a panic. func (db *DB) Update(fn func(*Tx) error) error { … } // View executes a function within the context of a managed read-only transaction. // Any error that is returned from the function is returned from the View() method. // // Attempting to manually rollback within the function will cause a panic. func (db *DB) View(fn func(*Tx) error) error { … } // Batch calls fn as part of a batch. It behaves similar to Update, // except: // // 1. concurrent Batch calls can be combined into a single Bolt // transaction. // // 2. the function passed to Batch may be called multiple times, // regardless of whether it returns error or not. // // This means that Batch function side effects must be idempotent and // take permanent effect only after a successful return is seen in // caller. // // The maximum batch size and delay can be adjusted with DB.MaxBatchSize // and DB.MaxBatchDelay, respectively. // // Batch is only useful when there are multiple goroutines calling it. func (db *DB) Batch(fn func(*Tx) error) error { … } type call … type batch … // trigger runs the batch if it hasn't already been run. func (b *batch) trigger() { … } // run performs the transactions in the batch and communicates results // back to DB.Batch. func (b *batch) run() { … } var trySolo … type panicked … func (p panicked) Error() string { … } func safelyCall(fn func(*Tx) error, tx *Tx) (err error) { … } // Sync executes fdatasync() against the database file handle. // // This is not necessary under normal operation, however, if you use NoSync // then it allows you to force the database file to sync against the disk. func (db *DB) Sync() error { … } // Stats retrieves ongoing performance stats for the database. // This is only updated when a transaction closes. func (db *DB) Stats() Stats { … } // This is for internal access to the raw data bytes from the C cursor, use // carefully, or not at all. func (db *DB) Info() *Info { … } // page retrieves a page reference from the mmap based on the current page size. func (db *DB) page(id pgid) *page { … } // pageInBuffer retrieves a page reference from a given byte array based on the current page size. func (db *DB) pageInBuffer(b []byte, id pgid) *page { … } // meta retrieves the current meta page reference. func (db *DB) meta() *meta { … } // allocate returns a contiguous block of memory starting at a given page. func (db *DB) allocate(txid txid, count int) (*page, error) { … } // grow grows the size of the database to the given sz. func (db *DB) grow(sz int) error { … } func (db *DB) IsReadOnly() bool { … } func (db *DB) freepages() []pgid { … } type Options … var DefaultOptions … type Stats … // Sub calculates and returns the difference between two sets of database stats. // This is useful when obtaining stats at two different points and time and // you need the performance counters that occurred within that time span. func (s *Stats) Sub(other *Stats) Stats { … } type Info … type meta … // validate checks the marker bytes and version of the meta page to ensure it matches this binary. func (m *meta) validate() error { … } // copy copies one meta object to another. func (m *meta) copy(dest *meta) { … } // write writes the meta onto a page. func (m *meta) write(p *page) { … } // generates the checksum for the meta. func (m *meta) sum64() uint64 { … } // _assert will panic with a given formatted message if the given condition is false. func _assert(condition bool, msg string, v ...interface{ … }