m_Endpoint->RegisterSubscription("checker");
Service::OnCheckerChanged.connect(bind(&CheckerComponent::CheckerChangedHandler, this, _1));
+ Service::OnNextCheckChanged.connect(bind(&CheckerComponent::NextCheckChangedHandler, this, _1));
DynamicObject::OnUnregistered.connect(bind(&CheckerComponent::ObjectRemovedHandler, this, _1));
m_CheckTimer = boost::make_shared<Timer>();
}
}
+void CheckerComponent::NextCheckChangedHandler(const Service::Ptr& service)
+{
+ /* remove and re-insert the service from the set in order to force an index update */
+ typedef nth_index<ServiceSet, 0>::type ServiceView;
+ ServiceView& idx = boost::get<0>(m_IdleServices);
+
+ ServiceView::iterator it = idx.find(service);
+ if (it == idx.end())
+ return;
+
+ idx.erase(it);
+ idx.insert(service);
+}
+
void CheckerComponent::ObjectRemovedHandler(const DynamicObject::Ptr& object)
{
Service::Ptr service = dynamic_pointer_cast<Service>(object);
void AdjustCheckTimer(void);
void CheckerChangedHandler(const Service::Ptr& service);
+ void NextCheckChangedHandler(const Service::Ptr& service);
void ObjectRemovedHandler(const DynamicObject::Ptr& object);
};
boost::signal<void (const Service::Ptr&, const CheckResultMessage&)> Service::OnCheckResultReceived;
boost::signal<void (const Service::Ptr&, const String&)> Service::OnCheckerChanged;
+boost::signal<void (const Service::Ptr&, const Value&)> Service::OnNextCheckChanged;
Service::Service(const Dictionary::Ptr& serializedObject)
: DynamicObject(serializedObject)
{
if (name == "checker")
OnCheckerChanged(GetSelf(), oldValue);
+ else if (name == "next_check")
+ OnNextCheckChanged(GetSelf(), oldValue);
}
void Service::BeginExecuteCheck(const function<void (void)>& callback)
static boost::signal<void (const Service::Ptr& service, const CheckResultMessage&)> OnCheckResultReceived;
static boost::signal<void (const Service::Ptr&, const String&)> OnCheckerChanged;
+ static boost::signal<void (const Service::Ptr&, const Value&)> OnNextCheckChanged;
protected:
virtual void OnAttributeChanged(const String& name, const Value& oldValue);