File tree Expand file tree Collapse file tree 8 files changed +31
-17
lines changed Expand file tree Collapse file tree 8 files changed +31
-17
lines changed Original file line number Diff line number Diff line change
1
+ module example
2
+
3
+ go 1.16
4
+
5
+ require (
6
+ github.com/golang-queue/queue v0.0.7-0.20210820051048-3cc52a575c1c // indirect
7
+ github.com/golang/protobuf v1.5.2 // indirect
8
+ github.com/nats-io/nats-server/v2 v2.3.2 // indirect
9
+ github.com/nsqio/go-nsq v1.0.8 // indirect
10
+ google.golang.org/protobuf v1.27.1 // indirect
11
+ )
Original file line number Diff line number Diff line change 1
1
github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
2
2
github.com/golang-queue/queue v0.0.6 h1:TLd0lSM7uNgXXj7SXSMfyaZUwRgbOu9tq6UfZXXELnA =
3
3
github.com/golang-queue/queue v0.0.6 /go.mod h1:IeIGBO1largDrFEaxDgIckoAFIUTn0eolTQris8bm08 =
4
+ github.com/golang-queue/queue v0.0.7-0.20210820051048-3cc52a575c1c h1:RX+BTPGEITf2Jy/B1X5Qu+l8yGdGR3Z/Cx/9IM3MffI =
5
+ github.com/golang-queue/queue v0.0.7-0.20210820051048-3cc52a575c1c /go.mod h1:JS5tYJacahCjafcplU5idNLX2vkYioqh6wEDX5o9Nms =
4
6
github.com/golang/protobuf v1.4.0-rc.1 /go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8 =
5
7
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208 /go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA =
6
8
github.com/golang/protobuf v1.4.0-rc.2 /go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs =
Original file line number Diff line number Diff line change 8
8
"time"
9
9
10
10
"github.com/golang-queue/queue"
11
- "github.com/golang-queue/queue/simple"
12
11
)
13
12
14
13
type job struct {
@@ -29,9 +28,9 @@ func main() {
29
28
rets := make (chan string , taskN )
30
29
31
30
// define the worker
32
- w := simple . NewWorker (
33
- simple . WithQueueNum (taskN ),
34
- simple . WithRunFunc (func (ctx context.Context , m queue.QueuedMessage ) error {
31
+ w := queue . NewConsumer (
32
+ queue . WithQueueSize (taskN ),
33
+ queue . WithFn (func (ctx context.Context , m queue.QueuedMessage ) error {
35
34
v , ok := m .(* job )
36
35
if ! ok {
37
36
if err := json .Unmarshal (m .Bytes (), & v ); err != nil {
Original file line number Diff line number Diff line change
1
+ module example
2
+
3
+ go 1.16
4
+
5
+ require (
6
+ github.com/golang-queue/queue v0.0.7-0.20210820051048-3cc52a575c1c
7
+ github.com/golang/protobuf v1.5.2 // indirect
8
+ github.com/nats-io/nats-server/v2 v2.3.2 // indirect
9
+ github.com/nsqio/go-nsq v1.0.8 // indirect
10
+ google.golang.org/protobuf v1.27.1 // indirect
11
+ )
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
2
2
github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
3
3
github.com/golang-queue/queue v0.0.6 h1:TLd0lSM7uNgXXj7SXSMfyaZUwRgbOu9tq6UfZXXELnA =
4
4
github.com/golang-queue/queue v0.0.6 /go.mod h1:IeIGBO1largDrFEaxDgIckoAFIUTn0eolTQris8bm08 =
5
+ github.com/golang-queue/queue v0.0.7-0.20210820051048-3cc52a575c1c h1:RX+BTPGEITf2Jy/B1X5Qu+l8yGdGR3Z/Cx/9IM3MffI =
6
+ github.com/golang-queue/queue v0.0.7-0.20210820051048-3cc52a575c1c /go.mod h1:JS5tYJacahCjafcplU5idNLX2vkYioqh6wEDX5o9Nms =
5
7
github.com/golang/protobuf v1.4.0-rc.1 /go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8 =
6
8
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208 /go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA =
7
9
github.com/golang/protobuf v1.4.0-rc.2 /go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs =
Original file line number Diff line number Diff line change @@ -7,16 +7,15 @@ import (
7
7
"time"
8
8
9
9
"github.com/golang-queue/queue"
10
- "github.com/golang-queue/queue/simple"
11
10
)
12
11
13
12
func main () {
14
13
taskN := 100
15
14
rets := make (chan string , taskN )
16
15
17
16
// define the worker
18
- w := simple . NewWorker (
19
- simple . WithQueueNum (taskN ),
17
+ w := queue . NewConsumer (
18
+ queue . WithQueueSize (taskN ),
20
19
)
21
20
22
21
// define the queue
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments