query

package module
v0.0.0-...-8088db3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 8 Imported by: 0

README

SQLite queue

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LocalFile string // The path to the local file or in-memory database identifier.
	Reset     bool   // Flag to indicate whether the database should be reset.
}

Config represents configuration options for setting up a Queue or database.

type Item

type Item struct {
	ID   int    // Unique identifier for the item.
	Data []byte // Data of the item, stored as a byte slice.
}

Item represents a queue item with an ID, data, and a creation timestamp.

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue provides a FIFO queue backed by a SQLite database.

func New

func New(config ...Config) (*Queue, error)

New initializes a new Queue instance and sets up the database connection. It optionally resets the database if specified in the configuration.

func (*Queue) Add

func (c *Queue) Add(data []byte) error

Add inserts a new item with the specified data into the queue.

func (*Queue) Close

func (c *Queue) Close() error

func (*Queue) Delete

func (c *Queue) Delete(id int) error

Delete removes an item with the specified ID from the queue.

func (*Queue) Get

func (c *Queue) Get(limit int) ([]Item, error)

Get retrieves up to 'limit' items from the queue. It returns the items along with any error encountered.

func (*Queue) Listener

func (c *Queue) Listener(clb func(item Item, breaked func()))

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL