1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 10:18:38 +00:00

Add Unique Queue infrastructure and move TestPullRequests to this (#9856)

* Upgrade levelqueue to version 0.2.0

This adds functionality for Unique Queues

* Add UniqueQueue interface and functions to create them

* Add UniqueQueue implementations

* Move TestPullRequests over to use UniqueQueue

* Reduce code duplication

* Add bytefifos

* Ensure invalid types are logged

* Fix close race in PersistableChannelQueue Shutdown
This commit is contained in:
zeripath
2020-02-02 23:19:58 +00:00
committed by GitHub
parent b4914249ee
commit 2c903383b5
29 changed files with 1950 additions and 516 deletions

View File

@@ -25,4 +25,36 @@ data, err = queue.LPop()
queue.LHandle(func(dt []byte) error{
return nil
})
```
```
You can now create a Set from a leveldb:
```Go
set, err := levelqueue.OpenSet("./set")
added, err:= set.Add([]byte("member1"))
has, err := set.Has([]byte("member1"))
members, err := set.Members()
removed, err := set.Remove([]byte("member1"))
```
And you can create a UniqueQueue from a leveldb:
```Go
queue, err := levelqueue.OpenUnique("./queue")
err := queue.RPush([]byte("member1"))
err = queue.LPush([]byte("member1"))
// Will return ErrAlreadyInQueue
// and so on.
```
## Creating Queues, UniqueQueues and Sets from already open DB
If you have an already open DB you can create these from this using the
`NewQueue`, `NewUniqueQueue` and `NewSet` functions.