File: options.go

package info (click to toggle)
incus 6.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 24,428 kB
  • sloc: sh: 16,313; ansic: 3,121; python: 457; makefile: 337; ruby: 51; sql: 50; lisp: 6
file content (36 lines) | stat: -rw-r--r-- 1,001 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cluster

// Option to be passed to NewGateway to customize the resulting instance.
type Option func(*options)

// LogLevel sets the logging level for messages emitted by dqlite and raft.
func LogLevel(level string) Option {
	return func(options *options) {
		options.logLevel = level
	}
}

// Latency is a coarse grain measure of how fast/reliable network links
// are. This is used to tweak the various timeouts parameters of the raft
// algorithm. See the raft.Config structure for more details. A value of 1.0
// means use the default values from hashicorp's raft package. Values closer to
// 0 reduce the values of the various timeouts (useful when running unit tests
// in-memory).
func Latency(latency float64) Option {
	return func(options *options) {
		options.latency = latency
	}
}

// Create a options instance with default values.
func newOptions() *options {
	return &options{
		latency:  1.0,
		logLevel: "ERROR",
	}
}

type options struct {
	latency  float64
	logLevel string
}