frontend

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package frontend contains provides a frontend service for ingest limits. It is responsible for receiving and answering gRPC requests from distributors, such as exceeds limits requests, forwarding them to individual limits backends, gathering and aggregating their responses (where required), and returning the final result.

Index

Constants

View Source
const (
	// ReasonExceedsMaxStreams is returned when a tenant exceeds the maximum
	// number of active streams as per their per-tenant limit.
	ReasonExceedsMaxStreams = "exceeds_max_streams"

	// ReasonExceedsRateLimit is returned when a tenant exceeds their maximum
	// rate limit as per their per-tenant limit.
	ReasonExceedsRateLimit = "exceeds_rate_limit"
)
View Source
const (
	RingKey  = "ingest-limits-frontend"
	RingName = "ingest-limits-frontend"
)

Variables

View Source
var (
	LimitsRead = ring.NewOp([]ring.InstanceState{ring.ACTIVE}, nil)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	ClientConfig     limits_client.Config  `yaml:"client_config"`
	LifecyclerConfig ring.LifecyclerConfig `yaml:"lifecycler,omitempty"`
	RecheckPeriod    time.Duration         `yaml:"recheck_period"`
}

Config contains the config for an ingest-limits-frontend.

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

func (*Config) Validate

func (cfg *Config) Validate() error

type Frontend

type Frontend struct {
	services.Service
	// contains filtered or unexported fields
}

Frontend is the limits-frontend service, and acts a service wrapper for all components needed to run the limits-frontend.

func New

func New(cfg Config, ringName string, limitsRing ring.ReadRing, limits Limits, logger log.Logger, reg prometheus.Registerer) (*Frontend, error)

New returns a new Frontend.

func (*Frontend) CheckReady

func (f *Frontend) CheckReady(ctx context.Context) error

func (*Frontend) ExceedsLimits

ExceedsLimits implements logproto.IngestLimitsFrontendClient.

func (*Frontend) Flush

func (f *Frontend) Flush()

Flush implements ring.FlushTransferer. It transfers state to another ingest limits frontend instance.

func (*Frontend) ServeHTTP

func (f *Frontend) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

func (*Frontend) TransferOut

func (f *Frontend) TransferOut(_ context.Context) error

TransferOut implements ring.FlushTransferer. It transfers state to another ingest limits frontend instance.

type GetStreamUsageRequest

type GetStreamUsageRequest struct {
	Tenant       string
	StreamHashes []uint64
}

type GetStreamUsageResponse

type GetStreamUsageResponse struct {
	Addr     string
	Response *logproto.GetStreamUsageResponse
}

type Limits

type Limits interface {
	IngestionRateBytes(userID string) float64
	IngestionBurstSizeBytes(userID string) int
	MaxGlobalStreamsPerUser(userID string) int
}

Limits contains all limits enforced by the limits frontend.

type RingStreamUsageGatherer

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

RingStreamUsageGatherer implements StreamUsageGatherer. It uses a ring to find limits instances.

func NewRingStreamUsageGatherer

func NewRingStreamUsageGatherer(ring ring.ReadRing, pool *ring_client.Pool, logger log.Logger) *RingStreamUsageGatherer

NewRingStreamUsageGatherer returns a new RingStreamUsageGatherer.

func (*RingStreamUsageGatherer) GetStreamUsage

GetStreamUsage implements StreamUsageGatherer.

type StreamUsageGatherer

type StreamUsageGatherer interface {
	// GetStreamUsage returns the current usage data for the stream hashes
	// in the request. It returns multiple responses if the usage data for
	// the requested stream hashes is partitioned over a number of limits
	// instances.
	GetStreamUsage(context.Context, GetStreamUsageRequest) ([]GetStreamUsageResponse, error)
}

Directories

Path Synopsis
Package client provides gRPC client implementation for limits-frontend.
Package client provides gRPC client implementation for limits-frontend.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