Skip to content

Commit

Permalink
Rename consumer field in middlewares
Browse files Browse the repository at this point in the history
Signed-off-by: dusanb94 <[email protected]>
  • Loading branch information
dborovcanin committed Jan 5, 2021
1 parent f8fa29f commit 792e57a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions consumers/api/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (
var _ consumers.Consumer = (*loggingMiddleware)(nil)

type loggingMiddleware struct {
logger log.Logger
c consumers.Consumer
logger log.Logger
consumer consumers.Consumer
}

// LoggingMiddleware adds logging facilities to the adapter.
func LoggingMiddleware(c consumers.Consumer, logger log.Logger) consumers.Consumer {
func LoggingMiddleware(consumer consumers.Consumer, logger log.Logger) consumers.Consumer {
return &loggingMiddleware{
logger: logger,
c: c,
logger: logger,
consumer: consumer,
}
}

Expand All @@ -38,5 +38,5 @@ func (lm *loggingMiddleware) Consume(msgs interface{}) (err error) {
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())

return lm.c.Consume(msgs)
return lm.consumer.Consume(msgs)
}
16 changes: 8 additions & 8 deletions consumers/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ import (
var _ consumers.Consumer = (*metricsMiddleware)(nil)

type metricsMiddleware struct {
counter metrics.Counter
latency metrics.Histogram
c consumers.Consumer
counter metrics.Counter
latency metrics.Histogram
consumer consumers.Consumer
}

// MetricsMiddleware returns new message repository
// with Save method wrapped to expose metrics.
func MetricsMiddleware(c consumers.Consumer, counter metrics.Counter, latency metrics.Histogram) consumers.Consumer {
func MetricsMiddleware(consumer consumers.Consumer, counter metrics.Counter, latency metrics.Histogram) consumers.Consumer {
return &metricsMiddleware{
counter: counter,
latency: latency,
c: c,
counter: counter,
latency: latency,
consumer: consumer,
}
}

Expand All @@ -33,5 +33,5 @@ func (mm *metricsMiddleware) Consume(msgs interface{}) error {
mm.counter.With("method", "consume").Add(1)
mm.latency.With("method", "consume").Observe(time.Since(begin).Seconds())
}(time.Now())
return mm.c.Consume(msgs)
return mm.consumer.Consume(msgs)
}
4 changes: 2 additions & 2 deletions consumers/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package consumers

// Consumer specifies message writing API.
type Consumer interface {
// MessageConsumer method is used to save published message. A non-nil
// error is returned to indicate operation failure.
// Consume method is used to consumed received messages.
// A non-nil error is returned to indicate operation failure.
Consume(messages interface{}) error
}

0 comments on commit 792e57a

Please sign in to comment.