ratelimit

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package ratelimit provides tools to work with rate limits imposed by Sentry's data ingestion pipeline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category string

Category classifies supported payload types that can be ingested by Sentry and, therefore, rate limited.

const (
	CategoryAll         Category = ""
	CategoryError       Category = "error"
	CategoryTransaction Category = "transaction"
)

Known rate limit categories. As a special case, the CategoryAll applies to all known payload types.

func (Category) String

func (c Category) String() string

String returns the category formatted for debugging.

type Deadline

type Deadline time.Time

A Deadline is a time instant when a rate limit expires.

func (Deadline) After

func (d Deadline) After(other Deadline) bool

After reports whether the deadline d is after other.

func (Deadline) Equal

func (d Deadline) Equal(e Deadline) bool

Equal reports whether d and e represent the same deadline.

func (Deadline) String

func (d Deadline) String() string

String returns the deadline formatted for debugging.

type Map

type Map map[Category]Deadline

Map maps categories to rate limit deadlines.

A rate limit is in effect for a given category if either the category's deadline or the deadline for the special CategoryAll has not yet expired.

Use IsRateLimited to check whether a category is rate-limited.

func FromResponse

func FromResponse(r *http.Response) Map

FromResponse returns a rate limit map from an HTTP response.

func (Map) Deadline

func (m Map) Deadline(c Category) Deadline

Deadline returns the deadline when the rate limit for the given category or the special CategoryAll expire, whichever is furthest into the future.

func (Map) IsRateLimited

func (m Map) IsRateLimited(c Category) bool

IsRateLimited returns true if the category is currently rate limited.

func (Map) Merge

func (m Map) Merge(other Map)

Merge merges the other map into m.

If a category appears in both maps, the deadline that is furthest into the future is preserved.

Jump to

Keyboard shortcuts

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