mirror of
https://github.com/jangraefen/hcloud-pricing-exporter
synced 2024-11-10 05:54:15 +00:00
Add documentation
This commit is contained in:
parent
f96fd1b23c
commit
de4833ebe1
8 changed files with 19 additions and 8 deletions
|
@ -12,9 +12,13 @@ var (
|
|||
ctx = context.Background()
|
||||
)
|
||||
|
||||
// Fetcher defines a common interface for types that fetch pricing data from the HCloud API.
|
||||
type Fetcher interface {
|
||||
// GetHourly returns the prometheus collector that collects pricing data for hourly expenses.
|
||||
GetHourly() prometheus.Collector
|
||||
// GetMonthly returns the prometheus collector that collects pricing data for monthly expenses.
|
||||
GetMonthly() prometheus.Collector
|
||||
// Run executes a new data fetching cycle and updates the prometheus exposed collectors.
|
||||
Run(*hcloud.Client) error
|
||||
}
|
||||
|
||||
|
@ -31,7 +35,7 @@ func (fetcher baseFetcher) GetMonthly() prometheus.Collector {
|
|||
return fetcher.monthly
|
||||
}
|
||||
|
||||
func new(resource string, additionalLabels ...string) *baseFetcher {
|
||||
func newBase(resource string, additionalLabels ...string) *baseFetcher {
|
||||
labels := []string{"name"}
|
||||
labels = append(labels, additionalLabels...)
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@ const (
|
|||
|
||||
var _ Fetcher = &floatingIP{}
|
||||
|
||||
// NewFloatingIP creates a new fetcher that will collect pricing information on floating IPs.
|
||||
func NewFloatingIP() Fetcher {
|
||||
return &floatingIP{new("floatingip", "location")}
|
||||
return &floatingIP{newBase("floatingip", "location")}
|
||||
}
|
||||
|
||||
type floatingIP struct {
|
||||
|
|
|
@ -8,8 +8,9 @@ import (
|
|||
|
||||
var _ Fetcher = &loadBalancer{}
|
||||
|
||||
// NewLoadbalancer creates a new fetcher that will collect pricing information on load balancers.
|
||||
func NewLoadbalancer() Fetcher {
|
||||
return &loadBalancer{new("loadbalancer", "location", "type")}
|
||||
return &loadBalancer{newBase("loadbalancer", "location", "type")}
|
||||
}
|
||||
|
||||
type loadBalancer struct {
|
||||
|
|
|
@ -8,8 +8,9 @@ import (
|
|||
|
||||
var _ Fetcher = &server{}
|
||||
|
||||
// NewServer creates a new fetcher that will collect pricing information on servers.
|
||||
func NewServer() Fetcher {
|
||||
return &server{new("server", "location")}
|
||||
return &server{newBase("server", "location")}
|
||||
}
|
||||
|
||||
type server struct {
|
||||
|
|
|
@ -12,8 +12,9 @@ const (
|
|||
|
||||
var _ Fetcher = &server{}
|
||||
|
||||
// NewServerBackup creates a new fetcher that will collect pricing information on server backups.
|
||||
func NewServerBackup() Fetcher {
|
||||
return &serverBackup{new("server_backup", "location", "type")}
|
||||
return &serverBackup{newBase("server_backup", "location", "type")}
|
||||
}
|
||||
|
||||
type serverBackup struct {
|
||||
|
|
|
@ -12,8 +12,9 @@ const (
|
|||
|
||||
var _ Fetcher = &serverTraffic{}
|
||||
|
||||
// NewServerTraffic creates a new fetcher that will collect pricing information on server traffic.
|
||||
func NewServerTraffic() Fetcher {
|
||||
return &serverTraffic{new("server_traffic", "location", "type")}
|
||||
return &serverTraffic{newBase("server_traffic", "location", "type")}
|
||||
}
|
||||
|
||||
type serverTraffic struct {
|
||||
|
|
|
@ -12,8 +12,9 @@ const (
|
|||
|
||||
var _ Fetcher = &snapshot{}
|
||||
|
||||
// NewSnapshot creates a new fetcher that will collect pricing information on server snapshots.
|
||||
func NewSnapshot() Fetcher {
|
||||
return &snapshot{new("snapshot")}
|
||||
return &snapshot{newBase("snapshot")}
|
||||
}
|
||||
|
||||
type snapshot struct {
|
||||
|
|
|
@ -13,8 +13,9 @@ const (
|
|||
|
||||
var _ Fetcher = &volume{}
|
||||
|
||||
// NewVolume creates a new fetcher that will collect pricing information on volumes.
|
||||
func NewVolume() Fetcher {
|
||||
return &server{new("volume", "location", "bytes")}
|
||||
return &server{newBase("volume", "location", "bytes")}
|
||||
}
|
||||
|
||||
type volume struct {
|
||||
|
|
Loading…
Reference in a new issue