registry_opts.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package mock
  2. import (
  3. "github.com/ydb-platform/ydb/library/go/core/metrics/internal/pkg/registryutil"
  4. )
  5. type RegistryOpts struct {
  6. Separator rune
  7. Prefix string
  8. Tags map[string]string
  9. AllowLoadRegisteredMetrics bool
  10. }
  11. // NewRegistryOpts returns new initialized instance of RegistryOpts
  12. func NewRegistryOpts() *RegistryOpts {
  13. return &RegistryOpts{
  14. Separator: '.',
  15. Tags: make(map[string]string),
  16. }
  17. }
  18. // SetTags overrides existing tags
  19. func (o *RegistryOpts) SetTags(tags map[string]string) *RegistryOpts {
  20. o.Tags = tags
  21. return o
  22. }
  23. // AddTags merges given tags with existing
  24. func (o *RegistryOpts) AddTags(tags map[string]string) *RegistryOpts {
  25. for k, v := range tags {
  26. o.Tags[k] = v
  27. }
  28. return o
  29. }
  30. // SetPrefix overrides existing prefix
  31. func (o *RegistryOpts) SetPrefix(prefix string) *RegistryOpts {
  32. o.Prefix = prefix
  33. return o
  34. }
  35. // AppendPrefix adds given prefix as postfix to existing using separator
  36. func (o *RegistryOpts) AppendPrefix(prefix string) *RegistryOpts {
  37. o.Prefix = registryutil.BuildFQName(string(o.Separator), o.Prefix, prefix)
  38. return o
  39. }
  40. // SetSeparator overrides existing separator
  41. func (o *RegistryOpts) SetSeparator(separator rune) *RegistryOpts {
  42. o.Separator = separator
  43. return o
  44. }