valvidaabs

package
v1.70.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IRatelimService

type IRatelimService interface {
	HitAndCheck(
		PRA []string,

		key string,

		xMultiplier float64,

	) (
		result *Result,
		err error,
	)
}

type Result

type Result struct {
	// The main result
	Allow bool

	// 0% = fresh, 100% = full load
	// Can be used on client side, to determine the delay, to slow down the rate even before we hit the limit
	SaturationPerc float64

	// just a flag, for metrics
	// Can be used on client side to report _why_ the request failed - because of throttling, or because of fail-to-ban
	BannedByFailToBan bool

	// The time, during which any new requests are guaranteed to fail. This happens when the bucket overflows,
	// or the F2B goes to banned state.
	// This can be used on client side, to avoid excessive RPCs, when it can know for sure they'll fail.
	RetryAfter time.Duration

	PRANotFound bool

	// can return a textual error message, explaining "why" not allowed, e.g. to report to logs or user
	Why string

	// can be used to re-route to another PRA (redirect)
	RedirectPRA []string
}

Jump to

Keyboard shortcuts

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