quotakeys

package
v0.0.0-...-5fcb699 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package quotakeys has utility functions for generating internal quota Redis keys.

Index

Constants

View Source
const (
	// ASIFieldDelim is used to delimit sections within Application Specific
	// Identifiers (ASIs).
	//
	// NOTE: this is ascii85-safe.
	ASIFieldDelim = "|"

	// EncodedSectionPrefix is the prefix used for ASI sections which are nominally
	// encoded with ascii85.
	//
	// NOTE: this is ascii85-safe.
	EncodedSectionPrefix = "{"

	// EscapedCharacters is the set of characters which are reserved within
	// Application-specific-identifiers (ASIs) and will cause the ASI section to be
	// escaped with ascii85.
	//
	// We also encode ASI sections which start with `EncodedSectionPrefix`.
	EscapedCharacters = QuotaFieldDelim + ASIFieldDelim
)
View Source
const (
	// QuotaFieldDelim is used to delimit sections of keys which are user provided values.
	//
	// NOTE: this is ascii85-safe.
	QuotaFieldDelim = "~"
)

Variables

This section is empty.

Functions

func AccountKey

func AccountKey(id *quotapb.AccountID) string

AccountKey returns the full redis key for an account.

func AssembleASI

func AssembleASI(sections ...string) string

AssembleASI will return an ASI with the given sections.

Sections are assembled with a "|" separator verbatim, unless the section contains a "|", "~" or begins with "{". In this case the section will be encoded with ascii85 and inserted to the final string with a "{" prefix character.

func DecodeASI

func DecodeASI(asi string) ([]string, error)

DecodeASI will return the sections within an ASI, decoding any which appear to be ascii85-encoded.

If a section has the ascii85 prefix, but doesn't correctly decode, this returns an error.

func ParseAccountKey

func ParseAccountKey(key string) (*quotapb.AccountID, error)

ParseAccountKey parses a raw key string and extracts a AccountID from it (or returns an error).

func ParsePolicyConfigID

func ParsePolicyConfigID(policyConfigID string) (*quotapb.PolicyConfigID, error)

ParsePolicyConfigID parses a raw key string and extracts a PolicyConfigID from it (or returns an error).

func ParsePolicyKey

func ParsePolicyKey(policyKey string) (*quotapb.PolicyKey, error)

ParsePolicyKey parses a raw key string and extracts a PolicyKey from it (or returns an error).

func ParsePolicyRef

func ParsePolicyRef(ref *quotapb.PolicyRef) (ret *quotapb.PolicyID, err error)

ParsePolicyRef parses a raw PolicyRef and extracts a PolicyID from it (or returns an error).

func ParseRequestDedupKey

func ParseRequestDedupKey(key string) (*quotapb.RequestDedupKey, error)

ParseRequestDedupKey parses a raw key string and extracts the userID and requestID from the request key.

func PolicyConfigID

func PolicyConfigID(id *quotapb.PolicyConfigID) string

PolicyConfigID returns a full redis key for the given PolicyConfigID.

`id` must already be validated, or this could panic.

func PolicyKey

func PolicyKey(id *quotapb.PolicyKey) string

PolicyKey returns a full redis key for the given PolicyKey.

`id` must already be validated, or this could panic.

func PolicyRef

func PolicyRef(id *quotapb.PolicyID) *quotapb.PolicyRef

PolicyRef returns a PolicyRef for the given PolicyID.

`id` must already be validated, or this could panic.

func RequestDedupKey

func RequestDedupKey(id *quotapb.RequestDedupKey) string

RequestDedupKey returns the full redis key for a request dedup entry.

Args:

  • userID is the luci auth identity of the requestor.
  • requestID is the user's provided requestID.

Example (`RequestDedupKey("user:user@example.com", "something")`):

"a~r~user:user@example.com~something

Returns a request deduplication key.

None of the arguments may contain "~".

Types

This section is empty.

Jump to

Keyboard shortcuts

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