Documentation
¶
Overview ¶
package bigqueue implements is pure Golang implementation for big, fast and persistent queue based on memory mapped file.
Index ¶
- Constants
- Variables
- func Assert(condition bool, message string, v ...interface{})
- func BytesToInt(b []byte) int64
- func BytesToInt32(b []byte) int32
- func GetFileName(prefix string, suffix string, index int64) string
- func GetFiles(pathname string) (*list.List, error)
- func IntToBytes(n int64) []byte
- func Mod(val int64, bits int) int64
- func PathExists(path string) (bool, error)
- func RemoveFiles(pathname string) error
- type DB
- type DBFactory
- type FileQueue
- func (q *FileQueue) Close() error
- func (q *FileQueue) Dequeue() (int64, []byte, error)
- func (q *FileQueue) Enqueue(data []byte) (int64, error)
- func (q *FileQueue) EnqueueAsync(data []byte, fn func(int64, error))
- func (q *FileQueue) Gc() error
- func (q *FileQueue) IsEmpty() bool
- func (q *FileQueue) Open(dir string, queueName string, options *Options) error
- func (q *FileQueue) Peek() (int64, []byte, error)
- func (q *FileQueue) Size() int64
- func (q *FileQueue) Skip(count int64) error
- type Options
- type Queue
Constants ¶
View Source
const ( // data file size DefaultDataPageSize = 128 * 1024 * 1024 DefaultIndexItemsPerPage = 17 MaxInt64 = 0x7fffffffffffffff IndexFileName = "index" DataFileName = "data" MetaFileName = "meta_data" FrontFileName = "front_index" )
Variables ¶
View Source
var ( ErrEnqueueDataNull = errors.New("Enqueue data can not be null") IndexOutOfBoundTH = errors.New("Index is valid which should between tail and head index") )
These errors can be returned when opening or calling methods on a DB.
View Source
var DefaultOptions = &Options{ DataPageSize: DefaultDataPageSize, indexPageSize: defaultIndexPageSize, IndexItemsPerPage: DefaultIndexItemsPerPage, itemsPerPage: defaultItemsPerPage, GcLock: false, }
Functions ¶
func BytesToInt32 ¶
func PathExists ¶
func RemoveFiles ¶
Types ¶
type DB ¶
type DB struct {
// If you want to read the entire database fast, you can set MmapFlag to
// syscall.MAP_POPULATE on Linux 2.6.23+ for sequential read-ahead.
MmapFlags int
InitialMmapSize int
// contains filtered or unexported fields
}
DB represents a collection of buckets persisted to a file on disk. All data access is performed through transactions which can be obtained through the DB. All the functions on DB will return a ErrDatabaseNotOpen if accessed before Open() is called.
type DBFactory ¶
type DBFactory struct {
InitialMmapSize int
// contains filtered or unexported fields
}
type FileQueue ¶
type FileQueue struct {
// front index of the big queue,
FrontIndex int64
// head index of the array, this is the read write barrier.
// readers can only read items before this index, and writes can write this index or after
HeadIndex int64
// tail index of the array,
// readers can't read items before this tail
TailIndex int64
// contains filtered or unexported fields
}
func (*FileQueue) EnqueueAsync ¶
type Queue ¶
type Queue interface {
Open(dir string, queueName string, options *Options) error
// Determines whether a queue is empty
// return ture if empty, false otherwise
IsEmpty() bool
// return avaiable queue size
Size() int64
// Append an item to the queue and return index no
// if any error ocurres a non-nil error returned
Enqueue(data []byte) (int64, error)
EnqueueAsync(data []byte, fn func(int64, error))
Dequeue() (int64, []byte, error)
Peek() (int64, []byte, error)
// To skip deqeue target number of items
Skip(count int64) error
Close() error
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.

