File: handler_options.go

package info (click to toggle)
golang-gitlab-gitlab-org-labkit 1.17.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,092 kB
  • sloc: sh: 210; javascript: 49; makefile: 4
file content (24 lines) | stat: -rw-r--r-- 564 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package metrics

type handlerConfig struct {
	labelValues map[string]string
}

// HandlerOption is used to pass options to the HandlerFactory instance.
type HandlerOption func(*handlerConfig)

func applyHandlerOptions(opts []HandlerOption) handlerConfig {
	config := handlerConfig{}
	for _, v := range opts {
		v(&config)
	}

	return config
}

// WithLabelValues will configure labels values to apply to this handler.
func WithLabelValues(labelValues map[string]string) HandlerOption {
	return func(config *handlerConfig) {
		config.labelValues = labelValues
	}
}