Skip to content

Commit

Permalink
register with macro (envoyproxy#5716)
Browse files Browse the repository at this point in the history
*Description*:
From discussion in envoyproxy#5602.

*Risk Level*: Low
*Testing*: CI
*Docs Changes*:
*Release Notes*:

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Fred Douglas <fredlas@google.com>
  • Loading branch information
lizan authored and fredlas committed Mar 5, 2019
1 parent d611054 commit 4ce3921
Show file tree
Hide file tree
Showing 71 changed files with 105 additions and 200 deletions.
8 changes: 8 additions & 0 deletions include/envoy/registry/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,13 @@ template <class T, class Base> class RegisterFactory {
T instance_{};
};

/**
* Macro used for static registration.
*/
#define REGISTER_FACTORY(FACTORY, BASE) \
static Envoy::Registry::RegisterFactory</* NOLINT(fuchsia-statically-constructed-objects) */ \
FACTORY, BASE> \
FACTORY##_registered

} // namespace Registry
} // namespace Envoy
4 changes: 1 addition & 3 deletions source/extensions/access_loggers/file/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ FileAccessLogFactory::convertJsonFormatToMap(ProtobufWkt::Struct json_format) {
/**
* Static registration for the file access log. @see RegisterFactory.
*/
static Registry::RegisterFactory<FileAccessLogFactory,
Server::Configuration::AccessLogInstanceFactory>
register_;
REGISTER_FACTORY(FileAccessLogFactory, Server::Configuration::AccessLogInstanceFactory);

} // namespace File
} // namespace AccessLoggers
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/access_loggers/http_grpc/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ std::string HttpGrpcAccessLogFactory::name() const { return AccessLogNames::get(
/**
* Static registration for the HTTP gRPC access log. @see RegisterFactory.
*/
static Registry::RegisterFactory<HttpGrpcAccessLogFactory,
Server::Configuration::AccessLogInstanceFactory>
register_;
REGISTER_FACTORY(HttpGrpcAccessLogFactory, Server::Configuration::AccessLogInstanceFactory);

} // namespace HttpGrpc
} // namespace AccessLoggers
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/buffer/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ BufferFilterFactory::createRouteSpecificFilterConfigTyped(
/**
* Static registration for the buffer filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<BufferFilterFactory,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(BufferFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace BufferFilter
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/cors/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ CorsFilterFactory::createFilter(const std::string& stats_prefix,
/**
* Static registration for the cors filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<CorsFilterFactory,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(CorsFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace Cors
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/dynamo/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ DynamoFilterConfig::createFilter(const std::string& stat_prefix,
/**
* Static registration for the http dynamodb filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<DynamoFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(DynamoFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace Dynamo
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/ext_authz/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ ExtAuthzFilterConfig::createRouteSpecificFilterConfigTyped(
/**
* Static registration for the external authorization filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<ExtAuthzFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(ExtAuthzFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace ExtAuthz
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/fault/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ FaultFilterFactory::createRouteSpecificFilterConfigTyped(
/**
* Static registration for the fault filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<FaultFilterFactory,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(FaultFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace Fault
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/grpc_http1_bridge/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ GrpcHttp1BridgeFilterConfig::createFilter(const std::string&,
/**
* Static registration for the grpc HTTP1 bridge filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<GrpcHttp1BridgeFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(GrpcHttp1BridgeFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace GrpcHttp1Bridge
} // namespace HttpFilters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Http::FilterFactoryCb Config::createFilterFactoryFromProtoTyped(
/**
* Static registration for the grpc http1 reverse bridge filter. @see RegisterFactory.
*/
static Envoy::Registry::RegisterFactory<Config, Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(Config, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace GrpcHttp1ReverseBridge
} // namespace HttpFilters
} // namespace Extensions
Expand Down
5 changes: 2 additions & 3 deletions source/extensions/filters/http/grpc_json_transcoder/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ Http::FilterFactoryCb GrpcJsonTranscoderFilterConfig::createFilterFactory(
/**
* Static registration for the grpc transcoding filter. @see RegisterNamedHttpFilterConfigFactory.
*/
static Registry::RegisterFactory<GrpcJsonTranscoderFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(GrpcJsonTranscoderFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace GrpcJsonTranscoder
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/grpc_web/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ Http::FilterFactoryCb GrpcWebFilterConfig::createFilter(const std::string&,
/**
* Static registration for the gRPC-Web filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<GrpcWebFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(GrpcWebFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace GrpcWeb
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/gzip/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ Http::FilterFactoryCb GzipFilterFactory::createFilterFactoryFromProtoTyped(
/**
* Static registration for the gzip filter. @see NamedHttpFilterConfigFactory.
*/
static Registry::RegisterFactory<GzipFilterFactory,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(GzipFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace Gzip
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/header_to_metadata/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ Http::FilterFactoryCb HeaderToMetadataConfig::createFilterFactoryFromProtoTyped(
/**
* Static registration for the header-to-metadata filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<HeaderToMetadataConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(HeaderToMetadataConfig, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace HeaderToMetadataFilter
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/health_check/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ HealthCheckFilterConfig::createFilterFactory(const Json::Object& json_config,
/**
* Static registration for the health check filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<HealthCheckFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(HealthCheckFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace HealthCheck
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/ip_tagging/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ Http::FilterFactoryCb IpTaggingFilterFactory::createFilterFactoryFromProtoTyped(
/**
* Static registration for the ip tagging filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<IpTaggingFilterFactory,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(IpTaggingFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace IpTagging
} // namespace HttpFilters
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/filters/http/jwt_authn/filter_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ FilterFactory::createFilterFactoryFromProtoTyped(const JwtAuthentication& proto_
/**
* Static registration for this jwt_authn filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<FilterFactory, Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(FilterFactory, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace JwtAuthn
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/lua/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ LuaFilterConfig::createFilterFactory(const Json::Object& json_config,
/**
* Static registration for the Lua filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<LuaFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(LuaFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace Lua
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/ratelimit/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ RateLimitFilterConfig::createFilterFactory(const Json::Object& json_config,
/**
* Static registration for the rate limit filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<RateLimitFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(RateLimitFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace RateLimitFilter
} // namespace HttpFilters
Expand Down
5 changes: 2 additions & 3 deletions source/extensions/filters/http/rbac/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ RoleBasedAccessControlFilterConfigFactory::createRouteSpecificFilterConfigTyped(
/**
* Static registration for the RBAC filter. @see RegisterFactory
*/
static Registry::RegisterFactory<RoleBasedAccessControlFilterConfigFactory,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(RoleBasedAccessControlFilterConfigFactory,
Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace RBACFilter
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/router/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ RouterFilterConfig::createFilterFactory(const Json::Object& json_config,
/**
* Static registration for the router filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<RouterFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(RouterFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace RouterFilter
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/squash/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ Http::FilterFactoryCb SquashFilterConfigFactory::createFilterFactoryFromProtoTyp
/**
* Static registration for the squash filter. @see RegisterFactory.
*/
static Envoy::Registry::RegisterFactory<SquashFilterConfigFactory,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(SquashFilterConfigFactory, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace Squash
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/http/tap/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ Http::FilterFactoryCb TapFilterFactory::createFilterFactoryFromProtoTyped(
/**
* Static registration for the tap filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<TapFilterFactory,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(TapFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory);

} // namespace TapFilter
} // namespace HttpFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/listener/original_dst/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ class OriginalDstConfigFactory : public Server::Configuration::NamedListenerFilt
/**
* Static registration for the original dst filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<OriginalDstConfigFactory,
Server::Configuration::NamedListenerFilterConfigFactory>
registered_;
REGISTER_FACTORY(OriginalDstConfigFactory, Server::Configuration::NamedListenerFilterConfigFactory);

} // namespace OriginalDst
} // namespace ListenerFilters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ ProtobufTypes::MessagePtr OriginalSrcConfigFactory::createEmptyConfigProto() {
/**
* Static registration for the original_src filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<OriginalSrcConfigFactory,
Server::Configuration::NamedListenerFilterConfigFactory>
registered_;
REGISTER_FACTORY(OriginalSrcConfigFactory, Server::Configuration::NamedListenerFilterConfigFactory);

} // namespace OriginalSrc
} // namespace ListenerFilters
Expand Down
5 changes: 2 additions & 3 deletions source/extensions/filters/listener/proxy_protocol/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ class ProxyProtocolConfigFactory : public Server::Configuration::NamedListenerFi
/**
* Static registration for the proxy protocol filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<ProxyProtocolConfigFactory,
Server::Configuration::NamedListenerFilterConfigFactory>
registered_;
REGISTER_FACTORY(ProxyProtocolConfigFactory,
Server::Configuration::NamedListenerFilterConfigFactory);

} // namespace ProxyProtocol
} // namespace ListenerFilters
Expand Down
5 changes: 2 additions & 3 deletions source/extensions/filters/listener/tls_inspector/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class TlsInspectorConfigFactory : public Server::Configuration::NamedListenerFil
/**
* Static registration for the TLS inspector filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<TlsInspectorConfigFactory,
Server::Configuration::NamedListenerFilterConfigFactory>
registered_;
REGISTER_FACTORY(TlsInspectorConfigFactory,
Server::Configuration::NamedListenerFilterConfigFactory);

} // namespace TlsInspector
} // namespace ListenerFilters
Expand Down
5 changes: 2 additions & 3 deletions source/extensions/filters/network/client_ssl_auth/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ Network::FilterFactoryCb ClientSslAuthConfigFactory::createFilterFactoryFromProt
/**
* Static registration for the client SSL auth filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<ClientSslAuthConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory>
registered_;
REGISTER_FACTORY(ClientSslAuthConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory);

} // namespace ClientSslAuth
} // namespace NetworkFilters
Expand Down
5 changes: 2 additions & 3 deletions source/extensions/filters/network/dubbo_proxy/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ Network::FilterFactoryCb DubboProxyFilterConfigFactory::createFilterFactoryFromP
/**
* Static registration for the dubbo filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<DubboProxyFilterConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory>
registered_;
REGISTER_FACTORY(DubboProxyFilterConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory);

} // namespace DubboProxy
} // namespace NetworkFilters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class DubboProtocolConfigFactory : public ProtocolFactoryBase<DubboProtocolImpl>
/**
* Static registration for the Dubbo protocol. @see RegisterFactory.
*/
static Registry::RegisterFactory<DubboProtocolConfigFactory, NamedProtocolConfigFactory> register_;
REGISTER_FACTORY(DubboProtocolConfigFactory, NamedProtocolConfigFactory);

} // namespace DubboProxy
} // namespace NetworkFilters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ class HessianDeserializerConfigFactory : public DeserializerFactoryBase<HessianD
/**
* Static registration for the Hessian protocol. @see RegisterFactory.
*/
static Registry::RegisterFactory<HessianDeserializerConfigFactory, NamedDeserializerConfigFactory>
register_;
REGISTER_FACTORY(HessianDeserializerConfigFactory, NamedDeserializerConfigFactory);

} // namespace DubboProxy
} // namespace NetworkFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/network/echo/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class EchoConfigFactory : public Server::Configuration::NamedNetworkFilterConfig
/**
* Static registration for the echo filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<EchoConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory>
registered_;
REGISTER_FACTORY(EchoConfigFactory, Server::Configuration::NamedNetworkFilterConfigFactory);

} // namespace Echo
} // namespace NetworkFilters
Expand Down
4 changes: 1 addition & 3 deletions source/extensions/filters/network/ext_authz/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ Network::FilterFactoryCb ExtAuthzConfigFactory::createFilterFactoryFromProtoType
/**
* Static registration for the external authorization filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<ExtAuthzConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory>
registered_;
REGISTER_FACTORY(ExtAuthzConfigFactory, Server::Configuration::NamedNetworkFilterConfigFactory);

} // namespace ExtAuthz
} // namespace NetworkFilters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ Network::FilterFactoryCb HttpConnectionManagerFilterConfigFactory::createFilterF
/**
* Static registration for the HTTP connection manager filter.
*/
static Registry::RegisterFactory<HttpConnectionManagerFilterConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory>
registered_;
REGISTER_FACTORY(HttpConnectionManagerFilterConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory);

InternalAddressConfig::InternalAddressConfig(
const envoy::config::filter::network::http_connection_manager::v2::HttpConnectionManager::
Expand Down
5 changes: 2 additions & 3 deletions source/extensions/filters/network/mongo_proxy/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ MongoProxyFilterConfigFactory::createFilterFactory(const Json::Object& json_conf
/**
* Static registration for the mongo filter. @see RegisterFactory.
*/
static Registry::RegisterFactory<MongoProxyFilterConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory>
registered_;
REGISTER_FACTORY(MongoProxyFilterConfigFactory,
Server::Configuration::NamedNetworkFilterConfigFactory);

} // namespace MongoProxy
} // namespace NetworkFilters
Expand Down
Loading

0 comments on commit 4ce3921

Please sign in to comment.