cache

package
v1.24.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const FindParentScript = `` /* 655-byte string literal not displayed */
View Source
const InMemoryModelCacheSize = 128
View Source
const (
	// 全局模型结构缓存
	ModelCacheKey = "_model_cache"
)

Variables

View Source
var ErrCacheEntryNotFound = errors.New("cache entry not found")

Functions

This section is empty.

Types

type CommonResourceIface

type CommonResourceIface interface {
	GetKind() string
	GetID() uint
	GetTenantID() uint
	GetProjectID() uint
	GetEnvironmentID() uint
	GetVirtualSpaceID() uint
	GetName() string
	GetCluster() string
	GetNamespace() string
	GetOwners() []CommonResourceIface
}

type Entity

type Entity struct {
	Name      string    `json:",omitempty"`
	Kind      string    `json:",omitempty"`
	ID        uint      `json:",omitempty"`
	Namespace string    `json:",omitempty"`
	Cluster   string    `json:",omitempty"`
	Owner     []*Entity `json:",omitempty"`
	Children  []string  `json:",omitempty"`
}

func (*Entity) GetCluster

func (n *Entity) GetCluster() string

func (*Entity) GetEnvironmentID

func (n *Entity) GetEnvironmentID() uint

func (*Entity) GetID

func (n *Entity) GetID() uint

func (*Entity) GetKind

func (n *Entity) GetKind() string

func (*Entity) GetName

func (n *Entity) GetName() string

func (*Entity) GetNamespace

func (n *Entity) GetNamespace() string

func (*Entity) GetOwners

func (n *Entity) GetOwners() []CommonResourceIface

func (*Entity) GetProjectID

func (n *Entity) GetProjectID() uint

func (*Entity) GetTenantID

func (n *Entity) GetTenantID() uint

func (*Entity) GetVirtualSpaceID

func (n *Entity) GetVirtualSpaceID() uint

func (*Entity) MarshalBinary

func (n *Entity) MarshalBinary() ([]byte, error)

func (*Entity) UnmarshalBinary

func (n *Entity) UnmarshalBinary(data []byte) error

type InMemoryModelCache added in v1.24.4

type InMemoryModelCache struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

func NewMemoryModelCache added in v1.24.4

func NewMemoryModelCache(db *gorm.DB) *InMemoryModelCache

func (*InMemoryModelCache) BuildCacheIfNotExist added in v1.24.4

func (i *InMemoryModelCache) BuildCacheIfNotExist() error

BuildCacheIfNotExist implements ModelCache.

func (*InMemoryModelCache) DelEnvironment added in v1.24.4

func (i *InMemoryModelCache) DelEnvironment(pid uint, eid uint, cluster string, namespace string) error

DelEnvironment implements ModelCache.

func (*InMemoryModelCache) DelProject added in v1.24.4

func (i *InMemoryModelCache) DelProject(tid uint, pid uint) error

DelProject implements ModelCache.

func (*InMemoryModelCache) DelTenant added in v1.24.4

func (i *InMemoryModelCache) DelTenant(tid uint) error

DelTenant implements ModelCache.

func (*InMemoryModelCache) DelVirtualSpace added in v1.24.4

func (i *InMemoryModelCache) DelVirtualSpace(vid uint) error

DelVirtualSpace implements ModelCache.

func (*InMemoryModelCache) FindEnvironment added in v1.24.4

func (i *InMemoryModelCache) FindEnvironment(cluster string, namespace string) CommonResourceIface

FindEnvironment implements ModelCache.

func (*InMemoryModelCache) FindParents added in v1.24.4

func (i *InMemoryModelCache) FindParents(kind string, id uint) []CommonResourceIface

FindParents implements ModelCache. NOTE: find parents recursively returns all parents AND IT SELF.

func (*InMemoryModelCache) FindResource added in v1.24.4

func (i *InMemoryModelCache) FindResource(kind string, id uint) CommonResourceIface

FindResource implements ModelCache.

func (*InMemoryModelCache) FlushUserAuthority added in v1.24.4

func (c *InMemoryModelCache) FlushUserAuthority(user models.CommonUserIface) *UserAuthority

FlushUserAuthority implements ModelCache.

func (*InMemoryModelCache) GetUserAuthority added in v1.24.4

func (i *InMemoryModelCache) GetUserAuthority(user models.CommonUserIface) *UserAuthority

GetUserAuthority implements ModelCache.

func (*InMemoryModelCache) UpsertEnvironment added in v1.24.4

func (i *InMemoryModelCache) UpsertEnvironment(pid uint, eid uint, name string, cluster string, namespace string) error

UpsertEnvironment implements ModelCache.

func (*InMemoryModelCache) UpsertProject added in v1.24.4

func (i *InMemoryModelCache) UpsertProject(tid uint, pid uint, name string) error

UpsertProject implements ModelCache.

func (*InMemoryModelCache) UpsertTenant added in v1.24.4

func (i *InMemoryModelCache) UpsertTenant(tid uint, name string) error

UpsertTenant implements ModelCache.

func (*InMemoryModelCache) UpsertVirtualSpace added in v1.24.4

func (i *InMemoryModelCache) UpsertVirtualSpace(vid uint, name string) error

UpsertVirtualSpace implements ModelCache.

type ModelCache

