storage

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryEqualWithParam = " (%s = ?) "
	QueryLess           = " (%s <= %s) "
	QueryGreater        = " (%s >= %d) "
	QueryLikeWithParam  = " (%s LIKE ?) "
	QueryInWithParam    = " (%s IN (?)) "
	QueryNotInWithParam = " (%s NOT IN (?)) "
	QueryIsNull         = " (%s IS NULL) "
	QueryAnd            = " AND "
	QueryOr             = " OR "

	CreatedAt     = "created_at"
	UpdatedAt     = "updated_at"
	Type          = "type"
	ServerAddress = "server_address"
	State         = "state"
	ID            = "id"
	FsID          = "fs_id"
	FsCacheID     = "cache_id"
	FsPath        = "fs_path"
	NodeName      = "nodename"
	ClusterID     = "cluster_id"
	Address       = "address"
	UserName      = "user_name"
	UserROOT      = "root"

	ASC  = "asc"
	DESC = "desc"
)

Variables

Functions

func InitStores

func InitStores(db *gorm.DB)

Types

type AuthStore

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

func (*AuthStore) CreateGrant

func (as *AuthStore) CreateGrant(ctx *logger.RequestContext, grant *model.Grant) error

func (*AuthStore) CreateUser

func (as *AuthStore) CreateUser(ctx *logger.RequestContext, user *model.User) error

func (*AuthStore) DeleteGrant

func (as *AuthStore) DeleteGrant(ctx *logger.RequestContext, userName, resourceType, resourceID string) error

func (*AuthStore) DeleteGrantByResourceID

func (as *AuthStore) DeleteGrantByResourceID(ctx *logger.RequestContext, resourceID string) error

func (*AuthStore) DeleteGrantByUserName

func (as *AuthStore) DeleteGrantByUserName(ctx *logger.RequestContext, userName string) error

func (*AuthStore) DeleteUser

func (as *AuthStore) DeleteUser(ctx *logger.RequestContext, userName string) error

func (*AuthStore) GetGrant

func (as *AuthStore) GetGrant(ctx *logger.RequestContext, userName, resourceType, resourceID string) (*model.Grant, error)

func (*AuthStore) GetLastGrant

func (as *AuthStore) GetLastGrant(ctx *logger.RequestContext) (model.Grant, error)

func (*AuthStore) GetLastUser

func (as *AuthStore) GetLastUser(ctx *logger.RequestContext) (model.User, error)

func (*AuthStore) GetUserByName

func (as *AuthStore) GetUserByName(ctx *logger.RequestContext, userName string) (model.User, error)

func (*AuthStore) HasAccessToResource

func (as *AuthStore) HasAccessToResource(ctx *logger.RequestContext, resourceType string, resourceID string) bool

func (*AuthStore) ListGrant

func (as *AuthStore) ListGrant(ctx *logger.RequestContext, pk int64, maxKeys int, userName string) ([]model.Grant, error)

func (*AuthStore) ListUser

func (as *AuthStore) ListUser(ctx *logger.RequestContext, pk int64, maxKey int) ([]model.User, error)

func (*AuthStore) UpdateUser

func (as *AuthStore) UpdateUser(ctx *logger.RequestContext, userName, password string) error

type AuthStoreInterface

type AuthStoreInterface interface {
	// user
	CreateUser(ctx *logger.RequestContext, user *model.User) error
	UpdateUser(ctx *logger.RequestContext, userName, password string) error
	ListUser(ctx *logger.RequestContext, pk int64, maxKey int) ([]model.User, error)
	DeleteUser(ctx *logger.RequestContext, userName string) error
	GetUserByName(ctx *logger.RequestContext, userName string) (model.User, error)
	GetLastUser(ctx *logger.RequestContext) (model.User, error)
	// grant
	CreateGrant(ctx *logger.RequestContext, grant *model.Grant) error
	DeleteGrant(ctx *logger.RequestContext, userName, resourceType, resourceID string) error
	GetGrant(ctx *logger.RequestContext, userName, resourceType, resourceID string) (*model.Grant, error)
	HasAccessToResource(ctx *logger.RequestContext, resourceType string, resourceID string) bool
	DeleteGrantByUserName(ctx *logger.RequestContext, userName string) error
	DeleteGrantByResourceID(ctx *logger.RequestContext, resourceID string) error
	ListGrant(ctx *logger.RequestContext, pk int64, maxKeys int, userName string) ([]model.Grant, error)
	GetLastGrant(ctx *logger.RequestContext) (model.Grant, error)
}

type ConcurrentFSCacheMap

type ConcurrentFSCacheMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*ConcurrentFSCacheMap) Delete

func (cm *ConcurrentFSCacheMap) Delete(key1, key2 string) error

func (*ConcurrentFSCacheMap) Get

func (cm *ConcurrentFSCacheMap) Get(key1, key2 string) *model.FSCache

func (*ConcurrentFSCacheMap) GetBatch

func (cm *ConcurrentFSCacheMap) GetBatch(key string) []model.FSCache

func (*ConcurrentFSCacheMap) Put

func (cm *ConcurrentFSCacheMap) Put(key string, value *model.FSCache)

func (*ConcurrentFSCacheMap) Update

func (cm *ConcurrentFSCacheMap) Update(key string, value *model.FSCache) (has bool, err error)

type DBFSCache

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

func (*DBFSCache) Add

func (f *DBFSCache) Add(value *model.FSCache) error

func (*DBFSCache) Delete

func (f *DBFSCache) Delete(fsID, cacheID string) error

func (*DBFSCache) Get

func (f *DBFSCache) Get(fsID string, cacheID string) (*model.FSCache, error)

func (*DBFSCache) List

func (f *DBFSCache) List(fsID, cacheID string) ([]model.FSCache, error)

