shared

package
v1.2.13-prerelease11 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package shared holds some types that are used between multiple global-ratelimiter packages, and need to be broken out to prevent import cycles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GlobalKey

type GlobalKey string // GlobalKey represents a "global" / globally unique ratelimit key (i.e. namespaced by collection)

type KeyMapper

type KeyMapper interface {
	LocalToGlobal(key LocalKey) GlobalKey
	// GlobalToLocal does the reverse of LocalToGlobal.
	//
	// An error will be returned if the global key does not seem to have
	// come from this mapper.
	GlobalToLocal(key GlobalKey) (LocalKey, error)
}

KeyMapper is used to ensure that all keys that get communicated to aggregators are uniquely identifiable, when multiple collections are used.

A unique prefix / pattern per collection should be sufficient.

func PrefixKey

func PrefixKey(prefix string) KeyMapper

PrefixKey builds a KeyMapper that simply adds (or removes) a fixed prefix to all keys. If the global key does not have this prefix, an error will be returned when mapping to local.

type LocalKey

type LocalKey string // LocalKey represents a "local" / unique to this collection ratelimit key

Jump to

Keyboard shortcuts

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