h->start("ACL");
#endif
- debugs(93, 5, "AccessCheck constructed for " <<
- methodStr(filter.method) << " " << vectPointStr(filter.point));
+ debugs(93, 5, "AccessCheck constructed for " << filter);
}
Adaptation::AccessCheck::~AccessCheck()
if (!ah)
return false; // dynamic rules not enabled or not triggered
- DynamicGroupCfg services;
- if (!ah->extractFutureServices(services)) { // clears history
- debugs(85,9, "no service-proposed rules stored");
- return false; // earlier service did not plan for the future
+ const auto services = ah->extractCurrentServices(filter); // updates history
+ if (services.empty()) {
+ debugs(85, 5, "no service-proposed rules for " << filter);
+ return false;
}
debugs(85,3, "using stored service-proposed rules: " << services);
Store services; ///< services in the group
bool empty() const { return services.empty(); } ///< no services added
+
+ /// configured service IDs in X-Next-Services value (comma-separated) format
+ const String &serviceIds() const { return id; }
+
void add(const String &item); ///< updates group id and services
void clear(); ///< makes the config empty
};
#include "squid.h"
#include "adaptation/Config.h"
#include "adaptation/History.h"
+#include "adaptation/ServiceGroups.h"
#include "base/TextException.h"
#include "debug/Stream.h"
#include "globals.h"
theFutureServices = services; // may be empty
}
-bool Adaptation::History::extractFutureServices(DynamicGroupCfg &value)
+Adaptation::DynamicGroupCfg
+Adaptation::History::extractCurrentServices(const ServiceFilter &filter)
{
- if (theFutureServices.empty())
- return false;
-
- value = theFutureServices;
- theFutureServices.clear();
- return true;
+ DynamicGroupCfg current, future;
+ DynamicServiceChain::Split(filter, theFutureServices.serviceIds(), current, future);
+ theFutureServices = future; // may already be the same
+ return current; // may be empty
}
#define SQUID_ADAPT_HISTORY_H
#include "adaptation/DynamicGroupCfg.h"
+#include "adaptation/forward.h"
#include "base/RefCount.h"
#include "HttpHeader.h"
#include "Notes.h"
/// sets future services for the Adaptation::AccessCheck to notice
void setFutureServices(const DynamicGroupCfg &services);
- /// returns true, fills the value, and resets iff future services were set
- bool extractFutureServices(DynamicGroupCfg &services);
+ /// returns and forgets planned/future services matching the given filter
+ DynamicGroupCfg extractCurrentServices(const ServiceFilter &);
private:
/// single Xaction stats (i.e., a historical record entry)
return *this;
}
+std::ostream &
+Adaptation::operator <<(std::ostream &os, const ServiceFilter &filter)
+{
+ os << methodStr(filter.method) << ' ' << vectPointStr(filter.point);
+ return os;
+}
+
AccessLogEntry::Pointer al; ///< info for the future access.log entry
};
+std::ostream &operator <<(std::ostream &, const ServiceFilter &);
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__SERVICE_FILTER_H */