<#6853 [Refactor]: CreateRun add initial service a...
# flyte-github
a
#6853 [Refactor]: CreateRun add initial service and response structure Pull request opened by yuhuan130 Tracking issue Closes part 1 of #6824 Why are the changes needed? Currently,
CreateRun
passes protobuf requests directly to the repository layer, violating separation of concerns. This creates tight coupling between the API and data layers, making testing harder and inconsistent with the pattern in
task_service.go
(PR #6813). What changes were proposed in this pull request? Refactored
CreateRun
to use the transformer pattern:
Copy code
Before:  Service → Repository (protobuf) → Database
After:   Service → Transformer → Repository (domain model) → Database
New Files: •
runs/repository/transformers/run.go
- Converts protobuf → domain model • `CreateRunRequestToModel`: Transforms incoming request to domain model • `RunModelToCreateRunResponse`: Builds complete API response with Action hierarchy (ID, Status, Metadata) Modified Files: •
runs/service/create_run.go
- Uses transformers instead of passing protobuf directly •
runs/repository/interfaces/action.go
- Changed signature to accept
*models.Run
•
runs/repository/impl/action_repo.go
- Accepts domain models, removed protobuf logic •
runs/service/run_service_test.go
- Updated mocks and tests •
runs/repository/mocks/mock_ActionRepo.go
- Regenerated mocks to match new interface signature Key improvements: • Repository layer no longer depends on protobuf definitions • Clean separation between API and data layers • Follows closely as pattern for
task_service.go
• Completed
RunModelToCreateRunResponse
transformer to build full API response hierarchy (includes Action ID, Status with phase/timestamps, and Metadata with source) How was this patch tested? • Added unit tests for transformer functions • Updated service and repository tests to use domain models • Verified response structure matches expected hierarchy • All tests pass locally:
go test ./runs/... -v
Screenshots Screenshot 2026-01-11 at 18 14 09 Screenshot 2026-01-12 at 18 13 30 Screenshot 2026-01-12 at 18 13 42 •
main
• #6583 • [Refactor]: CreateRun add initial service and response structure 👈 flyteorg/flyte