File: backrest_converters.go

package info (click to toggle)
prometheus-pgbackrest-exporter 0.19.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 480 kB
  • sloc: sh: 141; makefile: 136
file content (49 lines) | stat: -rw-r--r-- 952 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
48
49
package backrest

// Convert bool to float64.
func convertBoolToFloat64(value bool) float64 {
	if value {
		return 1
	}
	return 0
}

// Convert pointer (bool) to float64.
func convertBoolPointerToFloat64(value *bool) float64 {
	if value != nil {
		return convertBoolToFloat64(*value)
	}
	return 0
}

// Convert pointer (int64) to float64.
func convertInt64PointerToFloat64(value *int64) float64 {
	if value != nil {
		return float64(*value)
	}
	return 0
}

// Convert pointer (annotation) to float64.
func convertAnnotationPointerToFloat64(value *annotation) float64 {
	if value != nil {
		return float64(len(*value))
	}
	return 0
}

// Convert pointer (databaseRef) to float64.
func convertDatabaseRefPointerToFloat(value *[]databaseRef) float64 {
	if value != nil {
		return float64(len(*value))
	}
	return 0
}

// Convert empty LSN value label.
func convertEmptyLSNValueLabel(value string) string {
	if value == "" {
		return "-"
	}
	return value
}