Skip to content

Commit

Permalink
format and update
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Schore <[email protected]>
  • Loading branch information
goaway committed Jun 18, 2020
1 parent 3958a9f commit 3ed68fa
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 38 deletions.
2 changes: 1 addition & 1 deletion envoy
Submodule envoy updated 884 files
4 changes: 2 additions & 2 deletions library/common/api/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
licenses(["notice"]) # Apache 2

load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package")

licenses(["notice"]) # Apache 2

envoy_package()

envoy_cc_library(
Expand Down
4 changes: 1 addition & 3 deletions library/common/api/external.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ namespace External {

static std::unordered_map<std::string, void*> registry_{};

void registerApi(std::string name, void* api) {
registry_[name] = api;
}
void registerApi(std::string name, void* api) { registry_[name] = api; }

void* retrieveApi(std::string name) {
void* api = registry_[name];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package")
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

licenses(["notice"]) # Apache 2

package(default_visibility = ["//visibility:public"])

load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library")

load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")
envoy_package()

api_proto_package()

envoy_cc_library(
name = "platform_bridging_filter_lib",
srcs = ["bridging_filter.cc"],
hdrs = [
"c_types.h",
"bridging_filter.h",
"c_types.h",
],
repository = "@envoy",
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,33 @@ BridgingFilterConfig::BridgingFilterConfig(
: name_(proto_config.name()) {}

BridgingFilter::BridgingFilter(BridgingFilterConfigSharedPtr config)
: platform_filter_(static_cast<envoy_http_filter*>(Api::External::retrieveApi(config->name()))) {}
: platform_filter_(
static_cast<envoy_http_filter*>(Api::External::retrieveApi(config->name()))) {}

Http::FilterHeadersStatus BridgingFilter::decodeHeaders(Http::RequestHeaderMap& headers,
bool end_stream) {
bool end_stream) {
// This is a hack that results in a full copy of the header map every time.
// Viable optimizations include:
// 1) Only tracking modifications to the map at the bridging/platform layers and performing those modifications.
// 2) Implementing a fully-bridged header map so that modifications actually occur on the underlying Envoy map.
// 1) Only tracking modifications to the map at the bridging/platform layers and performing those
// modifications. 2) Implementing a fully-bridged header map so that modifications actually occur
// on the underlying Envoy map.
envoy_headers incoming_headers = Http::Utility::toBridgeHeaders(headers);
envoy_headers* new_headers = &incoming_headers;
Http::FilterHeadersStatus status = mapStatus(platform_filter_->on_request_headers(new_headers, end_stream, platform_filter_->context));
Http::FilterHeadersStatus status = mapStatus(
platform_filter_->on_request_headers(new_headers, end_stream, platform_filter_->context));
if (&incoming_headers != new_headers) {
headers.removePrefix(Http::LowerCaseString()); // Remove all headers
for (envoy_header_size_t i = 0; i < new_headers->length; i++) {
headers.addCopy(Http::LowerCaseString(Http::Utility::convertToString(new_headers->headers[i].key)),
Http::Utility::convertToString(new_headers->headers[i].value));
headers.addCopy(
Http::LowerCaseString(Http::Utility::convertToString(new_headers->headers[i].key)),
Http::Utility::convertToString(new_headers->headers[i].value));
}
}
// The C envoy_headers struct can be released now because the headers have been copied.
release_envoy_headers(*new_headers);
}

Http::FilterDataStatus BridgingFilter::decodeData(Buffer::Instance& /*data*/,
bool /*end_stream*/) {
Http::FilterDataStatus BridgingFilter::decodeData(Buffer::Instance& /*data*/, bool /*end_stream*/) {
return Http::FilterDataStatus::Continue;
}

Expand All @@ -76,12 +79,11 @@ BridgingFilter::encode100ContinueHeaders(Http::ResponseHeaderMap& /*headers*/) {
}

Http::FilterHeadersStatus BridgingFilter::encodeHeaders(Http::ResponseHeaderMap& /*headers*/,
bool /*end_stream*/) {
bool /*end_stream*/) {
return Http::FilterHeadersStatus::Continue;
}

Http::FilterDataStatus BridgingFilter::encodeData(Buffer::Instance& /*data*/,
bool /*end_stream*/) {
Http::FilterDataStatus BridgingFilter::encodeData(Buffer::Instance& /*data*/, bool /*end_stream*/) {
return Http::FilterDataStatus::Continue;
}

Expand All @@ -93,7 +95,7 @@ Http::FilterMetadataStatus BridgingFilter::encodeMetadata(Http::MetadataMap& /*m
return Http::FilterMetadataStatus::Continue;
}

}
}
} // namespace Http
} // namespace PlatformExtension
} // namespace HttpFilters
} // namespace Extensions
} // namespace Envoy
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace PlatformExtension {

class BridgingFilterConfig {
public:
BridgingFilterConfig(const envoymobile::extensions::filters::http::platform_extension::Bridging& proto_config);
BridgingFilterConfig(
const envoymobile::extensions::filters::http::platform_extension::Bridging& proto_config);

const std::string& name() const { return name_; }

Expand All @@ -24,7 +25,6 @@ class BridgingFilterConfig {

typedef std::shared_ptr<BridgingFilterConfig> BridgingFilterConfigSharedPtr;


/**
* Harness to bridge Envoy filter invocations up to the platform layer.
*/
Expand All @@ -33,14 +33,16 @@ class BridgingFilter final : public Http::PassThroughFilter {
BridgingFilter(BridgingFilterConfigSharedPtr config);

// StreamDecoderFilter
Http::FilterHeadersStatus decodeHeaders(Http::RequestHeaderMap& headers, bool end_stream) override;
Http::FilterHeadersStatus decodeHeaders(Http::RequestHeaderMap& headers,
bool end_stream) override;
Http::FilterDataStatus decodeData(Buffer::Instance& data, bool end_stream) override;
Http::FilterTrailersStatus decodeTrailers(Http::RequestTrailerMap& trailers) override;
Http::FilterMetadataStatus decodeMetadata(Http::MetadataMap& metadata) override;

// StreamEncoderFilter
Http::FilterHeadersStatus encode100ContinueHeaders(Http::ResponseHeaderMap& headers) override;
Http::FilterHeadersStatus encodeHeaders(Http::ResponseHeaderMap& headers, bool end_stream) override;
Http::FilterHeadersStatus encodeHeaders(Http::ResponseHeaderMap& headers,
bool end_stream) override;
Http::FilterDataStatus encodeData(Buffer::Instance& data, bool end_stream) override;
Http::FilterTrailersStatus encodeTrailers(Http::ResponseTrailerMap& trailers) override;
Http::FilterMetadataStatus encodeMetadata(Http::MetadataMap& metadata) override;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "library/common/extensions/filters/http/platform_extension/config.h"

#include "library/common/extensions/filters/http/platform_extension/bridging_filter.h"

namespace Envoy {
Expand All @@ -10,8 +11,8 @@ Http::FilterFactoryCb BridgingFilterFactory::createFilterFactoryFromProtoTyped(
const envoymobile::extensions::filters::http::platform_extension::Bridging& proto_config,
const std::string&, Server::Configuration::FactoryContext&) {

BridgingFilterConfigSharedPtr filter_config = std::make_shared<BridgingFilterConfig>(
proto_config);
BridgingFilterConfigSharedPtr filter_config =
std::make_shared<BridgingFilterConfig>(proto_config);
return [filter_config](Http::FilterChainFactoryCallbacks& callbacks) -> void {
callbacks.addStreamFilter(std::make_shared<BridgingFilter>(filter_config));
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <string>

#include "extensions/filters/http/common/factory_base.h"

#include "library/common/extensions/filters/http/platform_extension/filter.pb.h"
#include "library/common/extensions/filters/http/platform_extension/filter.pb.validate.h"

#include "extensions/filters/http/common/factory_base.h"

namespace Envoy {
namespace Extensions {
namespace HttpFilters {
Expand All @@ -14,7 +14,8 @@ namespace PlatformExtension {
* Config registration for the decompressor filter. @see NamedHttpFilterConfigFactory.
*/
class BridgingFilterFactory
: public Common::FactoryBase<envoymobile::extensions::filters::http::platform_extension::Bridging> {
: public Common::FactoryBase<
envoymobile::extensions::filters::http::platform_extension::Bridging> {
public:
BridgingFilterFactory() : FactoryBase("platform_extension") {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ package envoymobile.extensions.filters.http.platform_extension;
import "validate/validate.proto";

message Bridging {
string name = 1 [(validate.rules).string.min_bytes = 1];
string name = 1 [(validate.rules).string.min_bytes = 1];
}
1 change: 1 addition & 0 deletions library/common/extensions/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "extensions/filters/network/http_connection_manager/config.h"
#include "extensions/stat_sinks/metrics_service/config.h"
#include "extensions/transport_sockets/tls/config.h"

#include "library/common/extensions/filters/http/platform_extension/config.h"

namespace Envoy {
Expand Down
2 changes: 1 addition & 1 deletion library/common/main_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <atomic>
#include <string>

#include "library/common/engine.h"
#include "library/common/api/external.h"
#include "library/common/engine.h"
#include "library/common/http/dispatcher.h"

// NOLINT(namespace-envoy)
Expand Down
4 changes: 2 additions & 2 deletions library/objective-c/EnvoyEngineImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ static envoy_headers toNativeHeaders(EnvoyHeaders *headers) {
return ret;
}

static uint32_t ios_http_filter_on_request_headers(envoy_headers *headers, bool end_stream, void *context) {
static uint32_t ios_http_filter_on_request_headers(envoy_headers *headers, bool end_stream,
void *context) {
ios_http_filter_context *c = (ios_http_filter_context *)context;
EnvoyMutableHeaders *platformHeaders = to_ios_mutable_headers(*headers);
release_envoy_headers(*headers);
Expand All @@ -75,7 +76,6 @@ static uint32_t ios_http_filter_on_request_headers(envoy_headers *headers, bool
return 0; // Continue
}


@implementation EnvoyEngineImpl {
envoy_engine_t _engineHandle;
}
Expand Down

0 comments on commit 3ed68fa

Please sign in to comment.