Documentation ¶
Overview ¶
Package quotakeys has utility functions for generating internal quota Redis keys.
Index ¶
- Constants
- func AccountKey(id *quotapb.AccountID) string
- func AssembleASI(sections ...string) string
- func DecodeASI(asi string) ([]string, error)
- func ParseAccountKey(key string) (*quotapb.AccountID, error)
- func ParsePolicyConfigID(policyConfigID string) (*quotapb.PolicyConfigID, error)
- func ParsePolicyKey(policyKey string) (*quotapb.PolicyKey, error)
- func ParsePolicyRef(ref *quotapb.PolicyRef) (ret *quotapb.PolicyID, err error)
- func ParseRequestDedupKey(key string) (*quotapb.RequestDedupKey, error)
- func PolicyConfigID(id *quotapb.PolicyConfigID) string
- func PolicyKey(id *quotapb.PolicyKey) string
- func PolicyRef(id *quotapb.PolicyID) *quotapb.PolicyRef
- func RequestDedupKey(id *quotapb.RequestDedupKey) string
Constants ¶
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 )
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 ¶
AccountKey returns the full redis key for an account.
func AssembleASI ¶
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 ¶
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 ¶
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 ¶
ParsePolicyKey parses a raw key string and extracts a PolicyKey from it (or returns an error).
func ParsePolicyRef ¶
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 ¶
PolicyKey returns a full redis key for the given PolicyKey.
`id` must already be validated, or this could panic.
func 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.