storage

package
v0.0.0-...-51aff30 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	UserID   int
	Username string
	Command  string
	Result   string
	Date     string
	Comment  string
}

type ResultsList

type ResultsList struct {
	Results []Result
}

type SQLiteConnection

type SQLiteConnection struct {
	Database *sql.DB
	Users    UserCache
}

func ConnectSQLite

func ConnectSQLite(conf config.DBConfig) (*SQLiteConnection, error)

func (*SQLiteConnection) CreateDB

func (s *SQLiteConnection) CreateDB() error

func (*SQLiteConnection) GetCharacter

func (s *SQLiteConnection) GetCharacter(id int) (int, error)

func (*SQLiteConnection) GetLogs

func (s *SQLiteConnection) GetLogs(userid int) (*ResultsList, error)

func (*SQLiteConnection) GetUser

func (s *SQLiteConnection) GetUser(userId int) (string, error)

func (*SQLiteConnection) GetUsers

func (s *SQLiteConnection) GetUsers() (*UsersList, error)

func (*SQLiteConnection) LoadUsers

func (s *SQLiteConnection) LoadUsers() error

func (*SQLiteConnection) SetUser

func (s *SQLiteConnection) SetUser(userID int, username string) error

func (*SQLiteConnection) UsersList

func (s *SQLiteConnection) UsersList() string

func (*SQLiteConnection) WriteTask

func (s *SQLiteConnection) WriteTask(original, response, comment string, user int) error

type Storage

type Storage interface {
	GetUser(int) (string, error)
	SetUser(int, string) error
	LoadUsers() error
	UsersList() string
	GetUsers() (*UsersList, error)
	WriteTask(string, string, string, int) error
	GetLogs(int) (*ResultsList, error)
	GetCharacter(int) (int, error)
}

func CreateStorage

func CreateStorage(conf config.Config) (Storage, error)

type User

type User struct {
	ID       int
	Username string
	Count    int
}

type UserCache

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

func NewUserCache

func NewUserCache() UserCache

func (*UserCache) GetUser

func (uc *UserCache) GetUser(user int) (string, bool)

func (*UserCache) SetUser

func (uc *UserCache) SetUser(userID int, username string)

type UsersList

type UsersList struct {
	Users []User
}

Jump to

Keyboard shortcuts

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