From 0e96881ecd6baa5115fb60d032345c59fbb9d756 Mon Sep 17 00:00:00 2001 From: Thibault Leroy Date: Tue, 18 Jun 2024 09:27:58 +0200 Subject: [PATCH] feat(consumer): naming --- consume.go | 16 ++++++++-------- consumer_options.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/consume.go b/consume.go index d4eeba1..ad80012 100644 --- a/consume.go +++ b/consume.go @@ -114,16 +114,16 @@ func (consumer *Consumer) Run(handler Handler) error { } // Close cleans up resources and closes the consumer. -// It waits for all handlers to finish before returning by default +// It waits for handler to finish before returning by default // (use WithConsumerOptionsForceShutdown option to disable this behavior). -// Use CloseWithContext to specify a context to cancel the handlers completion. +// Use CloseWithContext to specify a context to cancel the handler completion. // It does not close the connection manager, just the subscription // to the connection manager and the consuming goroutines. // Only call once. func (consumer *Consumer) Close() { if consumer.options.CloseGracefully { - consumer.options.Logger.Infof("waiting for handlers to finish...") - err := consumer.waitForHandlers(context.Background()) + consumer.options.Logger.Infof("waiting for handler to finish...") + err := consumer.waitForHandlerCompletion(context.Background()) if err != nil { consumer.options.Logger.Warnf("error while waiting for handler to finish: %v", err) } @@ -151,15 +151,15 @@ func (consumer *Consumer) cleanupResources() { } // CloseWithContext cleans up resources and closes the consumer. -// It waits for all handlers to finish before returning +// It waits for handler to finish before returning // (use WithConsumerOptionsForceShutdown option to disable this behavior). -// Use the context to cancel the handlers completion. +// Use the context to cancel the handler completion. // CloseWithContext does not close the connection manager, just the subscription // to the connection manager and the consuming goroutines. // Only call once. func (consumer *Consumer) CloseWithContext(ctx context.Context) { if consumer.options.CloseGracefully { - err := consumer.waitForHandlers(ctx) + err := consumer.waitForHandlerCompletion(ctx) if err != nil { consumer.options.Logger.Warnf("error while waiting for handler to finish: %v", err) } @@ -256,7 +256,7 @@ func handlerGoroutine(consumer *Consumer, msgs <-chan amqp.Delivery, consumeOpti consumer.options.Logger.Infof("rabbit consumer goroutine closed") } -func (consumer *Consumer) waitForHandlers(ctx context.Context) error { +func (consumer *Consumer) waitForHandlerCompletion(ctx context.Context) error { if ctx == nil { ctx = context.Background() } else if ctx.Err() != nil { diff --git a/consumer_options.go b/consumer_options.go index fff0ed7..aa87bdd 100644 --- a/consumer_options.go +++ b/consumer_options.go @@ -314,7 +314,7 @@ func WithConsumerOptionsQOSGlobal(options *ConsumerOptions) { } // WithConsumerOptionsForceShutdown tells the consumer to not wait for -// the handlers to complete in consumer.Close +// the handler to complete in consumer.Close func WithConsumerOptionsForceShutdown(options *ConsumerOptions) { options.CloseGracefully = false }