envoyproxy/envoy

make `per_filter_config` specific configs work automatically for filters

Open

#10 164 ouverte le 25 févr. 2020

Voir sur GitHub
 (4 commentaires) (0 réactions) (0 assignés)C++ (5 373 forks)batch import
area/httpenhancementhelp wanted

Métriques du dépôt

Stars
 (27 997 stars)
Métriques de merge PR
 (Merge moyen 8j) (378 PRs mergées en 30 j)

Description

Currently filter writers need additional plumbing to allow their filter to do per vhost/route overrides. E.g.:

// Fetch the virtual host specific config.
const VHostSpecificFilterConfig* Filter::getSpecificConfig() const {
  if (!decoder_callbacks_->route() || !decoder_callbacks_->route()->routeEntry()) {
    return nullptr;
  }

  const auto* entry = decoder_callbacks_->route()->routeEntry();
  const auto* settings = entry->virtualHost().perFilterConfig("pinterest.my_filter");

  if (settings != nullptr) {
    auto* vhost_config = dynamic_cast<const VHostSpecificFilterConfig*>(settings);
    return vhost_config;
  }

  return nullptr;
}

and then you have to merge that, with the config object you got from the Filter Factory. It's not that much logic, but it's a bit of hassle to a) do it for every filter and b) remember that you have to do it.

Thoughts on providing some plumbing to avoid repeating the above pattern (or thoughts on the general future of per vhost/route config overrides)?

cc: @mattklein123 @htuch @fishcakez

Guide contributeur