common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package common provides general utility helper functions and types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeExternalURL

func ComputeExternalURL(u, listenAddr string) (*url.URL, error)

ComputeExternalURL computes a sanitized external URL from a raw input. It infers unset URL parts from the OS and the given listen address.

func GenerateKey added in v0.2.0

func GenerateKey(url string) uint64

GenerateKey generates a reproducible key from a given URL string.

func GetFreePort

func GetFreePort() (int, *net.TCPListener, error)

GetFreePort in this case makes the closing of the listener the responsibility of the caller to allow for a guarantee that multiple random port allocations don't collide.

func GetUUIDFromString

func GetUUIDFromString(stringSlice []string) (string, error)

GetUUIDFromString returns a UUID5 for given slice of strings.

func MakeConfig

func MakeConfig[T any](filePath string) (*T, error)

MakeConfig reads config file, merges with passed default config and returns updated config instance.

func NewGrafanaClient added in v0.2.0

func NewGrafanaClient(config *GrafanaWebConfig, logger log.Logger) (*grafana.Grafana, error)

NewGrafanaClient instantiates a new instance of Grafana client.

func Round added in v0.2.0

func Round(value int64, nearest int64) int64

Round returns a value less than or equal to value that is multiple of nearest.

func SanitizeFloat

func SanitizeFloat(v float64) float64

SanitizeFloat replaces +/-Inf and NaN with zero.

func TimeTrack

func TimeTrack(start time.Time, name string, logger log.Logger)

TimeTrack tracks execution time of each function.

Types

type GrafanaWebConfig

type GrafanaWebConfig struct {
	URL              string                       `yaml:"url"`
	TeamsIDs         []string                     `yaml:"teams_ids"`
	HTTPClientConfig config_util.HTTPClientConfig `yaml:",inline"`
}

GrafanaWebConfig makes HTTP Grafana config.

Jump to

Keyboard shortcuts

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