consul

package
v0.0.0-...-f179113 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package consul contains types and utilities for updating data from Consul.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowlistUpdater

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

AllowlistUpdater is a wrapper that updates the allowlist on refresh. It should be initially refreshed before use.

func NewAllowlistUpdater

func NewAllowlistUpdater(c *AllowlistUpdaterConfig) (upd *AllowlistUpdater)

NewAllowlistUpdater returns a properly initialized *AllowlistUpdater. c must not be nil.

func (*AllowlistUpdater) Refresh

func (upd *AllowlistUpdater) Refresh(ctx context.Context) (err error)

Refresh implements the agdservice.Refresher interface for *AllowlistUpdater.

type AllowlistUpdaterConfig

type AllowlistUpdaterConfig struct {
	// Logger is used for logging the operation of the allowlist updater.
	Logger *slog.Logger

	// Allowlist is the allowlist to update.
	Allowlist *ratelimit.DynamicAllowlist

	// ConsulURL is the URL from which to update Allowlist.
	ConsulURL *url.URL

	// ErrColl is used to collect errors during refreshes.
	ErrColl errcoll.Interface

	// Metrics is used to collect allowlist statistics.
	Metrics Metrics

	// Timeout is the timeout for Consul queries.
	Timeout time.Duration
}

AllowlistUpdaterConfig is the configuration structure for the allowlist updater. All fields must not be nil.

type EmptyMetrics

type EmptyMetrics struct{}

EmptyMetrics is the implementation of the Metrics interface that does nothing.

func (EmptyMetrics) SetSize

func (EmptyMetrics) SetSize(_ context.Context, _ int)

SetSize implements the Metrics interface for EmptyMetrics.

func (EmptyMetrics) SetStatus

func (EmptyMetrics) SetStatus(_ context.Context, _ error)

SetStatus plements the Metrics interface for EmptyMetrics.

type Metrics

type Metrics interface {
	// SetSize sets the number of received subnets.
	SetSize(ctx context.Context, n int)

	// SetStatus sets the status and time of the allowlist refresh attempt.
	SetStatus(ctx context.Context, err error)
}

Metrics is an interface that is used for the collection of the allowlist statistics.

Jump to

Keyboard shortcuts

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