control: Timer trigger can preload groups
The timer trigger is used to run actions when it expires. This commit
adds the ability for it to preload group properties so the latest values
are in the cache before it runs the actions.
This means that there doesn't need to be propertiesChanged triggers for
the groups, instead the load just reads them straight from D-Bus.
One reason to use this is so an action can be run on a slower cadence than
propertiesChanged signals would be sent. An example is a virtual sensor
that has component sensors spread out across multiple daemons. Even if
the daemons all use the same poll rates, they can be staggered between
them so virtual sensor changes could occur faster then any component
sensor read interval.
The trade off is there will be D-Bus traffic every timer interval, even
in the case the group property values don't change.
To enable this, use the following in the trigger JSON:
"preload_groups": true
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I1a92007c10fdd8017c1a89d15983ae50134c852a
diff --git a/control/json/manager.hpp b/control/json/manager.hpp
index 22b5630..2b913fe 100644
--- a/control/json/manager.hpp
+++ b/control/json/manager.hpp
@@ -64,9 +64,12 @@
* std::string = Timer package unique identifier
* std::vector<std::unique_ptr<ActionBase>> = List of pointers to actions
* that run when the timer expires
+ * const std::vector<Group> = List of groups
+ * bool = If groups should be preloaded before actions are run
*/
using TimerPkg =
- std::tuple<std::string, std::vector<std::unique_ptr<ActionBase>>&>;
+ std::tuple<std::string, std::vector<std::unique_ptr<ActionBase>>&,
+ const std::vector<Group>&, bool>;
/**
* Data associated with a running timer that's used when it expires
* Pair constructed of:
@@ -594,6 +597,13 @@
* @param[out] data - The JSON that will be filled in
*/
void dumpCache(json& data);
+
+ /**
+ * @brief Add a group to the cache dataset.
+ *
+ * @param[in] group - The group to add
+ */
+ void addGroup(const Group& group);
};
} // namespace phosphor::fan::control::json