storage

package
v0.0.0-...-6d75db2 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnString

func NewConnString(host, user, pass, dbname string, port int, kw KW) string

func WrapLogrus

func WrapLogrus(log *logrus.Logger) *logger

Types

type KW

type KW map[string]interface{}

type Logger

type Logger interface {
	Print(...interface{})
}

type Postgres

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

func NewPostgres

func NewPostgres(conn string, logger Logger) (*Postgres, error)

func (*Postgres) GetChatsRating

func (p *Postgres) GetChatsRating() ([]model.ChatStatistics, error)

func (*Postgres) GetGlobalRating

func (p *Postgres) GetGlobalRating() ([]model.UserInChat, error)

func (*Postgres) GetRating

func (p *Postgres) GetRating(chatID int64) ([]model.UserInChat, error)

func (*Postgres) GetStatistics

func (p *Postgres) GetStatistics() (model.Statistics, error)

func (*Postgres) GetUserStats

func (p *Postgres) GetUserStats(userID int, chatID int64) (model.UserInChat, model.UserInChat, error)

func (*Postgres) IncrementUserStats

func (p *Postgres) IncrementUserStats(chat model.Chat, givenUser ...model.UserInChat) error

func (*Postgres) ResetStats

func (p *Postgres) ResetStats(chatID int64) error

type Redis

type Redis struct {
	Pool *redis.Pool
}

func NewRedis

func NewRedis(p *redis.Pool) *Redis

func (*Redis) LookupForMachine

func (r *Redis) LookupForMachine(m *crocodile.Machine) error

LookupForMachine will take machine from Redis and unmarshal json to m argument

func (*Redis) SaveMachineState

func (r *Redis) SaveMachineState(m crocodile.Machine) error

type Storage

type Storage struct {
	*Postgres
	*Redis
}

func NewStorage

func NewStorage(conn string, pool *redis.Pool, logger Logger) (*Storage, error)

Jump to

Keyboard shortcuts

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