provider

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package provider defines Vale snapshot/config provider interfaces and helpers.

Index

Constants

View Source
const (
	EventNameConfigSourceLoaded  = "provider.config_source.loaded"
	EventNameConfigSourceFailed  = "provider.config_source.failed"
	EventNameSnapshotRecompiled  = "provider.snapshot.recompiled"
	EventNameSnapshotUnchanged   = "provider.snapshot.unchanged"
	EventNameWatchSetupFailed    = "provider.watch.setup_failed"
	EventNameConfigSourceChanged = "provider.config_source.changed"
)

Variables

This section is empty.

Functions

func AppendSortedRoutes

func AppendSortedRoutes(cfg *config.Config, routes *mapping.Map[string, config.Route])

func AppendSortedServices

func AppendSortedServices(cfg *config.Config, services *mapping.Map[string, *config.Service])

func ApplyLogger

func ApplyLogger(target any, logger *slog.Logger)

ApplyLogger injects logger when target supports LoggerAware.

func ConfigEndpoint

func ConfigEndpoint(rawURL string, weight int) config.Endpoint

func ConfigProviderName

func ConfigProviderName(provider ConfigProvider, fallback string) string

func NewEntrypointConfig

func NewEntrypointConfig(name, address string) *config.Config

func NewOnceCloser

func NewOnceCloser(closeFn func()) io.Closer

NewOnceCloser wraps a close function so it runs at most once.

func SortedStrings

func SortedStrings(values *collectionlist.List[string]) *collectionlist.List[string]

SortedStrings returns a sorted copy of values.

func SplitCSV

func SplitCSV(value string) *collectionlist.List[string]

func StripTraefikProviderNamespace

func StripTraefikProviderNamespace(name string) string

StripTraefikProviderNamespace strips a Traefik provider suffix such as "auth@docker".

Types

type ConfigBuilder

type ConfigBuilder struct {
	// contains filtered or unexported fields
}

func NewConfigBuilder

func NewConfigBuilder() *ConfigBuilder

func (*ConfigBuilder) Admin

func (b *ConfigBuilder) Admin(address string) *ConfigBuilder

func (*ConfigBuilder) Build

func (b *ConfigBuilder) Build() *config.Config

func (*ConfigBuilder) BuildValidated

func (b *ConfigBuilder) BuildValidated() (*config.Config, error)

func (*ConfigBuilder) Entrypoint

func (b *ConfigBuilder) Entrypoint(name, address string, options ...EntrypointOption) *ConfigBuilder

func (*ConfigBuilder) Errors

func (b *ConfigBuilder) Errors() *collectionlist.List[error]

func (*ConfigBuilder) Health

func (b *ConfigBuilder) Health(interval, timeout string) *ConfigBuilder

func (*ConfigBuilder) Middleware

func (b *ConfigBuilder) Middleware(middleware config.Middleware) *ConfigBuilder

func (*ConfigBuilder) MiddlewareNamed

func (b *ConfigBuilder) MiddlewareNamed(name string, options ...MiddlewareOption) *ConfigBuilder

func (*ConfigBuilder) Observability

func (b *ConfigBuilder) Observability(accessLog, metrics bool) *ConfigBuilder

func (*ConfigBuilder) Route

func (b *ConfigBuilder) Route(route config.Route) *ConfigBuilder

func (*ConfigBuilder) RouteTo

func (b *ConfigBuilder) RouteTo(name, entrypoint, service string, options ...RouteOption) *ConfigBuilder

func (*ConfigBuilder) Security

func (b *ConfigBuilder) Security(security config.Security) *ConfigBuilder

func (*ConfigBuilder) Service

func (b *ConfigBuilder) Service(name, endpointURL string) *ConfigBuilder

func (*ConfigBuilder) ServiceWithEndpoints

func (b *ConfigBuilder) ServiceWithEndpoints(name string, endpoints ...config.Endpoint) *ConfigBuilder

func (*ConfigBuilder) ServiceWithStrategy

func (b *ConfigBuilder) ServiceWithStrategy(name, strategy string, endpoints ...config.Endpoint) *ConfigBuilder

type ConfigProvider

type ConfigProvider interface {
	Load(context.Context) (*config.Config, error)
	Watch(context.Context, func(), func(error)) (io.Closer, error)
}

type ConfigProviderFactory

type ConfigProviderFactory func(context.Context, ProviderSpec) (ConfigProvider, error)

type ConfigProviderRegistry

type ConfigProviderRegistry struct {
	// contains filtered or unexported fields
}

func NewConfigProviderRegistry

func NewConfigProviderRegistry() *ConfigProviderRegistry

