feat: Optimize findMatchingFunction #1071
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sometimes the name of a newly added configurable pipeline function may start with one of the existing function names. For example, user is unaware of the existence of AddTags, implements function AddTagsFromDeviceResource and uses it in App Service configuration. In this case, sdk will resolve it as the function AddTags.
To make the result more accurate, the findMatchingFunction should try to find if there is a function with name identical to the target configuration function first. If no match, then iterate over all the functions to see if the target configuration function name starts with actual function name. If there are multiple matches then pick the one with the longest name.
Signed-off-by: Felix Ting [email protected]
If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/app-functions-sdk-go/blob/main/.github/CONTRIBUTING.md
PR Checklist
Please check if your PR fulfills the following requirements:
BREAKING CHANGE:
describing the break)Testing Instructions
Clone app-functions-sdk and modify /internal/app/configurable.go:
Add the following to the end of the built-in AddTags function
app.lc.Info("I am AddTags")
Add the following two functions
Run core services using EdgeX Docker Compose
Clone app-service-configurable
Modify go.mod to replace the app-functions-sdk dependency with the local app-functions-sdk
Run app-service-configurable with the following pipeline configuration
Verify logs contain following messages
New Dependency Instructions (If applicable)