Documentation
¶
Index ¶
- Variables
- type ClientConfig
- type ErrorResult
- type HTTPClient
- func (c *HTTPClient) DoWithContext(ctx context.Context, r *http.Request, data interface{}) error
- func (c *HTTPClient) GetHostFacts(ctx context.Context, hostID, page, perPage int64) (HostFactsResponse, error)
- func (c *HTTPClient) GetHostFactsWithConcurrency(hosts []Host) []HostFactsWithConcurrencyResult
- func (c *HTTPClient) GetHostWithConcurrency(pages []int64, perPage int64) []HostWithConcurrencyResult
- func (c *HTTPClient) GetHosts(ctx context.Context, thin string, page, perPage int64) (HostResponse, error)
- func (c *HTTPClient) GetHostsFactsFiltered(perPage int64) (map[string]map[string]string, error)
- func (c *HTTPClient) GetHostsFiltered(perPage int64) ([]Host, error)
- func (c *HTTPClient) OnRequestCompleted(rc RequestCompletionCallback)
- func (c *HTTPClient) SetHostsFactsRegistry(reg prometheus.Registerer)
- func (c *HTTPClient) SetHostsRegistry(reg prometheus.Registerer)
- type Host
- type HostFactsResponse
- type HostFactsWithConcurrencyResult
- type HostResponse
- type HostWithConcurrencyResult
- type LeveledLogrus
- type RequestCompletionCallback
Constants ¶
This section is empty.
Variables ¶
var (
UserAgent = fmt.Sprintf("foreman_exporter/%s", version.Version)
)
Functions ¶
This section is empty.
Types ¶
type ClientConfig ¶ added in v1.3.0
type ClientConfig struct {
BaseURL *url.URL
Username string
Password string
SkipTLSVerify bool
// Concurrency caps the in-flight requests fanned out per collector.
Concurrency int64
// MaxConnsPerHost sizes the idle connection pool. 0 derives it from
// Concurrency. It is not a hard cap on open connections: both collectors can
// fan out at the same time, so capping would make them queue on the
// transport instead of on their own semaphore.
MaxConnsPerHost int64
Limit int64
RetryMax int64
// RetryMaxWait caps the Retry-After delay honored on 429/503 (0 = no cap).
RetryMaxWait time.Duration
// RateLimit paces outgoing requests, in requests per second (0 = disabled).
// It bounds throughput, where Concurrency bounds parallelism: the two are
// independent, and which one binds depends on how fast foreman answers.
RateLimit float64
// RateLimitBurst is the token bucket depth. 0 derives it from RateLimit.
RateLimitBurst int64
Search string
SearchHostFact string
IncludeHostFactRegex *regexp.Regexp
ExcludeHostFactRegex *regexp.Regexp
Log *logrus.Logger
}
ClientConfig holds the foreman HTTP client settings. It replaces the long positional argument list NewHTTPClient used to take, so adding a knob no longer risks silently swapping two same-typed arguments at a call site.
type ErrorResult ¶ added in v0.0.6
type HTTPClient ¶
type HTTPClient struct {
BaseURL *url.URL
Username string
Password string
Concurrency int64
Limit int64
Search string
SearchHostFact string
IncludeHostFactRegex *regexp.Regexp
ExcludeHostFactRegex *regexp.Regexp
Log *logrus.Logger
// contains filtered or unexported fields
}
func NewHTTPClient ¶
func NewHTTPClient(cfg ClientConfig) *HTTPClient
func (*HTTPClient) DoWithContext ¶
DoWithContext sends an API Request and returns back the response. The API response is checked to see if it was a successful call. A successful call is then checked to see if we need to unmarshal since some resources have their own implements of unmarshal.
func (*HTTPClient) GetHostFacts ¶
func (c *HTTPClient) GetHostFacts(ctx context.Context, hostID, page, perPage int64) (HostFactsResponse, error)
func (*HTTPClient) GetHostFactsWithConcurrency ¶
func (c *HTTPClient) GetHostFactsWithConcurrency(hosts []Host) []HostFactsWithConcurrencyResult
GetHostFactsWithConcurrency sends requests in parallel but only up to a certain limit, and furthermore it's only parallel up to the amount of CPUs but is always concurrent up to the concurrency limit
func (*HTTPClient) GetHostWithConcurrency ¶
func (c *HTTPClient) GetHostWithConcurrency(pages []int64, perPage int64) []HostWithConcurrencyResult
GetHostWithConcurrency sends requests in parallel but only up to a certain limit, and furthermore it's only parallel up to the amount of CPUs but is always concurrent up to the concurrency limit
func (*HTTPClient) GetHosts ¶
func (c *HTTPClient) GetHosts(ctx context.Context, thin string, page, perPage int64) (HostResponse, error)
func (*HTTPClient) GetHostsFactsFiltered ¶
func (*HTTPClient) GetHostsFiltered ¶
func (c *HTTPClient) GetHostsFiltered(perPage int64) ([]Host, error)
func (*HTTPClient) OnRequestCompleted ¶
func (c *HTTPClient) OnRequestCompleted(rc RequestCompletionCallback)
OnRequestCompleted sets the API request completion callback
func (*HTTPClient) SetHostsFactsRegistry ¶ added in v0.0.6
func (c *HTTPClient) SetHostsFactsRegistry(reg prometheus.Registerer)
Set hosts facts prometheus registry
func (*HTTPClient) SetHostsRegistry ¶ added in v0.0.6
func (c *HTTPClient) SetHostsRegistry(reg prometheus.Registerer)
Set hosts prometheus registry
type Host ¶
type Host struct {
ID int64 `json:"id"`
Name string `json:"name"`
GlobalStatusLabel string `json:"global_status_label,omitempty"`
ConfigurationStatusLabel string `json:"configuration_status_label,omitempty"`
BuildStatusLabel string `json:"build_status_label,omitempty"`
OrganizationName string `json:"organization_name,omitempty"`
EnvironmentName string `json:"environment_name,omitempty"`
OperatingSystemName string `json:"operatingsystem_name,omitempty"`
OwnerName string `json:"owner_name,omitempty"`
LocationName string `json:"location_name,omitempty"`
ModelName string `json:"model_name,omitempty"`
HostgroupName string `json:"hostgroup_name,omitempty"`
}
type HostFactsResponse ¶
type HostFactsWithConcurrencyResult ¶
type HostFactsWithConcurrencyResult struct {
Index int
Result HostFactsResponse
Error error
}
a struct to hold the result from each request including an index which will be used for sorting the results after they come in
type HostResponse ¶
type HostResponse struct {
Total int64 `json:"total"`
// Subtotal is how many records match the search. Foreman sets it equal to
// Total when no search is given; Total itself always counts every record,
// so paginating on Total overshoots as soon as a search filter is set. It is
// a pointer so that a search matching nothing (subtotal 0) is not mistaken
// for a foreman version that does not report the field at all.
Subtotal *int64 `json:"subtotal"`
Page int64 `json:"page"`
PerPage int64 `json:"per_page"`
Results []Host `json:"results"`
}
type HostWithConcurrencyResult ¶
type HostWithConcurrencyResult struct {
Index int
Result HostResponse
Error error
}
a struct to hold the result from each request including an index which will be used for sorting the results after they come in
type LeveledLogrus ¶
func (*LeveledLogrus) Debug ¶
func (l *LeveledLogrus) Debug(msg string, keysAndValues ...interface{})
func (*LeveledLogrus) Error ¶
func (l *LeveledLogrus) Error(msg string, keysAndValues ...interface{})
func (*LeveledLogrus) Info ¶
func (l *LeveledLogrus) Info(msg string, keysAndValues ...interface{})
func (*LeveledLogrus) Warn ¶
func (l *LeveledLogrus) Warn(msg string, keysAndValues ...interface{})