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 11github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
22github.com/golang-queue/queue v0.0.6 h1:TLd0lSM7uNgXXj7SXSMfyaZUwRgbOu9tq6UfZXXELnA =
33github.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 =
46github.com/golang/protobuf v1.4.0-rc.1 /go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8 =
57github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208 /go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA =
68github.com/golang/protobuf v1.4.0-rc.2 /go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs =
Original file line number Diff line number Diff line change 88 "time"
99
1010 "github.com/golang-queue/queue"
11- "github.com/golang-queue/queue/simple"
1211)
1312
1413type job struct {
@@ -29,9 +28,9 @@ func main() {
2928 rets := make (chan string , taskN )
3029
3130 // 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 {
3534 v , ok := m .(* job )
3635 if ! ok {
3736 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
22github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
33github.com/golang-queue/queue v0.0.6 h1:TLd0lSM7uNgXXj7SXSMfyaZUwRgbOu9tq6UfZXXELnA =
44github.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 =
57github.com/golang/protobuf v1.4.0-rc.1 /go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8 =
68github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208 /go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA =
79github.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 (
77 "time"
88
99 "github.com/golang-queue/queue"
10- "github.com/golang-queue/queue/simple"
1110)
1211
1312func main () {
1413 taskN := 100
1514 rets := make (chan string , taskN )
1615
1716 // define the worker
18- w := simple . NewWorker (
19- simple . WithQueueNum (taskN ),
17+ w := queue . NewConsumer (
18+ queue . WithQueueSize (taskN ),
2019 )
2120
2221 // 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