-
Notifications
You must be signed in to change notification settings - Fork 5
refactor(otto): implement modular architecture with database support using sqlx #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
refactor(otto): implement modular architecture with database support using sqlx #17
Conversation
This commit includes: - Restructured code into specialized packages for better separation of concerns - Added database support with migrations for persistent storage - Implemented oncall rotation management module with SQLite backend - Added module system for easy extension and component management - Fixed all linting issues across the codebase - Enhanced Makefile with improved tooling and workflow commands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some initial thoughts for review. code is a bit verbose, but makes sense in structure. Some suggestions on how to simplify.
// Entity represents a database entity with an ID. | ||
type Entity interface { | ||
GetID() string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like this should be in the entity.go file.
otto/internal/database/repository.go
Outdated
} | ||
|
||
// Create inserts a new entity. | ||
func (r *SQLRepository[T]) Create(ctx context.Context, entity *T) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it would probably be easier to use something like sqlx which handles most of this mapping and selecting.
// SlogLogger is an implementation of Logger using Go's standard log/slog package. | ||
type SlogLogger struct { | ||
logger *slog.Logger | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we wrapping slog here and not just using directly?
} | ||
|
||
// MockRegistry is a mock implementation of Registry for testing. | ||
type MockRegistry struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we need a mock registry, we can probably use the real one.
otto/modules/oncall/mappers.go
Outdated
} | ||
|
||
// ToRow maps an entity to database column values. | ||
func (m *OnCallRotationMapper) ToRow(entity *OnCallRotation) []interface{} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like above, i think sqlx will handle a lot of this.
- Added jmoiron/sqlx library for simplified database operations - Replaced custom SQL mapping with struct-based scanning - Fixed type handling for EscalationStatus - Updated tests to work with the new implementation - Removed no longer needed mappers.go file
@austinlparker is this ready for another review? |
Summary
Technical Changes
Test Plan
make test
make lint
🤖 Generated with Claude Code