Skip to content

Commit

Permalink
Bump Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinTimperio committed Dec 23, 2024
1 parent de7710a commit cac64a8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
</h4>

<p align="center">
<img alt="Go version" src="https://img.shields.io/github/go-mod/go-version/JustinTimperio/gpq">
<a href="https://pkg.go.dev/github.com/JustinTimperio/gpq"><img src="https://pkg.go.dev/badge/github.com/JustinTimperio/gpq.svg" alt="Go Reference"></a>
<img alt="GitHub License" src="https://img.shields.io/github/license/JustinTimperio/gpq">
<img alt="GitHub Release" src="https://img.shields.io/github/v/release/JustinTimperio/gpq">
<img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues/JustinTimperio/gpq">
</p>

## 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.

Expand Down
25 changes: 14 additions & 11 deletions gpq.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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()
}
Expand All @@ -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()
Expand Down

0 comments on commit cac64a8

Please sign in to comment.