userstore

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdminRole   = "admin"
	UserRole    = "user"
	VisitorRole = "visitor"
	InitNs      = "usersInit"
	IDsNs       = "ids"
	UsersNs     = "users"
	RoleListNs  = "roleList"
	InitTimeKey = "initTime"
	VisitorID   = uint64(1)
	VisitorName = "visitor"
)

Variables

View Source
var (
	ErrReachedLimit = errors.New("reached space limit")
)

Functions

func IsReachedLimitErr

func IsReachedLimitErr(err error) bool

Types

type IUserStore

type IUserStore interface {
	Init(rootName, rootPwd string) error
	IsInited() bool
	AddUser(user *User) error
	DelUser(id uint64) error
	GetUser(id uint64) (*User, error)
	GetUserByName(name string) (*User, error)
	SetInfo(id uint64, user *User) error
	CanIncrUsed(id uint64, capacity int64) (bool, error)
	SetUsed(id uint64, incr bool, capacity int64) error
	SetPwd(id uint64, pwd string) error
	ListUsers() ([]*User, error)
	AddRole(role string) error
	DelRole(role string) error
	ListRoles() (map[string]bool, error)
}

type KVUserStore

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

func NewKVUserStore

func NewKVUserStore(store kvstore.IKVStore) (*KVUserStore, error)

func (*KVUserStore) AddRole

func (us *KVUserStore) AddRole(role string) error

func (*KVUserStore) AddUser

func (us *KVUserStore) AddUser(user *User) error

func (*KVUserStore) CanIncrUsed

func (us *KVUserStore) CanIncrUsed(id uint64, capacity int64) (bool, error)

func (*KVUserStore) DelRole

func (us *KVUserStore) DelRole(role string) error

func (*KVUserStore) DelUser

func (us *KVUserStore) DelUser(id uint64) error

func (*KVUserStore) GetUser

func (us *KVUserStore) GetUser(id uint64) (*User, error)

func (*KVUserStore) GetUserByName

func (us *KVUserStore) GetUserByName(name string) (*User, error)

func (*KVUserStore) Init

func (us *KVUserStore) Init(rootName, rootPwd string) error

func (*KVUserStore) IsInited

func (us *KVUserStore) IsInited() bool

func (*KVUserStore) ListRoles

func (us *KVUserStore) ListRoles() (map[string]bool, error)

func (*KVUserStore) ListUsers

func (us *KVUserStore) ListUsers() ([]*User, error)

func (*KVUserStore) SetInfo

func (us *KVUserStore) SetInfo(id uint64, user *User) error

func (*KVUserStore) SetPwd

func (us *KVUserStore) SetPwd(id uint64, pwd string) error

func (*KVUserStore) SetUsed

func (us *KVUserStore) SetUsed(id uint64, incr bool, capacity int64) error

type Quota

type Quota struct {
	SpaceLimit         int64 `json:"spaceLimit,string"`
	UploadSpeedLimit   int   `json:"uploadSpeedLimit"`
	DownloadSpeedLimit int   `json:"downloadSpeedLimit"`
}

type User

type User struct {
	ID        uint64 `json:"id,string"`
	Name      string `json:"name"`
	Pwd       string `json:"pwd"`
	Role      string `json:"role"`
	UsedSpace int64  `json:"usedSpace,string"`
	Quota     *Quota `json:"quota"`
}

type UserCfg

type UserCfg struct {
	Name string `json:"name"`
	Role string `json:"role"`
	Pwd  string `json:"pwd"`
}

Jump to

Keyboard shortcuts

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