From cac64a8aa0532820ce4604e4436153e13332039c Mon Sep 17 00:00:00 2001 From: Justin Timperio Date: Mon, 23 Dec 2024 03:55:31 -0800 Subject: [PATCH] Bump Docs --- README.md | 8 ++++++++ gpq.go | 25 ++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b7ff4e7..dcd293e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,14 @@ GPQ is an extremely fast and flexible priority queue, capable of millions transactions a second. GPQ supports a complex "Double Priority Queue" which allows for priorities to be distributed across N buckets, with each bucket holding a second priority queue which allows for internal escalation and timeouts of items based on parameters the user can specify during submission combined with how frequently you ask GPQ to prioritize the queue. +

+ Go version + Go Reference + GitHub License + GitHub Release + GitHub Issues or Pull Requests +

+ ## Notice While GPQ is largely stable, bugs are more than likely present at this early stage, and you should carefully consider if your application can tolerate any down time or lost messages that may result from adopting this project into a production workflow. If you run into any bugs please submit an issue or better a PR! Check out the guide to contributing below. diff --git a/gpq.go b/gpq.go index 20d2df1..7425d5f 100644 --- a/gpq.go +++ b/gpq.go @@ -113,17 +113,6 @@ func (g *GPQ[d]) ActiveBuckets() uint { return g.queue.ActiveBuckets() } -func (g *GPQ[d]) restoreDB(items []*schema.Item[d]) []error { - // Quick sanity check - for i := 0; i < len(items); i++ { - if items[i].Priority > uint(g.options.MaxPriority) { - return []error{fmt.Errorf("You are trying to restore items with priorities higher than the max allowed for this queue")} - } - } - - return g.queue.EnqueueBatch(items) -} - // Enqueue adds an item to the queue with the given options func (g *GPQ[d]) Enqueue(item schema.Item[d]) error { @@ -257,6 +246,9 @@ func (g *GPQ[d]) DequeueBatch(batchSize uint) (items []*schema.Item[d], errs []e return items, nil } +// Prioritize orders the queue based on the individual options added to +// every message in the queue. Prioritizing the queue is a stop-the-world +// event, so consider your usage carefully. func (g *GPQ[d]) Prioritize() (escalated, removed uint, err error) { return g.queue.Prioritize() } @@ -279,6 +271,17 @@ func (g *GPQ[d]) Close() { } +func (g *GPQ[d]) restoreDB(items []*schema.Item[d]) []error { + // Quick sanity check + for i := 0; i < len(items); i++ { + if items[i].Priority > uint(g.options.MaxPriority) { + return []error{fmt.Errorf("You are trying to restore items with priorities higher than the max allowed for this queue")} + } + } + + return g.queue.EnqueueBatch(items) +} + func (g *GPQ[d]) lazyDiskWriter(maxDelay time.Duration) { g.activeDBSessions.Add(1) defer g.activeDBSessions.Done()