mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
87c77727e4
* lib/backup/s3remote: update AWS SDK to v2 * Update lib/backup/s3remote/s3.go Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com> * lib/backup/s3remote: refactor error handling Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
36 lines
1 KiB
Go
36 lines
1 KiB
Go
package waiter
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/aws/smithy-go/logging"
|
|
"github.com/aws/smithy-go/middleware"
|
|
)
|
|
|
|
// Logger is the Logger middleware used by the waiter to log an attempt
|
|
type Logger struct {
|
|
// Attempt is the current attempt to be logged
|
|
Attempt int64
|
|
}
|
|
|
|
// ID representing the Logger middleware
|
|
func (*Logger) ID() string {
|
|
return "WaiterLogger"
|
|
}
|
|
|
|
// HandleInitialize performs handling of request in initialize stack step
|
|
func (m *Logger) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
|
|
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
|
|
) {
|
|
logger := middleware.GetLogger(ctx)
|
|
|
|
logger.Logf(logging.Debug, fmt.Sprintf("attempting waiter request, attempt count: %d", m.Attempt))
|
|
|
|
return next.HandleInitialize(ctx, in)
|
|
}
|
|
|
|
// AddLogger is a helper util to add waiter logger after `SetLogger` middleware in
|
|
func (m Logger) AddLogger(stack *middleware.Stack) error {
|
|
return stack.Initialize.Insert(&m, "SetLogger", middleware.After)
|
|
}
|