ballerina-lang
ballerina-lang copied to clipboard
Add chain invocation for `$moduleInit()`, `$moduleStart()`, `$moduleStop()`, and `$configureInit()` methods
Purpose
During the codegen phase we generate a set of functions for initializing modules and their ballerina constructs. As of now, these initializations are done using a flattened dependency list for each ballerina module. With this PR we intend to refactor the invocation design to graph like a chain invocation. Refer to the issue for more information.
Fixes #42367
Approach
Changed the $moduleInit()
BIRFunction generation boilerplate to generate invocations of $moduleInit()
functions instead of <.init>()
functions. The new method generation will be as follows,
Did the same change for generated $moduleStart
, $moduleStop
, and $configureInit()
functions.
To achieve the chain invocation effect, had to add a set of static fields to $configurationMapper
and $_init
classes as well.
For $moduleStop
methods, the stop order is determined by the algorithm(suggested by @manuranga) specified in this document.
Samples
Full change comparison can be found in this document.
Generated executable JAR samples of before and after the change can be found in this folder.
Performance comparison for bal build
command can be found in this document.
Remarks
List any other known issues, related PRs, TODO items, or any other notes related to the PR.
Check List
- [x] Read the Contributing Guide
- [ ] Updated Change Log
- [ ] Checked Tooling Support (#<Issue Number>)
- [ ] Added necessary tests
- [ ] Unit Tests
- [ ] Spec Conformance Tests
- [ ] Integration Tests
- [ ] Ballerina By Example Tests
- [ ] Increased Test Coverage
- [ ] Added necessary documentation
- [ ] API documentation
- [ ] Module documentation in Module.md files
- [ ] Ballerina By Examples
During the offline discussion with @warunalakshitha we decided to add chain invocations for $moduleStop()
as well. Explanation on how the $moduleStop()
methods get triggered can be found in this document.
Codecov Report
Attention: Patch coverage is 98.81890%
with 3 lines
in your changes missing coverage. Please review.
Project coverage is 77.66%. Comparing base (
8bbaeaa
) to head (48458c0
). Report is 207 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #42433 +/- ##
============================================
+ Coverage 77.28% 77.66% +0.37%
- Complexity 51339 51479 +140
============================================
Files 2929 2933 +4
Lines 204465 204624 +159
Branches 26683 26711 +28
============================================
+ Hits 158030 158915 +885
+ Misses 37846 37089 -757
- Partials 8589 8620 +31
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale
label is removed or commented.
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale
label is removed or commented.
@warunalakshitha can you review this?