Goqueuelite
Tiny little queue on top of sqlite written in Go
Install / Use
/learn @risico/GoqueueliteREADME
sQueueLite is a simplistic, SQLite backed job embedded queue library for Go applications. It provides an easy way to manage and process background jobs, facilitating the scheduling and processing of tasks in an organized and efficient manner.
Warning Is still in heavy development and the API is not finalized yet and might change any moment.
Features
Installation
go get github.com/risico/goqueuelite
Usage
package main
import "github.com/risico/goqueuelite"
func main() {
params := goqueuelite.Params{
DatabasePath: "queue.db",
AutoVacuum: true,
AutoPrune: true,
}
queue, err := goqueuelite.New(params)
if err != nil {
panic(err)
}
defer queue.Close()
}
Enqueuing a Job
data := "Your job data here"
params := goqueuelite.EnqueueParams{
Namespace: "test_namespace",
ScheduleAfter: time.Now().Add(1 * time.Hour),
TTL: 2 * time.Hour,
}
id, err := queue.Enqueue(data, params)
if err != nil {}
Dequeueing a Job
params := goqueuelite.DequeueParams{
Namespace: "default",
}
message, err := queue.Dequeue(params)
if err != nil {}
fmt.Printf("Message(%+v) \n", message)
Message Payload
type Message struct {
ID int64
Data any
Namespace string
Status JobStatus
Delay uint64
LockTime int
DoneTime int
Retries int
ScheduledAt int
TTL int
}
Subscribe to namespaces
ch, err = queue.Subscribe("default")
if err != nil { }
for {
select {
case mEvent, ok := <-ch:
if !ok {
return
}
m, err := queue.Lock(mEvent.MessageID)
// do something with m
}
}
Marking a Job as Done or Failed
err = queue.Done(messageID)
if err != nil {
// handle error
}
err = queue.Fail(messageID)
if err != nil {
// handle error
}
Retrying a job
err = queue.Retry(messageID)
if err != nil {
// handle error
}
Getting the size of the queue
size, err := queue.Size()
Checking if the queue is empty
isEmpty, err := queue.Empty()
Manual Pruning and Vacuuming
If you have disabled AutoPrune and AutoVacuum, you can manually prune and vacuum the database.
queue.Prune()
queue.Vacuum()
To CGO or to Not CGO
CGO is required and enabled by default as the package makes use of github.com/mattn/go-sqlite3 but if you require cross-compilation and don't want to bother with
CGO you can set the -tags nocgo (alongside CGO_ENABLED=0) and it will switch to using modernc.org/sqlite which does not require CGO.
go build . -tags nocgo
Contributing
Feel free to contribute to this project by opening issues or submitting pull requests for bug fixes or features.
License
This project is licensed under the MIT License.
Related Skills
feishu-drive
347.2k|
things-mac
347.2kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
347.2kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
codebase-memory-mcp
1.2kHigh-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 66 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.