func (*DBFSCache) ListNodes

func (f *DBFSCache) ListNodes(fsIDs []string) ([]string, error)

func (*DBFSCache) Update

func (f *DBFSCache) Update(value *model.FSCache) (int64, error)

type FileSystemStoreInterface

type FileSystemStoreInterface interface {
	// filesystem
	CreatFileSystem(fs *model.FileSystem) error
	GetFileSystemWithFsID(fsID string) (model.FileSystem, error)
	DeleteFileSystem(tx *gorm.DB, id string) error
	ListFileSystem(limit int, userName, marker, fsName string) ([]model.FileSystem, error)
	GetSimilarityAddressList(fsType string, ips []string) ([]model.FileSystem, error)
	// link
	CreateLink(link *model.Link) error
	FsNameLinks(fsID string) ([]model.Link, error)
	LinkWithFsIDAndFsPath(fsID, fsPath string) (model.Link, error)
	DeleteLinkWithFsID(tx *gorm.DB, id string) error
	DeleteLinkWithFsIDAndFsPath(fsID, fsPath string) error
	ListLink(limit int, marker, fsID string) ([]model.Link, error)
	GetLinkWithFsIDAndPath(fsID, fsPath string) ([]model.Link, error)
	// fs_cache_config
	CreateFSCacheConfig(fsCacheConfig *model.FSCacheConfig) error
	UpdateFSCacheConfig(fsCacheConfig *model.FSCacheConfig) error
	DeleteFSCacheConfig(tx *gorm.DB, fsID string) error
	GetFSCacheConfig(fsID string) (model.FSCacheConfig, error)
}

type FilesystemStore

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

func (*FilesystemStore) CreatFileSystem

func (fss *FilesystemStore) CreatFileSystem(fs *model.FileSystem) error

func (*FilesystemStore) CreateFSCacheConfig

func (fss *FilesystemStore) CreateFSCacheConfig(fsCacheConfig *model.FSCacheConfig) error
func (fss *FilesystemStore) CreateLink(link *model.Link) error

func (*FilesystemStore) DeleteFSCacheConfig

func (fss *FilesystemStore) DeleteFSCacheConfig(tx *gorm.DB, fsID string) error

func (*FilesystemStore) DeleteFileSystem

func (fss *FilesystemStore) DeleteFileSystem(tx *gorm.DB, id string) error

func (*FilesystemStore) DeleteLinkWithFsID

func (fss *FilesystemStore) DeleteLinkWithFsID(tx *gorm.DB, fsID string) error

DeleteLinkWithFsID delete all filesystem links associated with fsID

func (*FilesystemStore) DeleteLinkWithFsIDAndFsPath

func (fss *FilesystemStore) DeleteLinkWithFsIDAndFsPath(fsID, fsPath string) error

DeleteLinkWithFsIDAndFsPath delete a file system link

func (fss *FilesystemStore) FsNameLinks(fsID string) ([]model.Link, error)

func (*FilesystemStore) GetFSCacheConfig

func (fss *FilesystemStore) GetFSCacheConfig(fsID string) (model.FSCacheConfig, error)

func (*FilesystemStore) GetFileSystemWithFsID

func (fss *FilesystemStore) GetFileSystemWithFsID(fsID string) (model.FileSystem, error)

func (*FilesystemStore) GetLinkWithFsIDAndPath

func (fss *FilesystemStore) GetLinkWithFsIDAndPath(fsID, fsPath string) ([]model.Link, error)

func (*FilesystemStore) GetSimilarityAddressList

func (fss *FilesystemStore) GetSimilarityAddressList(fsType string, ips []string) ([]model.FileSystem, error)

GetSimilarityAddressList find fs where have same type and serverAddress

func (*FilesystemStore) LinkWithFsIDAndFsPath

func (fss *FilesystemStore) LinkWithFsIDAndFsPath(fsID, fsPath string) (model.Link, error)

func (*FilesystemStore) ListFileSystem

func (fss *FilesystemStore) ListFileSystem(limit int, userName, marker, fsName string) ([]model.FileSystem, error)

ListFileSystem get file systems with marker and limit sort by create_at desc

func (fss *FilesystemStore) ListLink(limit int, marker, fsID string) ([]model.Link, error)

ListLink get links with marker and limit sort by create_at desc

func (*FilesystemStore) UpdateFSCacheConfig

func (fss *FilesystemStore) UpdateFSCacheConfig(fsCacheConfig *model.FSCacheConfig) error

type FsCacheStoreInterface

type FsCacheStoreInterface interface {
	Add(value *model.FSCache) error
	Get(fsID string, cacheID string) (*model.FSCache, error)
	Delete(fsID, cacheID string) error
	List(fsID, cacheID string) ([]model.FSCache, error)
	ListNodes(fsID []string) ([]string, error)
	Update(value *model.FSCache) (int64, error)
}

FsCacheStoreInterface currently has two implementations: DB and memory use newMemFSCache() or newDBFSCache(db *gorm.DB) to initiate

type MemFSCache

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

func (*MemFSCache) Add

func (mem *MemFSCache) Add(value *model.FSCache) error

func (*MemFSCache) Delete

func (mem *MemFSCache) Delete(fsID, cacheID string) error

func (*MemFSCache) Get

func (mem *MemFSCache) Get(fsID string, cacheID string) (*model.FSCache, error)

func (*MemFSCache) List

func (mem *MemFSCache) List(fsID, cacheID string) ([]model.FSCache, error)

func (*MemFSCache) ListNodes

func (mem *MemFSCache) ListNodes(fsIDs []string) ([]string, error)

func (*MemFSCache) Update

func (mem *MemFSCache) Update(value *model.FSCache) (int64, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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