type ModelCache interface {
	BuildCacheIfNotExist() error
	UpsertTenant(tid uint, name string) error
	DelTenant(tid uint) error
	UpsertProject(tid, pid uint, name string) error
	DelProject(tid, pid uint) error

	UpsertEnvironment(pid, eid uint, name, cluster, namespace string) error
	DelEnvironment(pid, eid uint, cluster, namespace string) error
	FindEnvironment(cluster, namespace string) CommonResourceIface

	UpsertVirtualSpace(vid uint, name string) error
	DelVirtualSpace(vid uint) error

	GetUserAuthority(user models.CommonUserIface) *UserAuthority
	FlushUserAuthority(user models.CommonUserIface) *UserAuthority

	FindParents(kind string, id uint) []CommonResourceIface
	FindResource(kind string, id uint) CommonResourceIface
}

nolint

func NewRedisModelCache added in v1.24.4

func NewRedisModelCache(db *gorm.DB, redis *redis.Client) ModelCache

type RedisModelCache added in v1.24.4

type RedisModelCache struct {
	DB    *gorm.DB
	Redis *redis.Client
}

func (RedisModelCache) BuildCacheIfNotExist added in v1.24.4

func (t RedisModelCache) BuildCacheIfNotExist() error

func (RedisModelCache) DelEnvironment added in v1.24.4

func (t RedisModelCache) DelEnvironment(pid, eid uint, cluster, namespace string) error

func (RedisModelCache) DelProject added in v1.24.4

func (t RedisModelCache) DelProject(tid, pid uint) error

func (RedisModelCache) DelTenant added in v1.24.4

func (t RedisModelCache) DelTenant(tid uint) error

func (RedisModelCache) DelVirtualSpace added in v1.24.4

func (t RedisModelCache) DelVirtualSpace(vid uint) error

func (RedisModelCache) FindEnvironment added in v1.24.4

func (c RedisModelCache) FindEnvironment(cluster, namespace string) CommonResourceIface

func (RedisModelCache) FindParents added in v1.24.4

func (c RedisModelCache) FindParents(kind string, id uint) []CommonResourceIface

func (RedisModelCache) FindResource added in v1.24.4

func (c RedisModelCache) FindResource(kind string, id uint) CommonResourceIface

func (RedisModelCache) FlushUserAuthority added in v1.24.4

func (c RedisModelCache) FlushUserAuthority(user models.CommonUserIface) *UserAuthority

func (RedisModelCache) GetUserAuthority added in v1.24.4

func (c RedisModelCache) GetUserAuthority(user models.CommonUserIface) *UserAuthority

func (RedisModelCache) UpsertEnvironment added in v1.24.4

func (t RedisModelCache) UpsertEnvironment(pid, eid uint, name, cluster, namespace string) error

func (RedisModelCache) UpsertProject added in v1.24.4

func (t RedisModelCache) UpsertProject(tid, pid uint, name string) error

func (RedisModelCache) UpsertTenant added in v1.24.4

func (t RedisModelCache) UpsertTenant(tid uint, name string) error

func (RedisModelCache) UpsertVirtualSpace added in v1.24.4

func (t RedisModelCache) UpsertVirtualSpace(vid uint, name string) error

type UserAuthority

type UserAuthority struct {
	SystemRole    string          `json:"systemRole"`
	Tenants       []*UserResource `json:"tenant"`
	Projects      []*UserResource `json:"projects"`
	Environments  []*UserResource `json:"environments"`
	VirtualSpaces []*UserResource `json:"virtualSpaces"`
}

UserAuthority 用户权限

func (*UserAuthority) GetResourceRole

func (auth *UserAuthority) GetResourceRole(kind string, id uint) string

func (*UserAuthority) IsAnyTenantAdmin

func (auth *UserAuthority) IsAnyTenantAdmin() bool

func (*UserAuthority) IsEnvironmentOperator

func (auth *UserAuthority) IsEnvironmentOperator(envid uint) bool

func (*UserAuthority) IsEnvironmentReader

func (auth *UserAuthority) IsEnvironmentReader(envid uint) bool

func (*UserAuthority) IsProjectAdmin

func (auth *UserAuthority) IsProjectAdmin(projectid uint) bool

func (*UserAuthority) IsProjectDev

func (auth *UserAuthority) IsProjectDev(projectid uint) bool

func (*UserAuthority) IsProjectOps

func (auth *UserAuthority) IsProjectOps(projectid uint) bool

func (*UserAuthority) IsProjectTest

func (auth *UserAuthority) IsProjectTest(projectid uint) bool

func (*UserAuthority) IsSystemAdmin

func (auth *UserAuthority) IsSystemAdmin() bool

func (*UserAuthority) IsTenantAdmin

func (auth *UserAuthority) IsTenantAdmin(tenantid uint) bool

func (*UserAuthority) IsTenantMember

func (auth *UserAuthority) IsTenantMember(tenantid uint) bool

func (*UserAuthority) IsVirtualSpaceAdmin

func (auth *UserAuthority) IsVirtualSpaceAdmin(vsid uint) bool

func (*UserAuthority) IsVirtualSpaceMember

func (auth *UserAuthority) IsVirtualSpaceMember(vsid uint) bool

func (*UserAuthority) MarshalBinary

func (auth *UserAuthority) MarshalBinary() ([]byte, error)

func (*UserAuthority) UnmarshalBinary

func (auth *UserAuthority) UnmarshalBinary(data []byte) error

type UserResource

type UserResource struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	Role    string `json:"role"`
	IsAdmin bool   `json:"isAdmin"`
}

Jump to

Keyboard shortcuts

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