Кобелев Андрей Андреевич e3c9643d05 Initial release of queue package
2025-10-10 22:50:00 +05:00
2025-10-10 22:50:00 +05:00
2025-10-10 22:50:00 +05:00
2025-10-10 22:50:00 +05:00
2025-10-10 22:50:00 +05:00
2025-10-10 22:50:00 +05:00
2025-10-10 22:50:00 +05:00
2025-10-10 22:50:00 +05:00

queue

Simple and lightweight queue implementation in Go with optional Dead Letter Queue (DLQ) support.

Repository: https://git.belvedersky.ru/belvedersky/queue

Installation

go get git.belvedersky.ru/queue

Usage

Basic example:

package main

import (
    "fmt"
    "git.belvedersky.ru/queue"
)

func main() {
    q := queue.NewQueue

    q.Push(1)
    q.Push(2)

    for !q.Empty() {
        item := q.Pop()
        fmt.Println(item)
    }
}

Dead Letter Queue Example

See examples/example_dlq_test.go:

mainQ := queue.NewQueue
dlq := queue.NewQueue

mainQ.SetDLQ(dlq)

Examples

Full examples are available in: https://git.belvedersky.ru/belvedersky/queue/src/branch/main/examples

Includes: - examples/example_basic_test.go - examples/example_dlq_test.go - examples/example_parallel_test.go

Benchmarks

goos: darwin
goarch: arm64
pkg: git.belvedersky.ru/belvedersky/queue
cpu: Apple M1 Pro
BenchmarkProduceConsume/workers_1-10         	    9488	    118244 ns/op	       8 B/op	       1 allocs/op
BenchmarkProduceConsume/workers_4-10         	   40800	     29371 ns/op	       8 B/op	       1 allocs/op
BenchmarkProduceConsume/workers_16-10        	  163110	      7340 ns/op	       8 B/op	       1 allocs/op
BenchmarkTryProduce-10                       	 1610434	       774.8 ns/op	     520 B/op	       7 allocs/op
PASS
ok  	git.belvedersky.ru/belvedersky/queue	6.574s

License

MIT

Description
Simple and lightweight queue implementation in Go with optional Dead Letter Queue (DLQ) support.
Readme 50 KiB
Languages
Go 100%