conf

package
v0.7.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfDryRun holds the name of the configuration setting which defines
	// whether we execute pin/unpin calls against skyd or not. Note that all
	// database operations will still be executed, i.e. skylinks records will
	// be updated. After using this option you will need to prune the database
	// before being able to use the service in "actual mode".
	ConfDryRun = "dry_run"
	// ConfMinPinners holds the name of the configuration setting which defines
	// the minimum number of pinners we want to ensure for each skyfile.
	ConfMinPinners = "min_pinners"
	// ConfNextScan holds the name of the configuration setting which controls
	// when the next cluster-wide scan for underpinned skylinks will happen.
	ConfNextScan = "next_scan"
)

Cluster-wide configuration variable names. Stored in the database.

View Source
const (
	// TimeFormat defines the time format we'll use throughout the service.
	TimeFormat = time.RFC3339Nano
)

Variables

View Source
var (
	// DefaultNextScanOffset is the time to next scan we set when we don't have
	// any value configured in the DB. It should be such a value that it gives
	// all servers enough time to read the DB and be ready by the time of the
	// scan.
	DefaultNextScanOffset = 2 * SleepBetweenChecksForScan

	// ErrTimeTooSoon is returned when we try to set the time of the next scan
	// too soon, not giving all servers enough time to get the memo.
	ErrTimeTooSoon = errors.New("time is too soon")

	// SleepBetweenChecksForScan defines how often we'll check the DB for
	// the next scheduled scan.
	SleepBetweenChecksForScan = build.Select(build.Var{
		Standard: 30 * time.Minute,
		Dev:      30 * time.Second,
		Testing:  time.Second,
	}).(time.Duration)
)

Functions

func DryRun added in v0.2.0

func DryRun(ctx context.Context, db *database.DB) (bool, error)

DryRun returns the cluster-wide value of the dry_run switch. This switch tells Pinner to omit the pin/unpin calls to skyd and assume they were successful.

func MinPinners added in v0.1.0

func MinPinners(ctx context.Context, db *database.DB) (int, error)

MinPinners returns the cluster-wide value of the minimum number of servers we expect to be pinning each skylink.

func NextScan added in v0.6.0

func NextScan(ctx context.Context, db *database.DB, logger logger.Logger) (time.Time, error)

NextScan returns the time of the next cluster-wide scan for underpinned files.

func SetNextScan added in v0.6.0

func SetNextScan(ctx context.Context, db *database.DB, t time.Time) error

SetNextScan sets the time of the next cluster-wide scan for underpinned files.

Types

type Config

type Config struct {
	// AccountsHost defines the IP or hostname of the local accounts service.
	AccountsHost string
	// AccountsPort defines the port of the local accounts service.
	AccountsPort string
	// DBCredentials holds all the information we need to connect to the DB.
	DBCredentials database.DBCredentials
	// Logfile defines the log file we want to write to. If it's empty we do
	// not log to a file.
	LogFile string
	// LogLevel defines the logging level of the entire service.
	LogLevel logrus.Level
	// MinPinners defines the minimum number of pinning servers
	// which a skylink needs in order to not be considered underpinned.
	// Anything below this value requires more servers to pin the skylink.
	MinPinners int
	// ScannerThreads defines the number of scanning threads which might attempt
	// to pin an underpinned skylink.
	ScannerThreads int
	// ServerName holds the name of the current server. This name will be
	// used for identifying which servers are pinning a given skylink.
	ServerName string
	// SiaAPIPassword is the apipassword for the local skyd.
	SiaAPIPassword string
	// SiaAPIHost is the hostname/IP of the local skyd.
	SiaAPIHost string
	// SiaAPIPort is the port of the local skyd.
	SiaAPIPort string
	// SleepBetweenScans defines the time between scans in hours.
	SleepBetweenScans time.Duration
}

Config represents the entire configurable state of the service. If a value is not here, then it can't be configured.

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig loads the required service defaultConfig from the environment and the provided .env file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL