tenancy

package
v0.14.0 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: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CachePropertiesPrefix = "security.cache"
View Source
const IsChildrenOfPredict = "is-children-of"
View Source
const IsParentOfPredict = "is-parent-of"
View Source
const RedisZsetMaxByte = "\uffff"
View Source
const RootTenantKey = "root-tenant-id"
View Source
const STATUS_FAILED_TO_LOAD_ROOT_TENANT = "FAILED_TO_LOAD_ROOT_TENANT"
View Source
const STATUS_IN_PROGRESS = "IN_PROGRESS"
View Source
const STATUS_LOADED = "LOADED"
View Source
const StatusKey = "tenant-hierarchy-status"
View Source
const ZsetKey = "tenant-hierarchy"

Variables

View Source
var Module = &bootstrap.Module{
	Name:       "tenant-hierarchy",
	Precedence: bootstrap.TenantHierarchyAccessorPrecedence,
	Options: []fx.Option{
		fx.Provide(bindCacheProperties),
		fx.Provide(defaultTenancyAccessorProvider()),
		fx.Invoke(setup),
	},
}

Functions

func AnyHasDescendant

func AnyHasDescendant(ctx context.Context, tenantIDs utils.StringSet, descendant string) bool

AnyHasDescendant returns true if any of "tenantIDs" in utils.StringSet contains "descendant" or its ancestors

func BuildSpsString

func BuildSpsString(subject string, predict string, object ...string) string

func GetAncestors

func GetAncestors(ctx context.Context, tenantId string) ([]string, error)

func GetChildren

func GetChildren(ctx context.Context, tenantId string) ([]string, error)

func GetDescendants

func GetDescendants(ctx context.Context, tenantId string) ([]string, error)

func GetObjectOfSpo

func GetObjectOfSpo(spo string) (string, error)

func GetParent

func GetParent(ctx context.Context, tenantId string) (string, error)

func GetRoot

func GetRoot(ctx context.Context) (string, error)

GetRoot because root tenantId won't change once system is started, we can cache it after first successful read.

func GetTenancyPath

func GetTenancyPath(ctx context.Context, tenantId string) ([]uuid.UUID, error)

func IsLoaded

func IsLoaded(ctx context.Context) bool

IsLoaded returns if tenancy information is available. Note that callers normally don't need to check this flag directly. Other top-level functions Get...() returns error if not loaded

func Use

func Use()

func ZInclusive

func ZInclusive(min string) string

Types

type Accessor

type Accessor interface {
	GetParent(ctx context.Context, tenantId string) (string, error)
	GetChildren(ctx context.Context, tenantId string) ([]string, error)
	GetAncestors(ctx context.Context, tenantId string) ([]string, error)
	GetDescendants(ctx context.Context, tenantId string) ([]string, error)
	GetRoot(ctx context.Context) (string, error)
	IsLoaded(ctx context.Context) bool
	GetTenancyPath(ctx context.Context, tenantId string) ([]uuid.UUID, error)
}

type CacheProperties

type CacheProperties struct {
	DbIndex int `json:"db-index"`
}

type TenancyAccessor

type TenancyAccessor struct {
	// contains filtered or unexported fields
}

func (*TenancyAccessor) GetAncestors

func (a *TenancyAccessor) GetAncestors(ctx context.Context, tenantId string) ([]string, error)

func (*TenancyAccessor) GetChildren

func (a *TenancyAccessor) GetChildren(ctx context.Context, tenantId string) ([]string, error)

func (*TenancyAccessor) GetDescendants

func (a *TenancyAccessor) GetDescendants(ctx context.Context, tenantId string) ([]string, error)

func (*TenancyAccessor) GetParent

func (a *TenancyAccessor) GetParent(ctx context.Context, tenantId string) (string, error)

func (*TenancyAccessor) GetRoot

func (a *TenancyAccessor) GetRoot(ctx context.Context) (string, error)

GetRoot will return the root tenantID. Because the root tenantId won't change once system is started, we can cache it after first successful read.

func (*TenancyAccessor) GetTenancyPath

func (a *TenancyAccessor) GetTenancyPath(ctx context.Context, tenantId string) ([]uuid.UUID, error)

func (*TenancyAccessor) IsLoaded

func (a *TenancyAccessor) IsLoaded(ctx context.Context) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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