Skip to content

Commit 0e96881

Browse files
author
Thibault Leroy
committed
feat(consumer): naming
1 parent 3b40794 commit 0e96881

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

consume.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ func (consumer *Consumer) Run(handler Handler) error {
114114
}
115115

116116
// Close cleans up resources and closes the consumer.
117-
// It waits for all handlers to finish before returning by default
117+
// It waits for handler to finish before returning by default
118118
// (use WithConsumerOptionsForceShutdown option to disable this behavior).
119-
// Use CloseWithContext to specify a context to cancel the handlers completion.
119+
// Use CloseWithContext to specify a context to cancel the handler completion.
120120
// It does not close the connection manager, just the subscription
121121
// to the connection manager and the consuming goroutines.
122122
// Only call once.
123123
func (consumer *Consumer) Close() {
124124
if consumer.options.CloseGracefully {
125-
consumer.options.Logger.Infof("waiting for handlers to finish...")
126-
err := consumer.waitForHandlers(context.Background())
125+
consumer.options.Logger.Infof("waiting for handler to finish...")
126+
err := consumer.waitForHandlerCompletion(context.Background())
127127
if err != nil {
128128
consumer.options.Logger.Warnf("error while waiting for handler to finish: %v", err)
129129
}
@@ -151,15 +151,15 @@ func (consumer *Consumer) cleanupResources() {
151151
}
152152

153153
// CloseWithContext cleans up resources and closes the consumer.
154-
// It waits for all handlers to finish before returning
154+
// It waits for handler to finish before returning
155155
// (use WithConsumerOptionsForceShutdown option to disable this behavior).
156-
// Use the context to cancel the handlers completion.
156+
// Use the context to cancel the handler completion.
157157
// CloseWithContext does not close the connection manager, just the subscription
158158
// to the connection manager and the consuming goroutines.
159159
// Only call once.
160160
func (consumer *Consumer) CloseWithContext(ctx context.Context) {
161161
if consumer.options.CloseGracefully {
162-
err := consumer.waitForHandlers(ctx)
162+
err := consumer.waitForHandlerCompletion(ctx)
163163
if err != nil {
164164
consumer.options.Logger.Warnf("error while waiting for handler to finish: %v", err)
165165
}
@@ -256,7 +256,7 @@ func handlerGoroutine(consumer *Consumer, msgs <-chan amqp.Delivery, consumeOpti
256256
consumer.options.Logger.Infof("rabbit consumer goroutine closed")
257257
}
258258

259-
func (consumer *Consumer) waitForHandlers(ctx context.Context) error {
259+
func (consumer *Consumer) waitForHandlerCompletion(ctx context.Context) error {
260260
if ctx == nil {
261261
ctx = context.Background()
262262
} else if ctx.Err() != nil {

consumer_options.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func WithConsumerOptionsQOSGlobal(options *ConsumerOptions) {
314314
}
315315

316316
// WithConsumerOptionsForceShutdown tells the consumer to not wait for
317-
// the handlers to complete in consumer.Close
317+
// the handler to complete in consumer.Close
318318
func WithConsumerOptionsForceShutdown(options *ConsumerOptions) {
319319
options.CloseGracefully = false
320320
}

0 commit comments

Comments
 (0)