Skip to content

Commit 0d1a1d7

Browse files
committed
refactor: refactor queue handling and improve test performance
- Add import for `github.com/golang-queue/queue/core` - Change `queue.QueuedMessage` to `core.TaskMessage` in `nsq.WithRunFunc` - Reduce sleep duration from 50ms to 10ms Signed-off-by: appleboy <[email protected]>
1 parent 4cb2969 commit 0d1a1d7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import (
4848

4949
"github.com/golang-queue/nsq"
5050
"github.com/golang-queue/queue"
51+
"github.com/golang-queue/queue/core"
5152
)
5253

5354
type job struct {
@@ -73,7 +74,7 @@ func main() {
7374
nsq.WithChannel("foobar"),
7475
// concurrent job number
7576
nsq.WithMaxInFlight(10),
76-
nsq.WithRunFunc(func(ctx context.Context, m queue.QueuedMessage) error {
77+
nsq.WithRunFunc(func(ctx context.Context, m core.TaskMessage) error {
7778
var v *job
7879
if err := json.Unmarshal(m.Payload(), &v); err != nil {
7980
return err
@@ -104,7 +105,7 @@ func main() {
104105
// wait until all tasks done
105106
for i := 0; i < taskN; i++ {
106107
fmt.Println("message:", <-rets)
107-
time.Sleep(50 * time.Millisecond)
108+
time.Sleep(10 * time.Millisecond)
108109
}
109110
}
110111
```

0 commit comments

Comments
 (0)