2018-10-12 18:49:49 +01:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package repairer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
q "storj.io/storj/pkg/datarepair/queue"
|
|
|
|
"storj.io/storj/pkg/provider"
|
|
|
|
"storj.io/storj/storage/redis"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config contains configurable values for repairer
|
|
|
|
type Config struct {
|
2018-10-30 19:16:40 +00:00
|
|
|
QueueAddress string `help:"data repair queue address" default:"redis://127.0.0.1:6378?db=1&password=abc123"`
|
2018-10-12 18:49:49 +01:00
|
|
|
MaxRepair int `help:"maximum segments that can be repaired concurrently" default:"100"`
|
|
|
|
Interval time.Duration `help:"how frequently checker should audit segments" default:"3600s"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run runs the repairer with configured values
|
|
|
|
func (c Config) Run(ctx context.Context, server *provider.Provider) (err error) {
|
2018-10-24 13:35:59 +01:00
|
|
|
client, err := redis.NewClientFrom(c.QueueAddress)
|
2018-10-12 18:49:49 +01:00
|
|
|
if err != nil {
|
2018-10-24 13:35:59 +01:00
|
|
|
return Error.Wrap(err)
|
2018-10-12 18:49:49 +01:00
|
|
|
}
|
|
|
|
|
2018-10-24 13:35:59 +01:00
|
|
|
queue := q.NewQueue(client)
|
|
|
|
|
2018-10-25 19:59:36 +01:00
|
|
|
repairer := newRepairer(queue, c.Interval, c.MaxRepair)
|
|
|
|
return repairer.Run(ctx)
|
2018-10-12 18:49:49 +01:00
|
|
|
}
|