Documentation
¶
Index ¶
- Constants
- type Persistencer
- func (p *Persistencer) Close() error
- func (p *Persistencer) DeleteUser(hash string) error
- func (p *Persistencer) ListUser(f func(hash string, u statistic.Metadata) bool) error
- func (p *Persistencer) LoadUser(hash string) (statistic.Metadata, error)
- func (p *Persistencer) SaveUser(u statistic.Metadata) error
- func (p *Persistencer) UpdateUserTraffic(hash string, sent, recv uint64) error
- type User
Constants ¶
View Source
const Name = "sqlite"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Persistencer ¶
type Persistencer struct {
// contains filtered or unexported fields
}
func NewSqlitePersistencer ¶
func NewSqlitePersistencer(path string) (*Persistencer, error)
func (*Persistencer) Close ¶ added in v1.2.0
func (p *Persistencer) Close() error
Close releases the underlying database handle. It is safe to call after Authenticator.Close.
func (*Persistencer) DeleteUser ¶
func (p *Persistencer) DeleteUser(hash string) error
func (*Persistencer) LoadUser ¶
func (p *Persistencer) LoadUser(hash string) (statistic.Metadata, error)
func (*Persistencer) UpdateUserTraffic ¶
func (p *Persistencer) UpdateUserTraffic(hash string, sent, recv uint64) error
type User ¶
type User struct {
Hash string `gorm:"primary_key"`
// uint64 = 8 byte binary
Sent []byte `gorm:"type:TEXT"`
Recv []byte `gorm:"type:TEXT"`
MaxIPNum int
SendLimit int
RecvLimit int
Quota int64
}
func (*User) Done ¶ added in v1.2.0
func (u *User) Done() <-chan struct{}
Done satisfies statistic.Metadata. The SQLite user record is a passive snapshot used only for persistence (SaveUser/LoadUser/ListUser); it has no live runtime to cancel, so the channel is never closed. The returned nil channel blocks forever in a select, which is the documented "no cutoff signal" behaviour.
func (*User) GetIPLimit ¶
func (*User) GetSpeedLimit ¶
func (*User) GetTraffic ¶
Click to show internal directories.
Click to hide internal directories.