func (*ConfigProviderRegistry) Clone

func (*ConfigProviderRegistry) Create

func (*ConfigProviderRegistry) Factory

func (r *ConfigProviderRegistry) Factory(providerType string) (ConfigProviderFactory, bool)

func (*ConfigProviderRegistry) Names

func (*ConfigProviderRegistry) Register

func (r *ConfigProviderRegistry) Register(providerType string, factory ConfigProviderFactory) error

type ConfigSourceChangedEvent

type ConfigSourceChangedEvent struct {
	Source string
}

func (ConfigSourceChangedEvent) Name

type ConfigSourceFailedEvent

type ConfigSourceFailedEvent struct {
	Source string
	Error  string
}

func (ConfigSourceFailedEvent) Name

type ConfigSourceLoadedEvent

type ConfigSourceLoadedEvent struct {
	Source     string
	Duration   time.Duration
	ConfigSize int
}

func (ConfigSourceLoadedEvent) Name

type EntrypointOption

type EntrypointOption func(*config.Entrypoint)

func EntrypointACME

func EntrypointACME(email, cacheDir string, domains ...string) EntrypointOption

func EntrypointTLS

func EntrypointTLS(certFile, keyFile string) EntrypointOption

type Event

type Event = eventx.Event

type EventBus

type EventBus = eventx.BusRuntime

type LoggerAware

type LoggerAware interface {
	SetLogger(*slog.Logger)
}

LoggerAware marks components that can receive the gateway-level logger.

type MiddlewareOption

type MiddlewareOption func(*config.Middleware)

func MiddlewareAddPrefix

func MiddlewareAddPrefix(pathPrefix string) MiddlewareOption

func MiddlewareBasicAuth added in v0.1.1

func MiddlewareBasicAuth(realm string, users map[string]string) MiddlewareOption

func MiddlewareChain

func MiddlewareChain(names ...string) MiddlewareOption

func MiddlewareCompress added in v0.1.1

func MiddlewareCompress(minBytes int) MiddlewareOption

func MiddlewareIPAllowList added in v0.1.1

func MiddlewareIPAllowList(trustForwardHeader bool, sourceRange ...string) MiddlewareOption

func MiddlewareMaxBodyBytes

func MiddlewareMaxBodyBytes(maxBodyBytes int64) MiddlewareOption

func MiddlewareRedirectRegex

func MiddlewareRedirectRegex(pattern, replacement string, permanent bool) MiddlewareOption

func MiddlewareRedirectScheme

func MiddlewareRedirectScheme(scheme, port string, permanent bool) MiddlewareOption

func MiddlewareReplacePath

func MiddlewareReplacePath(path string) MiddlewareOption

func MiddlewareReplacePathRegex

func MiddlewareReplacePathRegex(pattern, replacement string) MiddlewareOption

func MiddlewareRequestHeader

func MiddlewareRequestHeader(key, value string) MiddlewareOption

func MiddlewareResponseHeader

func MiddlewareResponseHeader(key, value string) MiddlewareOption

func MiddlewareStripPrefix

func MiddlewareStripPrefix(pathPrefix string) MiddlewareOption

func MiddlewareStripPrefixes

func MiddlewareStripPrefixes(pathPrefixes ...string) MiddlewareOption

func MiddlewareType

func MiddlewareType(middlewareType string) MiddlewareOption

type MultiCloser

type MultiCloser struct {
	// contains filtered or unexported fields
}

MultiCloser closes a group of resources and returns the first close error.

func NewMultiCloser

func NewMultiCloser(closers *collectionlist.List[io.Closer]) MultiCloser

func NewMultiCloserFrom

func NewMultiCloserFrom(closers ...io.Closer) MultiCloser

func (MultiCloser) Close

func (m MultiCloser) Close() error

type Named

type Named interface {
	Name() string
}

type NopCloser

type NopCloser struct{}

NopCloser is an io.Closer that does nothing.

func (NopCloser) Close

func (NopCloser) Close() error

type ProviderSpec

type ProviderSpec struct {
	Name     string
	Type     string
	Settings *mapping.Map[string, string]
}

func NewProviderSpec

func NewProviderSpec(providerType string) ProviderSpec

func (ProviderSpec) Setting

func (s ProviderSpec) Setting(key string) (string, bool)

func (ProviderSpec) WithName

func (s ProviderSpec) WithName(name string) ProviderSpec

func (ProviderSpec) WithSetting

func (s ProviderSpec) WithSetting(key, value string) ProviderSpec

type RouteOption

type RouteOption func(*config.Route)

func RouteHeader

