refactor: decouple workflow core into template, consignment, and preconsignment packages#270
refactor: decouple workflow core into template, consignment, and preconsignment packages#270sthanikan2000 wants to merge 1 commit intoOpenNSW:mainfrom
Conversation
…onsignment packages
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the application's architecture by extracting domain-specific logic related to templates, consignments, and pre-consignments into their own distinct packages. This change aims to enhance modularity, reduce tight coupling within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request successfully refactors the workflow core by decoupling domain-specific logic into dedicated template, consignment, and preconsignment packages. This significantly improves modularity, reduces package coupling, and enhances maintainability. The changes involve renaming packages, moving files, updating imports, and adjusting type references across the codebase. New unit tests have been added for the extracted handlers and services, ensuring continued test coverage. A notable improvement is the template package's GetWorkflowTemplateByHSCodeIDAndFlow method, which now accepts a generic string for the flow parameter and includes explicit validation, further enhancing decoupling and robustness.
| if flow != allowedFlowImport && flow != allowedFlowExport { | ||
| return nil, fmt.Errorf("invalid consignment flow: %s", flow) | ||
| } |
There was a problem hiding this comment.
The addition of explicit validation for the flow parameter in the GetWorkflowTemplateByHSCodeIDAndFlow method is a good practice. By accepting a generic string and then validating it against known constants, the template package maintains its independence from the consignment package's specific ConsignmentFlow enum, while still ensuring data integrity. This enhances the robustness and reusability of the template service.
Summary
This PR decouples domain-specific concerns from the workflow engine by extracting template, consignment, and pre-consignment logic into dedicated packages. The workflow package is reduced to orchestration core responsibilities, and bootstrap wiring is updated to compose the new modules directly.
The goal is to improve maintainability, reduce package coupling, and make future changes to domain behavior independent from workflow internals.
Type of Change
Changes Made
internal/workflow/serviceinto new package:internal/template/interfaces.gointernal/template/service.gointernal/template/service_test.gostringfor decoupling from workflow domain types.internal/consignment/model.gointernal/consignment/service.gointernal/consignment/cha_service.gointernal/consignment/hscode_service.gointernal/consignment/handler.gointernal/consignment/cha_handler.gointernal/consignment/hscode_handler.gointernal/preconsignment/model.gointernal/preconsignment/service.gointernal/preconsignment/handler.gointernal/workflow/manager/manager.gointernal/workflow/manager/node_service.gointernal/app/bootstrap/app.goto use new domain packages and handlers.internal/workflow/service/*internal/workflow/router/*internal/workflow/model/cha.gointernal/workflow/model/consignment.gointernal/workflow/model/hs_code.gointernal/workflow/model/pre_consignment.gointernal/workflow/model/workflow_template_map.go:ConsignmentFlowfield type tostringinternal/workflow/model/model_test.goto align with moved models.internal/consignment/handler_test.gointernal/consignment/hscode_handler_test.gointernal/preconsignment/handler_test.goTesting
Executed locally:
cd backend && go build ./...cd backend && go test ./...cd backend && go vet ./...Checklist
Screenshots/Demo
N/A (backend/refactor-only PR)
Additional Notes
internal/workflownow primarily represents orchestration core concerns (manager+ workflow-specific models).Deployment Notes
No special deployment steps required.