world

package
v0.0.0-...-bea2f44 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseInterface

type DatabaseInterface interface {
	GetDefaultWorld(ctx context.Context) (db.World, error)
	GetWorldByID(ctx context.Context, id pgtype.UUID) (db.World, error)
	ListWorlds(ctx context.Context) ([]db.World, error)
	CreateWorld(ctx context.Context, arg db.CreateWorldParams) (db.World, error)
	UpdateWorld(ctx context.Context, arg db.UpdateWorldParams) (db.World, error)
	DeleteWorld(ctx context.Context, id pgtype.UUID) error
}

DatabaseInterface abstracts database operations for the world service. This enables dependency injection and makes the service easily testable.

func NewDatabaseWrapper

func NewDatabaseWrapper(pool *pgxpool.Pool) DatabaseInterface

NewDatabaseWrapper creates a new database wrapper with the given connection pool.

type DatabaseWrapper

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

DatabaseWrapper implements DatabaseInterface using the actual database connection. This is the production implementation that wraps the SQLC generated queries.

func (*DatabaseWrapper) CreateWorld

func (d *DatabaseWrapper) CreateWorld(ctx context.Context, arg db.CreateWorldParams) (db.World, error)

CreateWorld creates a new world.

func (*DatabaseWrapper) DeleteWorld

func (d *DatabaseWrapper) DeleteWorld(ctx context.Context, id pgtype.UUID) error

DeleteWorld deletes a world by ID.

func (*DatabaseWrapper) GetDefaultWorld

func (d *DatabaseWrapper) GetDefaultWorld(ctx context.Context) (db.World, error)

GetDefaultWorld retrieves the default world.

func (*DatabaseWrapper) GetWorldByID

func (d *DatabaseWrapper) GetWorldByID(ctx context.Context, id pgtype.UUID) (db.World, error)

GetWorldByID retrieves a world by ID.

func (*DatabaseWrapper) ListWorlds

func (d *DatabaseWrapper) ListWorlds(ctx context.Context) ([]db.World, error)

ListWorlds retrieves all worlds.

func (*DatabaseWrapper) UpdateWorld

func (d *DatabaseWrapper) UpdateWorld(ctx context.Context, arg db.UpdateWorldParams) (db.World, error)

UpdateWorld updates a world's information.

type DefaultLoggerWrapper

type DefaultLoggerWrapper struct{}

DefaultLoggerWrapper wraps the internal logging package.

func (*DefaultLoggerWrapper) Debug

func (l *DefaultLoggerWrapper) Debug(msg string, keysAndValues ...interface{})

func (*DefaultLoggerWrapper) Error

func (l *DefaultLoggerWrapper) Error(msg string, keysAndValues ...interface{})

func (*DefaultLoggerWrapper) Info

func (l *DefaultLoggerWrapper) Info(msg string, keysAndValues ...interface{})

func (*DefaultLoggerWrapper) Warn

func (l *DefaultLoggerWrapper) Warn(msg string, keysAndValues ...interface{})

func (*DefaultLoggerWrapper) With

func (l *DefaultLoggerWrapper) With(keysAndValues ...interface{}) LoggerInterface

type LoggerInterface

type LoggerInterface interface {
	Debug(msg string, keysAndValues ...interface{})
	Info(msg string, keysAndValues ...interface{})
	Warn(msg string, keysAndValues ...interface{})
	Error(msg string, keysAndValues ...interface{})
	With(keysAndValues ...interface{}) LoggerInterface
}

LoggerInterface abstracts logging operations for dependency injection.

func NewDefaultLoggerWrapper

func NewDefaultLoggerWrapper() LoggerInterface

NewDefaultLoggerWrapper creates a new default logger wrapper.

type Service

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

Service provides operations on worlds

func NewService

func NewService(db DatabaseInterface, logger LoggerInterface) *Service

NewService creates a new world service with dependency injection.

func NewServiceWithPool

func NewServiceWithPool(pool *pgxpool.Pool, logger LoggerInterface) *Service

NewServiceWithPool creates a service with a database pool (convenience constructor for production use).

func (*Service) ChunkSize

func (s *Service) ChunkSize() int32

ChunkSize returns the chunk size (hardcoded to 32)

func (*Service) DeleteWorld

func (s *Service) DeleteWorld(ctx context.Context, id pgtype.UUID) error

DeleteWorld deletes a world

func (*Service) GetDefaultWorld

func (s *Service) GetDefaultWorld(ctx context.Context) (db.World, error)

GetDefaultWorld gets or creates the default world

func (*Service) GetWorldByID

func (s *Service) GetWorldByID(ctx context.Context, id pgtype.UUID) (db.World, error)

GetWorldByID gets a world by ID

func (*Service) ListWorlds

func (s *Service) ListWorlds(ctx context.Context) ([]db.World, error)

ListWorlds gets all worlds

func (*Service) UpdateWorld

func (s *Service) UpdateWorld(ctx context.Context, id pgtype.UUID, name string) (db.World, error)

UpdateWorld updates a world's name

Jump to

Keyboard shortcuts

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