tenancy

package
v1.46.0-tgt.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlags

func AddFlags(flags *flag.FlagSet)

AddFlags adds flags for tenancy to the FlagSet.

func ExtractTenantHTTPHandler

func ExtractTenantHTTPHandler(tc *Manager, h http.Handler) http.Handler

PropagationHandler returns a http.Handler containing the logic to extract the tenancy header of the http.Request and insert the tenant into request.Context for propagation. The token can be accessed via tenancy.GetTenant().

func GetTenant

func GetTenant(ctx context.Context) string

GetTenant retrieves a tenant associated with a Context

func NewClientStreamInterceptor

func NewClientStreamInterceptor(tc *Manager) grpc.StreamClientInterceptor

NewClientStreamInterceptor injects tenant header into gRPC request metadata.

func NewClientUnaryInterceptor

func NewClientUnaryInterceptor(tc *Manager) grpc.UnaryClientInterceptor

NewClientUnaryInterceptor injects tenant header into gRPC request metadata.

func NewGuardingStreamInterceptor

func NewGuardingStreamInterceptor(tc *Manager) grpc.StreamServerInterceptor

NewGuardingStreamInterceptor blocks handling of streams whose tenancy header doesn't meet tenancy requirements. It also ensures the tenant is directly in the context, rather than context metadata.

func NewGuardingUnaryInterceptor

func NewGuardingUnaryInterceptor(tc *Manager) grpc.UnaryServerInterceptor

NewGuardingUnaryInterceptor blocks handling of RPCs whose tenancy header doesn't meet tenancy requirements. It also ensures the tenant is directly in the context, rather than context metadata.

func WithTenant

func WithTenant(ctx context.Context, tenant string) context.Context

WithTenant creates a Context with a tenant association

Types

type Manager

type Manager struct {
	Enabled bool
	Header  string
	// contains filtered or unexported fields
}

Manager can check tenant usage for multi-tenant Jaeger configurations

func NewManager

func NewManager(options *Options) *Manager

NewManager creates a tenancy.Manager for given tenancy.Options.

func (*Manager) MetadataAnnotator

func (tc *Manager) MetadataAnnotator() func(context.Context, *http.Request) metadata.MD

MetadataAnnotator returns a function suitable for propagating tenancy via github.com/grpc-ecosystem/grpc-gateway/runtime.NewServeMux

func (*Manager) Valid

func (tc *Manager) Valid(tenant string) bool

type Options

type Options struct {
	Enabled bool
	Header  string
	Tenants []string
}

Options describes the configuration properties for multitenancy

func InitFromViper

func InitFromViper(v *viper.Viper) Options

InitFromViper creates tenancy.Options populated with values retrieved from Viper.

Jump to

Keyboard shortcuts

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