persist

package
v0.0.0-...-21a16ac Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidUsername = errors.New("username is invalid")
View Source
var ErrUserNotFound = errors.New("user not found")
View Source
var ErrUsernameTaken = errors.New("username is taken")

Functions

func IsValidUsername

func IsValidUsername(username string) bool

func NewGameStateRepository

func NewGameStateRepository(rdb redis.RedisClient) *gameStateRepo

func NewGameUserRepository

func NewGameUserRepository(rdb redis.RedisClient) *userRepo

func NewMarketRepository

func NewMarketRepository(rc redis.RedisClient) *marketRepo

func NewNotifyRepository

func NewNotifyRepository(rc redis.RedisClient) *notifyRepo

func NewReportsRepository

func NewReportsRepository(rdb redis.RedisClient) *reportsRepo

func NewWorldRepository

func NewWorldRepository(rc redis.RedisClient) *worldRepo

Types

type GameStateRepository

type GameStateRepository interface {
	NewMutex(userId string) Mutex
	Get(ctx context.Context, userId string) (*models.GameState, error)
	Patch(ctx context.Context, userId string, gs *models.GameState, patch *models.PatchMask) error
	Save(ctx context.Context, userId string, gs *models.GameState) error
}

type GameUser

type GameUser struct {
	Uid      string
	Username string
}

type GameUserRepository

type GameUserRepository interface {
	SetUserLatestActivity(ctx context.Context, userId string, value int64) error
	GetUserLatestActivity(ctx context.Context, userId string) (int64, error)
	GetAllUsers(ctx context.Context) ([]string, error)
	GetUserCount(ctx context.Context) (int64, error)
	CreateUser(ctx context.Context, userId, username string) error
	GetUser(ctx context.Context, userId string) (*GameUser, error)
	DeleteUser(ctx context.Context, userId string) error
}

type MarketRepository

type MarketRepository interface {
	GetGlobalDemandScore(ctx context.Context) (float64, error)
	SetUserDemandScore(ctx context.Context, userId string, demand float64) error
	GetDemandRankByUserId(ctx context.Context, userId string) (int64, error)
	GetDemandLeaderboard(ctx context.Context, skip int) (*models.DemandLeaderboard, error)
}

type Mutex

type Mutex interface {
	Lock() error
	LockContext(context.Context) error
	Unlock() (bool, error)
}

type NotifyRepository

type NotifyRepository interface {
	SendPushNotification(ctx context.Context, msg *messaging.Message) (int64, error)
	SchedulePushNotification(ctx context.Context, msg *messaging.Message, sendAt time.Time) (int64, error)
}

type ReportsRepository

type ReportsRepository interface {
	Save(ctx context.Context, userId string, report *models.Report) error
	Get(ctx context.Context, userId string) ([]*models.Report, error)
	MarkRead(ctx context.Context, userId string, reportId string) error
}

type User

type User struct {
	Id             string
	Username       string
	HashedPassword string
}

type UserRepository

type UserRepository interface {
	CreateUser(ctx context.Context, username string, password string) (string, error)
	GetAllUsers(ctx context.Context) ([]*User, error)
	GetUser(ctx context.Context, userId string) (*User, error)
	GetUserByUsername(ctx context.Context, username string) (*User, error)
	GetUserItems(ctx context.Context, userId string) ([]string, error)
	DeleteUser(ctx context.Context, userId string) error
}

type WorldRepository

type WorldRepository interface {
	GetState(ctx context.Context) (*models.WorldState, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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