void SCNetworkEventPublisher::configure() { for (const auto& sub : subscriptions_) { auto sc = getSubscriptionContext(sub->context); if (sc->type == ADDRESS_TARGET) { auto existing_address = std::find( target_addresses_.begin(), target_addresses_.end(), sc->target); if (existing_address != target_addresses_.end()) { // Add the address target. addAddress(sc); } } else { auto existing_hostname = std::find(target_names_.begin(), target_names_.end(), sc->target); if (existing_hostname != target_names_.end()) { // Add the hostname target. addHostname(sc); } } } // Make sure at least one target exists. if (targets_.empty()) { auto sc = createSubscriptionContext(); sc->type = NAME_TARGET; sc->target = "localhost"; addHostname(sc); } restart(); }
void KernelEventPublisher::configure() { for (const auto &sub : subscriptions_) { if (queue_ != nullptr) { auto sc = getSubscriptionContext(sub->context); queue_->subscribe(sc->event_type, sc->udata); } } }
void INotifyEventPublisher::configure() { for (const auto& sub : subscriptions_) { // Anytime a configure is called, try to monitor all subscriptions. // Configure is called as a response to removing/adding subscriptions. // This means recalculating all monitored paths. auto sc = getSubscriptionContext(sub->context); addMonitor(sc->path, sc->recursive); } }
void INotifyEventPublisher::configure() { for (auto& sub : subscriptions_) { // Anytime a configure is called, try to monitor all subscriptions. // Configure is called as a response to removing/adding subscriptions. // This means recalculating all monitored paths. auto sc = getSubscriptionContext(sub->context); if (sc->discovered_.size() > 0) { continue; } monitorSubscription(sc); } }
void FSEventsEventPublisher::configure() { // Rebuild the watch paths. { WriteLock lock(mutex_); for (auto& sub : subscriptions_) { auto sc = getSubscriptionContext(sub->context); if (sc->discovered_.size() > 0) { continue; } auto paths = transformSubscription(sc); paths_.insert(paths.begin(), paths.end()); } } restart(); }
void INotifyEventPublisher::configure() { for (auto& sub : subscriptions_) { // Anytime a configure is called, try to monitor all subscriptions. // Configure is called as a response to removing/adding subscriptions. // This means recalculating all monitored paths. auto sc = getSubscriptionContext(sub->context); if (sc->discovered_.size() > 0) { continue; } sc->discovered_ = sc->path; if (sc->path.find("**") != std::string::npos) { sc->recursive = true; sc->discovered_ = sc->path.substr(0, sc->path.find("**")); sc->path = sc->discovered_; } if (sc->path.find('*') != std::string::npos) { // If the wildcard exists within the file (leaf), remove and monitor the // directory instead. Apply a fnmatch on fired events to filter leafs. auto fullpath = fs::path(sc->path); if (fullpath.filename().string().find('*') != std::string::npos) { sc->discovered_ = fullpath.parent_path().string(); } if (sc->discovered_.find('*') != std::string::npos) { // If a wildcard exists within the tree (stem), resolve at configure // time and monitor each path. std::vector<std::string> paths; resolveFilePattern(sc->discovered_, paths); for (const auto& _path : paths) { addMonitor(_path, sc->recursive); } sc->recursive_match = sc->recursive; continue; } } addMonitor(sc->discovered_, sc->recursive); } }