func RouteHeader(key, value string) RouteOption

func RouteHost

func RouteHost(host string) RouteOption

func RouteMethod

func RouteMethod(method string) RouteOption

func RouteMiddlewares

func RouteMiddlewares(names ...string) RouteOption

func RoutePathPrefix

func RoutePathPrefix(pathPrefix string) RouteOption

type SnapshotProvider

type SnapshotProvider interface {
	Load(context.Context) (*runtime.CompiledSnapshot, error)
	Watch(context.Context, func(*runtime.CompiledSnapshot), func(error)) (io.Closer, error)
}

func Fallback

func Fallback(providers ...SnapshotProvider) SnapshotProvider

func FallbackList

func FallbackList(providers *collectionlist.List[SnapshotProvider]) SnapshotProvider

type SnapshotProviderFactory

type SnapshotProviderFactory func(context.Context, ProviderSpec) (SnapshotProvider, error)

type SnapshotProviderRegistry

type SnapshotProviderRegistry struct {
	// contains filtered or unexported fields
}

func NewSnapshotProviderRegistry

func NewSnapshotProviderRegistry() *SnapshotProviderRegistry

func (*SnapshotProviderRegistry) Clone

func (*SnapshotProviderRegistry) Create

func (*SnapshotProviderRegistry) Factory

func (r *SnapshotProviderRegistry) Factory(providerType string) (SnapshotProviderFactory, bool)

func (*SnapshotProviderRegistry) Names

func (*SnapshotProviderRegistry) Register

func (r *SnapshotProviderRegistry) Register(providerType string, factory SnapshotProviderFactory) error

type SnapshotRecompiledEvent

type SnapshotRecompiledEvent struct {
	SourceCount  int
	RouteCount   int
	ServiceCount int
	Fingerprint  string
}

func (SnapshotRecompiledEvent) Name

type SnapshotUnchangedEvent

type SnapshotUnchangedEvent struct {
	Source      string
	Fingerprint string
}

func (SnapshotUnchangedEvent) Name

func (e SnapshotUnchangedEvent) Name() string

type TraefikLabels

type TraefikLabels struct {
	Enabled     mo.Option[bool]
	Routers     *mapping.Map[string, TraefikRouter]
	Services    *mapping.Map[string, TraefikService]
	Middlewares *mapping.Map[string, config.Middleware]
}

TraefikLabels is the normalized subset of Traefik HTTP dynamic labels Vale can project.

func NewTraefikLabels

func NewTraefikLabels() TraefikLabels

NewTraefikLabels returns an empty Traefik label projection.

func ParseTraefikLabels

func ParseTraefikLabels(labels *mapping.Map[string, string]) TraefikLabels

ParseTraefikLabels parses Traefik-compatible HTTP labels.

func (TraefikLabels) HasHTTPConfig

func (labels TraefikLabels) HasHTTPConfig() bool

HasHTTPConfig reports whether the labels define Traefik HTTP routing resources.

type TraefikRouter

type TraefikRouter struct {
	Name        string
	Rule        string
	Entrypoints *collectionlist.List[string]
	Middlewares *collectionlist.List[string]
	Service     string
	Host        string
	PathPrefix  string
	Method      string
	Headers     *mapping.Map[string, string]
}

TraefikRouter contains router labels projected into Vale's HTTP route model.

type TraefikService

type TraefikService struct {
	Name   string
	Port   int
	Scheme string
}

TraefikService contains load balancer labels projected into Vale services.

type WatchHub added in v0.1.1

type WatchHub struct {
	// contains filtered or unexported fields
}

func NewWatchHub added in v0.1.1

func NewWatchHub() *WatchHub

func (*WatchHub) Notify added in v0.1.1

func (h *WatchHub) Notify()

func (*WatchHub) Watch added in v0.1.1

func (h *WatchHub) Watch(onReload func()) io.Closer

type WatchSetupFailedEvent

type WatchSetupFailedEvent struct {
	Source string
	Error  string
}

func (WatchSetupFailedEvent) Name

func (e WatchSetupFailedEvent) Name() string

Directories

Path Synopsis
docker module
file module
fileconfig module
k8s module
Package memoryconfig provides an in-memory mutable config provider.
Package memoryconfig provides an in-memory mutable config provider.
Package merged merges multiple config providers into one runtime provider.
Package merged merges multiple config providers into one runtime provider.
Package static provides an immutable runtime snapshot provider.
Package static provides an immutable runtime snapshot provider.
Package staticconfig provides an immutable declarative config provider.
Package staticconfig provides an immutable declarative config provider.

Jump to

Keyboard shortcuts

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