Skip to content

Commit fb8b6a5

Browse files
committed
chore(worker): Add disable consumer method
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 4343a22 commit fb8b6a5

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

_example/server-client/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.16
44

55
require (
66
github.com/golang-queue/nsq v0.0.0-00010101000000-000000000000
7-
github.com/golang-queue/queue v0.0.12-0.20220122071422-2c41650f045a
7+
github.com/golang-queue/queue v0.0.13-0.20220330060848-d1a0d31ce747
88
)
99

1010
replace github.com/golang-queue/nsq => ../../

_example/server-client/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ github.com/golang-queue/queue v0.0.8-0.20210905095503-cc99dff8fdc3 h1:ka4/BRgVnd
77
github.com/golang-queue/queue v0.0.8-0.20210905095503-cc99dff8fdc3/go.mod h1:JS5tYJacahCjafcplU5idNLX2vkYioqh6wEDX5o9Nms=
88
github.com/golang-queue/queue v0.0.12-0.20220122071422-2c41650f045a h1:olgbdu53u5A6Babr1w+CUO19UdZASYPPqqIBfdFWrWE=
99
github.com/golang-queue/queue v0.0.12-0.20220122071422-2c41650f045a/go.mod h1:ku8iyjYffqYY6Duts+xl+QYfN3/KDK4MEvXMZUkHyio=
10+
github.com/golang-queue/queue v0.0.13-0.20220330060848-d1a0d31ce747 h1:uNTbCoWORAcna89KcKgP22WFGv5fsij05e70DCnLrUU=
11+
github.com/golang-queue/queue v0.0.13-0.20220330060848-d1a0d31ce747/go.mod h1:ku8iyjYffqYY6Duts+xl+QYfN3/KDK4MEvXMZUkHyio=
1012
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
1113
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
1214
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=

_example/server-client/server/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func main() {
3030
nsq.WithAddr("127.0.0.1:4150"),
3131
nsq.WithTopic("example"),
3232
nsq.WithChannel("foobar"),
33+
nsq.WithDisableConsumer(),
3334
)
3435

3536
// define the queue

nsq_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func TestHandleTimeout(t *testing.T) {
276276
time.Sleep(200 * time.Millisecond)
277277
return nil
278278
}),
279-
withDisableConsumer(),
279+
WithDisableConsumer(),
280280
)
281281

282282
err := w.handle(job)
@@ -293,7 +293,7 @@ func TestHandleTimeout(t *testing.T) {
293293
time.Sleep(200 * time.Millisecond)
294294
return nil
295295
}),
296-
withDisableConsumer(),
296+
WithDisableConsumer(),
297297
)
298298

299299
done := make(chan error)
@@ -317,7 +317,7 @@ func TestJobComplete(t *testing.T) {
317317
WithRunFunc(func(ctx context.Context, m queue.QueuedMessage) error {
318318
return errors.New("job completed")
319319
}),
320-
withDisableConsumer(),
320+
WithDisableConsumer(),
321321
)
322322

323323
err := w.handle(job)

options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ func WithLogger(l queue.Logger) Option {
6262
}
6363
}
6464

65-
func withDisableConsumer() Option {
65+
// WithDisableConsumer disable consumer
66+
func WithDisableConsumer() Option {
6667
return func(w *options) {
6768
w.disableConsumer = true
6869
}

0 commit comments

Comments
 (0)