1fb96689b8
* creates run loop for data repair checker * moves actual checking and repairing under ticker case * fixes mismatched queueaddrs
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package checker
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
"storj.io/storj/pkg/datarepair/queue"
|
|
"storj.io/storj/pkg/overlay"
|
|
"storj.io/storj/pkg/pointerdb"
|
|
"storj.io/storj/pkg/provider"
|
|
"storj.io/storj/storage/redis"
|
|
)
|
|
|
|
// Config contains configurable values for repairer
|
|
type Config struct {
|
|
QueueAddress string `help:"data checker queue address" default:"redis://127.0.0.1:6378?db=1&password=abc123"`
|
|
Interval time.Duration `help:"how frequently checker should audit segments" default:"30s"`
|
|
}
|
|
|
|
// Initialize a Checker struct
|
|
func (c Config) initialize(ctx context.Context) (Checker, error) {
|
|
pointerdb := pointerdb.LoadFromContext(ctx)
|
|
overlay := overlay.LoadServerFromContext(ctx)
|
|
client, err := redis.NewClientFrom(c.QueueAddress)
|
|
if err != nil {
|
|
return nil, Error.Wrap(err)
|
|
}
|
|
repairQueue := queue.NewQueue(client)
|
|
return newChecker(pointerdb, repairQueue, overlay, 0, zap.L(), c.Interval), nil
|
|
}
|
|
|
|
// Run runs the checker with configured values
|
|
func (c Config) Run(ctx context.Context, server *provider.Provider) (err error) {
|
|
check, err := c.initialize(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return check.Run(ctx)
|
|
}
|