cdsframework / ice

Immunization Calculation Engine (ICE) Service
https://cdsframework.atlassian.net/wiki/spaces/ICE/overview
Other
12 stars 9 forks source link

Expose Version, Git and build info in a new controller (CIRSUP-2014) #11

Closed StanMarkov closed 2 years ago

StanMarkov commented 2 years ago

[#CIRSUP-2014]

StanMarkov commented 2 years ago

@darylbc @nicolary please take a look at this commit for exposing the version/git/build information.

In a nutshell - the idea is the version string is now stored in iceversion.properties and we read that in VersionData. VersionData is then shared with the VersionResource controller to expose it via http. On the rule processing side, VersionData is injected into RequestProcessorService and set on each EvaluationRequestDataItem. From there ICEDecisionEngineDSS7EvaluationAdapter sets it in the global context for the drl processing. I did comment out the line in org.cdsframework^ICE^1.0.0.drl that sets the version.

I've tested the rest/http part, but no idea how to test the rules processing. If the implementation looks good to you, we should do a test to make sure the version gets propagated properly when running the rules.

Depends on this other pull request https://github.com/cdsframework/opencds-rest-service/pull/5 that has the rest controller impl.

Sample output of the rest controller.

GET http://localhost:8080/opencds-decision-support-service/version

HTTP/1.1 200 
Date: Wed, 13 Oct 2021 00:32:41 GMT
Content-Type: application/json
Content-Length: 91
Keep-Alive: timeout=20
Connection: keep-alive

{
  "iceVersion": "ICE_1.30.1",
  "gitCommitSha": "6833826",
  "buildDate": "2021-10-12T15:48:00-0700"
}

Response code: 200; Time: 595ms; Content length: 91 bytes
StanMarkov commented 2 years ago

@darylbc @nicolary another try :)

I did shift all the changes to the ice3 project. The only remaining changes in the opencds project are to beans.xml.

Approach I took is to store iceversion.properties with the source of the opencds-ice-service, and also moved the git commit maven plugin to that project. The file it generates (git.properties) is put into the target/classes folder in the same location as iceversion.properties.

beans.xml reads those property files and creates a hash map with the data we want to expose. The map is passed to the VersionResource controller, and also ICEVersionUtil class to be used by the ICEDecisionEngineDSS7EvaluationAdapter .

One thing I felt was iffy is how I init the ICEVersionUtil from the spring context, instead of just reading iceversion.properties directly, but had two reasons:

If you feel there is a better approach, I'm open to changes 👍

darylbc commented 2 years ago

Thanks @StanMarkov. Do you have a sample http request, so that I can try this out?

darylbc commented 2 years ago

@StanMarkov - Nevermind. I see it in your description above :)

darylbc commented 2 years ago

Looks good. Thanks!