Documentation ¶
Index ¶
- Constants
- func ExtractTenantIDFromHTTPRequest(req *http.Request) (string, context.Context, error)
- func JoinTenantIDs(tenantIDs []string) string
- func NormalizeTenantIDs(tenantIDs []string) []string
- func TenantID(ctx context.Context) (string, error)
- func TenantIDs(ctx context.Context) ([]string, error)
- func TenantIDsFromOrgID(orgID string) ([]string, error)
- func ValidTenantID(s string) error
- type MultiResolver
- type Resolver
Constants ¶
const (
// MaxTenantIDLength is the max length of single tenant ID in bytes
MaxTenantIDLength = 150
)
Variables ¶
This section is empty.
Functions ¶
func ExtractTenantIDFromHTTPRequest ¶
ExtractTenantIDFromHTTPRequest extracts a single tenant ID directly from a HTTP request.
func JoinTenantIDs ¶
JoinTenantIDs returns all tenant IDs concatenated with the separator character `|`
func NormalizeTenantIDs ¶
NormalizeTenantIDs creates a normalized form by sorting and de-duplicating the list of tenantIDs
func TenantID ¶
TenantID returns exactly a single tenant ID from the context. It should be used when a certain endpoint should only support exactly a single tenant ID. It returns an error user.ErrNoOrgID if there is no tenant ID supplied or user.ErrTooManyOrgIDs if there are multiple tenant IDs present.
ignore stutter warning
func TenantIDs ¶
TenantIDs returns all tenant IDs from the context. It should return normalized list of ordered and distinct tenant IDs (as produced by NormalizeTenantIDs).
ignore stutter warning
func TenantIDsFromOrgID ¶
TenantIDsFromOrgID extracts different tenants from an orgID string value
ignore stutter warning
func ValidTenantID ¶
ValidTenantID returns an error if the single tenant ID is invalid, nil otherwise
Types ¶
type MultiResolver ¶
type MultiResolver struct{}
func NewMultiResolver ¶
func NewMultiResolver() *MultiResolver
NewMultiResolver creates a tenant resolver, which allows request to have multiple tenant ids submitted separated by a '|' character. This enforces further limits on the character set allowed within tenants as detailed here: https://grafana.com/docs/mimir/latest/configure/about-tenant-ids/
type Resolver ¶
type Resolver interface { // TenantID returns exactly a single tenant ID from the context. It should be // used when a certain endpoint should only support exactly a single // tenant ID. It returns an error user.ErrNoOrgID if there is no tenant ID // supplied or user.ErrTooManyOrgIDs if there are multiple tenant IDs present. TenantID(context.Context) (string, error) // TenantIDs returns all tenant IDs from the context. It should return // normalized list of ordered and distinct tenant IDs (as produced by // NormalizeTenantIDs). TenantIDs(context.Context) ([]string, error) }