Skip to content

Commit 8fa622a

Browse files
committed
chore: update all example
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 3cc52a5 commit 8fa622a

File tree

8 files changed

+31
-17
lines changed

8 files changed

+31
-17
lines changed

_example/example01/go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
)

_example/simple/example01/go.sum renamed to _example/example01/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22
github.com/golang-queue/queue v0.0.6 h1:TLd0lSM7uNgXXj7SXSMfyaZUwRgbOu9tq6UfZXXELnA=
33
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=
46
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
57
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
68
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=

_example/simple/example01/main.go renamed to _example/example01/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"time"
99

1010
"github.com/golang-queue/queue"
11-
"github.com/golang-queue/queue/simple"
1211
)
1312

1413
type 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 {

_example/example02/go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
)

_example/simple/example02/go.sum renamed to _example/example02/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
22
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/golang-queue/queue v0.0.6 h1:TLd0lSM7uNgXXj7SXSMfyaZUwRgbOu9tq6UfZXXELnA=
44
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=
57
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
68
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
79
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=

_example/simple/example02/main.go renamed to _example/example02/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff 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

1312
func 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

_example/simple/example01/go.mod

Lines changed: 0 additions & 5 deletions
This file was deleted.

_example/simple/example02/go.mod

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)