-
Notifications
You must be signed in to change notification settings - Fork 2
Configurability for OSHI #3
Comments
As examples of details that we might want to be able to configure:
There's even possible hybrids of the above stated, like wanting API level issues to fail-fast, but OS level issues to just return some default unavailable value (kind of what we were doing before) |
Time before a value is stale -- this needs to be a per-value configuration. See, for example, how the openHAB SystemInfo Binding separates high (1s), medium (1m), and low (init only). When I was briefly playing around with Metrics (before realizing it couldn't handle arrays nicely) I actually rewrote the config file from the json artifact to specify millisecond-level refresh for each item. A Fail fast -- Not sure what you mean here. I've implemented WMI timeouts. There are a few other places where we sometimes need some "retries" (I use 3 to 5 attempts with exponential fallbacks from 1ms up to 16ms) to get the values, but other than that we just wait for the results. A better solution would be multithreaded requests that all wait and update when they're done. Logging -- I'd like trace and debug logging but we should replace warnings and errors with exceptions that the user can individually handle. Caching -- how is this different from the first bullet regarding stale values? |
Fail-fast means that as soon as something doesn't work, we throw an exception and execution is halted. For example, if we try to parse a serial number from the O.S., and it fails to do so, we throw some kind of MissingValueOshiException. The counterpart to that would be the result objects, where a failure would be passed back as part of the result, and not as an exception. Both situations are useful for different use cases. |
Caching costs a lot of resources. The point for that is that you cache values when the overhead cost is lower than the costs of repeating the same operations over and over. However, if you're going to refresh all the values every 200ms (heck, even every 5s), caching becomes not only worthless, it actually increments resource cost unnecessarily. The same goes for manual updates. As a general example:
This would always be followed, even if we were to execute an update every single time before we ask for a value. Now, if the user could, for example, disable caching, everything within the lock (except for item 6) would be out of the picture, replaced by a check for caching status:
And here is where some of that inheritance we're talking about in #2 starts playing a factor too, because depending on how we're working the different modules/layers, we could even just check things like caching status at init time, and then use different API providers for cached and uncached. |
Touching on your point about staleness, but expanded to them all: It's not about us setting details, it's about the users being able to set them. For example, the OpenHAB model is not a bad idea, but the point would be to let the user decide if they want all fields to be high/medium/init, or which are of what type. |
Right, I was pointing to OpenHAB as a user, not how we should model it. I mentioned that I had each value have its own refresh value (in ms) specified. Basically a request for information would be:
|
Ahh, good. Yes, that's exactly what I meant too then ;) I'd also like to have the ability to configure default values for anything that will be that granular. This way, the user can define a single configuration value, plus a handful for special cases, instead of having to trawl through a reference manual to know the name of every single configuration variable. We'd also need to define default values for every single conceivable configuration value. For an internal delivery mechanism, the easiest way is to just use the Properties already given to us by Java. |
We will, however, need to define some procedure for naming the configuration values. Once you pass the dozen names (and we will most probably reach an order of magnitude, or two, more than that) things get messy pretty quick |
It may be that "seconds" resolution is better than milliseconds. |
Also, concur with |
That gave me flashbacks of using Hibernate. XML is probably overkill for this use case. I think Although I don't think many users will go for the external config file. |
Check out how I used Properties in the JSON output. Imagine doing the same thing for the |
For this version, now that we'll start decoupling the fetching, the caching, and the API - plus the implementation of a more standard vs specialized set of APIs -, we should start looking into setting a mechanism (or two) for configuring OSHI.
The text was updated successfully, but these errors were encountered: