Documentation
¶
Index ¶
- type DatabaseInterface
- type DatabaseWrapper
- func (d *DatabaseWrapper) CreateWorld(ctx context.Context, arg db.CreateWorldParams) (db.World, error)
- func (d *DatabaseWrapper) DeleteWorld(ctx context.Context, id pgtype.UUID) error
- func (d *DatabaseWrapper) GetDefaultWorld(ctx context.Context) (db.World, error)
- func (d *DatabaseWrapper) GetWorldByID(ctx context.Context, id pgtype.UUID) (db.World, error)
- func (d *DatabaseWrapper) ListWorlds(ctx context.Context) ([]db.World, error)
- func (d *DatabaseWrapper) UpdateWorld(ctx context.Context, arg db.UpdateWorldParams) (db.World, error)
- type DefaultLoggerWrapper
- func (l *DefaultLoggerWrapper) Debug(msg string, keysAndValues ...interface{})
- func (l *DefaultLoggerWrapper) Error(msg string, keysAndValues ...interface{})
- func (l *DefaultLoggerWrapper) Info(msg string, keysAndValues ...interface{})
- func (l *DefaultLoggerWrapper) Warn(msg string, keysAndValues ...interface{})
- func (l *DefaultLoggerWrapper) With(keysAndValues ...interface{}) LoggerInterface
- type LoggerInterface
- type Service
- func (s *Service) ChunkSize() int32
- func (s *Service) DeleteWorld(ctx context.Context, id pgtype.UUID) error
- func (s *Service) GetDefaultWorld(ctx context.Context) (db.World, error)
- func (s *Service) GetWorldByID(ctx context.Context, id pgtype.UUID) (db.World, error)
- func (s *Service) ListWorlds(ctx context.Context) ([]db.World, error)
- func (s *Service) UpdateWorld(ctx context.Context, id pgtype.UUID, name string) (db.World, error)
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 ¶
DeleteWorld deletes a world by ID.
func (*DatabaseWrapper) GetDefaultWorld ¶
GetDefaultWorld retrieves the default world.
func (*DatabaseWrapper) GetWorldByID ¶
GetWorldByID retrieves a world by ID.
func (*DatabaseWrapper) ListWorlds ¶
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) DeleteWorld ¶
DeleteWorld deletes a world
func (*Service) GetDefaultWorld ¶
GetDefaultWorld gets or creates the default world
func (*Service) GetWorldByID ¶
GetWorldByID gets a world by ID
func (*Service) ListWorlds ¶
ListWorlds gets all worlds