usermanager

package
v0.12.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package usermanager provides a service for user management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Quota

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

Quota defines a user quota for requests.

type User

type User struct {
	UserInfo models.UserInfo
	Session  UserSession
}

User defines user info and session.

func NewUser

func NewUser(userInfo models.UserInfo, quota Quota) *User

NewUser creates a new User.

func (*User) RequestQuota

func (u *User) RequestQuota() error

RequestQuota checks a user request limit.

type UserInformer

type UserInformer interface {
	GetUserInfo(userID string) (models.UserInfo, error)
}

UserInformer defines an interface for getting user info.

type UserList

type UserList map[string]*User // UID -> UserInfo.

UserList represents map of users stored in UserManager.

type UserManager

type UserManager struct {
	UserInformer UserInformer
	QuotaConfig  definition.Quota
	// contains filtered or unexported fields
}

UserManager defines a user manager service.

func NewUserManager

func NewUserManager(informer UserInformer, quotaCfg definition.Quota, users UserList) *UserManager

NewUserManager creates a new user manager.

func (*UserManager) CreateUser

func (um *UserManager) CreateUser(userID string) (*User, error)

CreateUser creates a new user.

func (*UserManager) Users

func (um *UserManager) Users() UserList

Users returns all users.

type UserSession

type UserSession struct {
	PlatformSessionID string
	ChannelID         string
	Direct            bool

	Quota Quota

	LastActionTs time.Time
	IdleInterval uint

	Clone           *dblabmodels.Clone
	ConnParams      models.Clone
	Pool            *pgxpool.Pool `json:"-"`
	CloneConnection *pgx.Conn     `json:"-"`
	DBVersion       int           `json:"-"`
}

UserSession defines a user session.

Jump to

Keyboard shortcuts

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