Documentation ¶
Index ¶
- 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
- func WithDefaultResolver(r Resolver)
- type MultiResolver
- type Resolver
- type SingleResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTenantIDFromHTTPRequest ¶
ExtractTenantIDFromHTTPRequest extracts a single TenantID through a given resolver directly from a HTTP request.
func JoinTenantIDs ¶ added in v1.7.0
func NormalizeTenantIDs ¶
NormalizeTenantIDs is creating a normalized form by sortiing 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 ¶ added in v1.7.0
TenantIDsFromOrgID extracts different tenants from an orgID string value
ignore stutter warning
func WithDefaultResolver ¶
func WithDefaultResolver(r Resolver)
WithDefaultResolver updates the resolver used for the package methods.
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://cortexmetrics.io/docs/guides/limitations/#tenant-id-naming)
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) }
type SingleResolver ¶
type SingleResolver struct { }
func NewSingleResolver ¶
func NewSingleResolver() *SingleResolver
NewSingleResolver creates a tenant resolver, which restricts all requests to be using a single tenant only. This allows a wider set of characters to be used within the tenant ID and should not impose a breaking change.