http

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

README

HTTP Data Source

The HTTP Data Source is a base implementation for data layer sources that retrieve data via HTTP/HTTPS. It is designed to be embedded or used by specific data source plugins to handle the mechanics of HTTP polling and parsing.

Features

  • Supports both http and https schemes.
  • Configurable TLS certificate verification (skip verification).
  • Pluggable response parsers.
  • Directly polls endpoints based on their addressable metadata.

Usage in Other Plugins

The metrics-data-source uses HTTPDataSource as its underlying implementation, providing it with a Prometheus-specific parser.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExtractorTypeMismatch = errors.New("extractor type mismatch")

Functions

This section is empty.

Types

type Addressable

type Addressable interface {
	GetIPAddress() string
	GetPort() string
	GetMetricsHost() string
	GetNamespacedName() types.NamespacedName
}

Addressable supports getting an IP address and a namespaced name.

type Client

type Client interface {
	Get(ctx context.Context, target *url.URL, ep Addressable, parser func(io.Reader) (any, error)) (any, error)
}

Client is an interface for retrieving the data from an endpoint URL.

type HTTPDataSource

type HTTPDataSource[T any] struct {
	// contains filtered or unexported fields
}

HTTPDataSource is a typed polling dispatcher. T is the data type the source produces; bound extractors must implement Extractor[PollInput[T]].

func NewHTTPDataSource

func NewHTTPDataSource[T any](scheme, path string, skipCertVerification bool,
	pluginType, pluginName string, parser func(io.Reader) (T, error)) (*HTTPDataSource[T], error)

NewHTTPDataSource constructs a typed polling dispatcher.

func (*HTTPDataSource[T]) AppendExtractor

func (s *HTTPDataSource[T]) AppendExtractor(ext fwkplugin.Plugin) error

AppendExtractor binds ext as a typed PollingExtractor[T]. Duplicate-Type detection is the caller's responsibility (see runtime.Configure); this is a pure append.

func (*HTTPDataSource[T]) Dispatch

func (s *HTTPDataSource[T]) Dispatch(ctx context.Context, ep fwkdl.Endpoint) error

Dispatch polls the endpoint and fans the result out to every bound extractor. Each step (Poll and each Extract) runs under its own defaultStepTimeout so one slow extractor does not starve siblings.

Return contract: a non-nil return indicates a poll-level failure (the dispatcher could not produce data). Per-extractor failures are recorded in DataLayerExtractErrorsTotal and do NOT surface as a returned error. This keeps the collector's poll/extract counters cleanly separated.

func (*HTTPDataSource[T]) Poll

func (s *HTTPDataSource[T]) Poll(ctx context.Context, ep fwkdl.Endpoint) (T, error)

Poll fetches and parses one tick. Exposed for tests; runtime uses Dispatch.

func (*HTTPDataSource[T]) TypedName

func (s *HTTPDataSource[T]) TypedName() fwkplugin.TypedName

Directories

Path Synopsis
Package httptest provides test helpers for HTTPDataSource parser implementations.
Package httptest provides test helpers for HTTPDataSource parser implementations.

Jump to

Keyboard shortcuts

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