common

package
v0.0.0-...-3278dbb Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: GPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSessionCooldownBySessionId

func GetSessionCooldownBySessionId(rdb *redis.Client, sessionId string) (int, error)

func RedisLoad

func RedisLoad(rdb *redis.Client, entity string, key string, rec interface{}) error

Load data from redis.

func RedisStore

func RedisStore(rdb *redis.Client, entity string, key string, rec interface{}) error

Store data into redis.

func StoreSession

func StoreSession(rdb *redis.Client, session *SessionData) error

func StoreUser

func StoreUser(rdb *redis.Client, user *UserData) error

func TestAndUpdateSessionCooldown

func TestAndUpdateSessionCooldown(rdb *redis.Client, appConfig *AppConfig, sessionId string) (error, bool)

Check cooldown for user session. Return true if there was cooldown info (user made request less than `CooldownSeconds' seconds ago). Otherwise return false AND add cooldown info. Should be atomic.

Types

type AppConfig

type AppConfig struct {
	CanvasRows      int
	CanvasCols      int
	CooldownSeconds int

	PaletteColors []string
	InitialImage  string

	RedisAddress  string
	RedisPassword string
	RedisDatabase int

	AllowedOrigins string

	WebSocketAppAddresses []string
}

func MustReadAppConfig

func MustReadAppConfig(path string) *AppConfig

Read configuration file. Panic on error

type SessionData

type SessionData struct {
	Login            string
	Id               string
	ValidationErrors map[string]string
}

func GetSessionBySessionId

func GetSessionBySessionId(rdb *redis.Client, sessionId string) (*SessionData, error)

type UserData

type UserData struct {
	Login        string
	PasswordHash string
}

func GetUserByLogin

func GetUserByLogin(rdb *redis.Client, login string) (*UserData, error)

Jump to

Keyboard shortcuts

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