Documentation ¶
Overview ¶
Package store provides implementations of the diskoque.Store interface for different storage backends. The FlatFilesStore is a filesystem-based implementation that stores each message in its own file.
Package store provides implementations of the diskoque.Store interface for different storage backends. The LevelDBStore is a LevelDB-based implementation that stores messages in a LevelDB database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FlatFilesStore ¶
type FlatFilesStore struct {
// contains filtered or unexported fields
}
FlatFilesStore implements the diskoque.Store interface using the filesystem. Each message is stored in its own file within a specified directory.
func NewFlatFiles ¶
func NewFlatFiles(dataDir string) *FlatFilesStore
NewFlatFiles initializes a new FlatFilesStore with the given data directory. This directory is used to store all message files.
func (*FlatFilesStore) Delete ¶
func (f *FlatFilesStore) Delete(id diskoque.MessageID) error
Delete removes a message file from the filesystem based on the provided message ID.
func (*FlatFilesStore) Get ¶
Get retrieves a message by its ID from the filesystem. It reads the file corresponding to the message ID, unmarshals the JSON data into a diskoque.Message, and returns it.
func (*FlatFilesStore) Iterator ¶
func (f *FlatFilesStore) Iterator() (diskoque.StoreIterator, error)
Iterator returns a StoreIterator that can be used to traverse the messages stored in the filesystem. It allows for batch processing of messages by returning a specified number of message IDs at a time.
func (*FlatFilesStore) Push ¶
func (f *FlatFilesStore) Push(message diskoque.Message) error
Push writes a message to the filesystem as a new file. Each message is stored in its own file, with the message ID generated at the time of saving. This ensures each message is uniquely identified and can be retrieved or deleted individually.
type FlatFilesStoreIterator ¶
type FlatFilesStoreIterator struct {
// contains filtered or unexported fields
}
FlatFilesStoreIterator implements the diskoque.StoreIterator interface, allowing for batch processing of message files within the data directory. It supports fetching a specified number of message IDs at a time and closing the iterator when done to free up resources.
func (*FlatFilesStoreIterator) Close ¶
func (f *FlatFilesStoreIterator) Close() error
Close closes the directory file handle, effectively ending the iteration process.
func (*FlatFilesStoreIterator) NextN ¶
func (f *FlatFilesStoreIterator) NextN(numMessages int) ([]diskoque.MessageID, error)
NextN returns the next N message IDs from the iterator. It reads a specified number of filenames from the directory, filters out any filenames that represent messages scheduled for the future, and returns the valid message IDs.
type LevelDBStore ¶
type LevelDBStore struct {
// contains filtered or unexported fields
}
LevelDBStore implements the diskoque.Store interface using LevelDB for storage. Messages are stored with unique IDs as keys, allowing efficient retrieval and deletion.
func NewLevelDB ¶
func NewLevelDB(db *leveldb.DB) *LevelDBStore
NewLevelDB initializes a new LevelDBStore using the provided LevelDB database instance. This database instance is used to store, retrieve, and delete messages.
func (*LevelDBStore) Delete ¶
func (f *LevelDBStore) Delete(id diskoque.MessageID) error
Delete removes a message from the LevelDB database using the message ID as the key. This facilitates efficient deletion of messages once they are processed or no longer needed.
func (*LevelDBStore) Get ¶
Get retrieves a message by its ID from the LevelDB database, deserializes it from JSON into a diskoque.Message, and returns the message object. This allows for efficient message retrieval using its unique ID.
func (*LevelDBStore) Iterator ¶
func (f *LevelDBStore) Iterator() (diskoque.StoreIterator, error)
Iterator creates and returns a LevelDBStoreIterator that can be used to iterate over messages stored in the LevelDB database. It enables batch processing of messages by fetching multiple IDs at a time.
type LevelDBStoreIterator ¶
type LevelDBStoreIterator struct {
// contains filtered or unexported fields
}
LevelDBStoreIterator implements the diskoque.StoreIterator interface for LevelDB, allowing for the iteration over messages in the database. It supports fetching a specific number of message IDs at a time and can be closed to release resources associated with the iterator.
func (*LevelDBStoreIterator) Close ¶
func (f *LevelDBStoreIterator) Close() error
Close releases resources associated with the iterator, such as closing database connections or cleaning up internal data structures. It should be called when iteration is complete.
func (*LevelDBStoreIterator) NextN ¶
func (f *LevelDBStoreIterator) NextN(numMessages int) ([]diskoque.MessageID, error)
NextN fetches the next N message IDs from the LevelDB database, ensuring that only messages scheduled for the current time or the past are included. This method enables batch retrieval of message IDs for processing.