buffet: Make periodic polling secondary if XMPP channel is up
Now that GCD server allows us to change the supported notification
channel at run-time, start with the frequent poll (every 7 seconds)
and start up XMPP channel. Once XMPP connection is established, switch
over to using XMPP as the primary command delivery mechanism and
throttle down periodic polling to once every 30 minutes.
If, for some reason, XMPP channel gets disconnected, start polling
the server frequently again, until XMPP connection is re-established.
BUG=brillo:458, brillo:713
TEST=`FEATURES=test emerge-link buffet`
Change-Id: I148a98b8229aa4597a0f6a40e596aba15265ec91
Reviewed-on: https://chromium-review.googlesource.com/273631
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/buffet_config.h b/buffet/buffet_config.h
index 6b73911..d755f08 100644
--- a/buffet/buffet_config.h
+++ b/buffet/buffet_config.h
@@ -97,6 +97,9 @@
const std::string& model_id() const { return model_id_; }
const std::string& device_kind() const { return device_kind_; }
uint64_t polling_period_ms() const { return polling_period_ms_; }
+ uint64_t backup_polling_period_ms() const {
+ return backup_polling_period_ms_;
+ }
const std::string& name() const { return name_; }
const std::string& description() const { return description_; }
@@ -129,7 +132,8 @@
std::string model_name_{"Brillo"};
std::string model_id_{"AAAAA"};
std::string device_kind_{"vendor"};
- uint64_t polling_period_ms_{7000};
+ uint64_t polling_period_ms_{7000}; // 7 seconds.
+ uint64_t backup_polling_period_ms_{30 * 60 * 1000}; // 30 minutes.
std::string device_id_;
std::string refresh_token_;