From 7ddce429c8e22322bbfbd2be952a584e4dd7494d Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 18 Jun 2020 09:48:57 +0000 Subject: [PATCH 01/36] format: add checks for type alias Signed-off-by: tomocy --- tools/code_format/check_format.py | 9 +++++++++ tools/code_format/check_format_test_helper.py | 5 +++++ tools/testdata/check_format/cpp_std.cc | 2 +- tools/testdata/check_format/cpp_std.cc.gold | 2 +- .../testdata/check_format/non_type_alias_optional.cc | 11 +++++++++++ .../testdata/check_format/non_type_alias_smart_ptr.cc | 9 +++++++++ 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tools/testdata/check_format/non_type_alias_optional.cc create mode 100644 tools/testdata/check_format/non_type_alias_smart_ptr.cc diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 689ed09c7e5ba..8e42c33c02094 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -696,6 +696,15 @@ def checkSourceLine(line, file_path, reportError): reportError("Don't call grpc_init() or grpc_shutdown() directly, instantiate " + "Grpc::GoogleGrpcContext. See #8282") + if not line.startswith("using"): + smart_ptr_m = re.search("std::(unique_ptr|shared_ptr)<(.*?)>", line) + if smart_ptr_m: + reportError(f"Use type alias for '{smart_ptr_m.group(2)}' instead. See STYLE.md") + + optional_m = re.search("absl::optional>", line) + if optional_m: + reportError(f"Use type alias for '{optional_m.group(1)}' instead. See STYLE.md") + def checkBuildLine(line, file_path, reportError): if "@bazel_tools" in line and not (isSkylarkFile(file_path) or file_path.startswith("./bazel/") or diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index e00144812e409..20cc56584de05 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -216,6 +216,11 @@ def runChecks(): "grpc_shutdown.cc", "Don't call grpc_init() or grpc_shutdown() directly, instantiate Grpc::GoogleGrpcContext. " + "See #8282") + errors += checkUnfixableError("non_type_alias_smart_ptr.cc", + "Use type alias for 'Network::Connection' instead. See STYLE.md") + errors += checkUnfixableError( + "non_type_alias_optional.cc", + "Use type alias for 'ConnectionHandlerImpl::ActiveTcpListener' instead. See STYLE.md") errors += checkUnfixableError("clang_format_double_off.cc", "clang-format nested off") errors += checkUnfixableError("clang_format_trailing_off.cc", "clang-format remains off") errors += checkUnfixableError("clang_format_double_on.cc", "clang-format nested on") diff --git a/tools/testdata/check_format/cpp_std.cc b/tools/testdata/check_format/cpp_std.cc index 8342a139f26a3..ee4b0510eb561 100644 --- a/tools/testdata/check_format/cpp_std.cc +++ b/tools/testdata/check_format/cpp_std.cc @@ -4,7 +4,7 @@ namespace Envoy { -std::unique_ptr to_be_fix = absl::make_unique(0); +auto to_be_fix = absl::make_unique(0); // Awesome stuff goes here. diff --git a/tools/testdata/check_format/cpp_std.cc.gold b/tools/testdata/check_format/cpp_std.cc.gold index 8414a46360327..7f9457b3a3fc2 100644 --- a/tools/testdata/check_format/cpp_std.cc.gold +++ b/tools/testdata/check_format/cpp_std.cc.gold @@ -4,7 +4,7 @@ namespace Envoy { -std::unique_ptr to_be_fix = std::make_unique(0); +auto to_be_fix = std::make_unique(0); // Awesome stuff goes here. diff --git a/tools/testdata/check_format/non_type_alias_optional.cc b/tools/testdata/check_format/non_type_alias_optional.cc new file mode 100644 index 0000000000000..df57aaa64adb8 --- /dev/null +++ b/tools/testdata/check_format/non_type_alias_optional.cc @@ -0,0 +1,11 @@ +#include + +#include "server/connection_handler_impl.h" + +namespace Envoy { + +absl::optional> a() { + return nullptr; +} + +} // namespace Envoy diff --git a/tools/testdata/check_format/non_type_alias_smart_ptr.cc b/tools/testdata/check_format/non_type_alias_smart_ptr.cc new file mode 100644 index 0000000000000..6bf4739a8a893 --- /dev/null +++ b/tools/testdata/check_format/non_type_alias_smart_ptr.cc @@ -0,0 +1,9 @@ +#include + +#include "envoy/network/connection.h" + +namespace Envoy { + +std::unique_ptr a() { return nullptr; } + +} // namespace Envoy From 9159b57799f9c93c5640161f28a2c1e1171a4c8b Mon Sep 17 00:00:00 2001 From: tomocy Date: Fri, 19 Jun 2020 10:17:03 +0000 Subject: [PATCH 02/36] modify using type alias match Signed-off-by: tomocy --- tools/code_format/check_format.py | 2 +- tools/code_format/check_format_test_helper.py | 1 + tools/testdata/check_format/using_type_alias.cc | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tools/testdata/check_format/using_type_alias.cc diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 8e42c33c02094..e9ffa04184fcf 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -696,7 +696,7 @@ def checkSourceLine(line, file_path, reportError): reportError("Don't call grpc_init() or grpc_shutdown() directly, instantiate " + "Grpc::GoogleGrpcContext. See #8282") - if not line.startswith("using"): + if not re.search("using .* = .*;", line): smart_ptr_m = re.search("std::(unique_ptr|shared_ptr)<(.*?)>", line) if smart_ptr_m: reportError(f"Use type alias for '{smart_ptr_m.group(2)}' instead. See STYLE.md") diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index 20cc56584de05..5ff51b312f783 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -276,6 +276,7 @@ def runChecks(): errors += checkFileExpectingOK("real_time_source_override.cc") errors += checkFileExpectingOK("time_system_wait_for.cc") errors += checkFileExpectingOK("clang_format_off.cc") + errors += checkFileExpectingOK("using_type_alias.cc") return errors diff --git a/tools/testdata/check_format/using_type_alias.cc b/tools/testdata/check_format/using_type_alias.cc new file mode 100644 index 0000000000000..b218ce40c8937 --- /dev/null +++ b/tools/testdata/check_format/using_type_alias.cc @@ -0,0 +1,14 @@ +#include + +namespace Envoy { +namespace Network { +class Connection; + +using ConnectionPtr = std::unique_ptr; + +class A { + using ConnectionSharedPtr = std::shared_ptr; + using ConnectionOptRef = absl::optional>; +}; +} // namespace Network +} // namespace Envoy \ No newline at end of file From aa2dd3c5c68a90b730f220f3deb5e060fb2df2ee Mon Sep 17 00:00:00 2001 From: tomocy Date: Fri, 19 Jun 2020 10:36:27 +0000 Subject: [PATCH 03/36] modify to find all of non type alias type in line Signed-off-by: tomocy --- tools/code_format/check_format.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index e9ffa04184fcf..3b217aff143da 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -697,13 +697,13 @@ def checkSourceLine(line, file_path, reportError): "Grpc::GoogleGrpcContext. See #8282") if not re.search("using .* = .*;", line): - smart_ptr_m = re.search("std::(unique_ptr|shared_ptr)<(.*?)>", line) - if smart_ptr_m: - reportError(f"Use type alias for '{smart_ptr_m.group(2)}' instead. See STYLE.md") + smart_ptr_m = re.finditer("std::(unique_ptr|shared_ptr)<(.*?)>", line) + for m in smart_ptr_m: + reportError(f"Use type alias for '{m.group(2)}' instead. See STYLE.md") - optional_m = re.search("absl::optional>", line) - if optional_m: - reportError(f"Use type alias for '{optional_m.group(1)}' instead. See STYLE.md") + optional_m = re.finditer("absl::optional>", line) + for m in optional_m: + reportError(f"Use type alias for '{m.group(1)}' instead. See STYLE.md") def checkBuildLine(line, file_path, reportError): From c70a52e2e9df0e04c5b4c9fb4dc764f9c1a3f1ba Mon Sep 17 00:00:00 2001 From: tomocy Date: Fri, 19 Jun 2020 10:38:55 +0000 Subject: [PATCH 04/36] add non type alias allowed type list Signed-off-by: tomocy --- tools/code_format/check_format.py | 55 ++++++++++++++++++- tools/code_format/check_format_test_helper.py | 1 + .../non_type_alias_allowed_type.cc | 11 ++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 tools/testdata/check_format/non_type_alias_allowed_type.cc diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 3b217aff143da..7851db9732e30 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -168,6 +168,52 @@ "extensions/filters/network/common", "extensions/filters/network/common/redis", } + +NON_TYPE_ALIAS_ALLOWED_TYPES = { + "void", + "bool", + "short", + "short int", + "signed short", + "signed short int", + "unsigned short", + "unsigned short int", + "int", + "signed", + "signed int", + "unsigned", + "unsigned int", + "long", + "long int", + "signed long", + "signed long int", + "unsigned long", + "unsigned long int", + "long long", + "long long int", + "signed long long", + "signed long long int", + "unsigned long long", + "unsigned long long int", + "int8_t", + "int16_t", + "int32_t", + "int64_t", + "uint8_t", + "uint16_t", + "uint32_t", + "uint64_t", + "signed char", + "unsigned char", + "char", + "wchar_t", + "char16_t", + "char32_t", + "std::string", + "float", + "double", + "long double", +} # yapf: enable @@ -352,6 +398,9 @@ def whitelistedForUnpackTo(file_path): "./source/common/protobuf/utility.cc", "./source/common/protobuf/utility.h" ] +def whitelistedForNonTypeAlias(name): + return re.match(r".*\[\]$", name) or re.match("^std::vector<.*", name) or re.match(f"^({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})$", name) + def findSubstringAndReturnError(pattern, file_path, error_message): text = readFile(file_path) @@ -699,11 +748,13 @@ def checkSourceLine(line, file_path, reportError): if not re.search("using .* = .*;", line): smart_ptr_m = re.finditer("std::(unique_ptr|shared_ptr)<(.*?)>", line) for m in smart_ptr_m: - reportError(f"Use type alias for '{m.group(2)}' instead. See STYLE.md") + if not whitelistedForNonTypeAlias(m.group(2)): + reportError(f"Use type alias for '{m.group(2)}' instead. See STYLE.md") optional_m = re.finditer("absl::optional>", line) for m in optional_m: - reportError(f"Use type alias for '{m.group(1)}' instead. See STYLE.md") + if not whitelistedForNonTypeAlias(m.group(1)): + reportError(f"Use type alias for '{m.group(1)}' instead. See STYLE.md") def checkBuildLine(line, file_path, reportError): diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index 5ff51b312f783..cb59e6a8ada60 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -277,6 +277,7 @@ def runChecks(): errors += checkFileExpectingOK("time_system_wait_for.cc") errors += checkFileExpectingOK("clang_format_off.cc") errors += checkFileExpectingOK("using_type_alias.cc") + errors += checkFileExpectingOK("non_type_alias_allowed_type.cc") return errors diff --git a/tools/testdata/check_format/non_type_alias_allowed_type.cc b/tools/testdata/check_format/non_type_alias_allowed_type.cc new file mode 100644 index 0000000000000..aa70841829276 --- /dev/null +++ b/tools/testdata/check_format/non_type_alias_allowed_type.cc @@ -0,0 +1,11 @@ +#include +#include +#include + +namespace Envoy { + +void a(std::unique_ptr, std::shared_ptr, + absl::optional>, + absl::optional>>) {} + +} // namespace Envoy From bf581d4decc349f1e3c61a276f3e70d797158713 Mon Sep 17 00:00:00 2001 From: tomocy Date: Mon, 22 Jun 2020 06:54:47 +0000 Subject: [PATCH 05/36] add trailing newline Signed-off-by: tomocy --- tools/testdata/check_format/using_type_alias.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testdata/check_format/using_type_alias.cc b/tools/testdata/check_format/using_type_alias.cc index b218ce40c8937..3acf022ca8e04 100644 --- a/tools/testdata/check_format/using_type_alias.cc +++ b/tools/testdata/check_format/using_type_alias.cc @@ -11,4 +11,4 @@ class A { using ConnectionOptRef = absl::optional>; }; } // namespace Network -} // namespace Envoy \ No newline at end of file +} // namespace Envoy From 658dc573db6c352cc07db479ad9f250400c63e39 Mon Sep 17 00:00:00 2001 From: tomocy Date: Mon, 22 Jun 2020 07:06:35 +0000 Subject: [PATCH 06/36] compile and combine regexs Signed-off-by: tomocy --- tools/code_format/check_format.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 7851db9732e30..a06c1a8eae65d 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -216,6 +216,8 @@ } # yapf: enable +NON_TYPE_ALIAS_ALLOWED_TYPE = re.compile(fr"(.*\[\]$|^std::vector<.*|{'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)}$)") + # Map a line transformation function across each line of a file, # writing the result lines as requested. @@ -399,7 +401,7 @@ def whitelistedForUnpackTo(file_path): ] def whitelistedForNonTypeAlias(name): - return re.match(r".*\[\]$", name) or re.match("^std::vector<.*", name) or re.match(f"^({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})$", name) + return NON_TYPE_ALIAS_ALLOWED_TYPE.match(name) def findSubstringAndReturnError(pattern, file_path, error_message): From a49224b3aab3e819ba3787fdcfa3ded436a9b050 Mon Sep 17 00:00:00 2001 From: tomocy Date: Tue, 23 Jun 2020 05:06:26 +0000 Subject: [PATCH 07/36] compile regexs Signed-off-by: tomocy --- tools/code_format/check_format.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index a06c1a8eae65d..0906ca5143c42 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -216,6 +216,9 @@ } # yapf: enable +USING_TYPE_ALIAS = re.compile("using .* = .*;") +SMART_PTR = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>") +OPTIONAL_REF = re.compile("absl::optional>") NON_TYPE_ALIAS_ALLOWED_TYPE = re.compile(fr"(.*\[\]$|^std::vector<.*|{'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)}$)") @@ -747,13 +750,13 @@ def checkSourceLine(line, file_path, reportError): reportError("Don't call grpc_init() or grpc_shutdown() directly, instantiate " + "Grpc::GoogleGrpcContext. See #8282") - if not re.search("using .* = .*;", line): - smart_ptr_m = re.finditer("std::(unique_ptr|shared_ptr)<(.*?)>", line) + if not USING_TYPE_ALIAS.search(line): + smart_ptr_m = SMART_PTR.finditer(line) for m in smart_ptr_m: if not whitelistedForNonTypeAlias(m.group(2)): reportError(f"Use type alias for '{m.group(2)}' instead. See STYLE.md") - optional_m = re.finditer("absl::optional>", line) + optional_m = OPTIONAL_REF.finditer(line) for m in optional_m: if not whitelistedForNonTypeAlias(m.group(1)): reportError(f"Use type alias for '{m.group(1)}' instead. See STYLE.md") From 0387590e3dc451334e743e1aadfe0170dd3fe8ef Mon Sep 17 00:00:00 2001 From: tomocy Date: Tue, 23 Jun 2020 05:12:28 +0000 Subject: [PATCH 08/36] refactor names Signed-off-by: tomocy --- tools/code_format/check_format.py | 28 +++++++++---------- tools/code_format/check_format_test_helper.py | 2 +- ...onal.cc => non_type_alias_optional_ref.cc} | 0 3 files changed, 15 insertions(+), 15 deletions(-) rename tools/testdata/check_format/{non_type_alias_optional.cc => non_type_alias_optional_ref.cc} (100%) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 0906ca5143c42..40020634217e2 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -216,10 +216,10 @@ } # yapf: enable -USING_TYPE_ALIAS = re.compile("using .* = .*;") -SMART_PTR = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>") -OPTIONAL_REF = re.compile("absl::optional>") -NON_TYPE_ALIAS_ALLOWED_TYPE = re.compile(fr"(.*\[\]$|^std::vector<.*|{'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)}$)") +USING_TYPE_ALIAS_REGEX = re.compile("using .* = .*;") +SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>") +OPTIONAL_REF_REGEX = re.compile("absl::optional>") +NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(fr"(.*\[\]$|^std::vector<.*|{'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)}$)") # Map a line transformation function across each line of a file, @@ -404,7 +404,7 @@ def whitelistedForUnpackTo(file_path): ] def whitelistedForNonTypeAlias(name): - return NON_TYPE_ALIAS_ALLOWED_TYPE.match(name) + return NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX.match(name) def findSubstringAndReturnError(pattern, file_path, error_message): @@ -750,16 +750,16 @@ def checkSourceLine(line, file_path, reportError): reportError("Don't call grpc_init() or grpc_shutdown() directly, instantiate " + "Grpc::GoogleGrpcContext. See #8282") - if not USING_TYPE_ALIAS.search(line): - smart_ptr_m = SMART_PTR.finditer(line) - for m in smart_ptr_m: - if not whitelistedForNonTypeAlias(m.group(2)): - reportError(f"Use type alias for '{m.group(2)}' instead. See STYLE.md") + if not USING_TYPE_ALIAS_REGEX.search(line): + smart_ptrs = SMART_PTR_REGEX.finditer(line) + for smart_ptr in smart_ptrs: + if not whitelistedForNonTypeAlias(smart_ptr.group(2)): + reportError(f"Use type alias for '{smart_ptr.group(2)}' instead. See STYLE.md") - optional_m = OPTIONAL_REF.finditer(line) - for m in optional_m: - if not whitelistedForNonTypeAlias(m.group(1)): - reportError(f"Use type alias for '{m.group(1)}' instead. See STYLE.md") + optional_refs = OPTIONAL_REF_REGEX.finditer(line) + for optional_ref in optional_refs: + if not whitelistedForNonTypeAlias(optional_ref.group(1)): + reportError(f"Use type alias for '{optional_ref.group(1)}' instead. See STYLE.md") def checkBuildLine(line, file_path, reportError): diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index cb59e6a8ada60..b751aa943896d 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -219,7 +219,7 @@ def runChecks(): errors += checkUnfixableError("non_type_alias_smart_ptr.cc", "Use type alias for 'Network::Connection' instead. See STYLE.md") errors += checkUnfixableError( - "non_type_alias_optional.cc", + "non_type_alias_optional_ref.cc", "Use type alias for 'ConnectionHandlerImpl::ActiveTcpListener' instead. See STYLE.md") errors += checkUnfixableError("clang_format_double_off.cc", "clang-format nested off") errors += checkUnfixableError("clang_format_trailing_off.cc", "clang-format remains off") diff --git a/tools/testdata/check_format/non_type_alias_optional.cc b/tools/testdata/check_format/non_type_alias_optional_ref.cc similarity index 100% rename from tools/testdata/check_format/non_type_alias_optional.cc rename to tools/testdata/check_format/non_type_alias_optional_ref.cc From 06fe468cd9c0f3979841f2d5b7bc8499cb759137 Mon Sep 17 00:00:00 2001 From: tomocy Date: Tue, 23 Jun 2020 17:14:19 +0000 Subject: [PATCH 09/36] modify regex Signed-off-by: tomocy --- tools/code_format/check_format.py | 56 ++++++------------------------- 1 file changed, 10 insertions(+), 46 deletions(-) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 40020634217e2..f0dbb8d582e43 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -170,56 +170,20 @@ } NON_TYPE_ALIAS_ALLOWED_TYPES = { - "void", - "bool", - "short", - "short int", - "signed short", - "signed short int", - "unsigned short", - "unsigned short int", - "int", - "signed", - "signed int", - "unsigned", - "unsigned int", - "long", - "long int", - "signed long", - "signed long int", - "unsigned long", - "unsigned long int", - "long long", - "long long int", - "signed long long", - "signed long long int", - "unsigned long long", - "unsigned long long int", - "int8_t", - "int16_t", - "int32_t", - "int64_t", - "uint8_t", - "uint16_t", - "uint32_t", - "uint64_t", - "signed char", - "unsigned char", - "char", - "wchar_t", - "char16_t", - "char32_t", - "std::string", - "float", - "double", - "long double", + "^(?![A-Z].*).*$", + "^(.*::){,1}(StrictMock<|NiceMock<).*$", + "^(.*::){,1}(Test|Mock|Fake).*$", + "^Protobuf.*::.*$", + "^[A-Z]$", + "^.*, .*", + r"^.*\[\]$", } # yapf: enable USING_TYPE_ALIAS_REGEX = re.compile("using .* = .*;") -SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>") -OPTIONAL_REF_REGEX = re.compile("absl::optional>") -NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(fr"(.*\[\]$|^std::vector<.*|{'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)}$)") +SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>(?!;)") +OPTIONAL_REF_REGEX = re.compile("absl::optional>(?!;)") +NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(fr"({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})") # Map a line transformation function across each line of a file, From 143d0dbf6b87496222b0a3df56be35b99d251cf6 Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 25 Jun 2020 11:05:14 +0000 Subject: [PATCH 10/36] add check line format hook Signed-off-by: tomocy --- support/hooks/pre-push | 16 +++++- tools/code_format/check_format_test_helper.py | 46 +++++++++++++--- tools/code_format/check_line_format.py | 53 +++++++++++++++++++ 3 files changed, 107 insertions(+), 8 deletions(-) create mode 100755 tools/code_format/check_line_format.py diff --git a/support/hooks/pre-push b/support/hooks/pre-push index 1a1378b0cd07e..5672855a67527 100755 --- a/support/hooks/pre-push +++ b/support/hooks/pre-push @@ -14,7 +14,7 @@ DUMMY_SHA=0000000000000000000000000000000000000000 echo "Running pre-push check; to skip this step use 'push --no-verify'" while read LOCAL_REF LOCAL_SHA REMOTE_REF REMOTE_SHA -do +do if [ "$LOCAL_SHA" = $DUMMY_SHA ] then # Branch deleted. Do nothing. @@ -52,6 +52,20 @@ do # our `relpath` helper. SCRIPT_DIR="$(dirname "$(realpath "$0")")/../../tools" + git diff $RANGE | grep -v -E '^\+\+\+' | grep -E '^\+' | sed -e 's/^\+//g' | while IFS='' read -r line + do + if [ -z "$line" ] + then + continue + fi + + echo -ne " Checking format for $line - " + "$SCRIPT_DIR"/code_format/check_line_format.py "$line" + if [[ $? -ne 0 ]]; then + exit 1 + fi + done + # TODO(hausdorff): We should have a more graceful failure story when the # user does not have all the tools set up correctly. This script assumes # `$CLANG_FORMAT` and `$BUILDIFY` are defined, or that the default values it diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index b751aa943896d..72120fe8e15b3 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -19,6 +19,7 @@ tools = os.path.dirname(curr_dir) src = os.path.join(tools, 'testdata', 'check_format') check_format = sys.executable + " " + os.path.join(curr_dir, 'check_format.py') +check_line_format = sys.executable + " " + os.path.join(curr_dir, 'check_line_format.py') errors = 0 @@ -31,6 +32,12 @@ def runCheckFormat(operation, filename): return (command, status, stdout + stderr) +def runCheckLineFormat(line): + command = f"{check_line_format} \"{line}\"" + status, stdout, stderr = runCommand(command) + return (command, status, stdout + stderr) + + def getInputFile(filename, extra_input_files=None): files_to_copy = [filename] if extra_input_files is not None: @@ -99,6 +106,19 @@ def expectError(filename, status, stdout, expected_substring): return 1 +def expectLineError(line, status, stdout, expected_error): + if status == 0: + logging.error(f"{line}: Expected failure `{expected_error}`, but succeeded") + return 1 + + for line in stdout: + if expected_error in line: + return 0 + + logging.error(f"{line}: Could not find '{expected_error}' in:\n") + emitStdoutAsError(stdout) + return 1 + def fixFileExpectingFailure(filename, expected_substring): command, infile, outfile, status, stdout = fixFileHelper(filename) return expectError(filename, status, stdout, expected_substring) @@ -110,6 +130,11 @@ def checkFileExpectingError(filename, expected_substring, extra_input_files=None return expectError(filename, status, stdout, expected_substring) +def checkLineExpectingError(line, expected_error): + command, status, stdout = runCheckLineFormat(line) + return expectLineError(line, status, stdout, expected_error) + + def checkAndFixError(filename, expected_substring, extra_input_files=None): errors = checkFileExpectingError(filename, expected_substring, @@ -138,6 +163,10 @@ def checkUnfixableError(filename, expected_substring): return errors + +def checkUnfixableLineError(line, expected_error): + return checkLineExpectingError(line, expected_error) + def checkFileExpectingOK(filename): command, status, stdout = runCheckFormat("check", getInputFile(filename)) if status != 0: @@ -146,6 +175,15 @@ def checkFileExpectingOK(filename): return status + fixFileExpectingNoChange(filename) +def checkLineExpectingOK(line): + command, status, stdout = runCheckLineFormat(line) + if status != 0: + logging.error(f"Expected '{line}' to have no errors; status={status}, output:\n") + emitStdoutAsError(stdout) + + return status + + def runChecks(): errors = 0 @@ -216,11 +254,6 @@ def runChecks(): "grpc_shutdown.cc", "Don't call grpc_init() or grpc_shutdown() directly, instantiate Grpc::GoogleGrpcContext. " + "See #8282") - errors += checkUnfixableError("non_type_alias_smart_ptr.cc", - "Use type alias for 'Network::Connection' instead. See STYLE.md") - errors += checkUnfixableError( - "non_type_alias_optional_ref.cc", - "Use type alias for 'ConnectionHandlerImpl::ActiveTcpListener' instead. See STYLE.md") errors += checkUnfixableError("clang_format_double_off.cc", "clang-format nested off") errors += checkUnfixableError("clang_format_trailing_off.cc", "clang-format remains off") errors += checkUnfixableError("clang_format_double_on.cc", "clang-format nested on") @@ -276,8 +309,7 @@ def runChecks(): errors += checkFileExpectingOK("real_time_source_override.cc") errors += checkFileExpectingOK("time_system_wait_for.cc") errors += checkFileExpectingOK("clang_format_off.cc") - errors += checkFileExpectingOK("using_type_alias.cc") - errors += checkFileExpectingOK("non_type_alias_allowed_type.cc") + return errors diff --git a/tools/code_format/check_line_format.py b/tools/code_format/check_line_format.py new file mode 100755 index 0000000000000..993db0ebb0f47 --- /dev/null +++ b/tools/code_format/check_line_format.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +import argparse +import re +import sys + + +def checkSourceLine(line, reportError): + None + + +def printError(error): + print(f"ERROR: {error}") + + +def checkFormat(line): + error_messages = [] + + def reportError(message): + error_messages.append(f"'{line}': {message}") + + checkSourceLine(line, reportError) + + return error_messages + + +def checkErrors(errors): + if errors: + for e in errors: + printError(e) + return True + + return False + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Check line format.") + parser.add_argument( + "target_line", + type=str, + help="specify the line to check the format of") + + args = parser.parse_args() + + target_line = args.target_line + + errors = checkFormat(target_line) + + if checkErrors(errors): + printError("check format failed.") + sys.exit(1) + + print("PASS") From cd5235b823d7ed09e6774a9a77fc23a8410e6458 Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 25 Jun 2020 11:07:20 +0000 Subject: [PATCH 11/36] add line format check for type alias Signed-off-by: tomocy --- tools/code_format/check_format.py | 28 ---------------- tools/code_format/check_format_test_helper.py | 20 ++++++++++++ tools/code_format/check_line_format.py | 32 +++++++++++++++++-- .../non_type_alias_allowed_type.cc | 11 ------- .../non_type_alias_optional_ref.cc | 11 ------- .../check_format/non_type_alias_smart_ptr.cc | 9 ------ .../testdata/check_format/using_type_alias.cc | 14 -------- 7 files changed, 50 insertions(+), 75 deletions(-) delete mode 100644 tools/testdata/check_format/non_type_alias_allowed_type.cc delete mode 100644 tools/testdata/check_format/non_type_alias_optional_ref.cc delete mode 100644 tools/testdata/check_format/non_type_alias_smart_ptr.cc delete mode 100644 tools/testdata/check_format/using_type_alias.cc diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index f0dbb8d582e43..98faa1740ca18 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -169,22 +169,8 @@ "extensions/filters/network/common/redis", } -NON_TYPE_ALIAS_ALLOWED_TYPES = { - "^(?![A-Z].*).*$", - "^(.*::){,1}(StrictMock<|NiceMock<).*$", - "^(.*::){,1}(Test|Mock|Fake).*$", - "^Protobuf.*::.*$", - "^[A-Z]$", - "^.*, .*", - r"^.*\[\]$", -} # yapf: enable -USING_TYPE_ALIAS_REGEX = re.compile("using .* = .*;") -SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>(?!;)") -OPTIONAL_REF_REGEX = re.compile("absl::optional>(?!;)") -NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(fr"({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})") - # Map a line transformation function across each line of a file, # writing the result lines as requested. @@ -367,9 +353,6 @@ def whitelistedForUnpackTo(file_path): "./source/common/protobuf/utility.cc", "./source/common/protobuf/utility.h" ] -def whitelistedForNonTypeAlias(name): - return NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX.match(name) - def findSubstringAndReturnError(pattern, file_path, error_message): text = readFile(file_path) @@ -714,17 +697,6 @@ def checkSourceLine(line, file_path, reportError): reportError("Don't call grpc_init() or grpc_shutdown() directly, instantiate " + "Grpc::GoogleGrpcContext. See #8282") - if not USING_TYPE_ALIAS_REGEX.search(line): - smart_ptrs = SMART_PTR_REGEX.finditer(line) - for smart_ptr in smart_ptrs: - if not whitelistedForNonTypeAlias(smart_ptr.group(2)): - reportError(f"Use type alias for '{smart_ptr.group(2)}' instead. See STYLE.md") - - optional_refs = OPTIONAL_REF_REGEX.finditer(line) - for optional_ref in optional_refs: - if not whitelistedForNonTypeAlias(optional_ref.group(1)): - reportError(f"Use type alias for '{optional_ref.group(1)}' instead. See STYLE.md") - def checkBuildLine(line, file_path, reportError): if "@bazel_tools" in line and not (isSkylarkFile(file_path) or file_path.startswith("./bazel/") or diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index 72120fe8e15b3..9c1fbea28c662 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -310,6 +310,26 @@ def runChecks(): errors += checkFileExpectingOK("time_system_wait_for.cc") errors += checkFileExpectingOK("clang_format_off.cc") + errors += checkUnfixableLineError( + "std::unique_ptr a() { return nullptr; }", + "Use type alias for 'Network::Connection' instead. See STYLE.md") + errors += checkUnfixableLineError( + ("absl::optional> a() {" + " return nullptr;" + "}"), + "Use type alias for 'ConnectionHandlerImpl::ActiveTcpListener' instead. See STYLE.md") + + errors += checkLineExpectingOK( + ("using ConnectionPtr = std::unique_ptr;" + + "class A {" + "using ConnectionSharedPtr = std::shared_ptr;" + "using ConnectionOptRef = absl::optional>;" + "};")) + errors += checkLineExpectingOK(("void a(std::unique_ptr, std::shared_ptr," + "absl::optional>," + "absl::optional>>) {}")) + return errors diff --git a/tools/code_format/check_line_format.py b/tools/code_format/check_line_format.py index 993db0ebb0f47..ac4c624fe979f 100755 --- a/tools/code_format/check_line_format.py +++ b/tools/code_format/check_line_format.py @@ -4,9 +4,37 @@ import re import sys +NON_TYPE_ALIAS_ALLOWED_TYPES = { + "^(?![A-Z].*).*$", + "^(.*::){,1}(StrictMock<|NiceMock<).*$", + "^(.*::){,1}(Test|Mock|Fake).*$", + "^Protobuf.*::.*$", + "^[A-Z]$", + "^.*, .*", + r"^.*\[\]$", +} + +USING_TYPE_ALIAS_REGEX = re.compile("using .* = .*;") +SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>(?!;)") +OPTIONAL_REF_REGEX = re.compile("absl::optional>(?!;)") +NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(fr"({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})") + + +def whitelistedForNonTypeAlias(name): + return NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX.match(name) + def checkSourceLine(line, reportError): - None + if not USING_TYPE_ALIAS_REGEX.search(line): + smart_ptrs = SMART_PTR_REGEX.finditer(line) + for smart_ptr in smart_ptrs: + if not whitelistedForNonTypeAlias(smart_ptr.group(2)): + reportError(f"Use type alias for '{smart_ptr.group(2)}' instead. See STYLE.md") + + optional_refs = OPTIONAL_REF_REGEX.finditer(line) + for optional_ref in optional_refs: + if not whitelistedForNonTypeAlias(optional_ref.group(1)): + reportError(f"Use type alias for '{optional_ref.group(1)}' instead. See STYLE.md") def printError(error): @@ -50,4 +78,4 @@ def checkErrors(errors): printError("check format failed.") sys.exit(1) - print("PASS") + print("PASS") \ No newline at end of file diff --git a/tools/testdata/check_format/non_type_alias_allowed_type.cc b/tools/testdata/check_format/non_type_alias_allowed_type.cc deleted file mode 100644 index aa70841829276..0000000000000 --- a/tools/testdata/check_format/non_type_alias_allowed_type.cc +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include - -namespace Envoy { - -void a(std::unique_ptr, std::shared_ptr, - absl::optional>, - absl::optional>>) {} - -} // namespace Envoy diff --git a/tools/testdata/check_format/non_type_alias_optional_ref.cc b/tools/testdata/check_format/non_type_alias_optional_ref.cc deleted file mode 100644 index df57aaa64adb8..0000000000000 --- a/tools/testdata/check_format/non_type_alias_optional_ref.cc +++ /dev/null @@ -1,11 +0,0 @@ -#include - -#include "server/connection_handler_impl.h" - -namespace Envoy { - -absl::optional> a() { - return nullptr; -} - -} // namespace Envoy diff --git a/tools/testdata/check_format/non_type_alias_smart_ptr.cc b/tools/testdata/check_format/non_type_alias_smart_ptr.cc deleted file mode 100644 index 6bf4739a8a893..0000000000000 --- a/tools/testdata/check_format/non_type_alias_smart_ptr.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#include "envoy/network/connection.h" - -namespace Envoy { - -std::unique_ptr a() { return nullptr; } - -} // namespace Envoy diff --git a/tools/testdata/check_format/using_type_alias.cc b/tools/testdata/check_format/using_type_alias.cc deleted file mode 100644 index 3acf022ca8e04..0000000000000 --- a/tools/testdata/check_format/using_type_alias.cc +++ /dev/null @@ -1,14 +0,0 @@ -#include - -namespace Envoy { -namespace Network { -class Connection; - -using ConnectionPtr = std::unique_ptr; - -class A { - using ConnectionSharedPtr = std::shared_ptr; - using ConnectionOptRef = absl::optional>; -}; -} // namespace Network -} // namespace Envoy From 09a8d13a3ab028ff3e4d91cc2ea67b14dc6e5c7e Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 25 Jun 2020 11:15:55 +0000 Subject: [PATCH 12/36] modify to check only source lines Signed-off-by: tomocy --- support/hooks/pre-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/hooks/pre-push b/support/hooks/pre-push index 5672855a67527..32ad458af920b 100755 --- a/support/hooks/pre-push +++ b/support/hooks/pre-push @@ -52,7 +52,7 @@ do # our `relpath` helper. SCRIPT_DIR="$(dirname "$(realpath "$0")")/../../tools" - git diff $RANGE | grep -v -E '^\+\+\+' | grep -E '^\+' | sed -e 's/^\+//g' | while IFS='' read -r line + git diff $RANGE -- '*.cc' '*.h' | grep -v -E '^\+\+\+' | grep -E '^\+' | sed -e 's/^\+//g' | while IFS='' read -r line do if [ -z "$line" ] then From 7aef23a15455b55bc6496651537d800125736738 Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 25 Jun 2020 11:24:40 +0000 Subject: [PATCH 13/36] fix Signed-off-by: tomocy --- tools/code_format/check_line_format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/code_format/check_line_format.py b/tools/code_format/check_line_format.py index ac4c624fe979f..d3db6fbc8411e 100755 --- a/tools/code_format/check_line_format.py +++ b/tools/code_format/check_line_format.py @@ -17,7 +17,7 @@ USING_TYPE_ALIAS_REGEX = re.compile("using .* = .*;") SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>(?!;)") OPTIONAL_REF_REGEX = re.compile("absl::optional>(?!;)") -NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(fr"({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})") +NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(f"({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})") def whitelistedForNonTypeAlias(name): From 04c7681ee3427ea4c20e32af28cb5cccfce4d8f4 Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 25 Jun 2020 11:27:56 +0000 Subject: [PATCH 14/36] format Signed-off-by: tomocy --- tools/code_format/check_format_test_helper.py | 25 +++++++++-------- tools/code_format/check_line_format.py | 27 +++++++++---------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index 9c1fbea28c662..3a24e3cbd0b27 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -36,7 +36,7 @@ def runCheckLineFormat(line): command = f"{check_line_format} \"{line}\"" status, stdout, stderr = runCommand(command) return (command, status, stdout + stderr) - + def getInputFile(filename, extra_input_files=None): files_to_copy = [filename] @@ -119,6 +119,7 @@ def expectLineError(line, status, stdout, expected_error): emitStdoutAsError(stdout) return 1 + def fixFileExpectingFailure(filename, expected_substring): command, infile, outfile, status, stdout = fixFileHelper(filename) return expectError(filename, status, stdout, expected_substring) @@ -163,10 +164,10 @@ def checkUnfixableError(filename, expected_substring): return errors - def checkUnfixableLineError(line, expected_error): return checkLineExpectingError(line, expected_error) + def checkFileExpectingOK(filename): command, status, stdout = runCheckFormat("check", getInputFile(filename)) if status != 0: @@ -311,24 +312,22 @@ def runChecks(): errors += checkFileExpectingOK("clang_format_off.cc") errors += checkUnfixableLineError( - "std::unique_ptr a() { return nullptr; }", + "std::unique_ptr a() { return nullptr; }", "Use type alias for 'Network::Connection' instead. See STYLE.md") errors += checkUnfixableLineError( ("absl::optional> a() {" - " return nullptr;" - "}"), - "Use type alias for 'ConnectionHandlerImpl::ActiveTcpListener' instead. See STYLE.md") + " return nullptr;" + "}"), "Use type alias for 'ConnectionHandlerImpl::ActiveTcpListener' instead. See STYLE.md") errors += checkLineExpectingOK( ("using ConnectionPtr = std::unique_ptr;" - - "class A {" - "using ConnectionSharedPtr = std::shared_ptr;" - "using ConnectionOptRef = absl::optional>;" - "};")) + "class A {" + "using ConnectionSharedPtr = std::shared_ptr;" + "using ConnectionOptRef = absl::optional>;" + "};")) errors += checkLineExpectingOK(("void a(std::unique_ptr, std::shared_ptr," - "absl::optional>," - "absl::optional>>) {}")) + "absl::optional>," + "absl::optional>>) {}")) return errors diff --git a/tools/code_format/check_line_format.py b/tools/code_format/check_line_format.py index d3db6fbc8411e..91628727098e3 100755 --- a/tools/code_format/check_line_format.py +++ b/tools/code_format/check_line_format.py @@ -5,13 +5,13 @@ import sys NON_TYPE_ALIAS_ALLOWED_TYPES = { - "^(?![A-Z].*).*$", - "^(.*::){,1}(StrictMock<|NiceMock<).*$", - "^(.*::){,1}(Test|Mock|Fake).*$", - "^Protobuf.*::.*$", - "^[A-Z]$", - "^.*, .*", - r"^.*\[\]$", + "^(?![A-Z].*).*$", + "^(.*::){,1}(StrictMock<|NiceMock<).*$", + "^(.*::){,1}(Test|Mock|Fake).*$", + "^Protobuf.*::.*$", + "^[A-Z]$", + "^.*, .*", + r"^.*\[\]$", } USING_TYPE_ALIAS_REGEX = re.compile("using .* = .*;") @@ -45,12 +45,12 @@ def checkFormat(line): error_messages = [] def reportError(message): - error_messages.append(f"'{line}': {message}") + error_messages.append(f"'{line}': {message}") checkSourceLine(line, reportError) return error_messages - + def checkErrors(errors): if errors: @@ -63,11 +63,8 @@ def checkErrors(errors): if __name__ == "__main__": parser = argparse.ArgumentParser(description="Check line format.") - parser.add_argument( - "target_line", - type=str, - help="specify the line to check the format of") - + parser.add_argument("target_line", type=str, help="specify the line to check the format of") + args = parser.parse_args() target_line = args.target_line @@ -78,4 +75,4 @@ def checkErrors(errors): printError("check format failed.") sys.exit(1) - print("PASS") \ No newline at end of file + print("PASS") From 50b3f102be5b95bbe470793665ad223c77aba614 Mon Sep 17 00:00:00 2001 From: tomocy Date: Mon, 29 Jun 2020 05:59:55 +0000 Subject: [PATCH 15/36] add aggressive option Signed-off-by: tomocy --- tools/code_format/check_format.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 98faa1740ca18..b63745b834722 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -732,7 +732,6 @@ def fixBuildPath(file_path): error_messages += ["buildifier rewrite failed for file: %s" % file_path] return error_messages - def checkBuildPath(file_path): error_messages = [] @@ -971,6 +970,9 @@ def checkErrorMessages(error_messages): type=str, default=",".join(common.includeDirOrder()), help="specify the header block include directory order.") + parser.add_argument("--aggressive", + action='store_true', + help="specify if it fixes formats making risky changes.") args = parser.parse_args() operation_type = args.operation_type @@ -988,6 +990,7 @@ def checkErrorMessages(error_messages): "./tools/clang_tools", ] include_dir_order = args.include_dir_order + aggressive = args.aggressive if args.add_excluded_prefixes: EXCLUDED_PREFIXES += tuple(args.add_excluded_prefixes) From 85d0cec1fa610448beb71dc971be8330f8dca683 Mon Sep 17 00:00:00 2001 From: tomocy Date: Mon, 29 Jun 2020 06:23:29 +0000 Subject: [PATCH 16/36] cherry pick check for type alias Signed-off-by: tomocy --- tools/code_format/check_format.py | 30 +++++++++++++++++++ tools/code_format/check_format_test_helper.py | 7 +++++ .../non_type_alias_allowed_type.cc | 11 +++++++ .../non_type_alias_optional_ref.cc | 11 +++++++ .../check_format/non_type_alias_smart_ptr.cc | 9 ++++++ .../testdata/check_format/using_type_alias.cc | 14 +++++++++ 6 files changed, 82 insertions(+) create mode 100644 tools/testdata/check_format/non_type_alias_allowed_type.cc create mode 100644 tools/testdata/check_format/non_type_alias_optional_ref.cc create mode 100644 tools/testdata/check_format/non_type_alias_smart_ptr.cc create mode 100644 tools/testdata/check_format/using_type_alias.cc diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index b63745b834722..c0787624c9476 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -171,6 +171,21 @@ # yapf: enable +NON_TYPE_ALIAS_ALLOWED_TYPES = { + "^(?![A-Z].*).*$", + "^(.*::){,1}(StrictMock<|NiceMock<).*$", + "^(.*::){,1}(Test|Mock|Fake).*$", + "^Protobuf.*::.*$", + "^[A-Z]$", + "^.*, .*", + r"^.*\[\]$", +} + +USING_TYPE_ALIAS_REGEX = re.compile("using .* = .*;") +SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>(?!;)") +OPTIONAL_REF_REGEX = re.compile("absl::optional>(?!;)") +NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(f"({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})") + # Map a line transformation function across each line of a file, # writing the result lines as requested. @@ -348,6 +363,10 @@ def whitelistedForGrpcInit(file_path): return file_path in GRPC_INIT_WHITELIST +def whitelistedForNonTypeAlias(name): + return NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX.match(name) + + def whitelistedForUnpackTo(file_path): return file_path.startswith("./test") or file_path in [ "./source/common/protobuf/utility.cc", "./source/common/protobuf/utility.h" @@ -697,6 +716,17 @@ def checkSourceLine(line, file_path, reportError): reportError("Don't call grpc_init() or grpc_shutdown() directly, instantiate " + "Grpc::GoogleGrpcContext. See #8282") + if not USING_TYPE_ALIAS_REGEX.search(line): + smart_ptrs = SMART_PTR_REGEX.finditer(line) + for smart_ptr in smart_ptrs: + if not whitelistedForNonTypeAlias(smart_ptr.group(2)): + reportError(f"Use type alias for '{smart_ptr.group(2)}' instead. See STYLE.md") + + optional_refs = OPTIONAL_REF_REGEX.finditer(line) + for optional_ref in optional_refs: + if not whitelistedForNonTypeAlias(optional_ref.group(1)): + reportError(f"Use type alias for '{optional_ref.group(1)}' instead. See STYLE.md") + def checkBuildLine(line, file_path, reportError): if "@bazel_tools" in line and not (isSkylarkFile(file_path) or file_path.startswith("./bazel/") or diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index 3a24e3cbd0b27..edf08debed211 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -255,6 +255,11 @@ def runChecks(): "grpc_shutdown.cc", "Don't call grpc_init() or grpc_shutdown() directly, instantiate Grpc::GoogleGrpcContext. " + "See #8282") + errors += checkUnfixableError("non_type_alias_smart_ptr.cc", + "Use type alias for 'Network::Connection' instead. See STYLE.md") + errors += checkUnfixableError( + "non_type_alias_optional_ref.cc", + "Use type alias for 'ConnectionHandlerImpl::ActiveTcpListener' instead. See STYLE.md") errors += checkUnfixableError("clang_format_double_off.cc", "clang-format nested off") errors += checkUnfixableError("clang_format_trailing_off.cc", "clang-format remains off") errors += checkUnfixableError("clang_format_double_on.cc", "clang-format nested on") @@ -310,6 +315,8 @@ def runChecks(): errors += checkFileExpectingOK("real_time_source_override.cc") errors += checkFileExpectingOK("time_system_wait_for.cc") errors += checkFileExpectingOK("clang_format_off.cc") + errors += checkFileExpectingOK("using_type_alias.cc") + errors += checkFileExpectingOK("non_type_alias_allowed_type.cc") errors += checkUnfixableLineError( "std::unique_ptr a() { return nullptr; }", diff --git a/tools/testdata/check_format/non_type_alias_allowed_type.cc b/tools/testdata/check_format/non_type_alias_allowed_type.cc new file mode 100644 index 0000000000000..f6514de2d9e59 --- /dev/null +++ b/tools/testdata/check_format/non_type_alias_allowed_type.cc @@ -0,0 +1,11 @@ +#include +#include +#include + +namespace Envoy { + +void a(std::unique_ptr, std::shared_ptr, + absl::optional>, + absl::optional>>) {} + +} // namespace Envoy \ No newline at end of file diff --git a/tools/testdata/check_format/non_type_alias_optional_ref.cc b/tools/testdata/check_format/non_type_alias_optional_ref.cc new file mode 100644 index 0000000000000..e4ccfcc2b5ec9 --- /dev/null +++ b/tools/testdata/check_format/non_type_alias_optional_ref.cc @@ -0,0 +1,11 @@ +#include + +#include "server/connection_handler_impl.h" + +namespace Envoy { + +absl::optional> a() { + return nullptr; +} + +} // namespace Envoy \ No newline at end of file diff --git a/tools/testdata/check_format/non_type_alias_smart_ptr.cc b/tools/testdata/check_format/non_type_alias_smart_ptr.cc new file mode 100644 index 0000000000000..48afd4ec59e0e --- /dev/null +++ b/tools/testdata/check_format/non_type_alias_smart_ptr.cc @@ -0,0 +1,9 @@ +#include + +#include "envoy/network/connection.h" + +namespace Envoy { + +std::unique_ptr a() { return nullptr; } + +} // namespace Envoy \ No newline at end of file diff --git a/tools/testdata/check_format/using_type_alias.cc b/tools/testdata/check_format/using_type_alias.cc new file mode 100644 index 0000000000000..b218ce40c8937 --- /dev/null +++ b/tools/testdata/check_format/using_type_alias.cc @@ -0,0 +1,14 @@ +#include + +namespace Envoy { +namespace Network { +class Connection; + +using ConnectionPtr = std::unique_ptr; + +class A { + using ConnectionSharedPtr = std::shared_ptr; + using ConnectionOptRef = absl::optional>; +}; +} // namespace Network +} // namespace Envoy \ No newline at end of file From c10380fe096dd926471c6916c892457869ffe2e5 Mon Sep 17 00:00:00 2001 From: tomocy Date: Mon, 29 Jun 2020 08:19:41 +0000 Subject: [PATCH 17/36] fix with type alias aggressively Signed-off-by: tomocy --- tools/code_format/check_format.py | 70 ++++++++++++++++++- tools/code_format/check_format_test_helper.py | 25 ++++--- .../non_type_alias_allowed_type.cc | 2 +- .../non_type_alias_optional_ref.cc | 2 +- .../check_format/non_type_alias_smart_ptr.cc | 2 +- .../check_format/non_type_alias_types.cc | 10 +++ .../check_format/non_type_alias_types.cc.gold | 7 ++ .../testdata/check_format/using_type_alias.cc | 2 +- 8 files changed, 107 insertions(+), 13 deletions(-) create mode 100644 tools/testdata/check_format/non_type_alias_types.cc create mode 100644 tools/testdata/check_format/non_type_alias_types.cc.gold diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index c0787624c9476..511b304c30a8c 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -168,7 +168,6 @@ "extensions/filters/network/common", "extensions/filters/network/common/redis", } - # yapf: enable NON_TYPE_ALIAS_ALLOWED_TYPES = { @@ -529,6 +528,71 @@ def reportError(message): return error_messages +def replaceWithTypeAlias(line): + + def replaceSmartPtr(match): + kind = match.group(1) + name = match.group(2) + const = "const " in name + if const: + name = name.replace("const ", "") + if whitelistedForNonTypeAlias(name): + return match.group() + + with_type_param = "<" in name + + if kind == "unique_ptr" and not const and not with_type_param: + return f"{name}Ptr" + elif kind == "unique_ptr" and const and not with_type_param: + return f"{name}ConstPtr" + elif kind == "unique_ptr" and not const and with_type_param: + splitted = name.split("<") + return f"{splitted[0]}Ptr<{splitted[1]}" + elif kind == "unique_ptr" and const and with_type_param: + splitted = name.split("<") + return f"{splitted[0]}ConstPtr<{splitted[1]}" + elif kind == "shared_ptr" and not const and not with_type_param: + return f"{name}SharedPtr" + elif kind == "shared_ptr" and const and not with_type_param: + return f"{name}ConstSharedPtr" + elif kind == "shared_ptr" and not const and with_type_param: + splitted = name.split("<") + return f"{splitted[0]}SharedPtr<{splitted[1]}" + elif kind == "shared_ptr" and const and with_type_param: + splitted = name.split("<") + return f"{splitted[0]}ConstSharedPtr<{splitted[1]}" + else: + return match.group() + + def replaceOptionalRef(match): + name = match.group(1) + const = "const " in name + if const: + name = name.replace("const ", "") + if whitelistedForNonTypeAlias(name): + return match.group() + + with_type_param = "<" in name + + if not const and not with_type_param: + return f"{name}OptRef" + elif const and not with_type_param: + return f"{name}OptConstRef" + elif not const and with_type_param: + splitted = name.split("<") + return f"{splitted[0]}OptRef<{splitted[1]}" + elif const and with_type_param: + splitted = name.split("<") + return f"{splitted[0]}OptConstRef<{splitted[1]}" + else: + return match.group() + + line = SMART_PTR_REGEX.sub(replaceSmartPtr, line) + line = OPTIONAL_REF_REGEX.sub(replaceOptionalRef, line) + + return line + + DOT_MULTI_SPACE_REGEX = re.compile("\\. +") @@ -548,6 +612,9 @@ def fixSourceLine(line, line_number): for invalid_construct, valid_construct in LIBCXX_REPLACEMENTS.items(): line = line.replace(invalid_construct, valid_construct) + if aggressive and not USING_TYPE_ALIAS_REGEX.match(line): + line = replaceWithTypeAlias(line) + return line @@ -762,6 +829,7 @@ def fixBuildPath(file_path): error_messages += ["buildifier rewrite failed for file: %s" % file_path] return error_messages + def checkBuildPath(file_path): error_messages = [] diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index edf08debed211..922f27338936c 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -26,8 +26,11 @@ # Runs the 'check_format' operation, on the specified file, printing # the comamnd run and the status code as well as the stdout, and returning # all of that to the caller. -def runCheckFormat(operation, filename): - command = check_format + " " + operation + " " + filename +def runCheckFormat(operation, filename, options=None): + command = f"{check_format} {operation} {filename} " + if options is not None: + command += f"{' '.join(options)} " + status, stdout, stderr = runCommand(command) return (command, status, stdout + stderr) @@ -54,9 +57,9 @@ def getInputFile(filename, extra_input_files=None): # Attempts to fix file, returning a 4-tuple: the command, input file name, # output filename, captured stdout as an array of lines, and the error status # code. -def fixFileHelper(filename, extra_input_files=None): +def fixFileHelper(filename, extra_input_files=None, options=None): command, status, stdout = runCheckFormat( - "fix", getInputFile(filename, extra_input_files=extra_input_files)) + "fix", getInputFile(filename, extra_input_files=extra_input_files), options) infile = os.path.join(src, filename) return command, infile, filename, status, stdout @@ -64,9 +67,10 @@ def fixFileHelper(filename, extra_input_files=None): # Attempts to fix a file, returning the status code and the generated output. # If the fix was successful, the diff is returned as a string-array. If the file # was not fixable, the error-messages are returned as a string-array. -def fixFileExpectingSuccess(file, extra_input_files=None): +def fixFileExpectingSuccess(file, extra_input_files=None, options=None): command, infile, outfile, status, stdout = fixFileHelper(file, - extra_input_files=extra_input_files) + extra_input_files=extra_input_files, + options=options) if status != 0: print("FAILED: " + infile) emitStdoutAsError(stdout) @@ -136,11 +140,11 @@ def checkLineExpectingError(line, expected_error): return expectLineError(line, status, stdout, expected_error) -def checkAndFixError(filename, expected_substring, extra_input_files=None): +def checkAndFixError(filename, expected_substring, extra_input_files=None, options=None): errors = checkFileExpectingError(filename, expected_substring, extra_input_files=extra_input_files) - errors += fixFileExpectingSuccess(filename, extra_input_files=extra_input_files) + errors += fixFileExpectingSuccess(filename, extra_input_files=extra_input_files, options=options) return errors @@ -311,6 +315,11 @@ def runChecks(): errors += checkAndFixError( "cpp_std.cc", "term absl::make_unique< should be replaced with standard library term std::make_unique<") + errors += checkAndFixError("non_type_alias_types.cc", + "Use type alias for", + options=[ + "--aggressive", + ]) errors += checkFileExpectingOK("real_time_source_override.cc") errors += checkFileExpectingOK("time_system_wait_for.cc") diff --git a/tools/testdata/check_format/non_type_alias_allowed_type.cc b/tools/testdata/check_format/non_type_alias_allowed_type.cc index f6514de2d9e59..aa70841829276 100644 --- a/tools/testdata/check_format/non_type_alias_allowed_type.cc +++ b/tools/testdata/check_format/non_type_alias_allowed_type.cc @@ -8,4 +8,4 @@ void a(std::unique_ptr, std::shared_ptr, absl::optional>, absl::optional>>) {} -} // namespace Envoy \ No newline at end of file +} // namespace Envoy diff --git a/tools/testdata/check_format/non_type_alias_optional_ref.cc b/tools/testdata/check_format/non_type_alias_optional_ref.cc index e4ccfcc2b5ec9..df57aaa64adb8 100644 --- a/tools/testdata/check_format/non_type_alias_optional_ref.cc +++ b/tools/testdata/check_format/non_type_alias_optional_ref.cc @@ -8,4 +8,4 @@ absl::optional> return nullptr; } -} // namespace Envoy \ No newline at end of file +} // namespace Envoy diff --git a/tools/testdata/check_format/non_type_alias_smart_ptr.cc b/tools/testdata/check_format/non_type_alias_smart_ptr.cc index 48afd4ec59e0e..6bf4739a8a893 100644 --- a/tools/testdata/check_format/non_type_alias_smart_ptr.cc +++ b/tools/testdata/check_format/non_type_alias_smart_ptr.cc @@ -6,4 +6,4 @@ namespace Envoy { std::unique_ptr a() { return nullptr; } -} // namespace Envoy \ No newline at end of file +} // namespace Envoy diff --git a/tools/testdata/check_format/non_type_alias_types.cc b/tools/testdata/check_format/non_type_alias_types.cc new file mode 100644 index 0000000000000..8434c6c2f530a --- /dev/null +++ b/tools/testdata/check_format/non_type_alias_types.cc @@ -0,0 +1,10 @@ +#include + +namespace Envoy { +void a(std::unique_ptr, std::unique_ptr, std::shared_ptr, + std::shared_ptr, absl::optional>, + absl::optional>, std::unique_ptr>, + std::unique_ptr>, std::shared_ptr>, std::shared_ptr>, + absl::optional>>, + absl::optional>>) {} +} // namespace Envoy diff --git a/tools/testdata/check_format/non_type_alias_types.cc.gold b/tools/testdata/check_format/non_type_alias_types.cc.gold new file mode 100644 index 0000000000000..a73b8290a39d8 --- /dev/null +++ b/tools/testdata/check_format/non_type_alias_types.cc.gold @@ -0,0 +1,7 @@ +#include + +namespace Envoy { +void a(AAAPtr, AAAConstPtr, BBBSharedPtr, BBBConstSharedPtr, CCCOptRef, + CCCOptConstRef, DDDPtr, DDDConstPtr, FFFSharedPtr, + FFFConstSharedPtr, HHHOptRef, HHHOptConstRef) {} +} // namespace Envoy \ No newline at end of file diff --git a/tools/testdata/check_format/using_type_alias.cc b/tools/testdata/check_format/using_type_alias.cc index b218ce40c8937..3acf022ca8e04 100644 --- a/tools/testdata/check_format/using_type_alias.cc +++ b/tools/testdata/check_format/using_type_alias.cc @@ -11,4 +11,4 @@ class A { using ConnectionOptRef = absl::optional>; }; } // namespace Network -} // namespace Envoy \ No newline at end of file +} // namespace Envoy From 9f9a80d769692c81c736f268cccae808c76d98c9 Mon Sep 17 00:00:00 2001 From: tomocy Date: Mon, 29 Jun 2020 08:35:24 +0000 Subject: [PATCH 18/36] replace with type alias aggressively Signed-off-by: tomocy --- include/envoy/config/grpc_mux.h | 2 +- include/envoy/config/typed_metadata.h | 3 +- include/envoy/http/message.h | 2 +- include/envoy/router/router.h | 2 +- include/envoy/stream_info/filter_state.h | 4 +- include/envoy/upstream/upstream.h | 9 ++- source/common/buffer/buffer_impl.h | 2 +- source/common/common/logger.h | 2 +- source/common/common/thread_synchronizer.h | 5 +- source/common/common/utility.h | 2 +- source/common/config/config_provider_impl.h | 4 +- .../config/filesystem_subscription_impl.h | 2 +- source/common/config/grpc_stream.h | 2 +- source/common/config/metadata.h | 2 +- source/common/config/new_grpc_mux_impl.h | 4 +- .../config/subscription_factory_impl.cc | 2 +- source/common/config/watch_map.h | 2 +- source/common/event/dispatcher_impl.h | 2 +- source/common/filesystem/win32/watcher_impl.h | 2 +- .../formatter/substitution_formatter.cc | 6 +- source/common/grpc/async_client_impl.cc | 2 +- source/common/grpc/async_client_impl.h | 2 +- .../common/grpc/google_async_client_impl.cc | 4 +- source/common/grpc/google_async_client_impl.h | 2 +- source/common/grpc/typed_async_client.h | 8 +-- source/common/http/async_client_impl.cc | 4 +- source/common/http/async_client_impl.h | 8 +-- source/common/http/codec_client.cc | 2 +- source/common/http/conn_manager_impl.h | 14 ++--- source/common/http/header_map_impl.h | 19 +++--- source/common/http/http2/codec_impl.h | 4 +- source/common/http/http3/quic_codec_factory.h | 8 +-- source/common/http/message_impl.h | 10 ++-- .../common/http/request_id_extension_impl.cc | 2 +- source/common/http/user_agent.h | 2 +- source/common/init/target_impl.h | 4 +- source/common/init/watcher_impl.cc | 3 +- source/common/init/watcher_impl.h | 2 +- .../addr_family_aware_socket_option_impl.cc | 3 +- .../addr_family_aware_socket_option_impl.h | 8 +-- source/common/network/connection_impl_base.h | 2 +- source/common/network/dns_impl.cc | 2 +- source/common/network/lc_trie.h | 6 +- .../common/network/socket_option_factory.cc | 35 ++++++----- source/common/network/socket_option_factory.h | 19 +++--- source/common/router/config_impl.cc | 3 +- source/common/router/config_impl.h | 10 ++-- source/common/router/rds_impl.cc | 12 ++-- source/common/router/rds_impl.h | 7 +-- source/common/router/router.cc | 6 +- source/common/router/router.h | 4 +- source/common/router/router_ratelimit.cc | 3 +- source/common/router/router_ratelimit.h | 2 +- source/common/router/scoped_config_impl.cc | 4 +- source/common/router/scoped_config_impl.h | 12 ++-- source/common/router/scoped_rds.cc | 10 ++-- source/common/router/scoped_rds.h | 9 ++- source/common/router/upstream_request.cc | 5 +- source/common/router/upstream_request.h | 9 ++- source/common/router/vhds.h | 2 +- source/common/runtime/runtime_impl.cc | 2 +- source/common/secret/sds_api.h | 4 +- source/common/secret/secret_manager_impl.h | 10 ++-- source/common/stats/isolated_store_impl.cc | 2 +- source/common/stats/isolated_store_impl.h | 2 +- source/common/stats/thread_local_store.cc | 3 +- source/common/stats/thread_local_store.h | 2 +- .../common/stream_info/filter_state_impl.cc | 4 +- source/common/stream_info/filter_state_impl.h | 7 +-- source/common/tcp_proxy/tcp_proxy.cc | 4 +- source/common/tcp_proxy/tcp_proxy.h | 19 +++--- .../common/thread_local/thread_local_impl.cc | 18 +++--- .../common/thread_local/thread_local_impl.h | 8 +-- source/common/upstream/cds_api_impl.cc | 2 +- source/common/upstream/cds_api_impl.h | 2 +- .../common/upstream/cluster_manager_impl.cc | 4 +- source/common/upstream/cluster_manager_impl.h | 5 +- source/common/upstream/conn_pool_map.h | 4 +- source/common/upstream/eds.h | 2 +- .../upstream/health_checker_base_impl.cc | 7 +-- .../upstream/health_checker_base_impl.h | 8 +-- source/common/upstream/health_checker_impl.cc | 2 +- source/common/upstream/health_checker_impl.h | 2 +- source/common/upstream/load_balancer_impl.cc | 11 ++-- source/common/upstream/load_balancer_impl.h | 2 +- .../common/upstream/original_dst_cluster.cc | 2 +- source/common/upstream/original_dst_cluster.h | 13 ++--- .../common/upstream/outlier_detection_impl.cc | 15 +++-- .../common/upstream/outlier_detection_impl.h | 14 ++--- .../common/upstream/priority_conn_pool_map.h | 2 +- source/common/upstream/thread_aware_lb_impl.h | 12 ++-- source/common/upstream/upstream_impl.cc | 8 +-- source/common/upstream/upstream_impl.h | 31 +++++----- source/exe/main_common.cc | 9 ++- source/exe/main_common.h | 16 ++--- source/exe/platform_impl.h | 4 +- .../access_loggers/grpc/config_utils.cc | 2 +- .../clusters/aggregate/lb_context.h | 2 +- .../clusters/dynamic_forward_proxy/cluster.cc | 11 ++-- .../clusters/dynamic_forward_proxy/cluster.h | 3 +- .../redis/cluster_refresh_manager_impl.h | 4 +- .../filters/common/rbac/engine_impl.h | 2 +- .../extensions/filters/common/rbac/utility.h | 4 +- .../adaptive_concurrency_filter.h | 2 +- .../http/adaptive_concurrency/config.cc | 2 +- .../admission_control/admission_control.cc | 2 +- .../admission_control/admission_control.h | 6 +- .../http/aws_lambda/aws_lambda_filter.cc | 2 +- .../http/aws_lambda/aws_lambda_filter.h | 4 +- .../aws_request_signing_filter.cc | 2 +- .../aws_request_signing_filter.h | 4 +- .../http/common/compressor/compressor.cc | 4 +- .../http/common/compressor/compressor.h | 2 +- .../filters/http/fault/fault_filter.h | 4 +- .../json_transcoder_filter.cc | 26 ++++----- .../http/ip_tagging/ip_tagging_filter.h | 2 +- .../filters/http/jwt_authn/filter_config.h | 5 +- .../filters/http/rbac/rbac_filter.h | 8 +-- .../filters/network/common/redis/codec.h | 10 ++-- .../common/redis/redis_command_stats.h | 3 +- .../filters/network/dubbo_proxy/config.cc | 2 +- .../dubbo_proxy/router/route_matcher.h | 2 +- .../network/dubbo_proxy/router/router_impl.h | 2 +- .../network/http_connection_manager/config.cc | 16 ++--- .../network/http_connection_manager/config.h | 13 ++--- .../filters/network/mongo_proxy/bson_impl.h | 2 +- .../filters/network/mongo_proxy/codec_impl.cc | 16 +++-- .../filters/network/mongo_proxy/proxy.h | 2 +- .../network/mysql_proxy/mysql_filter.h | 2 +- .../network/postgres_proxy/postgres_filter.h | 4 +- .../filters/network/rbac/rbac_filter.h | 4 +- .../redis_proxy/command_splitter_impl.cc | 11 ++-- .../filters/network/redis_proxy/config.cc | 7 +-- .../filters/network/rocketmq_proxy/config.cc | 2 +- .../filters/network/thrift_proxy/config.cc | 2 +- .../filters/network/thrift_proxy/config.h | 2 +- .../thrift_proxy/router/router_impl.cc | 4 +- .../network/thrift_proxy/router/router_impl.h | 2 +- .../router/router_ratelimit_impl.cc | 3 +- .../router/router_ratelimit_impl.h | 2 +- .../thrift_proxy/thrift_object_impl.cc | 2 +- .../filters/network/zookeeper_proxy/filter.h | 2 +- .../filters/udp/dns_filter/dns_parser.h | 2 +- .../grpc_credentials/aws_iam/config.cc | 2 +- .../quiche/active_quic_listener.cc | 2 +- .../quiche/active_quic_listener.h | 2 +- .../quic_listeners/quiche/codec_impl.cc | 6 +- .../quic_listeners/quiche/codec_impl.h | 4 +- .../quiche/envoy_quic_client_session.cc | 2 +- .../quiche/envoy_quic_client_session.h | 2 +- .../quiche/envoy_quic_connection.h | 2 +- .../quiche/envoy_quic_fake_proof_source.h | 2 +- .../quiche/envoy_quic_proof_source.cc | 6 +- .../quiche/envoy_quic_proof_source.h | 2 +- .../quiche/envoy_quic_server_session.cc | 2 +- .../quiche/envoy_quic_server_session.h | 5 +- .../quiche/platform/quic_mem_slice_impl.h | 2 +- .../quiche/quic_transport_socket_factory.h | 4 +- .../fixed_heap/fixed_heap_monitor.cc | 2 +- .../fixed_heap/fixed_heap_monitor.h | 4 +- .../stat_sinks/common/statsd/statsd.h | 4 +- .../extensions/stat_sinks/hystrix/hystrix.cc | 3 +- .../stat_sinks/metrics_service/config.cc | 9 ++- source/server/admin/config_tracker_impl.cc | 2 +- source/server/admin/config_tracker_impl.h | 6 +- source/server/config_validation/dispatcher.h | 2 +- source/server/config_validation/server.h | 12 ++-- source/server/configuration_impl.h | 2 +- source/server/connection_handler_impl.cc | 2 +- source/server/connection_handler_impl.h | 4 +- source/server/filter_chain_manager_impl.h | 2 +- source/server/hot_restarting_base.cc | 6 +- source/server/hot_restarting_child.cc | 8 +-- source/server/hot_restarting_child.h | 2 +- source/server/hot_restarting_parent.cc | 2 +- source/server/hot_restarting_parent.h | 2 +- source/server/lds_api.cc | 2 +- source/server/lds_api.h | 2 +- source/server/listener_impl.h | 13 ++--- source/server/listener_manager_impl.cc | 2 +- source/server/listener_manager_impl.h | 2 +- source/server/server.cc | 16 ++--- source/server/server.h | 26 ++++----- test/common/buffer/buffer_fuzz.cc | 2 +- test/common/common/utility_test.cc | 4 +- .../config/config_provider_impl_test.cc | 4 +- .../config/delta_subscription_impl_test.cc | 4 +- .../config/delta_subscription_test_harness.h | 4 +- test/common/config/grpc_mux_impl_test.cc | 2 +- .../config/grpc_subscription_test_harness.h | 4 +- .../config/http_subscription_test_harness.h | 2 +- test/common/config/metadata_test.cc | 3 +- test/common/config/new_grpc_mux_impl_test.cc | 2 +- .../config/subscription_factory_impl_test.cc | 2 +- test/common/config/subscription_impl_test.cc | 2 +- .../substitution_formatter_speed_test.cc | 9 ++- .../grpc/google_async_client_impl_test.cc | 2 +- .../grpc_client_integration_test_harness.h | 6 +- test/common/http/async_client_utility_test.cc | 3 +- test/common/http/codec_client_test.cc | 4 +- test/common/http/conn_manager_impl_test.cc | 2 +- test/common/http/conn_manager_utility_test.cc | 2 +- test/common/http/header_map_impl_fuzz_test.cc | 2 +- test/common/http/header_map_impl_test.cc | 2 +- test/common/http/http1/codec_impl_test.cc | 2 +- test/common/http/http1/conn_pool_test.cc | 2 +- .../http2/metadata_encoder_decoder_test.cc | 4 +- test/common/network/connection_impl_test.cc | 8 +-- test/common/network/dns_impl_test.cc | 6 +- test/common/network/filter_matcher_test.cc | 2 +- test/common/network/lc_trie_speed_test.cc | 12 ++-- test/common/network/lc_trie_test.cc | 2 +- .../common/network/listen_socket_impl_test.cc | 5 +- .../network/socket_option_factory_test.cc | 6 +- test/common/network/udp_listener_impl_test.cc | 2 +- test/common/protobuf/utility_test.cc | 2 +- test/common/router/config_impl_test.cc | 3 +- test/common/router/rds_impl_test.cc | 10 ++-- test/common/router/router_ratelimit_test.cc | 4 +- .../common/router/router_upstream_log_test.cc | 2 +- test/common/router/scoped_config_impl_test.cc | 28 +++++---- test/common/router/scoped_rds_test.cc | 4 +- test/common/router/upstream_request_test.cc | 4 +- test/common/runtime/runtime_impl_test.cc | 2 +- .../common/secret/secret_manager_impl_test.cc | 22 +++---- test/common/shared_pool/shared_pool_test.cc | 18 +++--- test/common/stats/isolated_store_impl_test.cc | 2 +- test/common/stats/stat_test_utility.cc | 6 +- test/common/stats/stats_matcher_impl_test.cc | 2 +- test/common/stats/symbol_table_impl_test.cc | 4 +- .../stats/thread_local_store_speed_test.cc | 4 +- test/common/stats/thread_local_store_test.cc | 12 ++-- test/common/stats/utility_test.cc | 2 +- .../stream_info/filter_state_impl_test.cc | 2 +- test/common/tcp/conn_pool_test.cc | 4 +- test/common/tcp_proxy/tcp_proxy_test.cc | 6 +- test/common/tcp_proxy/upstream_test.cc | 2 +- .../tracing/http_tracer_manager_impl_test.cc | 9 ++- test/common/upstream/eds_speed_test.cc | 6 +- test/common/upstream/eds_test.cc | 2 +- test/common/upstream/hds_test.cc | 2 +- .../upstream/health_checker_impl_test.cc | 9 ++- .../upstream/load_balancer_benchmark.cc | 8 +-- .../upstream/load_balancer_impl_test.cc | 6 +- .../upstream/load_stats_reporter_test.cc | 2 +- .../upstream/logical_dns_cluster_test.cc | 2 +- test/common/upstream/maglev_lb_test.cc | 2 +- .../upstream/outlier_detection_impl_test.cc | 52 ++++++++--------- test/common/upstream/ring_hash_lb_test.cc | 2 +- test/common/upstream/subset_lb_test.cc | 8 +-- test/common/upstream/upstream_impl_test.cc | 11 ++-- test/config_test/config_test.cc | 2 +- test/exe/main_common_test.cc | 6 +- .../grpc/grpc_access_log_impl_test.cc | 4 +- .../grpc/http_grpc_access_log_impl_test.cc | 2 +- .../clusters/aggregate/cluster_test.cc | 2 +- .../dynamic_forward_proxy/cluster_test.cc | 4 +- .../clusters/redis/redis_cluster_lb_test.cc | 4 +- .../clusters/redis/redis_cluster_test.cc | 2 +- .../dns_cache_impl_test.cc | 2 +- .../proxy_protocol_regression_test.cc | 2 +- .../redis/cluster_refresh_manager_test.cc | 2 +- test/extensions/common/tap/admin_test.cc | 2 +- test/extensions/common/wasm/wasm_vm_test.cc | 4 +- .../ext_authz/ext_authz_grpc_impl_test.cc | 2 +- .../ext_authz/ext_authz_http_impl_test.cc | 2 +- .../extensions/filters/common/lua/lua_test.cc | 2 +- .../filters/common/lua/lua_wrappers.h | 2 +- .../original_src_socket_option_test.cc | 2 +- .../adaptive_concurrency_filter_test.cc | 2 +- .../admission_control_filter_test.cc | 8 +-- .../http/admission_control/config_test.cc | 2 +- .../success_criteria_evaluator_test.cc | 2 +- .../http/aws_lambda/aws_lambda_filter_test.cc | 2 +- .../filters/http/aws_lambda/config_test.cc | 4 +- .../aws_request_signing_filter_test.cc | 2 +- .../compressor/compressor_filter_test.cc | 20 +++---- .../filters/http/common/jwks_fetcher_test.cc | 14 ++--- .../decompressor/decompressor_filter_test.cc | 26 ++++----- .../proxy_filter_test.cc | 2 +- .../filters/http/dynamo/dynamo_filter_test.cc | 2 +- .../filters/http/ext_authz/ext_authz_test.cc | 2 +- .../filters/http/fault/fault_filter_test.cc | 2 +- .../reverse_bridge_test.cc | 2 +- .../json_transcoder_filter_test.cc | 12 ++-- .../filters/http/grpc_stats/config_test.cc | 2 +- .../filters/http/gzip/gzip_filter_test.cc | 4 +- .../header_to_metadata_filter_test.cc | 2 +- .../http/health_check/health_check_test.cc | 2 +- .../http/ip_tagging/ip_tagging_filter_test.cc | 2 +- .../http/jwt_authn/all_verifier_test.cc | 2 +- .../http/jwt_authn/authenticator_test.cc | 2 +- .../filters/http/jwt_authn/filter_test.cc | 2 +- .../http/jwt_authn/provider_verifier_test.cc | 2 +- .../filters/http/lua/lua_filter_test.cc | 2 +- .../http/on_demand/on_demand_filter_test.cc | 2 +- .../http/original_src/original_src_test.cc | 9 +-- .../filters/http/ratelimit/ratelimit_test.cc | 2 +- .../filters/http/squash/squash_filter_test.cc | 2 +- .../filters/http/tap/tap_config_impl_test.cc | 2 +- .../filters/http/tap/tap_filter_test.cc | 2 +- .../http_inspector/http_inspector_test.cc | 2 +- .../original_src/original_src_test.cc | 4 +- .../proxy_protocol/proxy_protocol_test.cc | 4 +- .../tls_inspector/tls_inspector_test.cc | 2 +- .../client_ssl_auth/client_ssl_auth_test.cc | 2 +- .../network/common/redis/client_impl_test.cc | 4 +- .../network/dubbo_proxy/conn_manager_test.cc | 2 +- .../dubbo_hessian2_serializer_impl_test.cc | 8 +-- .../network/dubbo_proxy/router_test.cc | 2 +- .../network/ext_authz/ext_authz_test.cc | 2 +- .../kafka/request_codec_integration_test.cc | 2 +- .../network/mysql_proxy/mysql_filter_test.cc | 2 +- .../postgres_proxy/postgres_decoder_test.cc | 2 +- .../postgres_proxy/postgres_filter_test.cc | 2 +- .../network/ratelimit/ratelimit_test.cc | 2 +- .../filters/network/rbac/filter_test.cc | 2 +- .../redis_proxy/conn_pool_impl_test.cc | 6 +- .../network/redis_proxy/proxy_filter_test.cc | 2 +- .../network/rocketmq_proxy/codec_test.cc | 2 +- .../rocketmq_proxy/conn_manager_test.cc | 2 +- .../network/rocketmq_proxy/router_test.cc | 6 +- .../filters/network/rocketmq_proxy/utility.cc | 21 +++---- .../proxy_filter_test.cc | 2 +- .../network/thrift_proxy/conn_manager_test.cc | 2 +- .../filters/ratelimit/ratelimit_test.cc | 2 +- .../thrift_proxy/router_ratelimit_test.cc | 4 +- .../network/thrift_proxy/router_test.cc | 2 +- .../network/zookeeper_proxy/filter_test.cc | 2 +- .../dns_filter/dns_filter_integration_test.cc | 2 +- .../filters/udp/dns_filter/dns_filter_test.cc | 4 +- .../health_checkers/redis/redis_test.cc | 2 +- .../quiche/active_quic_listener_test.cc | 6 +- .../quiche/crypto_test_utils_for_envoy.cc | 8 +-- .../quiche/envoy_quic_client_session_test.cc | 2 +- .../quiche/envoy_quic_client_stream_test.cc | 2 +- .../quiche/envoy_quic_server_stream_test.cc | 2 +- .../quiche/quic_io_handle_wrapper_test.cc | 2 +- .../fixed_heap/fixed_heap_monitor_test.cc | 2 +- .../injected_resource_monitor_test.cc | 4 +- .../stats_sinks/common/statsd/statsd_test.cc | 2 +- .../stats_sinks/hystrix/hystrix_test.cc | 2 +- .../grpc_metrics_service_impl_test.cc | 2 +- .../datadog/datadog_tracer_impl_test.cc | 2 +- .../dynamic_opentracing_driver_impl_test.cc | 2 +- .../lightstep/lightstep_tracer_impl_test.cc | 2 +- .../tracers/opencensus/tracer_test.cc | 6 +- .../tracers/zipkin/zipkin_tracer_impl_test.cc | 2 +- .../transport_sockets/alts/tsi_socket_test.cc | 2 +- .../tap/tap_config_impl_test.cc | 2 +- .../tls/integration/ssl_integration_test.h | 2 +- .../transport_sockets/tls/ssl_socket_test.cc | 4 +- test/integration/fake_upstream.cc | 8 +-- .../filter_manager_integration_test.cc | 4 +- test/integration/integration.h | 8 +-- .../listener_filter_integration_test.cc | 2 +- test/integration/server.cc | 2 +- test/integration/server.h | 4 +- test/integration/tcp_proxy_integration_test.h | 4 +- test/integration/utility.h | 2 +- test/integration/xds_integration_test.cc | 10 ++-- test/integration/xfcc_integration_test.h | 2 +- test/main.cc | 2 +- test/mocks/grpc/mocks.h | 6 +- test/mocks/router/mocks.h | 5 +- test/mocks/server/mocks.h | 4 +- test/mocks/stats/mocks.h | 7 +-- test/mocks/upstream/cluster_info.h | 10 ++-- test/mocks/upstream/host.h | 4 +- test/server/admin/config_tracker_impl_test.cc | 2 +- test/server/admin/stats_handler_test.cc | 2 +- test/server/api_listener_test.cc | 2 +- .../config_validation/dispatcher_test.cc | 2 +- test/server/connection_handler_test.cc | 2 +- test/server/guarddog_impl_test.cc | 2 +- test/server/hot_restart_impl_test.cc | 2 +- test/server/lds_api_test.cc | 2 +- test/server/listener_manager_impl_test.h | 6 +- test/server/options_impl_test.cc | 58 +++++++++---------- test/server/overload_manager_impl_test.cc | 2 +- test/server/server_fuzz_test.cc | 2 +- test/server/server_test.cc | 10 ++-- test/test_common/global.h | 2 +- test/test_common/registry.h | 2 +- test/test_common/test_runtime.h | 2 +- test/test_common/utility.h | 2 +- test/test_runner.cc | 2 +- test/tools/router_check/coverage.cc | 5 +- test/tools/router_check/coverage.h | 2 +- test/tools/router_check/router.cc | 4 +- test/tools/router_check/router.h | 8 +-- 391 files changed, 939 insertions(+), 1008 deletions(-) diff --git a/include/envoy/config/grpc_mux.h b/include/envoy/config/grpc_mux.h index 35729b9f7ea91..c529cc893ebc0 100644 --- a/include/envoy/config/grpc_mux.h +++ b/include/envoy/config/grpc_mux.h @@ -146,7 +146,7 @@ template class GrpcStreamCallbacks { /** * For the GrpcStream to pass received protos to the context. */ - virtual void onDiscoveryResponse(std::unique_ptr&& message, + virtual void onDiscoveryResponse(ResponseProtoPtr&& message, ControlPlaneStats& control_plane_stats) PURE; /** diff --git a/include/envoy/config/typed_metadata.h b/include/envoy/config/typed_metadata.h index a05ca8235d645..e7b7a355a195e 100644 --- a/include/envoy/config/typed_metadata.h +++ b/include/envoy/config/typed_metadata.h @@ -62,8 +62,7 @@ class TypedMetadataFactory : public UntypedFactory { * @return a derived class object pointer of TypedMetadata. * @throw EnvoyException if the parsing can't be done. */ - virtual std::unique_ptr - parse(const ProtobufWkt::Struct& data) const PURE; + virtual TypedMetadata::ObjectConstPtr parse(const ProtobufWkt::Struct& data) const PURE; std::string category() const override { return "envoy.typed_metadata"; } }; diff --git a/include/envoy/http/message.h b/include/envoy/http/message.h index 7fa0c8c910a96..e2a5bb15bb92c 100644 --- a/include/envoy/http/message.h +++ b/include/envoy/http/message.h @@ -36,7 +36,7 @@ template class Message { * Set the trailers. * @param trailers supplies the new trailers. */ - virtual void trailers(std::unique_ptr&& trailers) PURE; + virtual void trailers(TrailerTypePtr&& trailers) PURE; /** * @return std::string the message body as a std::string. diff --git a/include/envoy/router/router.h b/include/envoy/router/router.h index b0761122f1c99..3115fae29422e 100644 --- a/include/envoy/router/router.h +++ b/include/envoy/router/router.h @@ -1169,7 +1169,7 @@ class GenericConnectionPoolCallbacks { * @param upstream_local_address supplies the local address of the upstream connection. * @param info supplies the stream info object associated with the upstream connection. */ - virtual void onPoolReady(std::unique_ptr&& upstream, + virtual void onPoolReady(GenericUpstreamPtr&& upstream, Upstream::HostDescriptionConstSharedPtr host, const Network::Address::InstanceConstSharedPtr& upstream_local_address, const StreamInfo::StreamInfo& info) PURE; diff --git a/include/envoy/stream_info/filter_state.h b/include/envoy/stream_info/filter_state.h index 20377176b56f5..3566f9d7b647d 100644 --- a/include/envoy/stream_info/filter_state.h +++ b/include/envoy/stream_info/filter_state.h @@ -81,8 +81,8 @@ class FilterState { * This is to enforce a single authoritative source for each piece of * data stored in FilterState. */ - virtual void setData(absl::string_view data_name, std::shared_ptr data, - StateType state_type, LifeSpan life_span = LifeSpan::FilterChain) PURE; + virtual void setData(absl::string_view data_name, ObjectSharedPtr data, StateType state_type, + LifeSpan life_span = LifeSpan::FilterChain) PURE; /** * @param data_name the name of the data being looked up (mutable/readonly). diff --git a/include/envoy/upstream/upstream.h b/include/envoy/upstream/upstream.h index 139eb8ebb3a3f..3d7aebddba81c 100644 --- a/include/envoy/upstream/upstream.h +++ b/include/envoy/upstream/upstream.h @@ -251,14 +251,14 @@ class HostsPerLocality { * @return vector of HostsPerLocalityConstSharedPtr clones of the HostsPerLocality that match * hosts according to predicates. */ - virtual std::vector> + virtual std::vector filter(const std::vector>& predicates) const PURE; /** * Clone object. * @return HostsPerLocalityConstSharedPtr clone of the HostsPerLocality. */ - std::shared_ptr clone() const { + HostsPerLocalityConstSharedPtr clone() const { return filter({[](const Host&) { return true; }})[0]; } }; @@ -738,12 +738,11 @@ class ClusterInfo { /** * @param name std::string containing the well-known name of the extension for which protocol * options are desired - * @return std::shared_ptr where Derived is a subclass of ProtocolOptionsConfig + * @return DerivedConstSharedPtr where Derived is a subclass of ProtocolOptionsConfig * and contains extension-specific protocol options for upstream connections. */ template - const std::shared_ptr - extensionProtocolOptionsTyped(const std::string& name) const { + const DerivedConstSharedPtr extensionProtocolOptionsTyped(const std::string& name) const { return std::dynamic_pointer_cast(extensionProtocolOptions(name)); } diff --git a/source/common/buffer/buffer_impl.h b/source/common/buffer/buffer_impl.h index 7da3adb821956..076b16f60440f 100644 --- a/source/common/buffer/buffer_impl.h +++ b/source/common/buffer/buffer_impl.h @@ -234,7 +234,7 @@ class OwnedSlice final : public Slice, public InlineStorage { */ static SlicePtr create(const void* data, uint64_t size) { uint64_t slice_capacity = sliceSize(size); - std::unique_ptr slice(new (slice_capacity) OwnedSlice(slice_capacity)); + OwnedSlicePtr slice(new (slice_capacity) OwnedSlice(slice_capacity)); memcpy(slice->base_, data, size); slice->reservable_ = size; return slice; diff --git a/source/common/common/logger.h b/source/common/common/logger.h index 3b2fd61db5bff..5a7a166f9bdef 100644 --- a/source/common/common/logger.h +++ b/source/common/common/logger.h @@ -183,7 +183,7 @@ class DelegatingLogSink : public spdlog::sinks::sink { SinkDelegate* delegate() { return sink_; } SinkDelegate* sink_{nullptr}; - std::unique_ptr stderr_sink_; // Builtin sink to use as a last resort. + StderrSinkDelegatePtr stderr_sink_; // Builtin sink to use as a last resort. std::unique_ptr formatter_ ABSL_GUARDED_BY(format_mutex_); absl::Mutex format_mutex_; // direct absl reference to break build cycle. bool should_escape_{false}; diff --git a/source/common/common/thread_synchronizer.h b/source/common/common/thread_synchronizer.h index b86df8a926bce..6b5ab2bece68e 100644 --- a/source/common/common/thread_synchronizer.h +++ b/source/common/common/thread_synchronizer.h @@ -80,8 +80,7 @@ class ThreadSynchronizer : Logger::Loggable { struct SynchronizerData { absl::Mutex mutex_; - absl::flat_hash_map> - entries_ ABSL_GUARDED_BY(mutex_); + absl::flat_hash_map entries_ ABSL_GUARDED_BY(mutex_); }; SynchronizerEntry& getOrCreateEntry(absl::string_view event_name); @@ -90,7 +89,7 @@ class ThreadSynchronizer : Logger::Loggable { void barrierOnWorker(absl::string_view event_name); void signalWorker(absl::string_view event_name); - std::unique_ptr data_; + SynchronizerDataPtr data_; }; } // namespace Thread diff --git a/source/common/common/utility.h b/source/common/common/utility.h index 8cab7c8a47c9b..283982407eecf 100644 --- a/source/common/common/utility.h +++ b/source/common/common/utility.h @@ -537,7 +537,7 @@ class WelfordStandardDeviation { template struct TrieEntry { Value value_{}; - std::array, 256> entries_; + std::array entries_; }; /** diff --git a/source/common/config/config_provider_impl.h b/source/common/config/config_provider_impl.h index 157941124d29f..135c377195d45 100644 --- a/source/common/config/config_provider_impl.h +++ b/source/common/config/config_provider_impl.h @@ -391,8 +391,8 @@ class ConfigProviderManagerImplBase : public ConfigProviderManager, public Singl protected: // Ordered set for deterministic config dump output. using ConfigProviderSet = std::set; - using ConfigProviderMap = std::unordered_map, EnumClassHash>; + using ConfigProviderMap = + std::unordered_map; using ConfigSubscriptionMap = std::unordered_map>; diff --git a/source/common/config/filesystem_subscription_impl.h b/source/common/config/filesystem_subscription_impl.h index 39c86f1654da2..4597f7deb9981 100644 --- a/source/common/config/filesystem_subscription_impl.h +++ b/source/common/config/filesystem_subscription_impl.h @@ -35,7 +35,7 @@ class FilesystemSubscriptionImpl : public Config::Subscription, bool started_{}; const std::string path_; - std::unique_ptr watcher_; + Filesystem::WatcherPtr watcher_; SubscriptionCallbacks& callbacks_; SubscriptionStats stats_; Api::Api& api_; diff --git a/source/common/config/grpc_stream.h b/source/common/config/grpc_stream.h index 7700b96a7dfc2..52bb7aedef63f 100644 --- a/source/common/config/grpc_stream.h +++ b/source/common/config/grpc_stream.h @@ -74,7 +74,7 @@ class GrpcStream : public Grpc::AsyncStreamCallbacks, UNREFERENCED_PARAMETER(metadata); } - void onReceiveMessage(std::unique_ptr&& message) override { + void onReceiveMessage(ResponseProtoPtr&& message) override { // Reset here so that it starts with fresh backoff interval on next disconnect. backoff_strategy_->reset(); // Sometimes during hot restarts this stat's value becomes inconsistent and will continue to diff --git a/source/common/config/metadata.h b/source/common/config/metadata.h index 3c59c77a20836..772b7f3e1a5e4 100644 --- a/source/common/config/metadata.h +++ b/source/common/config/metadata.h @@ -123,7 +123,7 @@ template class TypedMetadataImpl : public TypedMetadata } } - std::unordered_map> data_; + std::unordered_map data_; }; } // namespace Config diff --git a/source/common/config/new_grpc_mux_impl.h b/source/common/config/new_grpc_mux_impl.h index 73478991b17fb..0f3fb6a903cab 100644 --- a/source/common/config/new_grpc_mux_impl.h +++ b/source/common/config/new_grpc_mux_impl.h @@ -71,7 +71,7 @@ class NewGrpcMuxImpl }; // for use in tests only - const absl::flat_hash_map>& subscriptions() { + const absl::flat_hash_map& subscriptions() { return subscriptions_; } @@ -130,7 +130,7 @@ class NewGrpcMuxImpl PausableAckQueue pausable_ack_queue_; // Map key is type_url. - absl::flat_hash_map> subscriptions_; + absl::flat_hash_map subscriptions_; // Determines the order of initial discovery requests. (Assumes that subscriptions are added in // the order of Envoy's dependency ordering). diff --git a/source/common/config/subscription_factory_impl.cc b/source/common/config/subscription_factory_impl.cc index 342830ebc3d89..09c5107495889 100644 --- a/source/common/config/subscription_factory_impl.cc +++ b/source/common/config/subscription_factory_impl.cc @@ -25,7 +25,7 @@ SubscriptionPtr SubscriptionFactoryImpl::subscriptionFromConfigSource( const envoy::config::core::v3::ConfigSource& config, absl::string_view type_url, Stats::Scope& scope, SubscriptionCallbacks& callbacks) { Config::Utility::checkLocalInfo(type_url, local_info_); - std::unique_ptr result; + SubscriptionPtr result; SubscriptionStats stats = Utility::generateStats(scope); const auto transport_api_version = config.api_config_source().transport_api_version(); diff --git a/source/common/config/watch_map.h b/source/common/config/watch_map.h index 36bcf23f88ea1..c2bafc1756d2a 100644 --- a/source/common/config/watch_map.h +++ b/source/common/config/watch_map.h @@ -110,7 +110,7 @@ class WatchMap : public SubscriptionCallbacks, public Logger::Loggable watchesInterestedIn(const std::string& resource_name); - absl::flat_hash_set> watches_; + absl::flat_hash_set watches_; // Watches whose interest set is currently empty, which is interpreted as "everything". absl::flat_hash_set wildcard_watches_; diff --git a/source/common/event/dispatcher_impl.h b/source/common/event/dispatcher_impl.h index 41be86039ad23..dc9e02a3ca93c 100644 --- a/source/common/event/dispatcher_impl.h +++ b/source/common/event/dispatcher_impl.h @@ -104,7 +104,7 @@ class DispatcherImpl : Logger::Loggable, const std::string name_; Api::Api& api_; std::string stats_prefix_; - std::unique_ptr stats_; + DispatcherStatsPtr stats_; Thread::ThreadId run_tid_; Buffer::WatermarkFactoryPtr buffer_factory_; LibeventScheduler base_scheduler_; diff --git a/source/common/filesystem/win32/watcher_impl.h b/source/common/filesystem/win32/watcher_impl.h index f107f541eea7c..bcb283af21352 100644 --- a/source/common/filesystem/win32/watcher_impl.h +++ b/source/common/filesystem/win32/watcher_impl.h @@ -53,7 +53,7 @@ class WatcherImpl : public Watcher, Logger::Loggable { WatcherImpl* watcher_; }; - typedef std::unique_ptr DirectoryWatchPtr; + typedef DirectoryWatchPtr DirectoryWatchPtr; Api::Api& api_; std::unordered_map callback_map_; diff --git a/source/common/formatter/substitution_formatter.cc b/source/common/formatter/substitution_formatter.cc index 4400ca3f65100..193d91cdb5528 100644 --- a/source/common/formatter/substitution_formatter.cc +++ b/source/common/formatter/substitution_formatter.cc @@ -460,17 +460,17 @@ class StreamInfoAddressFieldExtractor : public StreamInfoFormatter::FieldExtract using FieldExtractor = std::function; - static std::unique_ptr withPort(FieldExtractor f) { + static StreamInfoAddressFieldExtractorPtr withPort(FieldExtractor f) { return std::make_unique( f, StreamInfoFormatter::StreamInfoAddressFieldExtractionType::WithPort); } - static std::unique_ptr withoutPort(FieldExtractor f) { + static StreamInfoAddressFieldExtractorPtr withoutPort(FieldExtractor f) { return std::make_unique( f, StreamInfoFormatter::StreamInfoAddressFieldExtractionType::WithoutPort); } - static std::unique_ptr justPort(FieldExtractor f) { + static StreamInfoAddressFieldExtractorPtr justPort(FieldExtractor f) { return std::make_unique( f, StreamInfoFormatter::StreamInfoAddressFieldExtractionType::JustPort); } diff --git a/source/common/grpc/async_client_impl.cc b/source/common/grpc/async_client_impl.cc index ecb5709288f71..c35a5fb600335 100644 --- a/source/common/grpc/async_client_impl.cc +++ b/source/common/grpc/async_client_impl.cc @@ -31,7 +31,7 @@ AsyncRequest* AsyncClientImpl::sendRaw(absl::string_view service_full_name, const Http::AsyncClient::RequestOptions& options) { auto* const async_request = new AsyncRequestImpl( *this, service_full_name, method_name, std::move(request), callbacks, parent_span, options); - std::unique_ptr grpc_stream{async_request}; + AsyncStreamImplPtr grpc_stream{async_request}; grpc_stream->initialize(true); if (grpc_stream->hasResetStream()) { diff --git a/source/common/grpc/async_client_impl.h b/source/common/grpc/async_client_impl.h index 750183afd4f5e..d1af191cdafdd 100644 --- a/source/common/grpc/async_client_impl.h +++ b/source/common/grpc/async_client_impl.h @@ -34,7 +34,7 @@ class AsyncClientImpl final : public RawAsyncClient { Upstream::ClusterManager& cm_; const std::string remote_cluster_name_; const Protobuf::RepeatedPtrField initial_metadata_; - std::list> active_streams_; + std::list active_streams_; TimeSource& time_source_; friend class AsyncRequestImpl; diff --git a/source/common/grpc/google_async_client_impl.cc b/source/common/grpc/google_async_client_impl.cc index d22903da723e1..be37dcc28d911 100644 --- a/source/common/grpc/google_async_client_impl.cc +++ b/source/common/grpc/google_async_client_impl.cc @@ -112,7 +112,7 @@ AsyncRequest* GoogleAsyncClientImpl::sendRaw(absl::string_view service_full_name const Http::AsyncClient::RequestOptions& options) { auto* const async_request = new GoogleAsyncRequestImpl( *this, service_full_name, method_name, std::move(request), callbacks, parent_span, options); - std::unique_ptr grpc_stream{async_request}; + GoogleAsyncStreamImplPtr grpc_stream{async_request}; grpc_stream->initialize(true); if (grpc_stream->callFailed()) { @@ -381,7 +381,7 @@ void GoogleAsyncStreamImpl::deferredDelete() { // Hence, it is safe here to create a unique_ptr to this and transfer // ownership to dispatcher_.deferredDelete(). After this call, no further // methods may be invoked on this object. - dispatcher_.deferredDelete(std::unique_ptr(this)); + dispatcher_.deferredDelete(GoogleAsyncStreamImplPtr(this)); } void GoogleAsyncStreamImpl::cleanup() { diff --git a/source/common/grpc/google_async_client_impl.h b/source/common/grpc/google_async_client_impl.h index f2dc3eded14dc..8aaf4b688580e 100644 --- a/source/common/grpc/google_async_client_impl.h +++ b/source/common/grpc/google_async_client_impl.h @@ -189,7 +189,7 @@ class GoogleAsyncClientImpl final : public RawAsyncClient, Logger::Loggable> active_streams_; + std::list active_streams_; const std::string stat_prefix_; const Protobuf::RepeatedPtrField initial_metadata_; Stats::ScopeSharedPtr scope_; diff --git a/source/common/grpc/typed_async_client.h b/source/common/grpc/typed_async_client.h index 1de73ff6e8d97..012013a6c998d 100644 --- a/source/common/grpc/typed_async_client.h +++ b/source/common/grpc/typed_async_client.h @@ -68,11 +68,11 @@ template class AsyncStream /* : public RawAsyncStream */ { template class AsyncRequestCallbacks : public RawAsyncRequestCallbacks { public: ~AsyncRequestCallbacks() override = default; - virtual void onSuccess(std::unique_ptr&& response, Tracing::Span& span) PURE; + virtual void onSuccess(ResponsePtr&& response, Tracing::Span& span) PURE; private: void onSuccessRaw(Buffer::InstancePtr&& response, Tracing::Span& span) override { - auto message = std::unique_ptr(dynamic_cast( + auto message = ResponsePtr(dynamic_cast( Internal::parseMessageUntyped(std::make_unique(), std::move(response)) .release())); if (!message) { @@ -138,11 +138,11 @@ class VersionedMethods { template class AsyncStreamCallbacks : public RawAsyncStreamCallbacks { public: ~AsyncStreamCallbacks() override = default; - virtual void onReceiveMessage(std::unique_ptr&& message) PURE; + virtual void onReceiveMessage(ResponsePtr&& message) PURE; private: bool onReceiveMessageRaw(Buffer::InstancePtr&& response) override { - auto message = std::unique_ptr(dynamic_cast( + auto message = ResponsePtr(dynamic_cast( Internal::parseMessageUntyped(std::make_unique(), std::move(response)) .release())); if (!message) { diff --git a/source/common/http/async_client_impl.cc b/source/common/http/async_client_impl.cc index 6a55567bc8dbc..1884c69959120 100644 --- a/source/common/http/async_client_impl.cc +++ b/source/common/http/async_client_impl.cc @@ -59,7 +59,7 @@ AsyncClient::Request* AsyncClientImpl::send(RequestMessagePtr&& request, AsyncRequestImpl* async_request = new AsyncRequestImpl(std::move(request), *this, callbacks, options); async_request->initialize(); - std::unique_ptr new_request{async_request}; + AsyncStreamImplPtr new_request{async_request}; // The request may get immediately failed. If so, we will return nullptr. if (!new_request->remote_closed_) { @@ -73,7 +73,7 @@ AsyncClient::Request* AsyncClientImpl::send(RequestMessagePtr&& request, AsyncClient::Stream* AsyncClientImpl::start(AsyncClient::StreamCallbacks& callbacks, const AsyncClient::StreamOptions& options) { - std::unique_ptr new_stream{new AsyncStreamImpl(*this, callbacks, options)}; + AsyncStreamImplPtr new_stream{new AsyncStreamImpl(*this, callbacks, options)}; new_stream->moveIntoList(std::move(new_stream), active_streams_); return active_streams_.front().get(); } diff --git a/source/common/http/async_client_impl.h b/source/common/http/async_client_impl.h index 90acf1aadda06..75de512b15740 100644 --- a/source/common/http/async_client_impl.h +++ b/source/common/http/async_client_impl.h @@ -61,7 +61,7 @@ class AsyncClientImpl final : public AsyncClient { Upstream::ClusterInfoConstSharedPtr cluster_; Router::FilterConfig config_; Event::Dispatcher& dispatcher_; - std::list> active_streams_; + std::list active_streams_; friend class AsyncStreamImpl; friend class AsyncRequestImpl; @@ -283,7 +283,7 @@ class AsyncStreamImpl : public AsyncClient::Stream, bool includeAttemptCountInResponse() const override { return false; } const Router::RouteEntry::UpgradeMap& upgradeMap() const override { return upgrade_map_; } const std::string& routeName() const override { return route_name_; } - std::unique_ptr hash_policy_; + HashPolicyImplConstPtr hash_policy_; static const NullHedgePolicy hedge_policy_; static const NullRateLimitPolicy rate_limit_policy_; static const NullRetryPolicy retry_policy_; @@ -409,7 +409,7 @@ class AsyncStreamImpl : public AsyncClient::Stream, StreamInfo::StreamInfoImpl stream_info_; Tracing::NullSpan active_span_; const Tracing::Config& tracing_config_; - std::shared_ptr route_; + RouteImplSharedPtr route_; uint32_t high_watermark_calls_{}; bool local_closed_{}; bool remote_closed_{}; @@ -454,7 +454,7 @@ class AsyncRequestImpl final : public AsyncClient::Request, RequestMessagePtr request_; AsyncClient::Callbacks& callbacks_; - std::unique_ptr response_; + ResponseMessageImplPtr response_; bool cancelled_{}; Tracing::SpanPtr child_span_; diff --git a/source/common/http/codec_client.cc b/source/common/http/codec_client.cc index 935fb6476e33e..e38edffc46131 100644 --- a/source/common/http/codec_client.cc +++ b/source/common/http/codec_client.cc @@ -163,7 +163,7 @@ CodecClientProd::CodecClientProd(Type type, Network::ClientConnectionPtr&& conne break; } case Type::HTTP3: { - codec_ = std::unique_ptr( + codec_ = ClientConnectionPtr( Config::Utility::getAndCheckFactoryByName( Http::QuicCodecNames::get().Quiche) .createQuicClientConnection(*connection_, *this)); diff --git a/source/common/http/conn_manager_impl.h b/source/common/http/conn_manager_impl.h index bf8f9d1530530..9f30365a41796 100644 --- a/source/common/http/conn_manager_impl.h +++ b/source/common/http/conn_manager_impl.h @@ -103,7 +103,7 @@ class ConnectionManagerImpl : Logger::Loggable, TimeSource& timeSource() { return time_source_; } // Return a reference to the shared_ptr so that it can be lazy created on demand. - std::shared_ptr& filterState() { return filter_state_; } + StreamInfo::FilterStateSharedPtr& filterState() { return filter_state_; } private: struct ActiveStream; @@ -190,8 +190,8 @@ class ConnectionManagerImpl : Logger::Loggable, // either because [de|en]codeHeaders() of the current filter returns StopAllIteration or because // [de|en]codeHeaders() adds new metadata to [de|en]code, but we don't know // [de|en]codeHeaders()'s return value yet. The storage is created on demand. - std::unique_ptr saved_request_metadata_{nullptr}; - std::unique_ptr saved_response_metadata_{nullptr}; + MetadataMapVectorPtr saved_request_metadata_{nullptr}; + MetadataMapVectorPtr saved_response_metadata_{nullptr}; // The state of iteration. enum class IterationState { Continue, // Iteration has not stopped for any frame type. @@ -735,13 +735,13 @@ class ConnectionManagerImpl : Logger::Loggable, // Stores metadata added in the decoding filter that is being processed. Will be cleared before // processing the next filter. The storage is created on demand. We need to store metadata // temporarily in the filter in case the filter has stopped all while processing headers. - std::unique_ptr request_metadata_map_vector_{nullptr}; + MetadataMapVectorPtr request_metadata_map_vector_{nullptr}; uint32_t buffer_limit_{0}; uint32_t high_watermark_count_{0}; const std::string* decorated_operation_{nullptr}; Network::Socket::OptionsSharedPtr upstream_options_; - std::unique_ptr route_config_update_requester_; - std::unique_ptr tracing_custom_tags_{nullptr}; + RouteConfigUpdateRequesterPtr route_config_update_requester_; + Tracing::CustomTagMapPtr tracing_custom_tags_{nullptr}; }; using ActiveStreamPtr = std::unique_ptr; @@ -803,7 +803,7 @@ class ConnectionManagerImpl : Logger::Loggable, const Server::OverloadActionState& overload_stop_accepting_requests_ref_; const Server::OverloadActionState& overload_disable_keepalive_ref_; TimeSource& time_source_; - std::shared_ptr filter_state_; + StreamInfo::FilterStateSharedPtr filter_state_; }; } // namespace Http diff --git a/source/common/http/header_map_impl.h b/source/common/http/header_map_impl.h index 30e2eab892b92..8f3e7ef6a99ec 100644 --- a/source/common/http/header_map_impl.h +++ b/source/common/http/header_map_impl.h @@ -378,8 +378,8 @@ template class TypedHeaderMapImpl : public HeaderMapImpl, publ class RequestHeaderMapImpl final : public TypedHeaderMapImpl, public InlineStorage { public: - static std::unique_ptr create() { - return std::unique_ptr(new (inlineHeadersSize()) RequestHeaderMapImpl()); + static RequestHeaderMapImplPtr create() { + return RequestHeaderMapImplPtr(new (inlineHeadersSize()) RequestHeaderMapImpl()); } INLINE_REQ_HEADERS(DEFINE_INLINE_HEADER_FUNCS) @@ -414,9 +414,8 @@ class RequestHeaderMapImpl final : public TypedHeaderMapImpl, class RequestTrailerMapImpl final : public TypedHeaderMapImpl, public InlineStorage { public: - static std::unique_ptr create() { - return std::unique_ptr(new (inlineHeadersSize()) - RequestTrailerMapImpl()); + static RequestTrailerMapImplPtr create() { + return RequestTrailerMapImplPtr(new (inlineHeadersSize()) RequestTrailerMapImpl()); } protected: @@ -438,9 +437,8 @@ class RequestTrailerMapImpl final : public TypedHeaderMapImpl class ResponseHeaderMapImpl final : public TypedHeaderMapImpl, public InlineStorage { public: - static std::unique_ptr create() { - return std::unique_ptr(new (inlineHeadersSize()) - ResponseHeaderMapImpl()); + static ResponseHeaderMapImplPtr create() { + return ResponseHeaderMapImplPtr(new (inlineHeadersSize()) ResponseHeaderMapImpl()); } INLINE_RESP_HEADERS(DEFINE_INLINE_HEADER_FUNCS) @@ -474,9 +472,8 @@ class ResponseHeaderMapImpl final : public TypedHeaderMapImpl class ResponseTrailerMapImpl final : public TypedHeaderMapImpl, public InlineStorage { public: - static std::unique_ptr create() { - return std::unique_ptr(new (inlineHeadersSize()) - ResponseTrailerMapImpl()); + static ResponseTrailerMapImplPtr create() { + return ResponseTrailerMapImplPtr(new (inlineHeadersSize()) ResponseTrailerMapImpl()); } INLINE_RESP_HEADERS_TRAILERS(DEFINE_INLINE_HEADER_FUNCS) diff --git a/source/common/http/http2/codec_impl.h b/source/common/http/http2/codec_impl.h index 7f8e26a31d340..20f667186ba62 100644 --- a/source/common/http/http2/codec_impl.h +++ b/source/common/http/http2/codec_impl.h @@ -287,8 +287,8 @@ class ConnectionImpl : public virtual Connection, protected Logger::Loggable void { this->pendingSendBufferHighWatermark(); }, []() -> void { /* TODO(adisuissa): Handle overflow watermark */ }}; HeaderMapPtr pending_trailers_to_encode_; - std::unique_ptr metadata_decoder_; - std::unique_ptr metadata_encoder_; + MetadataDecoderPtr metadata_decoder_; + MetadataEncoderPtr metadata_encoder_; absl::optional deferred_reset_; HeaderString cookies_; bool local_end_stream_sent_ : 1; diff --git a/source/common/http/http3/quic_codec_factory.h b/source/common/http/http3/quic_codec_factory.h index 0b4a724042009..aa52f79fc985a 100644 --- a/source/common/http/http3/quic_codec_factory.h +++ b/source/common/http/http3/quic_codec_factory.h @@ -14,8 +14,8 @@ class QuicHttpServerConnectionFactory : public Config::UntypedFactory { public: ~QuicHttpServerConnectionFactory() override = default; - virtual std::unique_ptr - createQuicServerConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; + virtual ServerConnectionPtr createQuicServerConnection(Network::Connection& connection, + ConnectionCallbacks& callbacks) PURE; std::string category() const override { return "envoy.quic_client_codec"; } }; @@ -25,8 +25,8 @@ class QuicHttpClientConnectionFactory : public Config::UntypedFactory { public: ~QuicHttpClientConnectionFactory() override = default; - virtual std::unique_ptr - createQuicClientConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; + virtual ClientConnectionPtr createQuicClientConnection(Network::Connection& connection, + ConnectionCallbacks& callbacks) PURE; std::string category() const override { return "envoy.quic_server_codec"; } }; diff --git a/source/common/http/message_impl.h b/source/common/http/message_impl.h index 698c51824a069..d44dc075bd9ee 100644 --- a/source/common/http/message_impl.h +++ b/source/common/http/message_impl.h @@ -20,15 +20,13 @@ template { public: MessageImpl() : headers_(HeadersImplType::create()) {} - MessageImpl(std::unique_ptr&& headers) : headers_(std::move(headers)) {} + MessageImpl(HeadersInterfaceTypePtr&& headers) : headers_(std::move(headers)) {} // Http::Message HeadersInterfaceType& headers() override { return *headers_; } Buffer::InstancePtr& body() override { return body_; } TrailersInterfaceType* trailers() override { return trailers_.get(); } - void trailers(std::unique_ptr&& trailers) override { - trailers_ = std::move(trailers); - } + void trailers(TrailersInterfaceTypePtr&& trailers) override { trailers_ = std::move(trailers); } std::string bodyAsString() const override { if (body_) { return body_->toString(); @@ -38,9 +36,9 @@ class MessageImpl : public Message } private: - std::unique_ptr headers_; + HeadersInterfaceTypePtr headers_; Buffer::InstancePtr body_; - std::unique_ptr trailers_; + TrailersInterfaceTypePtr trailers_; }; using RequestMessageImpl = diff --git a/source/common/http/request_id_extension_impl.cc b/source/common/http/request_id_extension_impl.cc index ed4022712fc09..5c4b6920219b2 100644 --- a/source/common/http/request_id_extension_impl.cc +++ b/source/common/http/request_id_extension_impl.cc @@ -45,7 +45,7 @@ RequestIDExtensionFactory::defaultInstance(Envoy::Runtime::RandomGenerator& rand } RequestIDExtensionSharedPtr RequestIDExtensionFactory::noopInstance() { - MUTABLE_CONSTRUCT_ON_FIRST_USE(std::shared_ptr, + MUTABLE_CONSTRUCT_ON_FIRST_USE(RequestIDExtensionSharedPtr, std::make_shared()); } diff --git a/source/common/http/user_agent.h b/source/common/http/user_agent.h index aa617f48c4e59..35727dbdd01b7 100644 --- a/source/common/http/user_agent.h +++ b/source/common/http/user_agent.h @@ -83,7 +83,7 @@ class UserAgent { private: const UserAgentContext& context_; bool initialized_{false}; - std::unique_ptr stats_; + UserAgentStatsPtr stats_; }; } // namespace Http diff --git a/source/common/init/target_impl.h b/source/common/init/target_impl.h index d6a098daaca25..4b3c2abb28e89 100644 --- a/source/common/init/target_impl.h +++ b/source/common/init/target_impl.h @@ -84,7 +84,7 @@ class TargetImpl : public Target, Logger::Loggable { WatcherHandlePtr watcher_handle_; // The callback function, called via TargetHandleImpl by the manager - const std::shared_ptr fn_; + const InternalInitalizeFnSharedPtr fn_; }; /** @@ -122,7 +122,7 @@ class SharedTargetImpl : public Target, Logger::Loggable { std::vector watcher_handles_; // The callback function, called via TargetHandleImpl by the manager - const std::shared_ptr fn_; + const InternalInitalizeFnSharedPtr fn_; // The state so as to signal the manager when a ready target is added. bool initialized_{false}; diff --git a/source/common/init/watcher_impl.cc b/source/common/init/watcher_impl.cc index b69fe3e7cf846..53819833b2216 100644 --- a/source/common/init/watcher_impl.cc +++ b/source/common/init/watcher_impl.cc @@ -30,8 +30,7 @@ absl::string_view WatcherImpl::name() const { return name_; } WatcherHandlePtr WatcherImpl::createHandle(absl::string_view handle_name) const { // Note: can't use std::make_unique because WatcherHandleImpl ctor is private - return std::unique_ptr( - new WatcherHandleImpl(handle_name, name_, std::weak_ptr(fn_))); + return WatcherHandlePtr(new WatcherHandleImpl(handle_name, name_, std::weak_ptr(fn_))); } } // namespace Init diff --git a/source/common/init/watcher_impl.h b/source/common/init/watcher_impl.h index 816a37c860eb2..2a7349a602315 100644 --- a/source/common/init/watcher_impl.h +++ b/source/common/init/watcher_impl.h @@ -66,7 +66,7 @@ class WatcherImpl : public Watcher, Logger::Loggable { const std::string name_; // The callback function, called via WatcherHandleImpl by either the target or the manager - const std::shared_ptr fn_; + const ReadyFnSharedPtr fn_; }; } // namespace Init diff --git a/source/common/network/addr_family_aware_socket_option_impl.cc b/source/common/network/addr_family_aware_socket_option_impl.cc index 4a234e8fbca3e..d10bf3f1a1f3c 100644 --- a/source/common/network/addr_family_aware_socket_option_impl.cc +++ b/source/common/network/addr_family_aware_socket_option_impl.cc @@ -55,8 +55,7 @@ absl::optional AddrFamilyAwareSocketOptionImpl::getOpti bool AddrFamilyAwareSocketOptionImpl::setIpSocketOption( Socket& socket, envoy::config::core::v3::SocketOption::SocketState state, - const std::unique_ptr& ipv4_option, - const std::unique_ptr& ipv6_option) { + const SocketOptionImplPtr& ipv4_option, const SocketOptionImplPtr& ipv6_option) { auto option = getOptionForSocket(socket, *ipv4_option, *ipv6_option); if (!option.has_value()) { diff --git a/source/common/network/addr_family_aware_socket_option_impl.h b/source/common/network/addr_family_aware_socket_option_impl.h index 37d4b93c338c7..f0bc6854ab9f3 100644 --- a/source/common/network/addr_family_aware_socket_option_impl.h +++ b/source/common/network/addr_family_aware_socket_option_impl.h @@ -48,12 +48,12 @@ class AddrFamilyAwareSocketOptionImpl : public Socket::Option, */ static bool setIpSocketOption(Socket& socket, envoy::config::core::v3::SocketOption::SocketState state, - const std::unique_ptr& ipv4_option, - const std::unique_ptr& ipv6_option); + const SocketOptionImplPtr& ipv4_option, + const SocketOptionImplPtr& ipv6_option); private: - const std::unique_ptr ipv4_option_; - const std::unique_ptr ipv6_option_; + const SocketOptionImplPtr ipv4_option_; + const SocketOptionImplPtr ipv6_option_; }; } // namespace Network diff --git a/source/common/network/connection_impl_base.h b/source/common/network/connection_impl_base.h index 8e6bd3ed1388b..eeebc93a58f32 100644 --- a/source/common/network/connection_impl_base.h +++ b/source/common/network/connection_impl_base.h @@ -49,7 +49,7 @@ class ConnectionImplBase : public FilterManagerConnection, Event::Dispatcher& dispatcher_; const uint64_t id_; std::list callbacks_; - std::unique_ptr connection_stats_; + ConnectionStatsPtr connection_stats_; private: // Callback issued when a delayed close timeout triggers. diff --git a/source/common/network/dns_impl.cc b/source/common/network/dns_impl.cc index d44d53c70f39e..c5008751e30d8 100644 --- a/source/common/network/dns_impl.cc +++ b/source/common/network/dns_impl.cc @@ -242,7 +242,7 @@ ActiveDnsQuery* DnsResolverImpl::resolve(const std::string& dns_name, AresOptions options = defaultAresOptions(); initializeChannel(&options.options_, options.optmask_); } - std::unique_ptr pending_resolution( + PendingResolutionPtr pending_resolution( new PendingResolution(*this, callback, dispatcher_, channel_, dns_name)); if (dns_lookup_family == DnsLookupFamily::Auto) { pending_resolution->fallback_if_failed_ = true; diff --git a/source/common/network/lc_trie.h b/source/common/network/lc_trie.h index aae1aa7c0ef7d..1b039ec4695dc 100644 --- a/source/common/network/lc_trie.h +++ b/source/common/network/lc_trie.h @@ -389,7 +389,7 @@ template class LcTrie { private: struct Node { - std::unique_ptr children[2]; + NodePtr children[2]; DataSetSharedPtr data; }; using NodePtr = std::unique_ptr; @@ -692,8 +692,8 @@ template class LcTrie { const uint32_t root_branching_factor_; }; - std::unique_ptr> ipv4_trie_; - std::unique_ptr> ipv6_trie_; + LcTrieInternalPtr ipv4_trie_; + LcTrieInternalPtr ipv6_trie_; }; template diff --git a/source/common/network/socket_option_factory.cc b/source/common/network/socket_option_factory.cc index 0a888525c8e8b..57ad2705c7673 100644 --- a/source/common/network/socket_option_factory.cc +++ b/source/common/network/socket_option_factory.cc @@ -9,9 +9,9 @@ namespace Envoy { namespace Network { -std::unique_ptr +Socket::OptionsPtr SocketOptionFactory::buildTcpKeepaliveOptions(Network::TcpKeepaliveConfig keepalive_config) { - std::unique_ptr options = std::make_unique(); + Socket::OptionsPtr options = std::make_unique(); options->push_back(std::make_shared( envoy::config::core::v3::SocketOption::STATE_PREBIND, ENVOY_SOCKET_SO_KEEPALIVE, 1)); @@ -33,16 +33,16 @@ SocketOptionFactory::buildTcpKeepaliveOptions(Network::TcpKeepaliveConfig keepal return options; } -std::unique_ptr SocketOptionFactory::buildIpFreebindOptions() { - std::unique_ptr options = std::make_unique(); +Socket::OptionsPtr SocketOptionFactory::buildIpFreebindOptions() { + Socket::OptionsPtr options = std::make_unique(); options->push_back(std::make_shared( envoy::config::core::v3::SocketOption::STATE_PREBIND, ENVOY_SOCKET_IP_FREEBIND, ENVOY_SOCKET_IPV6_FREEBIND, 1)); return options; } -std::unique_ptr SocketOptionFactory::buildIpTransparentOptions() { - std::unique_ptr options = std::make_unique(); +Socket::OptionsPtr SocketOptionFactory::buildIpTransparentOptions() { + Socket::OptionsPtr options = std::make_unique(); options->push_back(std::make_shared( envoy::config::core::v3::SocketOption::STATE_PREBIND, ENVOY_SOCKET_IP_TRANSPARENT, ENVOY_SOCKET_IPV6_TRANSPARENT, 1)); @@ -52,8 +52,8 @@ std::unique_ptr SocketOptionFactory::buildIpTransparentOptions( return options; } -std::unique_ptr SocketOptionFactory::buildSocketMarkOptions(uint32_t mark) { - std::unique_ptr options = std::make_unique(); +Socket::OptionsPtr SocketOptionFactory::buildSocketMarkOptions(uint32_t mark) { + Socket::OptionsPtr options = std::make_unique(); // we need this to happen prior to binding or prior to connecting. In both cases, PREBIND will // fire. options->push_back(std::make_shared( @@ -61,7 +61,7 @@ std::unique_ptr SocketOptionFactory::buildSocketMarkOptions(uin return options; } -std::unique_ptr SocketOptionFactory::buildLiteralOptions( +Socket::OptionsPtr SocketOptionFactory::buildLiteralOptions( const Protobuf::RepeatedPtrField& socket_options) { auto options = std::make_unique(); for (const auto& socket_option : socket_options) { @@ -90,25 +90,24 @@ std::unique_ptr SocketOptionFactory::buildLiteralOptions( return options; } -std::unique_ptr -SocketOptionFactory::buildTcpFastOpenOptions(uint32_t queue_length) { - std::unique_ptr options = std::make_unique(); +Socket::OptionsPtr SocketOptionFactory::buildTcpFastOpenOptions(uint32_t queue_length) { + Socket::OptionsPtr options = std::make_unique(); options->push_back(std::make_shared( envoy::config::core::v3::SocketOption::STATE_LISTENING, ENVOY_SOCKET_TCP_FASTOPEN, queue_length)); return options; } -std::unique_ptr SocketOptionFactory::buildIpPacketInfoOptions() { - std::unique_ptr options = std::make_unique(); +Socket::OptionsPtr SocketOptionFactory::buildIpPacketInfoOptions() { + Socket::OptionsPtr options = std::make_unique(); options->push_back(std::make_shared( envoy::config::core::v3::SocketOption::STATE_BOUND, ENVOY_SELF_IP_ADDR, ENVOY_SELF_IPV6_ADDR, 1)); return options; } -std::unique_ptr SocketOptionFactory::buildRxQueueOverFlowOptions() { - std::unique_ptr options = std::make_unique(); +Socket::OptionsPtr SocketOptionFactory::buildRxQueueOverFlowOptions() { + Socket::OptionsPtr options = std::make_unique(); #ifdef SO_RXQ_OVFL options->push_back(std::make_shared( envoy::config::core::v3::SocketOption::STATE_BOUND, @@ -117,8 +116,8 @@ std::unique_ptr SocketOptionFactory::buildRxQueueOverFlowOption return options; } -std::unique_ptr SocketOptionFactory::buildReusePortOptions() { - std::unique_ptr options = std::make_unique(); +Socket::OptionsPtr SocketOptionFactory::buildReusePortOptions() { + Socket::OptionsPtr options = std::make_unique(); options->push_back(std::make_shared( envoy::config::core::v3::SocketOption::STATE_PREBIND, ENVOY_SOCKET_SO_REUSEPORT, 1)); return options; diff --git a/source/common/network/socket_option_factory.h b/source/common/network/socket_option_factory.h index e93885e844b9c..b246781d7bfd8 100644 --- a/source/common/network/socket_option_factory.h +++ b/source/common/network/socket_option_factory.h @@ -21,17 +21,16 @@ struct TcpKeepaliveConfig { class SocketOptionFactory : Logger::Loggable { public: - static std::unique_ptr - buildTcpKeepaliveOptions(Network::TcpKeepaliveConfig keepalive_config); - static std::unique_ptr buildIpFreebindOptions(); - static std::unique_ptr buildIpTransparentOptions(); - static std::unique_ptr buildSocketMarkOptions(uint32_t mark); - static std::unique_ptr buildTcpFastOpenOptions(uint32_t queue_length); - static std::unique_ptr buildLiteralOptions( + static Socket::OptionsPtr buildTcpKeepaliveOptions(Network::TcpKeepaliveConfig keepalive_config); + static Socket::OptionsPtr buildIpFreebindOptions(); + static Socket::OptionsPtr buildIpTransparentOptions(); + static Socket::OptionsPtr buildSocketMarkOptions(uint32_t mark); + static Socket::OptionsPtr buildTcpFastOpenOptions(uint32_t queue_length); + static Socket::OptionsPtr buildLiteralOptions( const Protobuf::RepeatedPtrField& socket_options); - static std::unique_ptr buildIpPacketInfoOptions(); - static std::unique_ptr buildRxQueueOverFlowOptions(); - static std::unique_ptr buildReusePortOptions(); + static Socket::OptionsPtr buildIpPacketInfoOptions(); + static Socket::OptionsPtr buildRxQueueOverFlowOptions(); + static Socket::OptionsPtr buildReusePortOptions(); }; } // namespace Network } // namespace Envoy diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index 128351c99dd8b..c12cceeb68646 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -1286,8 +1286,7 @@ RouteConstSharedPtr RouteMatcher::route(const RouteCallback& cb, } const SslRedirector SslRedirectRoute::SSL_REDIRECTOR; -const std::shared_ptr VirtualHostImpl::SSL_REDIRECT_ROUTE{ - new SslRedirectRoute()}; +const SslRedirectRouteConstSharedPtr VirtualHostImpl::SSL_REDIRECT_ROUTE{new SslRedirectRoute()}; const VirtualCluster* VirtualHostImpl::virtualClusterFromEntries(const Http::HeaderMap& headers) const { diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index df1ab51e6e5fc..cf8dedb757531 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -219,7 +219,7 @@ class VirtualHostImpl : public VirtualHost { : VirtualClusterBase(pool.add("other"), scope.createScope("other")) {} }; - static const std::shared_ptr SSL_REDIRECT_ROUTE; + static const SslRedirectRouteConstSharedPtr SSL_REDIRECT_ROUTE; Stats::StatNamePool stat_name_pool_; const Stats::StatName stat_name_; @@ -228,7 +228,7 @@ class VirtualHostImpl : public VirtualHost { std::vector virtual_clusters_; SslRequirements ssl_requirements_; const RateLimitPolicyImpl rate_limit_policy_; - std::unique_ptr cors_policy_; + CorsPolicyImplConstPtr cors_policy_; const ConfigImpl& global_route_config_; // See note in RouteEntryImplBase::clusterEntry() on why // raw ref to the top level config is currently safe. HeaderParserPtr request_headers_parser_; @@ -740,7 +740,7 @@ class RouteEntryImplBase : public RouteEntry, // Default timeout is 15s if nothing is specified in the route config. static const uint64_t DEFAULT_ROUTE_TIMEOUT_MS = 15000; - std::unique_ptr cors_policy_; + CorsPolicyImplConstPtr cors_policy_; const VirtualHostImpl& vhost_; // See note in RouteEntryImplBase::clusterEntry() on why raw ref // to virtual host is currently safe. const bool auto_host_rewrite_; @@ -773,7 +773,7 @@ class RouteEntryImplBase : public RouteEntry, UpgradeMap upgrade_map_; const uint64_t total_cluster_weight_; - std::unique_ptr hash_policy_; + Http::HashPolicyImplConstPtr hash_policy_; MetadataMatchCriteriaConstPtr metadata_match_criteria_; TlsContextMatchCriteriaConstPtr tls_context_match_criteria_; HeaderParserPtr request_headers_parser_; @@ -980,7 +980,7 @@ class ConfigImpl : public Config { } private: - std::unique_ptr route_matcher_; + RouteMatcherPtr route_matcher_; std::list internal_only_headers_; HeaderParserPtr request_headers_parser_; HeaderParserPtr response_headers_parser_; diff --git a/source/common/router/rds_impl.cc b/source/common/router/rds_impl.cc index 8a041ce0f12c9..4faddfcf2aeed 100644 --- a/source/common/router/rds_impl.cc +++ b/source/common/router/rds_impl.cc @@ -122,8 +122,8 @@ void RdsRouteConfigSubscription::onConfigUpdate( // especially when it comes with per_filter_config, provider->validateConfig(route_config); } - std::unique_ptr noop_init_manager; - std::unique_ptr resume_rds; + Init::ManagerImplPtr noop_init_manager; + CleanupPtr resume_rds; if (config_update_info_->onRdsUpdate(route_config, version_info)) { stats_.config_reload_.inc(); if (config_update_info_->routeConfiguration().has_vhds() && @@ -159,9 +159,9 @@ void RdsRouteConfigSubscription::onConfigUpdate( // Initialize a no-op InitManager in case the one in the factory_context has completed // initialization. This can happen if an RDS config update for an already established RDS // subscription contains VHDS configuration. -void RdsRouteConfigSubscription::maybeCreateInitManager( - const std::string& version_info, std::unique_ptr& init_manager, - std::unique_ptr& init_vhds) { +void RdsRouteConfigSubscription::maybeCreateInitManager(const std::string& version_info, + Init::ManagerImplPtr& init_manager, + CleanupPtr& init_vhds) { if (local_init_manager_.state() == Init::Manager::State::Initialized) { init_manager = std::make_unique( fmt::format("VHDS {}:{}", route_config_name_, version_info)); @@ -339,7 +339,7 @@ Router::RouteConfigProviderSharedPtr RouteConfigProviderManagerImpl::createRdsRo RdsRouteConfigSubscriptionSharedPtr subscription(new RdsRouteConfigSubscription( rds, manager_identifier, factory_context, stat_prefix, *this)); init_manager.add(subscription->parent_init_target_); - std::shared_ptr new_provider{ + RdsRouteConfigProviderImplSharedPtr new_provider{ new RdsRouteConfigProviderImpl(std::move(subscription), factory_context)}; dynamic_route_config_providers_.insert( {manager_identifier, std::weak_ptr(new_provider)}); diff --git a/source/common/router/rds_impl.h b/source/common/router/rds_impl.h index 5481e33980644..a22138b11429b 100644 --- a/source/common/router/rds_impl.h +++ b/source/common/router/rds_impl.h @@ -122,9 +122,8 @@ class RdsRouteConfigSubscription } RouteConfigUpdatePtr& routeConfigUpdate() { return config_update_info_; } void updateOnDemand(const std::string& aliases); - void maybeCreateInitManager(const std::string& version_info, - std::unique_ptr& init_manager, - std::unique_ptr& resume_rds); + void maybeCreateInitManager(const std::string& version_info, Init::ManagerImplPtr& init_manager, + CleanupPtr& resume_rds); private: // Config::SubscriptionCallbacks @@ -152,7 +151,7 @@ class RdsRouteConfigSubscription bool validateUpdateSize(int num_resources); - std::unique_ptr subscription_; + Envoy::Config::SubscriptionPtr subscription_; const std::string route_config_name_; Server::Configuration::ServerFactoryContext& factory_context_; ProtobufMessage::ValidationVisitor& validator_; diff --git a/source/common/router/router.cc b/source/common/router/router.cc index 64f8450de4177..2a53d0ba8f97e 100644 --- a/source/common/router/router.cc +++ b/source/common/router/router.cc @@ -492,7 +492,7 @@ Http::FilterHeadersStatus Filter::decodeHeaders(Http::RequestHeaderMap& headers, transport_socket_options_ = Network::TransportSocketOptionsUtility::fromFilterState( *callbacks_->streamInfo().filterState()); - std::unique_ptr generic_conn_pool = createConnPool(); + GenericConnPoolPtr generic_conn_pool = createConnPool(); if (!generic_conn_pool) { sendNoHealthyUpstreamResponse(); @@ -596,7 +596,7 @@ Http::FilterHeadersStatus Filter::decodeHeaders(Http::RequestHeaderMap& headers, return Http::FilterHeadersStatus::StopIteration; } -std::unique_ptr Filter::createConnPool() { +GenericConnPoolPtr Filter::createConnPool() { GenericConnPoolFactory* factory = nullptr; if (cluster_->upstreamConfig().has_value()) { factory = &Envoy::Config::Utility::getAndCheckFactory( @@ -1513,7 +1513,7 @@ void Filter::doRetry() { ASSERT(pending_retries_ > 0); pending_retries_--; - std::unique_ptr generic_conn_pool = createConnPool(); + GenericConnPoolPtr generic_conn_pool = createConnPool(); if (!generic_conn_pool) { sendNoHealthyUpstreamResponse(); cleanup(); diff --git a/source/common/router/router.h b/source/common/router/router.h index 18259f9c2dc43..328d08cb21b1d 100644 --- a/source/common/router/router.h +++ b/source/common/router/router.h @@ -477,7 +477,7 @@ class Filter : Logger::Loggable, Runtime::Loader& runtime, Runtime::RandomGenerator& random, Event::Dispatcher& dispatcher, Upstream::ResourcePriority priority) PURE; - std::unique_ptr createConnPool(); + GenericConnPoolPtr createConnPool(); UpstreamRequestPtr createUpstreamRequest(); void maybeDoShadowing(); @@ -521,7 +521,7 @@ class Filter : Logger::Loggable, RouteConstSharedPtr route_; const RouteEntry* route_entry_{}; Upstream::ClusterInfoConstSharedPtr cluster_; - std::unique_ptr alt_stat_prefix_; + Stats::StatNameDynamicStoragePtr alt_stat_prefix_; const VirtualCluster* request_vcluster_; Event::TimerPtr response_timeout_; FilterUtility::TimeoutData timeout_; diff --git a/source/common/router/router_ratelimit.cc b/source/common/router/router_ratelimit.cc index c883ce894210c..d4a402a32c480 100644 --- a/source/common/router/router_ratelimit.cc +++ b/source/common/router/router_ratelimit.cc @@ -140,8 +140,7 @@ RateLimitPolicyImpl::RateLimitPolicyImpl( const Protobuf::RepeatedPtrField& rate_limits) : rate_limit_entries_reference_(RateLimitPolicyImpl::MAX_STAGE_NUMBER + 1) { for (const auto& rate_limit : rate_limits) { - std::unique_ptr rate_limit_policy_entry( - new RateLimitPolicyEntryImpl(rate_limit)); + RateLimitPolicyEntryPtr rate_limit_policy_entry(new RateLimitPolicyEntryImpl(rate_limit)); uint64_t stage = rate_limit_policy_entry->stage(); ASSERT(stage < rate_limit_entries_reference_.size()); rate_limit_entries_reference_[stage].emplace_back(*rate_limit_policy_entry); diff --git a/source/common/router/router_ratelimit.h b/source/common/router/router_ratelimit.h index df42e898952bd..bfadd92f7a646 100644 --- a/source/common/router/router_ratelimit.h +++ b/source/common/router/router_ratelimit.h @@ -138,7 +138,7 @@ class RateLimitPolicyImpl : public RateLimitPolicy { bool empty() const override { return rate_limit_entries_.empty(); } private: - std::vector> rate_limit_entries_; + std::vector rate_limit_entries_; std::vector>> rate_limit_entries_reference_; // The maximum stage number supported. This value should match the maximum stage number in diff --git a/source/common/router/scoped_config_impl.cc b/source/common/router/scoped_config_impl.cc index e5e51b763191f..f4621a86a3259 100644 --- a/source/common/router/scoped_config_impl.cc +++ b/source/common/router/scoped_config_impl.cc @@ -38,7 +38,7 @@ HeaderValueExtractorImpl::HeaderValueExtractorImpl( } } -std::unique_ptr +ScopeKeyFragmentBasePtr HeaderValueExtractorImpl::computeFragment(const Http::HeaderMap& headers) const { const Envoy::Http::HeaderEntry* header_entry = headers.get(Envoy::Http::LowerCaseString(header_value_extractor_config_.name())); @@ -107,7 +107,7 @@ ScopeKeyPtr ScopeKeyBuilderImpl::computeScopeKey(const Http::HeaderMap& headers) ScopeKey key; for (const auto& builder : fragment_builders_) { // returns nullopt if a null fragment is found. - std::unique_ptr fragment = builder->computeFragment(headers); + ScopeKeyFragmentBasePtr fragment = builder->computeFragment(headers); if (fragment == nullptr) { return nullptr; } diff --git a/source/common/router/scoped_config_impl.h b/source/common/router/scoped_config_impl.h index 575a097407d6a..ee4424beac79a 100644 --- a/source/common/router/scoped_config_impl.h +++ b/source/common/router/scoped_config_impl.h @@ -54,7 +54,7 @@ class ScopeKey { ScopeKey operator=(const ScopeKey&) = delete; // Caller should guarantee the fragment is not nullptr. - void addFragment(std::unique_ptr&& fragment) { + void addFragment(ScopeKeyFragmentBasePtr&& fragment) { ASSERT(fragment != nullptr, "null fragment not allowed in ScopeKey."); updateHash(*fragment); fragments_.emplace_back(std::move(fragment)); @@ -75,7 +75,7 @@ class ScopeKey { } uint64_t hash_{0}; - std::vector> fragments_; + std::vector fragments_; }; using ScopeKeyPtr = std::unique_ptr; @@ -104,8 +104,7 @@ class FragmentBuilderBase { // Returns a fragment if the fragment rule applies, a nullptr indicates no fragment could be // generated from the headers. - virtual std::unique_ptr - computeFragment(const Http::HeaderMap& headers) const PURE; + virtual ScopeKeyFragmentBasePtr computeFragment(const Http::HeaderMap& headers) const PURE; protected: const ScopedRoutes::ScopeKeyBuilder::FragmentBuilder config_; @@ -115,8 +114,7 @@ class HeaderValueExtractorImpl : public FragmentBuilderBase { public: explicit HeaderValueExtractorImpl(ScopedRoutes::ScopeKeyBuilder::FragmentBuilder&& config); - std::unique_ptr - computeFragment(const Http::HeaderMap& headers) const override; + ScopeKeyFragmentBasePtr computeFragment(const Http::HeaderMap& headers) const override; private: const ScopedRoutes::ScopeKeyBuilder::FragmentBuilder::HeaderValueExtractor& @@ -146,7 +144,7 @@ class ScopeKeyBuilderImpl : public ScopeKeyBuilderBase { ScopeKeyPtr computeScopeKey(const Http::HeaderMap& headers) const override; private: - std::vector> fragment_builders_; + std::vector fragment_builders_; }; // ScopedRouteConfiguration and corresponding RouteConfigProvider. diff --git a/source/common/router/scoped_rds.cc b/source/common/router/scoped_rds.cc index a1ecd85c36392..a5c533d0a9cec 100644 --- a/source/common/router/scoped_rds.cc +++ b/source/common/router/scoped_rds.cc @@ -191,10 +191,10 @@ bool ScopedRdsConfigSubscription::addOrUpdateScopes( return any_applied; } -std::list> +std::list ScopedRdsConfigSubscription::removeScopes( const Protobuf::RepeatedPtrField& scope_names, const std::string& version_info) { - std::list> + std::list to_be_removed_rds_providers; for (const auto& scope_name : scope_names) { auto iter = scoped_route_map_.find(scope_name); @@ -230,10 +230,10 @@ void ScopedRdsConfigSubscription::onConfigUpdate( // If new route config sources come after the local init manager's initialize() been // called, the init manager can't accept new targets. Instead we use a local override which will // start new subscriptions but not wait on them to be ready. - std::unique_ptr noop_init_manager; + Init::ManagerImplPtr noop_init_manager; // NOTE: This should be defined after noop_init_manager as it depends on the // noop_init_manager. - std::unique_ptr resume_rds; + CleanupPtr resume_rds; // if local init manager is initialized, the parent init manager may have gone away. if (localInitManager().state() == Init::Manager::State::Initialized) { const auto type_urls = @@ -266,7 +266,7 @@ void ScopedRdsConfigSubscription::onConfigUpdate( std::vector exception_msgs; // Do not delete RDS config providers just yet, in case the to be deleted RDS subscriptions could // be reused by some to be added scopes. - std::list> + std::list to_be_removed_rds_providers = removeScopes(removed_resources, version_info); bool any_applied = addOrUpdateScopes(added_resources, diff --git a/source/common/router/scoped_rds.h b/source/common/router/scoped_rds.h index befa51a21dc22..184d7cc0b0b81 100644 --- a/source/common/router/scoped_rds.h +++ b/source/common/router/scoped_rds.h @@ -122,7 +122,7 @@ class ScopedRdsConfigSubscription ScopedRdsConfigSubscription& parent_; std::string scope_name_; - std::shared_ptr route_provider_; + RdsRouteConfigProviderImplSharedPtr route_provider_; // This handle_ is owned by the route config provider's RDS subscription, when the helper // destructs, the handle is deleted as well. Common::CallbackHandle* rds_update_callback_handle_; @@ -138,7 +138,7 @@ class ScopedRdsConfigSubscription // Removes given scopes from the managed set of scopes. // Returns a list of to be removed helpers which is temporally held in the onConfigUpdate method, // to make sure new scopes sharing the same RDS source configs could reuse the subscriptions. - std::list> + std::list removeScopes(const Protobuf::RepeatedPtrField& scope_names, const std::string& version_info); @@ -174,14 +174,13 @@ class ScopedRdsConfigSubscription ScopedRouteMap scoped_route_map_; // RdsRouteConfigProvider by scope name. - absl::flat_hash_map> - route_provider_by_scope_; + absl::flat_hash_map route_provider_by_scope_; // A map of (hash, scope-name), used to detect the key conflict between scopes. absl::flat_hash_map scope_name_by_hash_; // For creating RDS subscriptions. Server::Configuration::ServerFactoryContext& factory_context_; const std::string name_; - std::unique_ptr subscription_; + Envoy::Config::SubscriptionPtr subscription_; const envoy::extensions::filters::network::http_connection_manager::v3::ScopedRoutes:: ScopeKeyBuilder scope_key_builder_; Stats::ScopePtr scope_; diff --git a/source/common/router/upstream_request.cc b/source/common/router/upstream_request.cc index 7189a14003c96..a54ca16f6d688 100644 --- a/source/common/router/upstream_request.cc +++ b/source/common/router/upstream_request.cc @@ -41,8 +41,7 @@ namespace Envoy { namespace Router { -UpstreamRequest::UpstreamRequest(RouterFilterInterface& parent, - std::unique_ptr&& conn_pool) +UpstreamRequest::UpstreamRequest(RouterFilterInterface& parent, GenericConnPoolPtr&& conn_pool) : parent_(parent), conn_pool_(std::move(conn_pool)), grpc_rq_success_deferred_(false), stream_info_(parent_.callbacks()->dispatcher().timeSource()), start_time_(parent_.callbacks()->dispatcher().timeSource().monotonicTime()), @@ -329,7 +328,7 @@ void UpstreamRequest::onPoolFailure(ConnectionPool::PoolFailureReason reason, } void UpstreamRequest::onPoolReady( - std::unique_ptr&& upstream, Upstream::HostDescriptionConstSharedPtr host, + GenericUpstreamPtr&& upstream, Upstream::HostDescriptionConstSharedPtr host, const Network::Address::InstanceConstSharedPtr& upstream_local_address, const StreamInfo::StreamInfo& info) { // This may be called under an existing ScopeTrackerScopeState but it will unwind correctly. diff --git a/source/common/router/upstream_request.h b/source/common/router/upstream_request.h index c898fa5b495da..e97af827e8c2d 100644 --- a/source/common/router/upstream_request.h +++ b/source/common/router/upstream_request.h @@ -36,7 +36,7 @@ class UpstreamRequest : public Logger::Loggable, public LinkedObject, public GenericConnectionPoolCallbacks { public: - UpstreamRequest(RouterFilterInterface& parent, std::unique_ptr&& conn_pool); + UpstreamRequest(RouterFilterInterface& parent, GenericConnPoolPtr&& conn_pool); ~UpstreamRequest() override; void encodeHeaders(bool end_stream); @@ -68,8 +68,7 @@ class UpstreamRequest : public Logger::Loggable, void onPoolFailure(ConnectionPool::PoolFailureReason reason, absl::string_view transport_failure_reason, Upstream::HostDescriptionConstSharedPtr host) override; - void onPoolReady(std::unique_ptr&& upstream, - Upstream::HostDescriptionConstSharedPtr host, + void onPoolReady(GenericUpstreamPtr&& upstream, Upstream::HostDescriptionConstSharedPtr host, const Network::Address::InstanceConstSharedPtr& upstream_local_address, const StreamInfo::StreamInfo& info) override; UpstreamRequest* upstreamRequest() override { return this; } @@ -120,10 +119,10 @@ class UpstreamRequest : public Logger::Loggable, } RouterFilterInterface& parent_; - std::unique_ptr conn_pool_; + GenericConnPoolPtr conn_pool_; bool grpc_rq_success_deferred_; Event::TimerPtr per_try_timeout_; - std::unique_ptr upstream_; + GenericUpstreamPtr upstream_; absl::optional deferred_reset_reason_; Buffer::WatermarkBufferPtr buffered_request_body_; Upstream::HostDescriptionConstSharedPtr upstream_host_; diff --git a/source/common/router/vhds.h b/source/common/router/vhds.h index 372f5a08989c7..ac38442687a3f 100644 --- a/source/common/router/vhds.h +++ b/source/common/router/vhds.h @@ -74,7 +74,7 @@ class VhdsSubscription : Envoy::Config::SubscriptionBase subscription_; + Envoy::Config::SubscriptionPtr subscription_; Init::TargetImpl init_target_; std::unordered_set& route_config_providers_; }; diff --git a/source/common/runtime/runtime_impl.cc b/source/common/runtime/runtime_impl.cc index 7d95b940344cc..516c4985fc91d 100644 --- a/source/common/runtime/runtime_impl.cc +++ b/source/common/runtime/runtime_impl.cc @@ -588,7 +588,7 @@ void RtdsSubscription::validateUpdateSize(uint32_t num_resources) { } void LoaderImpl::loadNewSnapshot() { - std::shared_ptr ptr = createNewSnapshot(); + SnapshotImplSharedPtr ptr = createNewSnapshot(); tls_->set([ptr](Event::Dispatcher&) -> ThreadLocal::ThreadLocalObjectSharedPtr { return std::static_pointer_cast(ptr); }); diff --git a/source/common/secret/sds_api.h b/source/common/secret/sds_api.h index d0173f8ae470e..e3ad3389f1dec 100644 --- a/source/common/secret/sds_api.h +++ b/source/common/secret/sds_api.h @@ -77,7 +77,7 @@ class SdsApi : public Envoy::Config::SubscriptionBase< Stats::Store& stats_; const envoy::config::core::v3::ConfigSource sds_config_; - std::unique_ptr subscription_; + Config::SubscriptionPtr subscription_; const std::string sds_config_name_; uint64_t secret_hash_; @@ -89,7 +89,7 @@ class SdsApi : public Envoy::Config::SubscriptionBase< SecretData secret_data_; Event::Dispatcher& dispatcher_; Api::Api& api_; - std::unique_ptr watcher_; + Filesystem::WatcherPtr watcher_; }; class TlsCertificateSdsApi; diff --git a/source/common/secret/secret_manager_impl.h b/source/common/secret/secret_manager_impl.h index d7be0e8b6b548..89b2cb50e6082 100644 --- a/source/common/secret/secret_manager_impl.h +++ b/source/common/secret/secret_manager_impl.h @@ -74,14 +74,14 @@ class SecretManagerImpl : public SecretManager { class DynamicSecretProviders : public Logger::Loggable { public: // Finds or creates SdsApi object. - std::shared_ptr + SecretTypeSharedPtr findOrCreate(const envoy::config::core::v3::ConfigSource& sds_config_source, const std::string& config_name, Server::Configuration::TransportSocketFactoryContext& secret_provider_context) { const std::string map_key = absl::StrCat(MessageUtil::hash(sds_config_source), ".", config_name); - std::shared_ptr secret_provider = dynamic_secret_providers_[map_key].lock(); + SecretTypeSharedPtr secret_provider = dynamic_secret_providers_[map_key].lock(); if (!secret_provider) { // SdsApi is owned by ListenerImpl and ClusterInfo which are destroyed before // SecretManagerImpl. It is safe to invoke this callback at the destructor of SdsApi. @@ -95,10 +95,10 @@ class SecretManagerImpl : public SecretManager { return secret_provider; } - std::vector> allSecretProviders() { - std::vector> providers; + std::vector allSecretProviders() { + std::vector providers; for (const auto& secret_entry : dynamic_secret_providers_) { - std::shared_ptr secret_provider = secret_entry.second.lock(); + SecretTypeSharedPtr secret_provider = secret_entry.second.lock(); if (secret_provider) { providers.push_back(std::move(secret_provider)); } diff --git a/source/common/stats/isolated_store_impl.cc b/source/common/stats/isolated_store_impl.cc index d9511916e8449..4173ea5900e8b 100644 --- a/source/common/stats/isolated_store_impl.cc +++ b/source/common/stats/isolated_store_impl.cc @@ -16,7 +16,7 @@ namespace Stats { IsolatedStoreImpl::IsolatedStoreImpl() : IsolatedStoreImpl(SymbolTableCreator::makeSymbolTable()) {} -IsolatedStoreImpl::IsolatedStoreImpl(std::unique_ptr&& symbol_table) +IsolatedStoreImpl::IsolatedStoreImpl(SymbolTablePtr&& symbol_table) : IsolatedStoreImpl(*symbol_table) { symbol_table_storage_ = std::move(symbol_table); } diff --git a/source/common/stats/isolated_store_impl.h b/source/common/stats/isolated_store_impl.h index 2427e71a1b314..f71b42b9e3269 100644 --- a/source/common/stats/isolated_store_impl.h +++ b/source/common/stats/isolated_store_impl.h @@ -189,7 +189,7 @@ class IsolatedStoreImpl : public StoreImpl { } private: - IsolatedStoreImpl(std::unique_ptr&& symbol_table); + IsolatedStoreImpl(SymbolTablePtr&& symbol_table); SymbolTablePtr symbol_table_storage_; AllocatorImpl alloc_; diff --git a/source/common/stats/thread_local_store.cc b/source/common/stats/thread_local_store.cc index e2eeae81f2f42..cd7c9bf22a623 100644 --- a/source/common/stats/thread_local_store.cc +++ b/source/common/stats/thread_local_store.cc @@ -391,8 +391,7 @@ StatType& ThreadLocalStoreImpl::ScopeImpl::safeMakeStat( } template -absl::optional> -ThreadLocalStoreImpl::ScopeImpl::findStatLockHeld( +StatTypeOptConstRef ThreadLocalStoreImpl::ScopeImpl::findStatLockHeld( StatName name, StatNameHashMap>& central_cache_map) const { auto iter = central_cache_map.find(name); if (iter == central_cache_map.end()) { diff --git a/source/common/stats/thread_local_store.h b/source/common/stats/thread_local_store.h index 83c7b51e2a707..d7de158fb0aff 100644 --- a/source/common/stats/thread_local_store.h +++ b/source/common/stats/thread_local_store.h @@ -385,7 +385,7 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo * @return a reference to the stat, if it exists. */ template - absl::optional> + StatTypeOptConstRef findStatLockHeld(StatName name, StatNameHashMap>& central_cache_map) const; diff --git a/source/common/stream_info/filter_state_impl.cc b/source/common/stream_info/filter_state_impl.cc index d873587abfcf8..7bc4ba239c13b 100644 --- a/source/common/stream_info/filter_state_impl.cc +++ b/source/common/stream_info/filter_state_impl.cc @@ -5,7 +5,7 @@ namespace Envoy { namespace StreamInfo { -void FilterStateImpl::setData(absl::string_view data_name, std::shared_ptr data, +void FilterStateImpl::setData(absl::string_view data_name, ObjectSharedPtr data, FilterState::StateType state_type, FilterState::LifeSpan life_span) { if (life_span > life_span_) { if (hasDataWithNameInternally(data_name)) { @@ -35,7 +35,7 @@ void FilterStateImpl::setData(absl::string_view data_name, std::shared_ptr filter_object(new FilterStateImpl::FilterObject()); + FilterStateImpl::FilterObjectPtr filter_object(new FilterStateImpl::FilterObject()); filter_object->data_ = data; filter_object->state_type_ = state_type; data_storage_[data_name] = std::move(filter_object); diff --git a/source/common/stream_info/filter_state_impl.h b/source/common/stream_info/filter_state_impl.h index 793938e29eadc..45f5a43624485 100644 --- a/source/common/stream_info/filter_state_impl.h +++ b/source/common/stream_info/filter_state_impl.h @@ -40,8 +40,7 @@ class FilterStateImpl : public FilterState { } // FilterState - void setData(absl::string_view data_name, std::shared_ptr data, - FilterState::StateType state_type, + void setData(absl::string_view data_name, ObjectSharedPtr data, FilterState::StateType state_type, FilterState::LifeSpan life_span = FilterState::LifeSpan::FilterChain) override; bool hasDataWithName(absl::string_view) const override; const Object* getDataReadOnlyGeneric(absl::string_view data_name) const override; @@ -58,14 +57,14 @@ class FilterStateImpl : public FilterState { void maybeCreateParent(ParentAccessMode parent_access_mode); struct FilterObject { - std::shared_ptr data_; + ObjectSharedPtr data_; FilterState::StateType state_type_; }; absl::variant ancestor_; FilterStateSharedPtr parent_; const FilterState::LifeSpan life_span_; - absl::flat_hash_map> data_storage_; + absl::flat_hash_map data_storage_; }; } // namespace StreamInfo diff --git a/source/common/tcp_proxy/tcp_proxy.cc b/source/common/tcp_proxy/tcp_proxy.cc index b5b489238790d..ff8d2403886bd 100644 --- a/source/common/tcp_proxy/tcp_proxy.cc +++ b/source/common/tcp_proxy/tcp_proxy.cc @@ -667,7 +667,7 @@ UpstreamDrainManager::~UpstreamDrainManager() { void UpstreamDrainManager::add(const Config::SharedConfigSharedPtr& config, Tcp::ConnectionPool::ConnectionDataPtr&& upstream_conn_data, - const std::shared_ptr& callbacks, + const Filter::UpstreamCallbacksSharedPtr& callbacks, Event::TimerPtr&& idle_timer, const Upstream::HostDescriptionConstSharedPtr& upstream_host) { DrainerPtr drainer(new Drainer(*this, config, callbacks, std::move(upstream_conn_data), @@ -687,7 +687,7 @@ void UpstreamDrainManager::remove(Drainer& drainer, Event::Dispatcher& dispatche } Drainer::Drainer(UpstreamDrainManager& parent, const Config::SharedConfigSharedPtr& config, - const std::shared_ptr& callbacks, + const Filter::UpstreamCallbacksSharedPtr& callbacks, Tcp::ConnectionPool::ConnectionDataPtr&& conn_data, Event::TimerPtr&& idle_timer, const Upstream::HostDescriptionConstSharedPtr& upstream_host) : parent_(parent), callbacks_(callbacks), upstream_conn_data_(std::move(conn_data)), diff --git a/source/common/tcp_proxy/tcp_proxy.h b/source/common/tcp_proxy/tcp_proxy.h index 950f8f654dbe0..433de50e4418f 100644 --- a/source/common/tcp_proxy/tcp_proxy.h +++ b/source/common/tcp_proxy/tcp_proxy.h @@ -205,9 +205,9 @@ class Config { const uint32_t max_connect_attempts_; ThreadLocal::SlotPtr upstream_drain_manager_slot_; SharedConfigSharedPtr shared_config_; - std::unique_ptr cluster_metadata_match_criteria_; + Router::MetadataMatchCriteriaConstPtr cluster_metadata_match_criteria_; Runtime::RandomGenerator& random_generator_; - std::unique_ptr hash_policy_; + Network::HashPolicyImplConstPtr hash_policy_; }; using ConfigSharedPtr = std::shared_ptr; @@ -368,10 +368,10 @@ class Filter : public Network::ReadFilter, DownstreamCallbacks downstream_callbacks_; Event::TimerPtr idle_timer_; - std::shared_ptr upstream_handle_; - std::shared_ptr upstream_callbacks_; // shared_ptr required for passing as a - // read filter. - std::unique_ptr upstream_; + ConnectionHandleSharedPtr upstream_handle_; + UpstreamCallbacksSharedPtr upstream_callbacks_; // shared_ptr required for passing as a + // read filter. + GenericUpstreamPtr upstream_; RouteConstSharedPtr route_; Network::TransportSocketOptionsSharedPtr transport_socket_options_; uint32_t connect_attempts_{}; @@ -384,7 +384,7 @@ class Filter : public Network::ReadFilter, class Drainer : public Event::DeferredDeletable { public: Drainer(UpstreamDrainManager& parent, const Config::SharedConfigSharedPtr& config, - const std::shared_ptr& callbacks, + const Filter::UpstreamCallbacksSharedPtr& callbacks, Tcp::ConnectionPool::ConnectionDataPtr&& conn_data, Event::TimerPtr&& idle_timer, const Upstream::HostDescriptionConstSharedPtr& upstream_host); @@ -396,7 +396,7 @@ class Drainer : public Event::DeferredDeletable { private: UpstreamDrainManager& parent_; - std::shared_ptr callbacks_; + Filter::UpstreamCallbacksSharedPtr callbacks_; Tcp::ConnectionPool::ConnectionDataPtr upstream_conn_data_; Event::TimerPtr timer_; Upstream::HostDescriptionConstSharedPtr upstream_host_; @@ -410,8 +410,7 @@ class UpstreamDrainManager : public ThreadLocal::ThreadLocalObject { ~UpstreamDrainManager() override; void add(const Config::SharedConfigSharedPtr& config, Tcp::ConnectionPool::ConnectionDataPtr&& upstream_conn_data, - const std::shared_ptr& callbacks, - Event::TimerPtr&& idle_timer, + const Filter::UpstreamCallbacksSharedPtr& callbacks, Event::TimerPtr&& idle_timer, const Upstream::HostDescriptionConstSharedPtr& upstream_host); void remove(Drainer& drainer, Event::Dispatcher& dispatcher); diff --git a/source/common/thread_local/thread_local_impl.cc b/source/common/thread_local/thread_local_impl.cc index 8bfb093befae7..d4d02f8b2f5f0 100644 --- a/source/common/thread_local/thread_local_impl.cc +++ b/source/common/thread_local/thread_local_impl.cc @@ -26,7 +26,7 @@ SlotPtr InstanceImpl::allocateSlot() { ASSERT(!shutdown_); if (free_slot_indexes_.empty()) { - std::unique_ptr slot(new SlotImpl(*this, slots_.size())); + SlotImplPtr slot(new SlotImpl(*this, slots_.size())); auto wrapper = std::make_unique(*this, std::move(slot)); slots_.push_back(wrapper->slot_.get()); return wrapper; @@ -34,7 +34,7 @@ SlotPtr InstanceImpl::allocateSlot() { const uint32_t idx = free_slot_indexes_.front(); free_slot_indexes_.pop_front(); ASSERT(idx < slots_.size()); - std::unique_ptr slot(new SlotImpl(*this, idx)); + SlotImplPtr slot(new SlotImpl(*this, idx)); slots_[idx] = slot.get(); return std::make_unique(*this, std::move(slot)); } @@ -56,7 +56,7 @@ ThreadLocalObjectSharedPtr InstanceImpl::SlotImpl::get() { return thread_local_data_.data_[index_]; } -InstanceImpl::Bookkeeper::Bookkeeper(InstanceImpl& parent, std::unique_ptr&& slot) +InstanceImpl::Bookkeeper::Bookkeeper(InstanceImpl& parent, SlotImplPtr&& slot) : parent_(parent), slot_(std::move(slot)), ref_count_(/*not used.*/ nullptr, [slot = slot_.get(), &parent = this->parent_](uint32_t* /* not used */) { @@ -117,7 +117,7 @@ void InstanceImpl::registerThread(Event::Dispatcher& dispatcher, bool main_threa // Puts the slot into a deferred delete container, the slot will be destructed when its out-going // callback reference count goes to 0. -void InstanceImpl::recycle(std::unique_ptr&& slot) { +void InstanceImpl::recycle(SlotImplPtr&& slot) { ASSERT(std::this_thread::get_id() == main_thread_id_); ASSERT(slot != nullptr); auto* slot_addr = slot.get(); @@ -194,11 +194,11 @@ void InstanceImpl::runOnAllThreads(Event::PostCb cb, Event::PostCb all_threads_c // for programming simplicity here. cb(); - std::shared_ptr cb_guard(new Event::PostCb(cb), - [this, all_threads_complete_cb](Event::PostCb* cb) { - main_thread_dispatcher_->post(all_threads_complete_cb); - delete cb; - }); + Event::PostCbSharedPtr cb_guard(new Event::PostCb(cb), + [this, all_threads_complete_cb](Event::PostCb* cb) { + main_thread_dispatcher_->post(all_threads_complete_cb); + delete cb; + }); for (Event::Dispatcher& dispatcher : registered_threads_) { dispatcher.post([cb_guard]() -> void { (*cb_guard)(); }); diff --git a/source/common/thread_local/thread_local_impl.h b/source/common/thread_local/thread_local_impl.h index b451c4eb236a1..f285f1900cdbe 100644 --- a/source/common/thread_local/thread_local_impl.h +++ b/source/common/thread_local/thread_local_impl.h @@ -53,7 +53,7 @@ class InstanceImpl : Logger::Loggable, public NonCopyable, pub // A Wrapper of SlotImpl which on destruction returns the SlotImpl to the deferred delete queue // (detaches it). struct Bookkeeper : public Slot { - Bookkeeper(InstanceImpl& parent, std::unique_ptr&& slot); + Bookkeeper(InstanceImpl& parent, SlotImplPtr&& slot); ~Bookkeeper() override { parent_.recycle(std::move(slot_)); } // ThreadLocal::Slot @@ -66,7 +66,7 @@ class InstanceImpl : Logger::Loggable, public NonCopyable, pub void set(InitializeCb cb) override; InstanceImpl& parent_; - std::unique_ptr slot_; + SlotImplPtr slot_; std::shared_ptr ref_count_; }; @@ -75,7 +75,7 @@ class InstanceImpl : Logger::Loggable, public NonCopyable, pub std::vector data_; }; - void recycle(std::unique_ptr&& slot); + void recycle(SlotImplPtr&& slot); // Cleanup the deferred deletes queue. void scheduleCleanup(SlotImpl* slot); @@ -89,7 +89,7 @@ class InstanceImpl : Logger::Loggable, public NonCopyable, pub // A indexed container for Slots that has to be deferred to delete due to out-going callbacks // pointing to the Slot. To let the ref_count_ deleter find the SlotImpl by address, the container // is defined as a map of SlotImpl address to the unique_ptr. - absl::flat_hash_map> deferred_deletes_; + absl::flat_hash_map deferred_deletes_; std::vector slots_; // A list of index of freed slots. diff --git a/source/common/upstream/cds_api_impl.cc b/source/common/upstream/cds_api_impl.cc index 86759a9a3d940..76c49b64bdfd8 100644 --- a/source/common/upstream/cds_api_impl.cc +++ b/source/common/upstream/cds_api_impl.cc @@ -65,7 +65,7 @@ void CdsApiImpl::onConfigUpdate( const Protobuf::RepeatedPtrField& added_resources, const Protobuf::RepeatedPtrField& removed_resources, const std::string& system_version_info) { - std::unique_ptr maybe_eds_resume; + CleanupPtr maybe_eds_resume; if (cm_.adsMux()) { const auto type_urls = Config::getAllVersionTypeUrls(); diff --git a/source/common/upstream/cds_api_impl.h b/source/common/upstream/cds_api_impl.h index f2f66340e9b05..d7cd83e36c3a0 100644 --- a/source/common/upstream/cds_api_impl.h +++ b/source/common/upstream/cds_api_impl.h @@ -54,7 +54,7 @@ class CdsApiImpl : public CdsApi, void runInitializeCallbackIfAny(); ClusterManager& cm_; - std::unique_ptr subscription_; + Config::SubscriptionPtr subscription_; std::string system_version_info_; std::function initialize_callback_; Stats::ScopePtr scope_; diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index 0a9a21e48da22..358787a463ff4 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -153,7 +153,7 @@ void ClusterManagerInitHelper::maybeFinishInitialize() { // If the first CDS response doesn't have any primary cluster, ClusterLoadAssignment // should be already paused by CdsApiImpl::onConfigUpdate(). Need to check that to // avoid double pause ClusterLoadAssignment. - std::unique_ptr maybe_eds_resume; + CleanupPtr maybe_eds_resume; if (cm_.adsMux()) { const auto type_urls = Config::getAllVersionTypeUrls(); @@ -1023,7 +1023,7 @@ void ClusterManagerImpl::ThreadLocalClusterManagerImpl::drainConnPools( container.drains_remaining_ += container.pools_->size(); // Make a copy to protect against erasure in the callback. - std::shared_ptr pools = container.pools_; + ConnPoolsContainer::ConnPoolsSharedPtr pools = container.pools_; pools->addDrainedCallback([this, old_host]() -> void { if (destroying_) { // It is possible for a connection pool to fire drain callbacks during destruction. Instead diff --git a/source/common/upstream/cluster_manager_impl.h b/source/common/upstream/cluster_manager_impl.h index a373eb20aaf22..b40efda4b5086 100644 --- a/source/common/upstream/cluster_manager_impl.h +++ b/source/common/upstream/cluster_manager_impl.h @@ -283,7 +283,7 @@ class ClusterManagerImpl : public ClusterManager, Logger::Loggable, Http::ConnectionPool::Instance>; // This is a shared_ptr so we can keep it alive while cleaning up. - std::shared_ptr pools_; + ConnPoolsSharedPtr pools_; bool ready_to_drain_{false}; uint64_t drains_remaining_{}; }; @@ -319,8 +319,7 @@ class ClusterManagerImpl : public ClusterManager, Logger::Loggable>; + using TcpConnectionsMap = std::unordered_map; struct ClusterEntry : public ThreadLocalCluster { ClusterEntry(ThreadLocalClusterManagerImpl& parent, ClusterInfoConstSharedPtr cluster, diff --git a/source/common/upstream/conn_pool_map.h b/source/common/upstream/conn_pool_map.h index 041f619e0bfab..b496ef69c0876 100644 --- a/source/common/upstream/conn_pool_map.h +++ b/source/common/upstream/conn_pool_map.h @@ -19,7 +19,7 @@ namespace Upstream { */ template class ConnPoolMap { public: - using PoolFactory = std::function()>; + using PoolFactory = std::function; using DrainedCb = std::function; using PoolOptRef = absl::optional>; @@ -68,7 +68,7 @@ template class ConnPoolMap { **/ void clearActivePools(); - absl::flat_hash_map> active_pools_; + absl::flat_hash_map active_pools_; Event::Dispatcher& thread_local_dispatcher_; std::vector cached_callbacks_; Common::DebugRecursionChecker recursion_checker_; diff --git a/source/common/upstream/eds.h b/source/common/upstream/eds.h index fa3b09eb8cca3..1ff2d98a80c4d 100644 --- a/source/common/upstream/eds.h +++ b/source/common/upstream/eds.h @@ -76,7 +76,7 @@ class EdsClusterImpl const envoy::config::endpoint::v3::ClusterLoadAssignment& cluster_load_assignment_; }; - std::unique_ptr subscription_; + Config::SubscriptionPtr subscription_; const LocalInfo::LocalInfo& local_info_; const std::string cluster_name_; std::vector locality_weights_map_; diff --git a/source/common/upstream/health_checker_base_impl.cc b/source/common/upstream/health_checker_base_impl.cc index 691bc12552cf5..27b64afa2526a 100644 --- a/source/common/upstream/health_checker_base_impl.cc +++ b/source/common/upstream/health_checker_base_impl.cc @@ -43,8 +43,7 @@ HealthCheckerImplBase::HealthCheckerImplBase(const Cluster& cluster, }); } -std::shared_ptr -HealthCheckerImplBase::initTransportSocketOptions( +Network::TransportSocketOptionsImplConstSharedPtr HealthCheckerImplBase::initTransportSocketOptions( const envoy::config::core::v3::HealthCheck& config) { if (config.has_tls_options()) { std::vector protocols{config.tls_options().alpn_protocols().begin(), @@ -181,7 +180,7 @@ void HealthCheckerImplBase::runCallbacks(HostSharedPtr host, HealthTransition ch void HealthCheckerImplBase::HealthCheckHostMonitorImpl::setUnhealthy() { // This is called cross thread. The cluster/health checker might already be gone. - std::shared_ptr health_checker = health_checker_.lock(); + HealthCheckerImplBaseSharedPtr health_checker = health_checker_.lock(); if (health_checker) { health_checker->setUnhealthyCrossThread(host_.lock()); } @@ -197,7 +196,7 @@ void HealthCheckerImplBase::setUnhealthyCrossThread(const HostSharedPtr& host) { // 3) Additionally, the host/session may also be gone by then so we check that also. std::weak_ptr weak_this = shared_from_this(); dispatcher_.post([weak_this, host]() -> void { - std::shared_ptr shared_this = weak_this.lock(); + HealthCheckerImplBaseSharedPtr shared_this = weak_this.lock(); if (shared_this == nullptr) { return; } diff --git a/source/common/upstream/health_checker_base_impl.h b/source/common/upstream/health_checker_base_impl.h index 2da51007f0dfd..652228dbcbd8a 100644 --- a/source/common/upstream/health_checker_base_impl.h +++ b/source/common/upstream/health_checker_base_impl.h @@ -46,7 +46,7 @@ class HealthCheckerImplBase : public HealthChecker, // Upstream::HealthChecker void addHostCheckCompleteCb(HostStatusCb callback) override { callbacks_.push_back(callback); } void start() override; - std::shared_ptr transportSocketOptions() const { + Network::TransportSocketOptionsImplConstSharedPtr transportSocketOptions() const { return transport_socket_options_; } MetadataConstSharedPtr transportSocketMatchMetadata() const { @@ -114,7 +114,7 @@ class HealthCheckerImplBase : public HealthChecker, private: struct HealthCheckHostMonitorImpl : public HealthCheckHostMonitor { - HealthCheckHostMonitorImpl(const std::shared_ptr& health_checker, + HealthCheckHostMonitorImpl(const HealthCheckerImplBaseSharedPtr& health_checker, const HostSharedPtr& host) : health_checker_(health_checker), host_(host) {} @@ -137,7 +137,7 @@ class HealthCheckerImplBase : public HealthChecker, void onClusterMemberUpdate(const HostVector& hosts_added, const HostVector& hosts_removed); void runCallbacks(HostSharedPtr host, HealthTransition changed_state); void setUnhealthyCrossThread(const HostSharedPtr& host); - static std::shared_ptr + static Network::TransportSocketOptionsImplConstSharedPtr initTransportSocketOptions(const envoy::config::core::v3::HealthCheck& config); static MetadataConstSharedPtr initTransportSocketMatchMetadata(const envoy::config::core::v3::HealthCheck& config); @@ -154,7 +154,7 @@ class HealthCheckerImplBase : public HealthChecker, const std::chrono::milliseconds unhealthy_edge_interval_; const std::chrono::milliseconds healthy_edge_interval_; std::unordered_map active_sessions_; - const std::shared_ptr transport_socket_options_; + const Network::TransportSocketOptionsImplConstSharedPtr transport_socket_options_; const MetadataConstSharedPtr transport_socket_match_metadata_; }; diff --git a/source/common/upstream/health_checker_impl.cc b/source/common/upstream/health_checker_impl.cc index 3904b5a8986d5..c67cdf2d4a699 100644 --- a/source/common/upstream/health_checker_impl.cc +++ b/source/common/upstream/health_checker_impl.cc @@ -115,7 +115,7 @@ HealthCheckerSharedPtr HealthCheckerFactory::create( auto& factory = Config::Utility::getAndCheckFactory( health_check_config.custom_health_check()); - std::unique_ptr context( + Server::Configuration::HealthCheckerFactoryContextPtr context( new HealthCheckerFactoryContextImpl(cluster, runtime, random, dispatcher, std::move(event_logger), validation_visitor, api)); return factory.createCustomHealthChecker(health_check_config, *context); diff --git a/source/common/upstream/health_checker_impl.h b/source/common/upstream/health_checker_impl.h index b8b083138151b..ecfd1ce8ce762 100644 --- a/source/common/upstream/health_checker_impl.h +++ b/source/common/upstream/health_checker_impl.h @@ -260,7 +260,7 @@ class TcpHealthCheckerImpl : public HealthCheckerImplBase { TcpHealthCheckerImpl& parent_; Network::ClientConnectionPtr client_; - std::shared_ptr session_callbacks_; + TcpSessionCallbacksSharedPtr session_callbacks_; // If true, stream close was initiated by us, not e.g. remote close or TCP reset. // In this case healthcheck status already reported, only state cleanup required. bool expect_close_{}; diff --git a/source/common/upstream/load_balancer_impl.cc b/source/common/upstream/load_balancer_impl.cc index d5ec4fffa8bb6..68866dbaf0e39 100644 --- a/source/common/upstream/load_balancer_impl.cc +++ b/source/common/upstream/load_balancer_impl.cc @@ -280,12 +280,11 @@ void LoadBalancerBase::recalculatePerPriorityPanic() { void LoadBalancerBase::recalculateLoadInTotalPanic() { // First calculate total number of hosts across all priorities regardless // whether they are healthy or not. - const uint32_t total_hosts_count = - std::accumulate(priority_set_.hostSetsPerPriority().begin(), - priority_set_.hostSetsPerPriority().end(), static_cast(0), - [](size_t acc, const std::unique_ptr& host_set) { - return acc + host_set->hosts().size(); - }); + const uint32_t total_hosts_count = std::accumulate( + priority_set_.hostSetsPerPriority().begin(), priority_set_.hostSetsPerPriority().end(), + static_cast(0), [](size_t acc, const Envoy::Upstream::HostSetPtr& host_set) { + return acc + host_set->hosts().size(); + }); if (0 == total_hosts_count) { // Backend is empty, but load must be distributed somewhere. diff --git a/source/common/upstream/load_balancer_impl.h b/source/common/upstream/load_balancer_impl.h index 9ef6f9fd8fac8..62b92d210ea51 100644 --- a/source/common/upstream/load_balancer_impl.h +++ b/source/common/upstream/load_balancer_impl.h @@ -362,7 +362,7 @@ class EdfLoadBalancerBase : public ZoneAwareLoadBalancerBase { // EdfScheduler for weighted LB. The edf_ is only created when the original // host weights of 2 or more hosts differ. When not present, the // implementation of chooseHostOnce falls back to unweightedHostPick. - std::unique_ptr> edf_; + EdfSchedulerConstPtr edf_; }; void initialize(); diff --git a/source/common/upstream/original_dst_cluster.cc b/source/common/upstream/original_dst_cluster.cc index a84193ce64cb2..2e1f00e7585fd 100644 --- a/source/common/upstream/original_dst_cluster.cc +++ b/source/common/upstream/original_dst_cluster.cc @@ -65,7 +65,7 @@ HostConstSharedPtr OriginalDstCluster::LoadBalancer::chooseHost(LoadBalancerCont std::weak_ptr post_parent = parent_; parent_->dispatcher_.post([post_parent, host]() mutable { // The main cluster may have disappeared while this post was queued. - if (std::shared_ptr parent = post_parent.lock()) { + if (OriginalDstClusterSharedPtr parent = post_parent.lock()) { parent->addHost(host); } }); diff --git a/source/common/upstream/original_dst_cluster.h b/source/common/upstream/original_dst_cluster.h index 52d8e56a30dce..b71954aa8e4d9 100644 --- a/source/common/upstream/original_dst_cluster.h +++ b/source/common/upstream/original_dst_cluster.h @@ -52,7 +52,7 @@ class OriginalDstCluster : public ClusterImplBase { */ class LoadBalancer : public Upstream::LoadBalancer { public: - LoadBalancer(const std::shared_ptr& parent) + LoadBalancer(const OriginalDstClusterSharedPtr& parent) : parent_(parent), host_map_(parent->getCurrentHostMap()) {} // Upstream::LoadBalancer @@ -61,23 +61,22 @@ class OriginalDstCluster : public ClusterImplBase { private: Network::Address::InstanceConstSharedPtr requestOverrideHost(LoadBalancerContext* context); - const std::shared_ptr parent_; + const OriginalDstClusterSharedPtr parent_; HostMapConstSharedPtr host_map_; }; private: struct LoadBalancerFactory : public Upstream::LoadBalancerFactory { - LoadBalancerFactory(const std::shared_ptr& cluster) : cluster_(cluster) {} + LoadBalancerFactory(const OriginalDstClusterSharedPtr& cluster) : cluster_(cluster) {} // Upstream::LoadBalancerFactory Upstream::LoadBalancerPtr create() override { return std::make_unique(cluster_); } - const std::shared_ptr cluster_; + const OriginalDstClusterSharedPtr cluster_; }; struct ThreadAwareLoadBalancer : public Upstream::ThreadAwareLoadBalancer { - ThreadAwareLoadBalancer(const std::shared_ptr& cluster) - : cluster_(cluster) {} + ThreadAwareLoadBalancer(const OriginalDstClusterSharedPtr& cluster) : cluster_(cluster) {} // Upstream::ThreadAwareLoadBalancer Upstream::LoadBalancerFactorySharedPtr factory() override { @@ -85,7 +84,7 @@ class OriginalDstCluster : public ClusterImplBase { } void initialize() override {} - const std::shared_ptr cluster_; + const OriginalDstClusterSharedPtr cluster_; }; HostMapConstSharedPtr getCurrentHostMap() { diff --git a/source/common/upstream/outlier_detection_impl.cc b/source/common/upstream/outlier_detection_impl.cc index e077a862739e6..38f15dd02de71 100644 --- a/source/common/upstream/outlier_detection_impl.cc +++ b/source/common/upstream/outlier_detection_impl.cc @@ -35,8 +35,7 @@ DetectorSharedPtr DetectorImplFactory::createForCluster( } } -DetectorHostMonitorImpl::DetectorHostMonitorImpl(std::shared_ptr detector, - HostSharedPtr host) +DetectorHostMonitorImpl::DetectorHostMonitorImpl(DetectorImplSharedPtr detector, HostSharedPtr host) : detector_(detector), host_(host), // add Success Rate monitors external_origin_sr_monitor_(envoy::data::cluster::v2alpha::SUCCESS_RATE), @@ -67,7 +66,7 @@ void DetectorHostMonitorImpl::updateCurrentSuccessRateBucket() { void DetectorHostMonitorImpl::putHttpResponseCode(uint64_t response_code) { external_origin_sr_monitor_.incTotalReqCounter(); if (Http::CodeUtility::is5xx(response_code)) { - std::shared_ptr detector = detector_.lock(); + DetectorImplSharedPtr detector = detector_.lock(); if (!detector) { // It's possible for the cluster/detector to go away while we still have a host in use. return; @@ -180,7 +179,7 @@ void DetectorHostMonitorImpl::putResult(Result result, absl::optional } void DetectorHostMonitorImpl::localOriginFailure() { - std::shared_ptr detector = detector_.lock(); + DetectorImplSharedPtr detector = detector_.lock(); if (!detector) { // It's possible for the cluster/detector to go away while we still have a host in use. return; @@ -195,7 +194,7 @@ void DetectorHostMonitorImpl::localOriginFailure() { } void DetectorHostMonitorImpl::localOriginNoFailure() { - std::shared_ptr detector = detector_.lock(); + DetectorImplSharedPtr detector = detector_.lock(); if (!detector) { // It's possible for the cluster/detector to go away while we still have a host in use. return; @@ -274,12 +273,12 @@ DetectorImpl::~DetectorImpl() { } } -std::shared_ptr +DetectorImplSharedPtr DetectorImpl::create(const Cluster& cluster, const envoy::config::cluster::v3::OutlierDetection& config, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, TimeSource& time_source, EventLoggerSharedPtr event_logger) { - std::shared_ptr detector( + DetectorImplSharedPtr detector( new DetectorImpl(cluster, config, dispatcher, runtime, time_source, event_logger)); detector->initialize(cluster); @@ -498,7 +497,7 @@ void DetectorImpl::notifyMainThreadConsecutiveError( // Otherwise we do nothing since the detector/cluster is already gone. std::weak_ptr weak_this = shared_from_this(); dispatcher_.post([weak_this, host, type]() -> void { - std::shared_ptr shared_this = weak_this.lock(); + DetectorImplSharedPtr shared_this = weak_this.lock(); if (shared_this) { shared_this->onConsecutiveErrorWorker(host, type); } diff --git a/source/common/upstream/outlier_detection_impl.h b/source/common/upstream/outlier_detection_impl.h index 39e891e44e577..6e6e541029ef0 100644 --- a/source/common/upstream/outlier_detection_impl.h +++ b/source/common/upstream/outlier_detection_impl.h @@ -97,8 +97,8 @@ class SuccessRateAccumulator { absl::optional> getSuccessRateAndVolume(); private: - std::unique_ptr current_success_rate_bucket_; - std::unique_ptr backup_success_rate_bucket_; + SuccessRateAccumulatorBucketPtr current_success_rate_bucket_; + SuccessRateAccumulatorBucketPtr backup_success_rate_bucket_; }; class SuccessRateMonitor { @@ -137,7 +137,7 @@ class DetectorImpl; */ class DetectorHostMonitorImpl : public DetectorHostMonitor { public: - DetectorHostMonitorImpl(std::shared_ptr detector, HostSharedPtr host); + DetectorHostMonitorImpl(DetectorImplSharedPtr detector, HostSharedPtr host); void eject(MonotonicTime ejection_time); void uneject(MonotonicTime ejection_time); @@ -324,10 +324,10 @@ class DetectorConfig { */ class DetectorImpl : public Detector, public std::enable_shared_from_this { public: - static std::shared_ptr - create(const Cluster& cluster, const envoy::config::cluster::v3::OutlierDetection& config, - Event::Dispatcher& dispatcher, Runtime::Loader& runtime, TimeSource& time_source, - EventLoggerSharedPtr event_logger); + static DetectorImplSharedPtr create(const Cluster& cluster, + const envoy::config::cluster::v3::OutlierDetection& config, + Event::Dispatcher& dispatcher, Runtime::Loader& runtime, + TimeSource& time_source, EventLoggerSharedPtr event_logger); ~DetectorImpl() override; void onConsecutive5xx(HostSharedPtr host); diff --git a/source/common/upstream/priority_conn_pool_map.h b/source/common/upstream/priority_conn_pool_map.h index 92b17174170da..7527e86816198 100644 --- a/source/common/upstream/priority_conn_pool_map.h +++ b/source/common/upstream/priority_conn_pool_map.h @@ -52,7 +52,7 @@ template class PriorityConnPoolMap { void drainConnections(); private: - std::array, NumResourcePriorities> conn_pool_maps_; + std::array conn_pool_maps_; }; } // namespace Upstream diff --git a/source/common/upstream/thread_aware_lb_impl.h b/source/common/upstream/thread_aware_lb_impl.h index f2b07d6d3708c..ecf1ed7527d9f 100644 --- a/source/common/upstream/thread_aware_lb_impl.h +++ b/source/common/upstream/thread_aware_lb_impl.h @@ -47,7 +47,7 @@ class ThreadAwareLoadBalancerBase : public LoadBalancerBase, public ThreadAwareL private: struct PerPriorityState { - std::shared_ptr current_lb_; + HashingLoadBalancerSharedPtr current_lb_; bool global_panic_{}; }; using PerPriorityStatePtr = std::unique_ptr; @@ -62,8 +62,8 @@ class ThreadAwareLoadBalancerBase : public LoadBalancerBase, public ThreadAwareL ClusterStats& stats_; Runtime::RandomGenerator& random_; std::shared_ptr> per_priority_state_; - std::shared_ptr healthy_per_priority_load_; - std::shared_ptr degraded_per_priority_load_; + HealthyLoadSharedPtr healthy_per_priority_load_; + DegradedLoadSharedPtr degraded_per_priority_load_; }; struct LoadBalancerFactoryImpl : public LoadBalancerFactory { @@ -78,8 +78,8 @@ class ThreadAwareLoadBalancerBase : public LoadBalancerBase, public ThreadAwareL absl::Mutex mutex_; std::shared_ptr> per_priority_state_ ABSL_GUARDED_BY(mutex_); // This is split out of PerPriorityState so LoadBalancerBase::ChoosePriority can be reused. - std::shared_ptr healthy_per_priority_load_ ABSL_GUARDED_BY(mutex_); - std::shared_ptr degraded_per_priority_load_ ABSL_GUARDED_BY(mutex_); + HealthyLoadSharedPtr healthy_per_priority_load_ ABSL_GUARDED_BY(mutex_); + DegradedLoadSharedPtr degraded_per_priority_load_ ABSL_GUARDED_BY(mutex_); }; virtual HashingLoadBalancerSharedPtr @@ -87,7 +87,7 @@ class ThreadAwareLoadBalancerBase : public LoadBalancerBase, public ThreadAwareL double min_normalized_weight, double max_normalized_weight) PURE; void refresh(); - std::shared_ptr factory_; + LoadBalancerFactoryImplSharedPtr factory_; }; } // namespace Upstream diff --git a/source/common/upstream/upstream_impl.cc b/source/common/upstream/upstream_impl.cc index a11e06f2039e5..48f2e67e27c5c 100644 --- a/source/common/upstream/upstream_impl.cc +++ b/source/common/upstream/upstream_impl.cc @@ -354,7 +354,7 @@ std::vector HostsPerLocalityImpl::filter( // We keep two lists: one for being able to mutate the clone and one for returning to the caller. // Creating them both at the start avoids iterating over the mutable values at the end to convert // them to a const pointer. - std::vector> mutable_clones; + std::vector mutable_clones; std::vector filtered_clones; for (size_t i = 0; i < predicates.size(); ++i) { @@ -415,8 +415,8 @@ void HostSetImpl::updateHosts(PrioritySet::UpdateHostsParams&& update_hosts_para } void HostSetImpl::rebuildLocalityScheduler( - std::unique_ptr>& locality_scheduler, - std::vector>& locality_entries, + EdfSchedulerPtr& locality_scheduler, + std::vector& locality_entries, const HostsPerLocality& eligible_hosts_per_locality, const HostVector& eligible_hosts, HostsPerLocalityConstSharedPtr all_hosts_per_locality, HostsPerLocalityConstSharedPtr excluded_hosts_per_locality, @@ -470,7 +470,7 @@ HostSetImpl::chooseLocality(EdfScheduler* locality_scheduler) { if (locality_scheduler == nullptr) { return {}; } - const std::shared_ptr locality = locality_scheduler->pick(); + const LocalityEntrySharedPtr locality = locality_scheduler->pick(); // We don't build a schedule if there are no weighted localities, so we should always succeed. ASSERT(locality != nullptr); // If we picked it before, its weight must have been positive. diff --git a/source/common/upstream/upstream_impl.h b/source/common/upstream/upstream_impl.h index 372716d078949..59f97ef16efca 100644 --- a/source/common/upstream/upstream_impl.h +++ b/source/common/upstream/upstream_impl.h @@ -409,20 +409,21 @@ class HostSetImpl : public HostSet { // @param locality_weights the weighting of each locality. // @param overprovisioning_factor the overprovisioning factor to use when computing the effective // weight of a locality. - static void rebuildLocalityScheduler( - std::unique_ptr>& locality_scheduler, - std::vector>& locality_entries, - const HostsPerLocality& eligible_hosts_per_locality, const HostVector& eligible_hosts, - HostsPerLocalityConstSharedPtr all_hosts_per_locality, - HostsPerLocalityConstSharedPtr excluded_hosts_per_locality, - LocalityWeightsConstSharedPtr locality_weights, uint32_t overprovisioning_factor); + static void rebuildLocalityScheduler(EdfSchedulerPtr& locality_scheduler, + std::vector& locality_entries, + const HostsPerLocality& eligible_hosts_per_locality, + const HostVector& eligible_hosts, + HostsPerLocalityConstSharedPtr all_hosts_per_locality, + HostsPerLocalityConstSharedPtr excluded_hosts_per_locality, + LocalityWeightsConstSharedPtr locality_weights, + uint32_t overprovisioning_factor); static absl::optional chooseLocality(EdfScheduler* locality_scheduler); - std::vector> healthy_locality_entries_; - std::unique_ptr> healthy_locality_scheduler_; - std::vector> degraded_locality_entries_; - std::unique_ptr> degraded_locality_scheduler_; + std::vector healthy_locality_entries_; + EdfSchedulerPtr healthy_locality_scheduler_; + std::vector degraded_locality_entries_; + EdfSchedulerPtr degraded_locality_scheduler_; }; using HostSetImplPtr = std::unique_ptr; @@ -440,9 +441,7 @@ class PrioritySetImpl : public PrioritySet { Common::CallbackHandle* addPriorityUpdateCb(PriorityUpdateCb callback) const override { return priority_update_cb_helper_.add(callback); } - const std::vector>& hostSetsPerPriority() const override { - return host_sets_; - } + const std::vector& hostSetsPerPriority() const override { return host_sets_; } // Get the host set for this priority level, creating it if necessary. const HostSet& getOrCreateHostSet(uint32_t priority, @@ -473,7 +472,7 @@ class PrioritySetImpl : public PrioritySet { // This vector will generally have at least one member, for priority level 0. // It will expand as host sets are added but currently does not shrink to // avoid any potential lifetime issues. - std::vector> host_sets_; + std::vector host_sets_; private: // TODO(mattklein123): Remove mutable. @@ -662,7 +661,7 @@ class ClusterInfoImpl : public ClusterInfo, protected Logger::Loggable eds_service_name_; const absl::optional cluster_type_; - const std::unique_ptr factory_context_; + const Server::Configuration::CommonFactoryContextPtr factory_context_; std::vector filter_factories_; mutable Http::Http1::CodecStats::AtomicPtr http1_codec_stats_; mutable Http::Http2::CodecStats::AtomicPtr http2_codec_stats_; diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index 85f1cad8919bb..39de8b8ae9191 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -46,10 +46,9 @@ Runtime::LoaderPtr ProdComponentFactory::createRuntime(Server::Instance& server, MainCommonBase::MainCommonBase(const OptionsImpl& options, Event::TimeSystem& time_system, ListenerHooks& listener_hooks, Server::ComponentFactory& component_factory, - std::unique_ptr&& random_generator, + Runtime::RandomGeneratorPtr&& random_generator, Thread::ThreadFactory& thread_factory, - Filesystem::Instance& file_system, - std::unique_ptr process_context) + Filesystem::Instance& file_system, ProcessContextPtr process_context) : options_(options), component_factory_(component_factory), thread_factory_(thread_factory), file_system_(file_system), symbol_table_(Stats::SymbolTableCreator::initAndMakeSymbolTable( options_.fakeSymbolTableEnabled())), @@ -110,7 +109,7 @@ void MainCommonBase::configureHotRestarter(Runtime::RandomGenerator& random_gene if (options_.useDynamicBaseId()) { ASSERT(options_.restartEpoch() == 0, "cannot use dynamic base id during hot restart"); - std::unique_ptr restarter; + Server::HotRestartPtr restarter; // Try 100 times to get an unused base ID and then give up under the assumption // that some other problem has occurred to prevent binding the domain socket. @@ -208,7 +207,7 @@ int MainCommon::main(int argc, char** argv, PostServerHook hook) { // handling, such as running in a chroot jail. absl::InitializeSymbolizer(argv[0]); #endif - std::unique_ptr main_common; + Envoy::MainCommonPtr main_common; // Initialize the server's main context under a try/catch loop and simply return EXIT_FAILURE // as needed. Whatever code in the initialization path that fails is expected to log an error diff --git a/source/exe/main_common.h b/source/exe/main_common.h index 8f55253bf55ea..796dbbacfb7f1 100644 --- a/source/exe/main_common.h +++ b/source/exe/main_common.h @@ -38,9 +38,9 @@ class MainCommonBase { // destructed. MainCommonBase(const OptionsImpl& options, Event::TimeSystem& time_system, ListenerHooks& listener_hooks, Server::ComponentFactory& component_factory, - std::unique_ptr&& random_generator, + Runtime::RandomGeneratorPtr&& random_generator, Thread::ThreadFactory& thread_factory, Filesystem::Instance& file_system, - std::unique_ptr process_context); + ProcessContextPtr process_context); bool run(); @@ -78,12 +78,12 @@ class MainCommonBase { Stats::SymbolTablePtr symbol_table_; Stats::AllocatorImpl stats_allocator_; - std::unique_ptr tls_; - std::unique_ptr restarter_; - std::unique_ptr stats_store_; - std::unique_ptr logging_context_; - std::unique_ptr init_manager_{std::make_unique("Server")}; - std::unique_ptr server_; + ThreadLocal::InstanceImplPtr tls_; + Server::HotRestartPtr restarter_; + Stats::ThreadLocalStoreImplPtr stats_store_; + Logger::ContextPtr logging_context_; + Init::ManagerPtr init_manager_{std::make_unique("Server")}; + Server::InstanceImplPtr server_; private: void configureComponentLogLevels(); diff --git a/source/exe/platform_impl.h b/source/exe/platform_impl.h index 4c05dff225841..6e1ec22ce872a 100644 --- a/source/exe/platform_impl.h +++ b/source/exe/platform_impl.h @@ -13,8 +13,8 @@ class PlatformImpl { Filesystem::Instance& fileSystem() { return *file_system_; } private: - std::unique_ptr thread_factory_; - std::unique_ptr file_system_; + Thread::ThreadFactoryPtr thread_factory_; + Filesystem::InstancePtr file_system_; }; } // namespace Envoy diff --git a/source/extensions/access_loggers/grpc/config_utils.cc b/source/extensions/access_loggers/grpc/config_utils.cc index e950aea731fbb..aa59f2f28018c 100644 --- a/source/extensions/access_loggers/grpc/config_utils.cc +++ b/source/extensions/access_loggers/grpc/config_utils.cc @@ -10,7 +10,7 @@ namespace GrpcCommon { // Singleton registration via macro defined in envoy/singleton/manager.h SINGLETON_MANAGER_REGISTRATION(grpc_access_logger_cache); -std::shared_ptr +GrpcCommon::GrpcAccessLoggerCacheSharedPtr getGrpcAccessLoggerCacheSingleton(Server::Configuration::FactoryContext& context) { return context.singletonManager().getTyped( SINGLETON_MANAGER_REGISTERED_NAME(grpc_access_logger_cache), [&context] { diff --git a/source/extensions/clusters/aggregate/lb_context.h b/source/extensions/clusters/aggregate/lb_context.h index 08aae97f51e7e..52b23af45decf 100644 --- a/source/extensions/clusters/aggregate/lb_context.h +++ b/source/extensions/clusters/aggregate/lb_context.h @@ -68,7 +68,7 @@ class AggregateLoadBalancerContext : public Upstream::LoadBalancerContext { private: Upstream::HealthyAndDegradedLoad priority_load_; - std::unique_ptr owned_context_; + Upstream::LoadBalancerContextPtr owned_context_; Upstream::LoadBalancerContext* context_{nullptr}; const Upstream::LoadBalancerBase::HostAvailability host_availability_; const uint32_t host_priority_; diff --git a/source/extensions/clusters/dynamic_forward_proxy/cluster.cc b/source/extensions/clusters/dynamic_forward_proxy/cluster.cc index e79e6e0197568..0d70dc1c82419 100644 --- a/source/extensions/clusters/dynamic_forward_proxy/cluster.cc +++ b/source/extensions/clusters/dynamic_forward_proxy/cluster.cc @@ -46,8 +46,8 @@ void Cluster::startPreInit() { // If we are attaching to a pre-populated cache we need to initialize our hosts. auto existing_hosts = dns_cache_->hosts(); if (!existing_hosts.empty()) { - std::shared_ptr new_host_map; - std::unique_ptr hosts_added; + HostInfoMapSharedPtr new_host_map; + Upstream::HostVectorPtr hosts_added; for (const auto& existing_host : existing_hosts) { addOrUpdateWorker(existing_host.first, existing_host.second, new_host_map, hosts_added); } @@ -60,8 +60,7 @@ void Cluster::startPreInit() { void Cluster::addOrUpdateWorker( const std::string& host, const Extensions::Common::DynamicForwardProxy::DnsHostInfoSharedPtr& host_info, - std::shared_ptr& new_host_map, - std::unique_ptr& hosts_added) { + HostInfoMapSharedPtr& new_host_map, Upstream::HostVectorPtr& hosts_added) { // We should never get a host with no address from the cache. ASSERT(host_info->address() != nullptr); @@ -117,8 +116,8 @@ void Cluster::addOrUpdateWorker( void Cluster::onDnsHostAddOrUpdate( const std::string& host, const Extensions::Common::DynamicForwardProxy::DnsHostInfoSharedPtr& host_info) { - std::shared_ptr new_host_map; - std::unique_ptr hosts_added; + HostInfoMapSharedPtr new_host_map; + Upstream::HostVectorPtr hosts_added; addOrUpdateWorker(host, host_info, new_host_map, hosts_added); if (hosts_added != nullptr) { ASSERT(!new_host_map->empty()); diff --git a/source/extensions/clusters/dynamic_forward_proxy/cluster.h b/source/extensions/clusters/dynamic_forward_proxy/cluster.h index 7354c60de1689..8916bc7d85ff0 100644 --- a/source/extensions/clusters/dynamic_forward_proxy/cluster.h +++ b/source/extensions/clusters/dynamic_forward_proxy/cluster.h @@ -94,8 +94,7 @@ class Cluster : public Upstream::BaseDynamicClusterImpl, void addOrUpdateWorker(const std::string& host, const Extensions::Common::DynamicForwardProxy::DnsHostInfoSharedPtr& host_info, - std::shared_ptr& new_host_map, - std::unique_ptr& hosts_added); + HostInfoMapSharedPtr& new_host_map, Upstream::HostVectorPtr& hosts_added); void swapAndUpdateMap(const HostInfoMapSharedPtr& new_hosts_map, const Upstream::HostVector& hosts_added, const Upstream::HostVector& hosts_removed); diff --git a/source/extensions/common/redis/cluster_refresh_manager_impl.h b/source/extensions/common/redis/cluster_refresh_manager_impl.h index a62db60327f1b..200fb7e9f3286 100644 --- a/source/extensions/common/redis/cluster_refresh_manager_impl.h +++ b/source/extensions/common/redis/cluster_refresh_manager_impl.h @@ -57,8 +57,8 @@ class ClusterRefreshManagerImpl : public ClusterRefreshManager, ~HandleImpl() override { manager_->unregisterCluster(cluster_info_); } private: - const std::shared_ptr manager_; - const std::shared_ptr cluster_info_; + const ClusterRefreshManagerImplSharedPtr manager_; + const ClusterInfoSharedPtr cluster_info_; }; ClusterRefreshManagerImpl(Event::Dispatcher& main_thread_dispatcher, Upstream::ClusterManager& cm, diff --git a/source/extensions/filters/common/rbac/engine_impl.h b/source/extensions/filters/common/rbac/engine_impl.h index 261b45b0aa133..1091e1676f6e1 100644 --- a/source/extensions/filters/common/rbac/engine_impl.h +++ b/source/extensions/filters/common/rbac/engine_impl.h @@ -24,7 +24,7 @@ class RoleBasedAccessControlEngineImpl : public RoleBasedAccessControlEngine, No private: const bool allowed_if_matched_; - std::map> policies_; + std::map policies_; Protobuf::Arena constant_arena_; Expr::BuilderPtr builder_; diff --git a/source/extensions/filters/common/rbac/utility.h b/source/extensions/filters/common/rbac/utility.h index a48efb813234b..c7abeb97f68a3 100644 --- a/source/extensions/filters/common/rbac/utility.h +++ b/source/extensions/filters/common/rbac/utility.h @@ -43,13 +43,13 @@ RoleBasedAccessControlFilterStats generateStats(const std::string& prefix, Stats enum class EnforcementMode { Enforced, Shadow }; template -std::unique_ptr createEngine(const ConfigType& config) { +RoleBasedAccessControlEngineImplPtr createEngine(const ConfigType& config) { return config.has_rules() ? std::make_unique(config.rules()) : nullptr; } template -std::unique_ptr createShadowEngine(const ConfigType& config) { +RoleBasedAccessControlEngineImplPtr createShadowEngine(const ConfigType& config) { return config.has_shadow_rules() ? std::make_unique(config.shadow_rules()) : nullptr; diff --git a/source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h b/source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h index 7424e1d3bdbaa..19223b598d688 100644 --- a/source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h +++ b/source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h @@ -66,7 +66,7 @@ class AdaptiveConcurrencyFilter : public Http::PassThroughFilter, private: AdaptiveConcurrencyFilterConfigSharedPtr config_; const ConcurrencyControllerSharedPtr controller_; - std::unique_ptr deferred_sample_task_; + CleanupPtr deferred_sample_task_; }; } // namespace AdaptiveConcurrency diff --git a/source/extensions/filters/http/adaptive_concurrency/config.cc b/source/extensions/filters/http/adaptive_concurrency/config.cc index 63a3d2d7f3698..805bce4ef7288 100644 --- a/source/extensions/filters/http/adaptive_concurrency/config.cc +++ b/source/extensions/filters/http/adaptive_concurrency/config.cc @@ -18,7 +18,7 @@ Http::FilterFactoryCb AdaptiveConcurrencyFilterFactory::createFilterFactoryFromP auto acc_stats_prefix = stats_prefix + "adaptive_concurrency."; - std::shared_ptr controller; + Controller::ConcurrencyControllerSharedPtr controller; using Proto = envoy::extensions::filters::http::adaptive_concurrency::v3::AdaptiveConcurrency; ASSERT(config.concurrency_controller_config_case() == Proto::ConcurrencyControllerConfigCase::kGradientControllerConfig); diff --git a/source/extensions/filters/http/admission_control/admission_control.cc b/source/extensions/filters/http/admission_control/admission_control.cc index 7953b79c36f1c..5b773f11cb2ff 100644 --- a/source/extensions/filters/http/admission_control/admission_control.cc +++ b/source/extensions/filters/http/admission_control/admission_control.cc @@ -33,7 +33,7 @@ static constexpr double defaultAggression = 2.0; AdmissionControlFilterConfig::AdmissionControlFilterConfig( const AdmissionControlProto& proto_config, Runtime::Loader& runtime, TimeSource&, Runtime::RandomGenerator& random, Stats::Scope& scope, ThreadLocal::SlotPtr&& tls, - std::shared_ptr response_evaluator) + ResponseEvaluatorSharedPtr response_evaluator) : random_(random), scope_(scope), tls_(std::move(tls)), admission_control_feature_(proto_config.enabled(), runtime), aggression_( diff --git a/source/extensions/filters/http/admission_control/admission_control.h b/source/extensions/filters/http/admission_control/admission_control.h index 22edcf5393961..cad219c8aa84a 100644 --- a/source/extensions/filters/http/admission_control/admission_control.h +++ b/source/extensions/filters/http/admission_control/admission_control.h @@ -51,7 +51,7 @@ class AdmissionControlFilterConfig { AdmissionControlFilterConfig(const AdmissionControlProto& proto_config, Runtime::Loader& runtime, TimeSource&, Runtime::RandomGenerator& random, Stats::Scope& scope, ThreadLocal::SlotPtr&& tls, - std::shared_ptr response_evaluator); + ResponseEvaluatorSharedPtr response_evaluator); virtual ~AdmissionControlFilterConfig() = default; virtual ThreadLocalController& getController() const { NOT_IMPLEMENTED_GCOVR_EXCL_LINE; } @@ -67,8 +67,8 @@ class AdmissionControlFilterConfig { Stats::Scope& scope_; const ThreadLocal::SlotPtr tls_; Runtime::FeatureFlag admission_control_feature_; - std::unique_ptr aggression_; - std::shared_ptr response_evaluator_; + Runtime::DoublePtr aggression_; + ResponseEvaluatorSharedPtr response_evaluator_; }; using AdmissionControlFilterConfigSharedPtr = std::shared_ptr; diff --git a/source/extensions/filters/http/aws_lambda/aws_lambda_filter.cc b/source/extensions/filters/http/aws_lambda/aws_lambda_filter.cc index cd702fcba3c9c..9d371457b469e 100644 --- a/source/extensions/filters/http/aws_lambda/aws_lambda_filter.cc +++ b/source/extensions/filters/http/aws_lambda/aws_lambda_filter.cc @@ -116,7 +116,7 @@ bool isContentTypeTextual(const Http::RequestOrResponseHeaderMap& headers) { } // namespace Filter::Filter(const FilterSettings& settings, const FilterStats& stats, - const std::shared_ptr& sigv4_signer) + const Extensions::Common::Aws::SignerSharedPtr& sigv4_signer) : settings_(settings), stats_(stats), sigv4_signer_(sigv4_signer) {} absl::optional Filter::getRouteSpecificSettings() const { diff --git a/source/extensions/filters/http/aws_lambda/aws_lambda_filter.h b/source/extensions/filters/http/aws_lambda/aws_lambda_filter.h index 82bfdaf85cf2f..597b336e5adf1 100644 --- a/source/extensions/filters/http/aws_lambda/aws_lambda_filter.h +++ b/source/extensions/filters/http/aws_lambda/aws_lambda_filter.h @@ -96,7 +96,7 @@ class Filter : public Http::PassThroughFilter, Logger::Loggable& sigv4_signer); + const Extensions::Common::Aws::SignerSharedPtr& sigv4_signer); Http::FilterHeadersStatus decodeHeaders(Http::RequestHeaderMap&, bool end_stream) override; Http::FilterDataStatus decodeData(Buffer::Instance& data, bool end_stream) override; @@ -129,7 +129,7 @@ class Filter : public Http::PassThroughFilter, Logger::Loggable sigv4_signer_; + Extensions::Common::Aws::SignerSharedPtr sigv4_signer_; absl::optional arn_; InvocationMode invocation_mode_ = InvocationMode::Synchronous; bool payload_passthrough_ = false; diff --git a/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.cc b/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.cc index 5c4ff37272bf2..86df47e50ef06 100644 --- a/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.cc +++ b/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.cc @@ -13,7 +13,7 @@ FilterConfigImpl::FilterConfigImpl(Extensions::Common::Aws::SignerPtr&& signer, : signer_(std::move(signer)), stats_(Filter::generateStats(stats_prefix, scope)), host_rewrite_(host_rewrite) {} -Filter::Filter(const std::shared_ptr& config) : config_(config) {} +Filter::Filter(const FilterConfigSharedPtr& config) : config_(config) {} Extensions::Common::Aws::Signer& FilterConfigImpl::signer() { return *signer_; } diff --git a/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.h b/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.h index ecd22a7b0b4da..b096e6453d199 100644 --- a/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.h +++ b/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.h @@ -77,7 +77,7 @@ class FilterConfigImpl : public FilterConfig { */ class Filter : public Http::PassThroughDecoderFilter, Logger::Loggable { public: - Filter(const std::shared_ptr& config); + Filter(const FilterConfigSharedPtr& config); static FilterStats generateStats(const std::string& prefix, Stats::Scope& scope); @@ -85,7 +85,7 @@ class Filter : public Http::PassThroughDecoderFilter, Logger::Loggable config_; + FilterConfigSharedPtr config_; }; } // namespace AwsRequestSigningFilter diff --git a/source/extensions/filters/http/common/compressor/compressor.cc b/source/extensions/filters/http/common/compressor/compressor.cc index 1b961017fcbc1..5a91917a0aabc 100644 --- a/source/extensions/filters/http/common/compressor/compressor.cc +++ b/source/extensions/filters/http/common/compressor/compressor.cc @@ -154,7 +154,7 @@ bool CompressorFilter::hasCacheControlNoTransform(Http::ResponseHeaderMap& heade // request's Accept-Encoding, the response's Content-Type and the list of compressor // filters in the current chain. // TODO(rojkov): add an explicit fuzzer for chooseEncoding(). -std::unique_ptr +CompressorFilter::EncodingDecisionPtr CompressorFilter::chooseEncoding(const Http::ResponseHeaderMap& headers) const { using EncPair = std::pair; // pair of {encoding, q_value} std::vector pairs; @@ -332,7 +332,7 @@ bool CompressorFilter::isAcceptEncodingAllowed(const Http::ResponseHeaderMap& he } // No cached decision found, so decide now. - std::unique_ptr decision = chooseEncoding(headers); + CompressorFilter::EncodingDecisionPtr decision = chooseEncoding(headers); bool result = shouldCompress(*decision); filter_state->setData(encoding_decision_key, std::move(decision), StreamInfo::FilterState::StateType::ReadOnly); diff --git a/source/extensions/filters/http/common/compressor/compressor.h b/source/extensions/filters/http/common/compressor/compressor.h index 844719a334667..09ad099ad0757 100644 --- a/source/extensions/filters/http/common/compressor/compressor.h +++ b/source/extensions/filters/http/common/compressor/compressor.h @@ -145,7 +145,7 @@ class CompressorFilter : public Http::PassThroughFilter { const HeaderStat stat_; }; - std::unique_ptr chooseEncoding(const Http::ResponseHeaderMap& headers) const; + EncodingDecisionPtr chooseEncoding(const Http::ResponseHeaderMap& headers) const; bool shouldCompress(const EncodingDecision& decision) const; bool skip_compression_; diff --git a/source/extensions/filters/http/fault/fault_filter.h b/source/extensions/filters/http/fault/fault_filter.h index 2dfed7c9167d4..979613ec34cb6 100644 --- a/source/extensions/filters/http/fault/fault_filter.h +++ b/source/extensions/filters/http/fault/fault_filter.h @@ -271,10 +271,10 @@ class FaultFilter : public Http::StreamFilter, Logger::Loggable downstream_cluster_storage_; + Stats::StatNameDynamicStoragePtr downstream_cluster_storage_; const FaultSettings* fault_settings_; bool fault_active_{}; - std::unique_ptr response_limiter_; + StreamRateLimiterPtr response_limiter_; std::string downstream_cluster_delay_percent_key_{}; std::string downstream_cluster_abort_percent_key_{}; std::string downstream_cluster_delay_duration_key_{}; diff --git a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc index 3f04c64f1b350..82e215acd026d 100644 --- a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc +++ b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc @@ -71,9 +71,9 @@ class TranscoderImpl : public Transcoder { * @param request_translator a JsonRequestTranslator that does the request translation * @param response_translator a ResponseToJsonTranslator that does the response translation */ - TranscoderImpl(std::unique_ptr request_translator, - std::unique_ptr json_request_translator, - std::unique_ptr response_translator) + TranscoderImpl(RequestMessageTranslatorPtr request_translator, + JsonRequestTranslatorPtr json_request_translator, + ResponseToJsonTranslatorPtr response_translator) : request_translator_(std::move(request_translator)), json_request_translator_(std::move(json_request_translator)), request_message_stream_(request_translator_ ? *request_translator_ @@ -92,12 +92,12 @@ class TranscoderImpl : public Transcoder { ProtobufUtil::Status ResponseStatus() override { return response_translator_->Status(); } private: - std::unique_ptr request_translator_; - std::unique_ptr json_request_translator_; + RequestMessageTranslatorPtr request_translator_; + JsonRequestTranslatorPtr json_request_translator_; MessageStream& request_message_stream_; - std::unique_ptr response_translator_; - std::unique_ptr request_stream_; - std::unique_ptr response_stream_; + ResponseToJsonTranslatorPtr response_translator_; + TranscoderInputStreamPtr request_stream_; + TranscoderInputStreamPtr response_stream_; }; } // namespace @@ -257,8 +257,8 @@ bool JsonTranscoderConfig::convertGrpcStatus() const { return convert_grpc_statu ProtobufUtil::Status JsonTranscoderConfig::createTranscoder( const Http::RequestHeaderMap& headers, ZeroCopyInputStream& request_input, - google::grpc::transcoding::TranscoderInputStream& response_input, - std::unique_ptr& transcoder, MethodInfoSharedPtr& method_info) { + google::grpc::transcoding::TranscoderInputStream& response_input, TranscoderPtr& transcoder, + MethodInfoSharedPtr& method_info) { if (Grpc::Common::isGrpcRequestHeaders(headers)) { return ProtobufUtil::Status(Code::INVALID_ARGUMENT, "Request headers has application/grpc content-type"); @@ -302,8 +302,8 @@ ProtobufUtil::Status JsonTranscoderConfig::createTranscoder( request_info.variable_bindings.emplace_back(std::move(resolved_binding)); } - std::unique_ptr request_translator; - std::unique_ptr json_request_translator; + RequestMessageTranslatorPtr request_translator; + JsonRequestTranslatorPtr json_request_translator; if (method_info->request_type_is_http_body_) { request_translator = std::make_unique(*type_helper_->Resolver(), false, std::move(request_info)); @@ -316,7 +316,7 @@ ProtobufUtil::Status JsonTranscoderConfig::createTranscoder( const auto response_type_url = Grpc::Common::typeUrl(method_info->descriptor_->output_type()->full_name()); - std::unique_ptr response_translator{new ResponseToJsonTranslator( + ResponseToJsonTranslatorPtr response_translator{new ResponseToJsonTranslator( type_helper_->Resolver(), response_type_url, method_info->descriptor_->server_streaming(), &response_input, print_options_)}; diff --git a/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h b/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h index a37c5b9006a87..d1bbcd5de995f 100644 --- a/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h +++ b/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h @@ -70,7 +70,7 @@ class IpTaggingFilterConfig { const Stats::StatName no_hit_; const Stats::StatName total_; const Stats::StatName unknown_tag_; - std::unique_ptr> trie_; + Network::LcTrie::LcTriePtr trie_; }; using IpTaggingFilterConfigSharedPtr = std::shared_ptr; diff --git a/source/extensions/filters/http/jwt_authn/filter_config.h b/source/extensions/filters/http/jwt_authn/filter_config.h index 53c7cc965be33..7e7d4bca116c4 100644 --- a/source/extensions/filters/http/jwt_authn/filter_config.h +++ b/source/extensions/filters/http/jwt_authn/filter_config.h @@ -82,12 +82,11 @@ class FilterConfigImpl : public Logger::Loggable, ~FilterConfigImpl() override = default; // Finds the matcher that matched the header - static std::shared_ptr + static FilterConfigImplSharedPtr create(envoy::extensions::filters::http::jwt_authn::v3::JwtAuthentication proto_config, const std::string& stats_prefix, Server::Configuration::FactoryContext& context) { // We can't use make_shared here because the constructor of this class is private. - std::shared_ptr ptr( - new FilterConfigImpl(proto_config, stats_prefix, context)); + FilterConfigImplSharedPtr ptr(new FilterConfigImpl(proto_config, stats_prefix, context)); ptr->init(); return ptr; } diff --git a/source/extensions/filters/http/rbac/rbac_filter.h b/source/extensions/filters/http/rbac/rbac_filter.h index fe7369e34e6be..3083a6c63a70b 100644 --- a/source/extensions/filters/http/rbac/rbac_filter.h +++ b/source/extensions/filters/http/rbac/rbac_filter.h @@ -29,8 +29,8 @@ class RoleBasedAccessControlRouteSpecificFilterConfig : public Router::RouteSpec } private: - std::unique_ptr engine_; - std::unique_ptr shadow_engine_; + Filters::Common::RBAC::RoleBasedAccessControlEngineImplPtr engine_; + Filters::Common::RBAC::RoleBasedAccessControlEngineImplPtr shadow_engine_; }; /** @@ -57,8 +57,8 @@ class RoleBasedAccessControlFilterConfig { Filters::Common::RBAC::RoleBasedAccessControlFilterStats stats_; - std::unique_ptr engine_; - std::unique_ptr shadow_engine_; + Filters::Common::RBAC::RoleBasedAccessControlEngineImplConstPtr engine_; + Filters::Common::RBAC::RoleBasedAccessControlEngineImplConstPtr shadow_engine_; }; using RoleBasedAccessControlFilterConfigSharedPtr = diff --git a/source/extensions/filters/network/common/redis/codec.h b/source/extensions/filters/network/common/redis/codec.h index fa256cd6dc4aa..946c14f6acaff 100644 --- a/source/extensions/filters/network/common/redis/codec.h +++ b/source/extensions/filters/network/common/redis/codec.h @@ -32,7 +32,7 @@ class RespValue { public: RespValue() : type_(RespType::Null) {} - RespValue(std::shared_ptr base_array, const RespValue& command, const uint64_t start, + RespValue(RespValueSharedPtr base_array, const RespValue& command, const uint64_t start, const uint64_t end) : type_(RespType::CompositeArray) { new (&composite_array_) CompositeArray(std::move(base_array), command, start, end); @@ -57,8 +57,8 @@ class RespValue { class CompositeArray { public: CompositeArray() = default; - CompositeArray(std::shared_ptr base_array, const RespValue& command, - const uint64_t start, const uint64_t end) + CompositeArray(RespValueSharedPtr base_array, const RespValue& command, const uint64_t start, + const uint64_t end) : base_array_(std::move(base_array)), command_(&command), start_(start), end_(end) { ASSERT(command.type() == RespType::BulkString || command.type() == RespType::SimpleString); ASSERT(base_array_ != nullptr); @@ -68,7 +68,7 @@ class RespValue { } const RespValue* command() const { return command_; } - const std::shared_ptr& baseArray() const { return base_array_; } + const RespValueSharedPtr& baseArray() const { return base_array_; } bool operator==(const CompositeArray& other) const; @@ -107,7 +107,7 @@ class RespValue { } private: - std::shared_ptr base_array_; + RespValueSharedPtr base_array_; const RespValue* command_; uint64_t start_; uint64_t end_; diff --git a/source/extensions/filters/network/common/redis/redis_command_stats.h b/source/extensions/filters/network/common/redis/redis_command_stats.h index 5dddb9f8303c9..0790a046ca08e 100644 --- a/source/extensions/filters/network/common/redis/redis_command_stats.h +++ b/source/extensions/filters/network/common/redis/redis_command_stats.h @@ -23,8 +23,7 @@ class RedisCommandStats { // TODO (@FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg): Use Singleton to manage a single // RedisCommandStats on the client factory so that it can be used for proxy filter, discovery and // health check. - static std::shared_ptr - createRedisCommandStats(Stats::SymbolTable& symbol_table) { + static RedisCommandStatsSharedPtr createRedisCommandStats(Stats::SymbolTable& symbol_table) { return std::make_shared(symbol_table, "upstream_commands"); } diff --git a/source/extensions/filters/network/dubbo_proxy/config.cc b/source/extensions/filters/network/dubbo_proxy/config.cc index 2ea2a87315ac3..b45ca6bfc0551 100644 --- a/source/extensions/filters/network/dubbo_proxy/config.cc +++ b/source/extensions/filters/network/dubbo_proxy/config.cc @@ -21,7 +21,7 @@ namespace DubboProxy { Network::FilterFactoryCb DubboProxyFilterConfigFactory::createFilterFactoryFromProtoTyped( const envoy::extensions::filters::network::dubbo_proxy::v3::DubboProxy& proto_config, Server::Configuration::FactoryContext& context) { - std::shared_ptr filter_config(std::make_shared(proto_config, context)); + ConfigSharedPtr filter_config(std::make_shared(proto_config, context)); return [filter_config, &context](Network::FilterManager& filter_manager) -> void { filter_manager.addReadFilter(std::make_shared( diff --git a/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h b/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h index fb89c59c8a466..947ee2413b442 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h +++ b/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h @@ -124,7 +124,7 @@ class MethodRouteEntryImpl : public RouteEntryImplBase { private: const Matchers::StringMatcherImpl method_name_; - std::shared_ptr parameter_route_; + ParameterRouteEntryImplSharedPtr parameter_route_; }; class SingleRouteMatcherImpl : public RouteMatcher, public Logger::Loggable { diff --git a/source/extensions/filters/network/dubbo_proxy/router/router_impl.h b/source/extensions/filters/network/dubbo_proxy/router/router_impl.h index 8eb73cc122ffa..e9dbf3f61b575 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/router_impl.h +++ b/source/extensions/filters/network/dubbo_proxy/router/router_impl.h @@ -90,7 +90,7 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, const RouteEntry* route_entry_{}; Upstream::ClusterInfoConstSharedPtr cluster_; - std::unique_ptr upstream_request_; + UpstreamRequestPtr upstream_request_; Envoy::Buffer::OwnedImpl upstream_request_buffer_; bool filter_complete_{false}; diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index 1c0958ad6f1da..0d4b7c839602d 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -63,7 +63,7 @@ FilterFactoryMap::const_iterator findUpgradeCaseInsensitive(const FilterFactoryM return upgrade_map.end(); } -std::unique_ptr createInternalAddressConfig( +Http::InternalAddressConfigPtr createInternalAddressConfig( const envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager& config) { if (config.has_internal_address_config()) { @@ -82,20 +82,20 @@ SINGLETON_MANAGER_REGISTRATION(scoped_routes_config_provider_manager); SINGLETON_MANAGER_REGISTRATION(http_tracer_manager); Utility::Singletons Utility::createSingletons(Server::Configuration::FactoryContext& context) { - std::shared_ptr date_provider = + Http::TlsCachingDateProviderImplSharedPtr date_provider = context.singletonManager().getTyped( SINGLETON_MANAGER_REGISTERED_NAME(date_provider), [&context] { return std::make_shared(context.dispatcher(), context.threadLocal()); }); - std::shared_ptr route_config_provider_manager = + Router::RouteConfigProviderManagerSharedPtr route_config_provider_manager = context.singletonManager().getTyped( SINGLETON_MANAGER_REGISTERED_NAME(route_config_provider_manager), [&context] { return std::make_shared(context.admin()); }); - std::shared_ptr scoped_routes_config_provider_manager = + Router::ScopedRoutesConfigProviderManagerSharedPtr scoped_routes_config_provider_manager = context.singletonManager().getTyped( SINGLETON_MANAGER_REGISTERED_NAME(scoped_routes_config_provider_manager), [&context, route_config_provider_manager] { @@ -114,7 +114,7 @@ Utility::Singletons Utility::createSingletons(Server::Configuration::FactoryCont http_tracer_manager}; } -std::shared_ptr Utility::createConfig( +HttpConnectionManagerConfigSharedPtr Utility::createConfig( const envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager& proto_config, Server::Configuration::FactoryContext& context, Http::DateProvider& date_provider, @@ -427,7 +427,7 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig( fmt::format("Error: multiple upgrade configs with the same name: '{}'", name)); } if (!upgrade_config.filters().empty()) { - std::unique_ptr factories = std::make_unique(); + FilterFactoriesListPtr factories = std::make_unique(); for (int32_t j = 0; j < upgrade_config.filters().size(); j++) { processFilter(upgrade_config.filters(j), j, name, *factories, "http upgrade", j == upgrade_config.filters().size() - 1); @@ -435,7 +435,7 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig( upgrade_filter_factories_.emplace( std::make_pair(name, FilterConfig{std::move(factories), enabled})); } else { - std::unique_ptr factories(nullptr); + FilterFactoriesListPtr factories(nullptr); upgrade_filter_factories_.emplace( std::make_pair(name, FilterConfig{std::move(factories), enabled})); } @@ -495,7 +495,7 @@ HttpConnectionManagerConfig::createCodec(Network::Connection& connection, // TODO(danzh) Add support to get the factory name from config, possibly // from HttpConnectionManager protobuf. This is not essential till there are multiple // implementations of QUIC. - return std::unique_ptr( + return Http::ServerConnectionPtr( Config::Utility::getAndCheckFactoryByName( Http::QuicCodecNames::get().Quiche) .createQuicServerConnection(connection, callbacks)); diff --git a/source/extensions/filters/network/http_connection_manager/config.h b/source/extensions/filters/network/http_connection_manager/config.h index ca76b80a593a4..8f471f0254db9 100644 --- a/source/extensions/filters/network/http_connection_manager/config.h +++ b/source/extensions/filters/network/http_connection_manager/config.h @@ -94,7 +94,7 @@ class HttpConnectionManagerConfig : Logger::Loggable, void createFilterChain(Http::FilterChainFactoryCallbacks& callbacks) override; using FilterFactoriesList = std::list; struct FilterConfig { - std::unique_ptr filter_factories; + FilterFactoriesListPtr filter_factories; bool allow_upgrade; }; bool createUpgradeFilterChain(absl::string_view upgrade_type, @@ -195,7 +195,7 @@ class HttpConnectionManagerConfig : Logger::Loggable, mutable Http::Http2::CodecStats::AtomicPtr http2_codec_stats_; Http::ConnectionManagerTracingStats tracing_stats_; const bool use_remote_address_{}; - const std::unique_ptr internal_address_config_; + const Http::InternalAddressConfigPtr internal_address_config_; const uint32_t xff_num_trusted_hops_; const bool skip_xff_append_; const std::string via_; @@ -259,10 +259,9 @@ class HttpConnectionManagerFactory { class Utility { public: struct Singletons { - std::shared_ptr date_provider_; - std::shared_ptr route_config_provider_manager_; - std::shared_ptr - scoped_routes_config_provider_manager_; + Http::TlsCachingDateProviderImplSharedPtr date_provider_; + Router::RouteConfigProviderManagerSharedPtr route_config_provider_manager_; + Router::ScopedRoutesConfigProviderManagerSharedPtr scoped_routes_config_provider_manager_; Tracing::HttpTracerManagerSharedPtr http_tracer_manager_; }; @@ -284,7 +283,7 @@ class Utility { * @param scoped_routes_config_provider_manager the singleton used in config creation. * @return a shared_ptr to the created config object. */ - static std::shared_ptr createConfig( + static HttpConnectionManagerConfigSharedPtr createConfig( const envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager& proto_config, Server::Configuration::FactoryContext& context, Http::DateProvider& date_provider, diff --git a/source/extensions/filters/network/mongo_proxy/bson_impl.h b/source/extensions/filters/network/mongo_proxy/bson_impl.h index 71e18b4546fa0..7d19b5a6c06a4 100644 --- a/source/extensions/filters/network/mongo_proxy/bson_impl.h +++ b/source/extensions/filters/network/mongo_proxy/bson_impl.h @@ -183,7 +183,7 @@ class DocumentImpl : public Document, public: static DocumentSharedPtr create() { return DocumentSharedPtr{new DocumentImpl()}; } static DocumentSharedPtr create(Buffer::Instance& data) { - std::shared_ptr new_doc{new DocumentImpl()}; + DocumentImplSharedPtr new_doc{new DocumentImpl()}; new_doc->fromBuffer(data); return new_doc; } diff --git a/source/extensions/filters/network/mongo_proxy/codec_impl.cc b/source/extensions/filters/network/mongo_proxy/codec_impl.cc index d56fe7ff4e319..40deb0e4ff3e5 100644 --- a/source/extensions/filters/network/mongo_proxy/codec_impl.cc +++ b/source/extensions/filters/network/mongo_proxy/codec_impl.cc @@ -367,51 +367,49 @@ bool DecoderImpl::decode(Buffer::Instance& data) { switch (op_code) { case Message::OpCode::Reply: { - std::unique_ptr message(new ReplyMessageImpl(request_id, response_to)); + ReplyMessageImplPtr message(new ReplyMessageImpl(request_id, response_to)); message->fromBuffer(message_length, data); callbacks_.decodeReply(std::move(message)); break; } case Message::OpCode::Query: { - std::unique_ptr message(new QueryMessageImpl(request_id, response_to)); + QueryMessageImplPtr message(new QueryMessageImpl(request_id, response_to)); message->fromBuffer(message_length, data); callbacks_.decodeQuery(std::move(message)); break; } case Message::OpCode::GetMore: { - std::unique_ptr message(new GetMoreMessageImpl(request_id, response_to)); + GetMoreMessageImplPtr message(new GetMoreMessageImpl(request_id, response_to)); message->fromBuffer(message_length, data); callbacks_.decodeGetMore(std::move(message)); break; } case Message::OpCode::Insert: { - std::unique_ptr message(new InsertMessageImpl(request_id, response_to)); + InsertMessageImplPtr message(new InsertMessageImpl(request_id, response_to)); message->fromBuffer(message_length, data); callbacks_.decodeInsert(std::move(message)); break; } case Message::OpCode::KillCursors: { - std::unique_ptr message( - new KillCursorsMessageImpl(request_id, response_to)); + KillCursorsMessageImplPtr message(new KillCursorsMessageImpl(request_id, response_to)); message->fromBuffer(message_length, data); callbacks_.decodeKillCursors(std::move(message)); break; } case Message::OpCode::Command: { - std::unique_ptr message(new CommandMessageImpl(request_id, response_to)); + CommandMessageImplPtr message(new CommandMessageImpl(request_id, response_to)); message->fromBuffer(message_length, data); callbacks_.decodeCommand(std::move(message)); break; } case Message::OpCode::CommandReply: { - std::unique_ptr message( - new CommandReplyMessageImpl(request_id, response_to)); + CommandReplyMessageImplPtr message(new CommandReplyMessageImpl(request_id, response_to)); message->fromBuffer(message_length, data); callbacks_.decodeCommandReply(std::move(message)); break; diff --git a/source/extensions/filters/network/mongo_proxy/proxy.h b/source/extensions/filters/network/mongo_proxy/proxy.h index c54308f1ae386..34ba89edd3968 100644 --- a/source/extensions/filters/network/mongo_proxy/proxy.h +++ b/source/extensions/filters/network/mongo_proxy/proxy.h @@ -182,7 +182,7 @@ class ProxyFilter : public Network::Filter, void delayInjectionTimerCallback(); void tryInjectDelay(); - std::unique_ptr decoder_; + DecoderPtr decoder_; std::string stat_prefix_; MongoProxyStats stats_; Runtime::Loader& runtime_; diff --git a/source/extensions/filters/network/mysql_proxy/mysql_filter.h b/source/extensions/filters/network/mysql_proxy/mysql_filter.h index 2d73ef9b58468..f3f0502922fdf 100644 --- a/source/extensions/filters/network/mysql_proxy/mysql_filter.h +++ b/source/extensions/filters/network/mysql_proxy/mysql_filter.h @@ -101,7 +101,7 @@ class MySQLFilter : public Network::Filter, DecoderCallbacks, Logger::Loggable decoder_; + DecoderPtr decoder_; bool sniffing_{true}; }; diff --git a/source/extensions/filters/network/postgres_proxy/postgres_filter.h b/source/extensions/filters/network/postgres_proxy/postgres_filter.h index 0355bea4b1f3b..6ebe4a645e934 100644 --- a/source/extensions/filters/network/postgres_proxy/postgres_filter.h +++ b/source/extensions/filters/network/postgres_proxy/postgres_filter.h @@ -104,7 +104,7 @@ class PostgresFilter : public Network::Filter, void doDecode(Buffer::Instance& data, bool); DecoderPtr createDecoder(DecoderCallbacks* callbacks); - void setDecoder(std::unique_ptr decoder) { decoder_ = std::move(decoder); } + void setDecoder(DecoderPtr decoder) { decoder_ = std::move(decoder); } Decoder* getDecoder() const { return decoder_.get(); } // Routines used during integration and unit tests @@ -117,7 +117,7 @@ class PostgresFilter : public Network::Filter, PostgresFilterConfigSharedPtr config_; Buffer::OwnedImpl frontend_buffer_; Buffer::OwnedImpl backend_buffer_; - std::unique_ptr decoder_; + DecoderPtr decoder_; }; } // namespace PostgresProxy diff --git a/source/extensions/filters/network/rbac/rbac_filter.h b/source/extensions/filters/network/rbac/rbac_filter.h index 19c9360e21342..7ed2dbdc57561 100644 --- a/source/extensions/filters/network/rbac/rbac_filter.h +++ b/source/extensions/filters/network/rbac/rbac_filter.h @@ -40,8 +40,8 @@ class RoleBasedAccessControlFilterConfig { private: Filters::Common::RBAC::RoleBasedAccessControlFilterStats stats_; - std::unique_ptr engine_; - std::unique_ptr shadow_engine_; + Filters::Common::RBAC::RoleBasedAccessControlEngineImplPtr engine_; + Filters::Common::RBAC::RoleBasedAccessControlEngineImplPtr shadow_engine_; const envoy::extensions::filters::network::rbac::v3::RBAC::EnforcementType enforcement_type_; }; diff --git a/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc b/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc index adfbf7ff9fbe1..8af9f8d694450 100644 --- a/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc +++ b/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc @@ -105,8 +105,7 @@ SplitRequestPtr SimpleRequest::create(Router& router, Common::Redis::RespValuePtr&& incoming_request, SplitCallbacks& callbacks, CommandStats& command_stats, TimeSource& time_source) { - std::unique_ptr request_ptr{ - new SimpleRequest(callbacks, command_stats, time_source)}; + SimpleRequestPtr request_ptr{new SimpleRequest(callbacks, command_stats, time_source)}; const auto route = router.upstreamPool(incoming_request->asArray()[1].asString()); if (route) { @@ -135,7 +134,7 @@ SplitRequestPtr EvalRequest::create(Router& router, Common::Redis::RespValuePtr& return nullptr; } - std::unique_ptr request_ptr{new EvalRequest(callbacks, command_stats, time_source)}; + EvalRequestPtr request_ptr{new EvalRequest(callbacks, command_stats, time_source)}; const auto route = router.upstreamPool(incoming_request->asArray()[3].asString()); if (route) { @@ -178,7 +177,7 @@ void FragmentedRequest::onChildFailure(uint32_t index) { SplitRequestPtr MGETRequest::create(Router& router, Common::Redis::RespValuePtr&& incoming_request, SplitCallbacks& callbacks, CommandStats& command_stats, TimeSource& time_source) { - std::unique_ptr request_ptr{new MGETRequest(callbacks, command_stats, time_source)}; + MGETRequestPtr request_ptr{new MGETRequest(callbacks, command_stats, time_source)}; request_ptr->num_pending_responses_ = incoming_request->asArray().size() - 1; request_ptr->pending_requests_.reserve(request_ptr->num_pending_responses_); @@ -256,7 +255,7 @@ SplitRequestPtr MSETRequest::create(Router& router, Common::Redis::RespValuePtr& command_stats.error_.inc(); return nullptr; } - std::unique_ptr request_ptr{new MSETRequest(callbacks, command_stats, time_source)}; + MSETRequestPtr request_ptr{new MSETRequest(callbacks, command_stats, time_source)}; request_ptr->num_pending_responses_ = (incoming_request->asArray().size() - 1) / 2; request_ptr->pending_requests_.reserve(request_ptr->num_pending_responses_); @@ -326,7 +325,7 @@ SplitRequestPtr SplitKeysSumResultRequest::create(Router& router, SplitCallbacks& callbacks, CommandStats& command_stats, TimeSource& time_source) { - std::unique_ptr request_ptr{ + SplitKeysSumResultRequestPtr request_ptr{ new SplitKeysSumResultRequest(callbacks, command_stats, time_source)}; request_ptr->num_pending_responses_ = incoming_request->asArray().size() - 1; diff --git a/source/extensions/filters/network/redis_proxy/config.cc b/source/extensions/filters/network/redis_proxy/config.cc index e52a04ffe0655..974283a7105a8 100644 --- a/source/extensions/filters/network/redis_proxy/config.cc +++ b/source/extensions/filters/network/redis_proxy/config.cc @@ -86,10 +86,9 @@ Network::FilterFactoryCb RedisProxyFilterConfigFactory::createFilterFactoryFromP auto router = std::make_unique(prefix_routes, std::move(upstreams), context.runtime()); - std::shared_ptr splitter = - std::make_shared( - std::move(router), context.scope(), filter_config->stat_prefix_, context.timeSource(), - proto_config.latency_in_micros()); + CommandSplitter::InstanceSharedPtr splitter = std::make_shared( + std::move(router), context.scope(), filter_config->stat_prefix_, context.timeSource(), + proto_config.latency_in_micros()); return [splitter, filter_config](Network::FilterManager& filter_manager) -> void { Common::Redis::DecoderFactoryImpl factory; filter_manager.addReadFilter(std::make_shared( diff --git a/source/extensions/filters/network/rocketmq_proxy/config.cc b/source/extensions/filters/network/rocketmq_proxy/config.cc index 02f8da69c41f5..692a7cf4ab5fb 100644 --- a/source/extensions/filters/network/rocketmq_proxy/config.cc +++ b/source/extensions/filters/network/rocketmq_proxy/config.cc @@ -20,7 +20,7 @@ namespace rocketmq_config = envoy::extensions::filters::network::rocketmq_proxy: Network::FilterFactoryCb RocketmqProxyFilterConfigFactory::createFilterFactoryFromProtoTyped( const rocketmq_config::RocketmqProxy& proto_config, Server::Configuration::FactoryContext& context) { - std::shared_ptr filter_config = std::make_shared(proto_config, context); + ConfigImplSharedPtr filter_config = std::make_shared(proto_config, context); return [filter_config, &context](Network::FilterManager& filter_manager) -> void { filter_manager.addReadFilter( std::make_shared(*filter_config, context.dispatcher().timeSource())); diff --git a/source/extensions/filters/network/thrift_proxy/config.cc b/source/extensions/filters/network/thrift_proxy/config.cc index ab8aa302eb1f3..1aacd903003d2 100644 --- a/source/extensions/filters/network/thrift_proxy/config.cc +++ b/source/extensions/filters/network/thrift_proxy/config.cc @@ -101,7 +101,7 @@ ProtocolType ProtocolOptionsConfigImpl::protocol(ProtocolType downstream_protoco Network::FilterFactoryCb ThriftProxyFilterConfigFactory::createFilterFactoryFromProtoTyped( const envoy::extensions::filters::network::thrift_proxy::v3::ThriftProxy& proto_config, Server::Configuration::FactoryContext& context) { - std::shared_ptr filter_config(new ConfigImpl(proto_config, context)); + ConfigSharedPtr filter_config(new ConfigImpl(proto_config, context)); return [filter_config, &context](Network::FilterManager& filter_manager) -> void { filter_manager.addReadFilter(std::make_shared( diff --git a/source/extensions/filters/network/thrift_proxy/config.h b/source/extensions/filters/network/thrift_proxy/config.h index 62a123936bac4..01be67c6a7693 100644 --- a/source/extensions/filters/network/thrift_proxy/config.h +++ b/source/extensions/filters/network/thrift_proxy/config.h @@ -90,7 +90,7 @@ class ConfigImpl : public Config, ThriftFilterStats stats_; const TransportType transport_; const ProtocolType proto_; - std::unique_ptr route_matcher_; + Router::RouteMatcherPtr route_matcher_; std::list filter_factories_; }; diff --git a/source/extensions/filters/network/thrift_proxy/router/router_impl.cc b/source/extensions/filters/network/thrift_proxy/router/router_impl.cc index 885538c6298a1..936f386a9a2d3 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_impl.cc +++ b/source/extensions/filters/network/thrift_proxy/router/router_impl.cc @@ -42,7 +42,7 @@ RouteEntryImplBase::RouteEntryImplBase( total_cluster_weight_ = 0UL; for (const auto& cluster : route.route().weighted_clusters().clusters()) { - std::unique_ptr cluster_entry(new WeightedClusterEntry(*this, cluster)); + WeightedClusterEntryPtr cluster_entry(new WeightedClusterEntry(*this, cluster)); weighted_clusters_.emplace_back(std::move(cluster_entry)); total_cluster_weight_ += weighted_clusters_.back()->clusterWeight(); } @@ -247,7 +247,7 @@ FilterStatus Router::messageBegin(MessageMetadataSharedPtr metadata) { return FilterStatus::StopIteration; } - const std::shared_ptr options = + const ProtocolOptionsConfigConstSharedPtr options = cluster_->extensionProtocolOptionsTyped( NetworkFilterNames::get().ThriftProxy); diff --git a/source/extensions/filters/network/thrift_proxy/router/router_impl.h b/source/extensions/filters/network/thrift_proxy/router/router_impl.h index 26a94c90c7534..d30073594d411 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_impl.h +++ b/source/extensions/filters/network/thrift_proxy/router/router_impl.h @@ -263,7 +263,7 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, const RouteEntry* route_entry_{}; Upstream::ClusterInfoConstSharedPtr cluster_; - std::unique_ptr upstream_request_; + UpstreamRequestPtr upstream_request_; Buffer::OwnedImpl upstream_request_buffer_; }; diff --git a/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.cc b/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.cc index 694831013a42a..8d576891c593e 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.cc +++ b/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.cc @@ -140,8 +140,7 @@ RateLimitPolicyImpl::RateLimitPolicyImpl( const Protobuf::RepeatedPtrField& rate_limits) : rate_limit_entries_reference_(RateLimitPolicyImpl::MAX_STAGE_NUMBER + 1) { for (const auto& rate_limit : rate_limits) { - std::unique_ptr rate_limit_policy_entry( - new RateLimitPolicyEntryImpl(rate_limit)); + RateLimitPolicyEntryPtr rate_limit_policy_entry(new RateLimitPolicyEntryImpl(rate_limit)); uint32_t stage = rate_limit_policy_entry->stage(); ASSERT(stage < rate_limit_entries_reference_.size()); rate_limit_entries_reference_[stage].emplace_back(*rate_limit_policy_entry); diff --git a/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.h b/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.h index 48f3a4f860c7b..8b84668c643b0 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.h +++ b/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.h @@ -146,7 +146,7 @@ class RateLimitPolicyImpl : public RateLimitPolicy { static constexpr uint32_t MAX_STAGE_NUMBER = 10; private: - std::vector> rate_limit_entries_; + std::vector rate_limit_entries_; std::vector>> rate_limit_entries_reference_; }; diff --git a/source/extensions/filters/network/thrift_proxy/thrift_object_impl.cc b/source/extensions/filters/network/thrift_proxy/thrift_object_impl.cc index 0008f3f58495d..3a706db2cc7dc 100644 --- a/source/extensions/filters/network/thrift_proxy/thrift_object_impl.cc +++ b/source/extensions/filters/network/thrift_proxy/thrift_object_impl.cc @@ -6,7 +6,7 @@ namespace NetworkFilters { namespace ThriftProxy { namespace { -std::unique_ptr makeValue(ThriftBase* parent, FieldType type) { +ThriftValueBasePtr makeValue(ThriftBase* parent, FieldType type) { switch (type) { case FieldType::Stop: NOT_REACHED_GCOVR_EXCL_LINE; diff --git a/source/extensions/filters/network/zookeeper_proxy/filter.h b/source/extensions/filters/network/zookeeper_proxy/filter.h index dc932764b1569..1e14336739d5a 100644 --- a/source/extensions/filters/network/zookeeper_proxy/filter.h +++ b/source/extensions/filters/network/zookeeper_proxy/filter.h @@ -188,7 +188,7 @@ class ZooKeeperFilter : public Network::Filter, private: Network::ReadFilterCallbacks* read_callbacks_{}; ZooKeeperFilterConfigSharedPtr config_; - std::unique_ptr decoder_; + DecoderPtr decoder_; }; } // namespace ZooKeeperProxy diff --git a/source/extensions/filters/udp/dns_filter/dns_parser.h b/source/extensions/filters/udp/dns_filter/dns_parser.h index d06e6bb80afa7..13bf51c09acf1 100644 --- a/source/extensions/filters/udp/dns_filter/dns_parser.h +++ b/source/extensions/filters/udp/dns_filter/dns_parser.h @@ -50,7 +50,7 @@ class DnsQueryRecord : public BaseDnsRecord { : BaseDnsRecord(rec_name, rec_type, rec_class) {} bool serialize(Buffer::OwnedImpl& output) override; - std::unique_ptr query_time_ms_; + Stats::HistogramCompletableTimespanImplPtr query_time_ms_; }; using DnsQueryRecordPtr = std::unique_ptr; diff --git a/source/extensions/grpc_credentials/aws_iam/config.cc b/source/extensions/grpc_credentials/aws_iam/config.cc index 5f60eab1464f2..6254cbb4ba970 100644 --- a/source/extensions/grpc_credentials/aws_iam/config.cc +++ b/source/extensions/grpc_credentials/aws_iam/config.cc @@ -74,7 +74,7 @@ std::shared_ptr AwsIamGrpcCredentialsFactory::getChann std::string AwsIamGrpcCredentialsFactory::getRegion( const envoy::config::grpc_credential::v3::AwsIamConfig& config) { - std::unique_ptr region_provider; + Common::Aws::RegionProviderPtr region_provider; if (!config.region().empty()) { region_provider = std::make_unique(config.region()); } else { diff --git a/source/extensions/quic_listeners/quiche/active_quic_listener.cc b/source/extensions/quic_listeners/quiche/active_quic_listener.cc index 55f5da2e49f12..dbb48e83f4e17 100644 --- a/source/extensions/quic_listeners/quiche/active_quic_listener.cc +++ b/source/extensions/quic_listeners/quiche/active_quic_listener.cc @@ -151,7 +151,7 @@ Network::ConnectionHandler::ActiveListenerPtr ActiveQuicListenerFactory::createActiveUdpListener(Network::ConnectionHandler& parent, Event::Dispatcher& disptacher, Network::ListenerConfig& config) { - std::unique_ptr options = std::make_unique(); + Network::Socket::OptionsPtr options = std::make_unique(); #if defined(SO_ATTACH_REUSEPORT_CBPF) && defined(__linux__) // This BPF filter reads the 1st word of QUIC connection id in the UDP payload and mods it by the // number of workers to get the socket index in the SO_REUSEPORT socket groups. QUIC packets diff --git a/source/extensions/quic_listeners/quiche/active_quic_listener.h b/source/extensions/quic_listeners/quiche/active_quic_listener.h index a9c87d4b4d660..e2642ba00fdfb 100644 --- a/source/extensions/quic_listeners/quiche/active_quic_listener.h +++ b/source/extensions/quic_listeners/quiche/active_quic_listener.h @@ -69,7 +69,7 @@ class ActiveQuicListener : public Network::UdpListenerCallbacks, std::unique_ptr crypto_config_; Event::Dispatcher& dispatcher_; quic::QuicVersionManager version_manager_; - std::unique_ptr quic_dispatcher_; + EnvoyQuicDispatcherPtr quic_dispatcher_; Network::Socket& listen_socket_; Runtime::FeatureFlag enabled_; }; diff --git a/source/extensions/quic_listeners/quiche/codec_impl.cc b/source/extensions/quic_listeners/quiche/codec_impl.cc index ab9236b727c9c..101aeacd0f948 100644 --- a/source/extensions/quic_listeners/quiche/codec_impl.cc +++ b/source/extensions/quic_listeners/quiche/codec_impl.cc @@ -88,15 +88,13 @@ void QuicHttpClientConnectionImpl::onUnderlyingConnectionBelowWriteBufferLowWate runWatermarkCallbacksForEachStream(quic_client_session_.stream_map(), false); } -std::unique_ptr -QuicHttpClientConnectionFactoryImpl::createQuicClientConnection( +Http::ClientConnectionPtr QuicHttpClientConnectionFactoryImpl::createQuicClientConnection( Network::Connection& connection, Http::ConnectionCallbacks& callbacks) { return std::make_unique( dynamic_cast(connection), callbacks); } -std::unique_ptr -QuicHttpServerConnectionFactoryImpl::createQuicServerConnection( +Http::ServerConnectionPtr QuicHttpServerConnectionFactoryImpl::createQuicServerConnection( Network::Connection& connection, Http::ConnectionCallbacks& callbacks) { return std::make_unique( dynamic_cast(connection), diff --git a/source/extensions/quic_listeners/quiche/codec_impl.h b/source/extensions/quic_listeners/quiche/codec_impl.h index 58098ecd9ce5c..e34d2b7f6954e 100644 --- a/source/extensions/quic_listeners/quiche/codec_impl.h +++ b/source/extensions/quic_listeners/quiche/codec_impl.h @@ -80,7 +80,7 @@ class QuicHttpClientConnectionImpl : public QuicHttpConnectionImplBase, // A factory to create QuicHttpClientConnection. class QuicHttpClientConnectionFactoryImpl : public Http::QuicHttpClientConnectionFactory { public: - std::unique_ptr + Http::ClientConnectionPtr createQuicClientConnection(Network::Connection& connection, Http::ConnectionCallbacks& callbacks) override; @@ -90,7 +90,7 @@ class QuicHttpClientConnectionFactoryImpl : public Http::QuicHttpClientConnectio // A factory to create QuicHttpServerConnection. class QuicHttpServerConnectionFactoryImpl : public Http::QuicHttpServerConnectionFactory { public: - std::unique_ptr + Http::ServerConnectionPtr createQuicServerConnection(Network::Connection& connection, Http::ConnectionCallbacks& callbacks) override; diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_client_session.cc b/source/extensions/quic_listeners/quiche/envoy_quic_client_session.cc index 5f0984f1d5a10..3fd89a31bb9e7 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_client_session.cc +++ b/source/extensions/quic_listeners/quiche/envoy_quic_client_session.cc @@ -5,7 +5,7 @@ namespace Quic { EnvoyQuicClientSession::EnvoyQuicClientSession( const quic::QuicConfig& config, const quic::ParsedQuicVersionVector& supported_versions, - std::unique_ptr connection, const quic::QuicServerId& server_id, + EnvoyQuicClientConnectionPtr connection, const quic::QuicServerId& server_id, quic::QuicCryptoClientConfig* crypto_config, quic::QuicClientPushPromiseIndex* push_promise_index, Event::Dispatcher& dispatcher, uint32_t send_buffer_limit) diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_client_session.h b/source/extensions/quic_listeners/quiche/envoy_quic_client_session.h index b79943da1f12c..b3f5df3475bc2 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_client_session.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_client_session.h @@ -29,7 +29,7 @@ class EnvoyQuicClientSession : public QuicFilterManagerConnectionImpl, public: EnvoyQuicClientSession(const quic::QuicConfig& config, const quic::ParsedQuicVersionVector& supported_versions, - std::unique_ptr connection, + EnvoyQuicClientConnectionPtr connection, const quic::QuicServerId& server_id, quic::QuicCryptoClientConfig* crypto_config, quic::QuicClientPushPromiseIndex* push_promise_index, diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_connection.h b/source/extensions/quic_listeners/quiche/envoy_quic_connection.h index 51aebb2dd08f4..ce189d89f34f6 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_connection.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_connection.h @@ -60,7 +60,7 @@ class EnvoyQuicConnection : public quic::QuicConnection, private: // TODO(danzh): populate stats. - std::unique_ptr connection_stats_; + Network::Connection::ConnectionStatsPtr connection_stats_; // Assigned upon construction. Constructed with empty local address if unknown // by then. Network::ConnectionSocketPtr connection_socket_; diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h b/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h index cddf10b7799c1..b179f496327b7 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h @@ -63,7 +63,7 @@ class EnvoyQuicFakeProofSource : public quic::ProofSource { : success_(success), signature_(signature) {} // quic::ProofSource::SignatureCallback - void Run(bool ok, std::string signature, std::unique_ptr
/*details*/) override { + void Run(bool ok, std::string signature, DetailsPtr /*details*/) override { success_ = ok; signature_ = signature; } diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_proof_source.cc b/source/extensions/quic_listeners/quiche/envoy_quic_proof_source.cc index ffb567a4dbf35..3bc6c3d2a26df 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_proof_source.cc +++ b/source/extensions/quic_listeners/quiche/envoy_quic_proof_source.cc @@ -18,7 +18,7 @@ quic::QuicReferenceCountedPointer EnvoyQuicProofSource::GetCertChain(const quic::QuicSocketAddress& server_address, const quic::QuicSocketAddress& client_address, const std::string& hostname) { - absl::optional> cert_config_ref = + Envoy::Ssl::TlsCertificateConfigOptConstRef cert_config_ref = getTlsCertConfig(server_address, client_address, hostname); if (!cert_config_ref.has_value()) { ENVOY_LOG(warn, "No matching filter chain found for handshake."); @@ -42,7 +42,7 @@ void EnvoyQuicProofSource::ComputeTlsSignature( const quic::QuicSocketAddress& server_address, const quic::QuicSocketAddress& client_address, const std::string& hostname, uint16_t signature_algorithm, quiche::QuicheStringPiece in, std::unique_ptr callback) { - absl::optional> cert_config_ref = + Envoy::Ssl::TlsCertificateConfigOptConstRef cert_config_ref = getTlsCertConfig(server_address, client_address, hostname); if (!cert_config_ref.has_value()) { ENVOY_LOG(warn, "No matching filter chain found for handshake."); @@ -63,7 +63,7 @@ void EnvoyQuicProofSource::ComputeTlsSignature( callback->Run(success, sig, nullptr); } -absl::optional> +Envoy::Ssl::TlsCertificateConfigOptConstRef EnvoyQuicProofSource::getTlsCertConfig(const quic::QuicSocketAddress& server_address, const quic::QuicSocketAddress& client_address, const std::string& hostname) { diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_proof_source.h b/source/extensions/quic_listeners/quiche/envoy_quic_proof_source.h index 4204f4b136341..9560baee3c8d4 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_proof_source.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_proof_source.h @@ -23,7 +23,7 @@ class EnvoyQuicProofSource : public EnvoyQuicFakeProofSource, std::unique_ptr callback) override; private: - absl::optional> + Envoy::Ssl::TlsCertificateConfigOptConstRef getTlsCertConfig(const quic::QuicSocketAddress& server_address, const quic::QuicSocketAddress& client_address, const std::string& hostname); diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_server_session.cc b/source/extensions/quic_listeners/quiche/envoy_quic_server_session.cc index 73a62a93d8b3d..d5d39dcf7dda3 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_server_session.cc +++ b/source/extensions/quic_listeners/quiche/envoy_quic_server_session.cc @@ -17,7 +17,7 @@ namespace Quic { EnvoyQuicServerSession::EnvoyQuicServerSession( const quic::QuicConfig& config, const quic::ParsedQuicVersionVector& supported_versions, - std::unique_ptr connection, quic::QuicSession::Visitor* visitor, + EnvoyQuicConnectionPtr connection, quic::QuicSession::Visitor* visitor, quic::QuicCryptoServerStream::Helper* helper, const quic::QuicCryptoServerConfig* crypto_config, quic::QuicCompressedCertsCache* compressed_certs_cache, Event::Dispatcher& dispatcher, uint32_t send_buffer_limit) diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_server_session.h b/source/extensions/quic_listeners/quiche/envoy_quic_server_session.h index c0cbc334d8e35..9e79fd2eebff6 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_server_session.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_server_session.h @@ -28,8 +28,7 @@ class EnvoyQuicServerSession : public quic::QuicServerSessionBase, public: EnvoyQuicServerSession(const quic::QuicConfig& config, const quic::ParsedQuicVersionVector& supported_versions, - std::unique_ptr connection, - quic::QuicSession::Visitor* visitor, + EnvoyQuicConnectionPtr connection, quic::QuicSession::Visitor* visitor, quic::QuicCryptoServerStreamBase::Helper* helper, const quic::QuicCryptoServerConfig* crypto_config, quic::QuicCompressedCertsCache* compressed_certs_cache, @@ -75,7 +74,7 @@ class EnvoyQuicServerSession : public quic::QuicServerSessionBase, private: void setUpRequestDecoder(EnvoyQuicServerStream& stream); - std::unique_ptr quic_connection_; + EnvoyQuicConnectionPtr quic_connection_; // These callbacks are owned by network filters and quic session should out live // them. Http::ServerConnectionCallbacks* http_connection_callbacks_{nullptr}; diff --git a/source/extensions/quic_listeners/quiche/platform/quic_mem_slice_impl.h b/source/extensions/quic_listeners/quiche/platform/quic_mem_slice_impl.h index 8b6986a072823..e7c4eec77ef4b 100644 --- a/source/extensions/quic_listeners/quiche/platform/quic_mem_slice_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/quic_mem_slice_impl.h @@ -60,7 +60,7 @@ class QuicMemSliceImpl { // Prerequisite: buffer has at least one slice. size_t firstSliceLength(Envoy::Buffer::Instance& buffer); - std::unique_ptr fragment_; + Envoy::Buffer::BufferFragmentImplPtr fragment_; Envoy::Buffer::OwnedImpl single_slice_buffer_; }; diff --git a/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h b/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h index 009af30083689..85f32bf7902e8 100644 --- a/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h +++ b/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h @@ -34,7 +34,7 @@ class QuicServerTransportSocketFactory : public QuicTransportSocketFactoryBase { const Ssl::ServerContextConfig& serverContextConfig() const { return *config_; } private: - std::unique_ptr config_; + Ssl::ServerContextConfigConstPtr config_; }; class QuicClientTransportSocketFactory : public QuicTransportSocketFactoryBase { @@ -45,7 +45,7 @@ class QuicClientTransportSocketFactory : public QuicTransportSocketFactoryBase { const Ssl::ClientContextConfig& clientContextConfig() const { return *config_; } private: - std::unique_ptr config_; + Ssl::ClientContextConfigConstPtr config_; }; // Base class to create above QuicTransportSocketFactory for server and client diff --git a/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.cc b/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.cc index 17bc6c95406f2..0fc55367691b8 100644 --- a/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.cc +++ b/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.cc @@ -16,7 +16,7 @@ uint64_t MemoryStatsReader::unmappedHeapBytes() { return Memory::Stats::totalPag FixedHeapMonitor::FixedHeapMonitor( const envoy::config::resource_monitor::fixed_heap::v2alpha::FixedHeapConfig& config, - std::unique_ptr stats) + MemoryStatsReaderPtr stats) : max_heap_(config.max_heap_size_bytes()), stats_(std::move(stats)) { ASSERT(max_heap_ > 0); } diff --git a/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h b/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h index 8ac0cee6928b4..eee62144ad08f 100644 --- a/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h +++ b/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h @@ -29,13 +29,13 @@ class FixedHeapMonitor : public Server::ResourceMonitor { public: FixedHeapMonitor( const envoy::config::resource_monitor::fixed_heap::v2alpha::FixedHeapConfig& config, - std::unique_ptr stats = std::make_unique()); + MemoryStatsReaderPtr stats = std::make_unique()); void updateResourceUsage(Server::ResourceMonitor::Callbacks& callbacks) override; private: const uint64_t max_heap_; - std::unique_ptr stats_; + MemoryStatsReaderPtr stats_; }; } // namespace FixedHeapMonitor diff --git a/source/extensions/stat_sinks/common/statsd/statsd.h b/source/extensions/stat_sinks/common/statsd/statsd.h index 41218ace192d0..429b8dff89892 100644 --- a/source/extensions/stat_sinks/common/statsd/statsd.h +++ b/source/extensions/stat_sinks/common/statsd/statsd.h @@ -39,8 +39,8 @@ class UdpStatsdSink : public Stats::Sink { UdpStatsdSink(ThreadLocal::SlotAllocator& tls, Network::Address::InstanceConstSharedPtr address, const bool use_tag, const std::string& prefix = getDefaultPrefix()); // For testing. - UdpStatsdSink(ThreadLocal::SlotAllocator& tls, const std::shared_ptr& writer, - const bool use_tag, const std::string& prefix = getDefaultPrefix()) + UdpStatsdSink(ThreadLocal::SlotAllocator& tls, const WriterSharedPtr& writer, const bool use_tag, + const std::string& prefix = getDefaultPrefix()) : tls_(tls.allocateSlot()), use_tag_(use_tag), prefix_(prefix.empty() ? getDefaultPrefix() : prefix) { tls_->set( diff --git a/source/extensions/stat_sinks/hystrix/hystrix.cc b/source/extensions/stat_sinks/hystrix/hystrix.cc index c2317658a03bd..64a0e0c13e1e2 100644 --- a/source/extensions/stat_sinks/hystrix/hystrix.cc +++ b/source/extensions/stat_sinks/hystrix/hystrix.cc @@ -369,8 +369,7 @@ void HystrixSink::flush(Stats::MetricSnapshot& snapshot) { for (auto& cluster : clusters) { Upstream::ClusterInfoConstSharedPtr cluster_info = cluster.second.get().info(); - std::unique_ptr& cluster_stats_cache_ptr = - cluster_stats_cache_map_[cluster_info->name()]; + ClusterStatsCachePtr& cluster_stats_cache_ptr = cluster_stats_cache_map_[cluster_info->name()]; if (cluster_stats_cache_ptr == nullptr) { cluster_stats_cache_ptr = std::make_unique(cluster_info->name()); } diff --git a/source/extensions/stat_sinks/metrics_service/config.cc b/source/extensions/stat_sinks/metrics_service/config.cc index 73dadf66ddea6..c29ef3c00a632 100644 --- a/source/extensions/stat_sinks/metrics_service/config.cc +++ b/source/extensions/stat_sinks/metrics_service/config.cc @@ -28,11 +28,10 @@ Stats::SinkPtr MetricsServiceSinkFactory::createStatsSink(const Protobuf::Messag const auto& transport_api_version = sink_config.transport_api_version(); ENVOY_LOG(debug, "Metrics Service gRPC service configuration: {}", grpc_service.DebugString()); - std::shared_ptr grpc_metrics_streamer = - std::make_shared( - server.clusterManager().grpcAsyncClientManager().factoryForGrpcService( - grpc_service, server.stats(), false), - server.localInfo(), transport_api_version); + GrpcMetricsStreamerSharedPtr grpc_metrics_streamer = std::make_shared( + server.clusterManager().grpcAsyncClientManager().factoryForGrpcService(grpc_service, + server.stats(), false), + server.localInfo(), transport_api_version); return std::make_unique( grpc_metrics_streamer, server.timeSource(), diff --git a/source/server/admin/config_tracker_impl.cc b/source/server/admin/config_tracker_impl.cc index da1bc875a6ee3..5e391f8d92fd7 100644 --- a/source/server/admin/config_tracker_impl.cc +++ b/source/server/admin/config_tracker_impl.cc @@ -12,7 +12,7 @@ ConfigTracker::EntryOwnerPtr ConfigTrackerImpl::add(const std::string& key, Cb c const ConfigTracker::CbsMap& ConfigTrackerImpl::getCallbacksMap() const { return *map_; } -ConfigTrackerImpl::EntryOwnerImpl::EntryOwnerImpl(const std::shared_ptr& map, +ConfigTrackerImpl::EntryOwnerImpl::EntryOwnerImpl(const ConfigTracker::CbsMapSharedPtr& map, const std::string& key) : map_(map), key_(key) {} diff --git a/source/server/admin/config_tracker_impl.h b/source/server/admin/config_tracker_impl.h index 3c8ab1c156bfb..98d61ecbe5a1f 100644 --- a/source/server/admin/config_tracker_impl.h +++ b/source/server/admin/config_tracker_impl.h @@ -17,15 +17,15 @@ class ConfigTrackerImpl : public ConfigTracker { const CbsMap& getCallbacksMap() const override; private: - std::shared_ptr map_{std::make_shared()}; + CbsMapSharedPtr map_{std::make_shared()}; class EntryOwnerImpl : public ConfigTracker::EntryOwner { public: - EntryOwnerImpl(const std::shared_ptr& map, const std::string& key); + EntryOwnerImpl(const CbsMapSharedPtr& map, const std::string& key); ~EntryOwnerImpl() override; private: - std::shared_ptr map_; + CbsMapSharedPtr map_; std::string key_; }; }; diff --git a/source/server/config_validation/dispatcher.h b/source/server/config_validation/dispatcher.h index e322e3f1cdc17..afead33221db0 100644 --- a/source/server/config_validation/dispatcher.h +++ b/source/server/config_validation/dispatcher.h @@ -30,7 +30,7 @@ class ValidationDispatcher : public DispatcherImpl { bool bind_to_port) override; protected: - std::shared_ptr dns_resolver_{ + Network::ValidationDnsResolverSharedPtr dns_resolver_{ std::make_shared()}; }; diff --git a/source/server/config_validation/server.h b/source/server/config_validation/server.h index 14682097f4003..7f45d204663c1 100644 --- a/source/server/config_validation/server.h +++ b/source/server/config_validation/server.h @@ -183,7 +183,7 @@ class ValidationInstance final : Logger::Loggable, // - There may be active filter chains referencing it in listener_manager_. // - There may be active clusters referencing it in config_.cluster_manager_. // - There may be active connections referencing it. - std::unique_ptr secret_manager_; + Secret::SecretManagerPtr secret_manager_; const Options& options_; ProtobufMessage::ProdValidationContextImpl validation_context_; Stats::IsolatedStoreImpl& stats_store_; @@ -192,15 +192,15 @@ class ValidationInstance final : Logger::Loggable, Event::DispatcherPtr dispatcher_; Server::ValidationAdmin admin_; Singleton::ManagerPtr singleton_manager_; - std::unique_ptr runtime_singleton_; + Runtime::ScopedLoaderSingletonPtr runtime_singleton_; Runtime::RandomGeneratorImpl random_generator_; - std::unique_ptr ssl_context_manager_; + Ssl::ContextManagerPtr ssl_context_manager_; Configuration::MainImpl config_; LocalInfo::LocalInfoPtr local_info_; AccessLog::AccessLogManagerImpl access_log_manager_; - std::unique_ptr cluster_manager_factory_; - std::unique_ptr listener_manager_; - std::unique_ptr overload_manager_; + Upstream::ValidationClusterManagerFactoryPtr cluster_manager_factory_; + ListenerManagerImplPtr listener_manager_; + OverloadManagerPtr overload_manager_; MutexTracer* mutex_tracer_; Grpc::ContextImpl grpc_context_; Http::ContextImpl http_context_; diff --git a/source/server/configuration_impl.h b/source/server/configuration_impl.h index 5faf632f89594..9ea6f1e64ad73 100644 --- a/source/server/configuration_impl.h +++ b/source/server/configuration_impl.h @@ -119,7 +119,7 @@ class MainImpl : Logger::Loggable, public Main { void initializeStatsSinks(const envoy::config::bootstrap::v3::Bootstrap& bootstrap, Instance& server); - std::unique_ptr cluster_manager_; + Upstream::ClusterManagerPtr cluster_manager_; std::list stats_sinks_; std::chrono::milliseconds stats_flush_interval_; std::chrono::milliseconds watchdog_miss_timeout_; diff --git a/source/server/connection_handler_impl.cc b/source/server/connection_handler_impl.cc index 708eef2e47ef5..e00fdc0c7da98 100644 --- a/source/server/connection_handler_impl.cc +++ b/source/server/connection_handler_impl.cc @@ -486,7 +486,7 @@ ConnectionHandlerImpl::ActiveConnections::~ActiveConnections() { ConnectionHandlerImpl::ActiveTcpConnection::ActiveTcpConnection( ActiveConnections& active_connections, Network::ConnectionPtr&& new_connection, - TimeSource& time_source, std::unique_ptr&& stream_info) + TimeSource& time_source, StreamInfo::StreamInfoPtr&& stream_info) : stream_info_(std::move(stream_info)), active_connections_(active_connections), connection_(std::move(new_connection)), conn_length_(new Stats::HistogramCompletableTimespanImpl( diff --git a/source/server/connection_handler_impl.h b/source/server/connection_handler_impl.h index bc6f00ad657f4..c0667d3cbad01 100644 --- a/source/server/connection_handler_impl.h +++ b/source/server/connection_handler_impl.h @@ -199,7 +199,7 @@ class ConnectionHandlerImpl : public Network::ConnectionHandler, public Network::ConnectionCallbacks { ActiveTcpConnection(ActiveConnections& active_connections, Network::ConnectionPtr&& new_connection, TimeSource& time_system, - std::unique_ptr&& stream_info); + StreamInfo::StreamInfoPtr&& stream_info); ~ActiveTcpConnection() override; // Network::ConnectionCallbacks @@ -213,7 +213,7 @@ class ConnectionHandlerImpl : public Network::ConnectionHandler, void onAboveWriteBufferHighWatermark() override {} void onBelowWriteBufferLowWatermark() override {} - std::unique_ptr stream_info_; + StreamInfo::StreamInfoPtr stream_info_; ActiveConnections& active_connections_; Network::ConnectionPtr connection_; Stats::TimespanPtr conn_length_; diff --git a/source/server/filter_chain_manager_impl.h b/source/server/filter_chain_manager_impl.h index 6857bba4620bf..0ca672e2da57b 100644 --- a/source/server/filter_chain_manager_impl.h +++ b/source/server/filter_chain_manager_impl.h @@ -301,7 +301,7 @@ class FilterChainManagerImpl : public Network::FilterChainManager, const Network::Address::InstanceConstSharedPtr address_; // This is the reference to a factory context which all the generations of listener share. Configuration::FactoryContext& parent_context_; - std::list> factory_contexts_; + std::list factory_contexts_; // Reference to the previous generation of filter chain manager to share the filter chains. // Caution: only during warm up could the optional have value. diff --git a/source/server/hot_restarting_base.cc b/source/server/hot_restarting_base.cc index 95d12d089226e..ba7b2443b4d19 100644 --- a/source/server/hot_restarting_base.cc +++ b/source/server/hot_restarting_base.cc @@ -150,7 +150,7 @@ void HotRestartingBase::initRecvBufIfNewMessage() { // Must only be called when recv_buf_ contains a full proto. Returns that proto, and resets all of // our receive-buffering state back to empty, to await a new message. -std::unique_ptr HotRestartingBase::parseProtoAndResetState() { +HotRestartMessagePtr HotRestartingBase::parseProtoAndResetState() { auto ret = std::make_unique(); RELEASE_ASSERT( ret->ParseFromArray(recv_buf_.data() + sizeof(uint64_t), expected_proto_length_.value()), @@ -161,7 +161,7 @@ std::unique_ptr HotRestartingBase::parseProtoAndResetState() return ret; } -std::unique_ptr HotRestartingBase::receiveHotRestartMessage(Blocking block) { +HotRestartMessagePtr HotRestartingBase::receiveHotRestartMessage(Blocking block) { // By default the domain socket is non blocking. If we need to block, make it blocking first. if (block == Blocking::Yes) { RELEASE_ASSERT(fcntl(my_domain_socket_, F_SETFL, 0) != -1, @@ -173,7 +173,7 @@ std::unique_ptr HotRestartingBase::receiveHotRestartMessage(B iovec iov[1]; msghdr message; uint8_t control_buffer[CMSG_SPACE(sizeof(int))]; - std::unique_ptr ret = nullptr; + HotRestartMessagePtr ret = nullptr; while (!ret) { iov[0].iov_base = recv_buf_.data() + cur_msg_recvd_bytes_; iov[0].iov_len = MaxSendmsgSize; diff --git a/source/server/hot_restarting_child.cc b/source/server/hot_restarting_child.cc index 25cb46bcf0fd9..4adc059173209 100644 --- a/source/server/hot_restarting_child.cc +++ b/source/server/hot_restarting_child.cc @@ -25,14 +25,14 @@ int HotRestartingChild::duplicateParentListenSocket(const std::string& address) wrapped_request.mutable_request()->mutable_pass_listen_socket()->set_address(address); sendHotRestartMessage(parent_address_, wrapped_request); - std::unique_ptr wrapped_reply = receiveHotRestartMessage(Blocking::Yes); + HotRestartMessagePtr wrapped_reply = receiveHotRestartMessage(Blocking::Yes); if (!replyIsExpectedType(wrapped_reply.get(), HotRestartMessage::Reply::kPassListenSocket)) { return -1; } return wrapped_reply->reply().pass_listen_socket().fd(); } -std::unique_ptr HotRestartingChild::getParentStats() { +HotRestartMessagePtr HotRestartingChild::getParentStats() { if (restart_epoch_ == 0 || parent_terminated_) { return nullptr; } @@ -41,7 +41,7 @@ std::unique_ptr HotRestartingChild::getParentStats() { wrapped_request.mutable_request()->mutable_stats(); sendHotRestartMessage(parent_address_, wrapped_request); - std::unique_ptr wrapped_reply = receiveHotRestartMessage(Blocking::Yes); + HotRestartMessagePtr wrapped_reply = receiveHotRestartMessage(Blocking::Yes); RELEASE_ASSERT(replyIsExpectedType(wrapped_reply.get(), HotRestartMessage::Reply::kStats), "Hot restart parent did not respond as expected to get stats request."); return wrapped_reply; @@ -66,7 +66,7 @@ void HotRestartingChild::sendParentAdminShutdownRequest(time_t& original_start_t wrapped_request.mutable_request()->mutable_shutdown_admin(); sendHotRestartMessage(parent_address_, wrapped_request); - std::unique_ptr wrapped_reply = receiveHotRestartMessage(Blocking::Yes); + HotRestartMessagePtr wrapped_reply = receiveHotRestartMessage(Blocking::Yes); RELEASE_ASSERT(replyIsExpectedType(wrapped_reply.get(), HotRestartMessage::Reply::kShutdownAdmin), "Hot restart parent did not respond as expected to ShutdownParentAdmin."); original_start_time = wrapped_reply->reply().shutdown_admin().original_start_time_unix_seconds(); diff --git a/source/server/hot_restarting_child.h b/source/server/hot_restarting_child.h index 0fe656d06d105..c9e4e2bceb624 100644 --- a/source/server/hot_restarting_child.h +++ b/source/server/hot_restarting_child.h @@ -26,7 +26,7 @@ class HotRestartingChild : HotRestartingBase, Logger::Loggable const int restart_epoch_; bool parent_terminated_{}; sockaddr_un parent_address_; - std::unique_ptr stat_merger_{}; + Stats::StatMergerPtr stat_merger_{}; Stats::StatName hot_restart_generation_stat_name_; }; diff --git a/source/server/hot_restarting_parent.cc b/source/server/hot_restarting_parent.cc index 5049c8077f911..53961352cb5d5 100644 --- a/source/server/hot_restarting_parent.cc +++ b/source/server/hot_restarting_parent.cc @@ -33,7 +33,7 @@ void HotRestartingParent::initialize(Event::Dispatcher& dispatcher, Server::Inst } void HotRestartingParent::onSocketEvent() { - std::unique_ptr wrapped_request; + HotRestartMessagePtr wrapped_request; while ((wrapped_request = receiveHotRestartMessage(Blocking::No))) { if (wrapped_request->requestreply_case() == HotRestartMessage::kReply) { ENVOY_LOG(error, "child sent us a HotRestartMessage reply (we want requests); ignoring."); diff --git a/source/server/hot_restarting_parent.h b/source/server/hot_restarting_parent.h index d43d3636fe5ae..208eb0508131b 100644 --- a/source/server/hot_restarting_parent.h +++ b/source/server/hot_restarting_parent.h @@ -44,7 +44,7 @@ class HotRestartingParent : HotRestartingBase, Logger::Loggable internal_; + InternalPtr internal_; }; } // namespace Server diff --git a/source/server/lds_api.cc b/source/server/lds_api.cc index c767970aa1731..66137ad6d637b 100644 --- a/source/server/lds_api.cc +++ b/source/server/lds_api.cc @@ -41,7 +41,7 @@ void LdsApiImpl::onConfigUpdate( const Protobuf::RepeatedPtrField& added_resources, const Protobuf::RepeatedPtrField& removed_resources, const std::string& system_version_info) { - std::unique_ptr maybe_rds_resume; + CleanupPtr maybe_rds_resume; if (cm_.adsMux()) { const auto type_urls = Config::getAllVersionTypeUrls(); diff --git a/source/server/lds_api.h b/source/server/lds_api.h index 00a4155636688..9f488316936d0 100644 --- a/source/server/lds_api.h +++ b/source/server/lds_api.h @@ -46,7 +46,7 @@ class LdsApiImpl : public LdsApi, return MessageUtil::anyConvert(resource).name(); } - std::unique_ptr subscription_; + Config::SubscriptionPtr subscription_; std::string system_version_info_; ListenerManager& listener_manager_; Stats::ScopePtr scope_; diff --git a/source/server/listener_impl.h b/source/server/listener_impl.h index 082e384e0deed..96d01f77ae4b4 100644 --- a/source/server/listener_impl.h +++ b/source/server/listener_impl.h @@ -156,7 +156,7 @@ class PerListenerFactoryContextImpl : public Configuration::ListenerFactoryConte server, validation_visitor, config_message, std::move(drain_manager))), listener_config_(listener_config), listener_impl_(listener_impl) {} PerListenerFactoryContextImpl( - std::shared_ptr listener_factory_context_base, + ListenerFactoryContextBaseImplSharedPtr listener_factory_context_base, const Network::ListenerConfig* listener_config, ListenerImpl& listener_impl) : listener_factory_context_base_(listener_factory_context_base), listener_config_(listener_config), listener_impl_(listener_impl) {} @@ -198,7 +198,7 @@ class PerListenerFactoryContextImpl : public Configuration::ListenerFactoryConte friend class ListenerImpl; private: - std::shared_ptr listener_factory_context_base_; + ListenerFactoryContextBaseImplSharedPtr listener_factory_context_base_; const Network::ListenerConfig* listener_config_; ListenerImpl& listener_impl_; }; @@ -233,9 +233,8 @@ class ListenerImpl final : public Network::ListenerConfig, * Execute in place filter chain update. The filter chain update is less expensive than full * listener update because connections may not need to be drained. */ - std::unique_ptr - newListenerWithFilterChain(const envoy::config::listener::v3::Listener& config, - bool workers_started, uint64_t hash); + ListenerImplPtr newListenerWithFilterChain(const envoy::config::listener::v3::Listener& config, + bool workers_started, uint64_t hash); /** * Determine if in place filter chain update could be executed at this moment. */ @@ -370,7 +369,7 @@ class ListenerImpl final : public Network::ListenerConfig, Init::TargetImpl listener_init_target_; // This init manager is populated with targets from the filter chain factories, namely // RdsRouteConfigSubscription::init_target_, so the listener can wait for route configs. - std::unique_ptr dynamic_init_manager_; + Init::ManagerPtr dynamic_init_manager_; std::vector listener_filter_factories_; std::vector udp_listener_filter_factories_; @@ -384,7 +383,7 @@ class ListenerImpl final : public Network::ListenerConfig, const bool continue_on_listener_filters_timeout_; Network::ActiveUdpListenerFactoryPtr udp_listener_factory_; Network::ConnectionBalancerPtr connection_balancer_; - std::shared_ptr listener_factory_context_; + PerListenerFactoryContextImplSharedPtr listener_factory_context_; FilterChainManagerImpl filter_chain_manager_; // This init watcher, if workers_started_ is false, notifies the "parent" listener manager when diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index f4e6e87e9528a..53ba1535c6136 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -182,7 +182,7 @@ Network::ListenerFilterMatcherSharedPtr ProdListenerComponentFactory::createList if (!listener_filter.has_filter_disabled()) { return nullptr; } - return std::shared_ptr( + return Network::ListenerFilterMatcherSharedPtr( Network::ListenerFilterMatcherBuilder::buildListenerFilterMatcher( listener_filter.filter_disabled())); } diff --git a/source/server/listener_manager_impl.h b/source/server/listener_manager_impl.h index b677792800e41..27595cf9a2a37 100644 --- a/source/server/listener_manager_impl.h +++ b/source/server/listener_manager_impl.h @@ -304,7 +304,7 @@ class ListenerManagerImpl : public ListenerManager, Logger::Loggable> error_state_tracker_; + absl::flat_hash_map error_state_tracker_; FailureStates overall_error_state_; }; diff --git a/source/server/server.cc b/source/server/server.cc index 5b201c6c1e4c8..c16687c50a53e 100644 --- a/source/server/server.cc +++ b/source/server/server.cc @@ -52,13 +52,15 @@ namespace Envoy { namespace Server { -InstanceImpl::InstanceImpl( - Init::Manager& init_manager, const Options& options, Event::TimeSystem& time_system, - Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks, - HotRestart& restarter, Stats::StoreRoot& store, Thread::BasicLockable& access_log_lock, - ComponentFactory& component_factory, Runtime::RandomGeneratorPtr&& random_generator, - ThreadLocal::Instance& tls, Thread::ThreadFactory& thread_factory, - Filesystem::Instance& file_system, std::unique_ptr process_context) +InstanceImpl::InstanceImpl(Init::Manager& init_manager, const Options& options, + Event::TimeSystem& time_system, + Network::Address::InstanceConstSharedPtr local_address, + ListenerHooks& hooks, HotRestart& restarter, Stats::StoreRoot& store, + Thread::BasicLockable& access_log_lock, + ComponentFactory& component_factory, + Runtime::RandomGeneratorPtr&& random_generator, + ThreadLocal::Instance& tls, Thread::ThreadFactory& thread_factory, + Filesystem::Instance& file_system, ProcessContextPtr process_context) : init_manager_(init_manager), workers_started_(false), live_(false), shutdown_(false), options_(options), validation_context_(options_.allowUnknownStaticFields(), !options.rejectUnknownDynamicFields(), diff --git a/source/server/server.h b/source/server/server.h index b92dd5c96e379..da1598ee1981e 100644 --- a/source/server/server.h +++ b/source/server/server.h @@ -210,7 +210,7 @@ class InstanceImpl final : Logger::Loggable, Thread::BasicLockable& access_log_lock, ComponentFactory& component_factory, Runtime::RandomGeneratorPtr&& random_generator, ThreadLocal::Instance& tls, Thread::ThreadFactory& thread_factory, Filesystem::Instance& file_system, - std::unique_ptr process_context); + ProcessContextPtr process_context); ~InstanceImpl() override; @@ -302,7 +302,7 @@ class InstanceImpl final : Logger::Loggable, // - There may be active filter chains referencing it in listener_manager_. // - There may be active clusters referencing it in config_.cluster_manager_. // - There may be active connections referencing it. - std::unique_ptr secret_manager_; + Secret::SecretManagerPtr secret_manager_; bool workers_started_; std::atomic live_; bool shutdown_; @@ -316,20 +316,20 @@ class InstanceImpl final : Logger::Loggable, const time_t start_time_; time_t original_start_time_; Stats::StoreRoot& stats_store_; - std::unique_ptr server_stats_; + ServerStatsPtr server_stats_; Assert::ActionRegistrationPtr assert_action_registration_; ThreadLocal::Instance& thread_local_; Api::ApiPtr api_; Event::DispatcherPtr dispatcher_; - std::unique_ptr admin_; + AdminImplPtr admin_; Singleton::ManagerPtr singleton_manager_; Network::ConnectionHandlerPtr handler_; Runtime::RandomGeneratorPtr random_generator_; - std::unique_ptr runtime_singleton_; - std::unique_ptr ssl_context_manager_; + Runtime::ScopedLoaderSingletonPtr runtime_singleton_; + Ssl::ContextManagerPtr ssl_context_manager_; ProdListenerComponentFactory listener_component_factory_; ProdWorkerFactory worker_factory_; - std::unique_ptr listener_manager_; + ListenerManagerPtr listener_manager_; absl::node_hash_map stage_callbacks_; absl::node_hash_map stage_completable_callbacks_; Configuration::MainImpl config_; @@ -337,23 +337,23 @@ class InstanceImpl final : Logger::Loggable, Event::TimerPtr stat_flush_timer_; DrainManagerPtr drain_manager_; AccessLog::AccessLogManagerImpl access_log_manager_; - std::unique_ptr cluster_manager_factory_; - std::unique_ptr guard_dog_; + Upstream::ClusterManagerFactoryPtr cluster_manager_factory_; + Server::GuardDogPtr guard_dog_; bool terminated_; - std::unique_ptr file_logger_; + Logger::FileSinkDelegatePtr file_logger_; envoy::config::bootstrap::v3::Bootstrap bootstrap_; ConfigTracker::EntryOwnerPtr config_tracker_entry_; SystemTime bootstrap_config_update_time_; Grpc::AsyncClientManagerPtr async_client_manager_; Upstream::ProdClusterInfoFactory info_factory_; Upstream::HdsDelegatePtr hds_delegate_; - std::unique_ptr overload_manager_; + OverloadManagerImplPtr overload_manager_; std::vector bootstrap_extensions_; Envoy::MutexTracer* mutex_tracer_; Grpc::ContextImpl grpc_context_; Http::ContextImpl http_context_; - std::unique_ptr process_context_; - std::unique_ptr heap_shrinker_; + ProcessContextPtr process_context_; + Memory::HeapShrinkerPtr heap_shrinker_; const std::thread::id main_thread_id_; // initialization_time is a histogram for tracking the initialization time across hot restarts // whenever we have support for histogram merge across hot restarts. diff --git a/test/common/buffer/buffer_fuzz.cc b/test/common/buffer/buffer_fuzz.cc index 86e168532c9b2..9e596afdb660e 100644 --- a/test/common/buffer/buffer_fuzz.cc +++ b/test/common/buffer/buffer_fuzz.cc @@ -29,7 +29,7 @@ constexpr uint32_t BufferCount = 3; // These data are exogenous to the buffer, we don't need to worry about their // deallocation, just keep them around until the fuzz run is over. struct Context { - std::vector> fragments_; + std::vector fragments_; }; // Bound the maximum allocation size per action. We want this to be able to at diff --git a/test/common/common/utility_test.cc b/test/common/common/utility_test.cc index 531f7017204ea..4b90ec8c01307 100644 --- a/test/common/common/utility_test.cc +++ b/test/common/common/utility_test.cc @@ -457,10 +457,10 @@ using WeightedClusterEntrySharedPtr = std::shared_ptr; TEST(WeightedClusterUtil, pickCluster) { std::vector clusters; - std::unique_ptr cluster1(new WeightedClusterEntry("cluster1", 10)); + WeightedClusterEntryPtr cluster1(new WeightedClusterEntry("cluster1", 10)); clusters.emplace_back(std::move(cluster1)); - std::unique_ptr cluster2(new WeightedClusterEntry("cluster2", 90)); + WeightedClusterEntryPtr cluster2(new WeightedClusterEntry("cluster2", 90)); clusters.emplace_back(std::move(cluster2)); EXPECT_EQ("cluster1", WeightedClusterUtil::pickCluster(clusters, 100, 5, false)->clusterName()); diff --git a/test/common/config/config_provider_impl_test.cc b/test/common/config/config_provider_impl_test.cc index 63cdc00669d3b..afb66687d8033 100644 --- a/test/common/config/config_provider_impl_test.cc +++ b/test/common/config/config_provider_impl_test.cc @@ -238,7 +238,7 @@ class ConfigProviderImplTest : public testing::Test { Event::SimulatedTimeSystem time_system_; NiceMock server_factory_context_; NiceMock init_manager_; - std::unique_ptr provider_manager_; + DummyConfigProviderManagerPtr provider_manager_; }; test::common::config::DummyConfig parseDummyConfigFromYaml(const std::string& yaml) { @@ -674,7 +674,7 @@ class DeltaConfigProviderImplTest : public testing::Test { Event::SimulatedTimeSystem time_system_; NiceMock server_factory_context_; NiceMock init_manager_; - std::unique_ptr provider_manager_; + DeltaDummyConfigProviderManagerPtr provider_manager_; }; // Validate that delta config subscriptions are shared across delta dynamic config providers and diff --git a/test/common/config/delta_subscription_impl_test.cc b/test/common/config/delta_subscription_impl_test.cc index 58a7ad0bb0fd7..40f700674b13c 100644 --- a/test/common/config/delta_subscription_impl_test.cc +++ b/test/common/config/delta_subscription_impl_test.cc @@ -141,12 +141,12 @@ TEST(DeltaSubscriptionImplFixturelessTest, NoGrpcStream) { const Protobuf::MethodDescriptor* method_descriptor = Protobuf::DescriptorPool::generated_pool()->FindMethodByName( "envoy.api.v2.EndpointDiscoveryService.StreamEndpoints"); - std::shared_ptr xds_context = std::make_shared( + NewGrpcMuxImplSharedPtr xds_context = std::make_shared( std::unique_ptr(async_client), dispatcher, *method_descriptor, envoy::config::core::v3::ApiVersion::AUTO, random, stats_store, rate_limit_settings, local_info); - std::unique_ptr subscription = std::make_unique( + GrpcSubscriptionImplPtr subscription = std::make_unique( xds_context, callbacks, stats, Config::TypeUrl::get().ClusterLoadAssignment, dispatcher, std::chrono::milliseconds(12345), false); diff --git a/test/common/config/delta_subscription_test_harness.h b/test/common/config/delta_subscription_test_harness.h index 31439cd84bdbb..042fca1db7b63 100644 --- a/test/common/config/delta_subscription_test_harness.h +++ b/test/common/config/delta_subscription_test_harness.h @@ -196,8 +196,8 @@ class DeltaSubscriptionTestHarness : public SubscriptionTestHarness { NiceMock random_; NiceMock local_info_; Grpc::MockAsyncStream async_stream_; - std::shared_ptr xds_context_; - std::unique_ptr subscription_; + NewGrpcMuxImplSharedPtr xds_context_; + GrpcSubscriptionImplPtr subscription_; std::string last_response_nonce_; std::set last_cluster_names_; Envoy::Config::RateLimitSettings rate_limit_settings_; diff --git a/test/common/config/grpc_mux_impl_test.cc b/test/common/config/grpc_mux_impl_test.cc index 4f6abbc893c2a..b5e8b6dbaf976 100644 --- a/test/common/config/grpc_mux_impl_test.cc +++ b/test/common/config/grpc_mux_impl_test.cc @@ -97,7 +97,7 @@ class GrpcMuxImplTestBase : public testing::Test { NiceMock random_; Grpc::MockAsyncClient* async_client_; Grpc::MockAsyncStream async_stream_; - std::unique_ptr grpc_mux_; + GrpcMuxImplPtr grpc_mux_; NiceMock callbacks_; NiceMock local_info_; Stats::TestUtil::TestStore stats_; diff --git a/test/common/config/grpc_subscription_test_harness.h b/test/common/config/grpc_subscription_test_harness.h index 1673e9a5a411a..eba26ad8cbffb 100644 --- a/test/common/config/grpc_subscription_test_harness.h +++ b/test/common/config/grpc_subscription_test_harness.h @@ -180,8 +180,8 @@ class GrpcSubscriptionTestHarness : public SubscriptionTestHarness { envoy::config::core::v3::Node node_; NiceMock callbacks_; NiceMock async_stream_; - std::shared_ptr mux_; - std::unique_ptr subscription_; + GrpcMuxImplSharedPtr mux_; + GrpcSubscriptionImplPtr subscription_; std::string last_response_nonce_; std::set last_cluster_names_; NiceMock local_info_; diff --git a/test/common/config/http_subscription_test_harness.h b/test/common/config/http_subscription_test_harness.h index 0165c06edabd9..41e0c61ea576a 100644 --- a/test/common/config/http_subscription_test_harness.h +++ b/test/common/config/http_subscription_test_harness.h @@ -191,7 +191,7 @@ class HttpSubscriptionTestHarness : public SubscriptionTestHarness { Http::MockAsyncClientRequest http_request_; Http::AsyncClient::Callbacks* http_callbacks_; Config::MockSubscriptionCallbacks callbacks_; - std::unique_ptr subscription_; + HttpSubscriptionImplPtr subscription_; NiceMock local_info_; Event::MockTimer* init_timeout_timer_; NiceMock validation_visitor_; diff --git a/test/common/config/metadata_test.cc b/test/common/config/metadata_test.cc index 9cfae351d9cda..24193e0142881 100644 --- a/test/common/config/metadata_test.cc +++ b/test/common/config/metadata_test.cc @@ -64,8 +64,7 @@ class TypedMetadataTest : public testing::Test { public: std::string name() const override { return "foo"; } // Throws EnvoyException (conversion failure) if d is empty. - std::unique_ptr - parse(const ProtobufWkt::Struct& d) const override { + TypedMetadata::ObjectConstPtr parse(const ProtobufWkt::Struct& d) const override { if (d.fields().find("name") != d.fields().end()) { return std::make_unique(d.fields().at("name").string_value()); } diff --git a/test/common/config/new_grpc_mux_impl_test.cc b/test/common/config/new_grpc_mux_impl_test.cc index b1b3b18f2d0a4..fc80705570bab 100644 --- a/test/common/config/new_grpc_mux_impl_test.cc +++ b/test/common/config/new_grpc_mux_impl_test.cc @@ -58,7 +58,7 @@ class NewGrpcMuxImplTestBase : public testing::Test { NiceMock random_; Grpc::MockAsyncClient* async_client_; NiceMock async_stream_; - std::unique_ptr grpc_mux_; + NewGrpcMuxImplPtr grpc_mux_; NiceMock callbacks_; NiceMock local_info_; Stats::TestUtil::TestStore stats_; diff --git a/test/common/config/subscription_factory_impl_test.cc b/test/common/config/subscription_factory_impl_test.cc index bc772b6cf0734..29f7c138320a9 100644 --- a/test/common/config/subscription_factory_impl_test.cc +++ b/test/common/config/subscription_factory_impl_test.cc @@ -41,7 +41,7 @@ class SubscriptionFactoryTest : public testing::Test { subscription_factory_(local_info_, dispatcher_, cm_, random_, validation_visitor_, *api_, runtime_) {} - std::unique_ptr + SubscriptionPtr subscriptionFromConfigSource(const envoy::config::core::v3::ConfigSource& config) { return subscription_factory_.subscriptionFromConfigSource( config, Config::TypeUrl::get().ClusterLoadAssignment, stats_store_, callbacks_); diff --git a/test/common/config/subscription_impl_test.cc b/test/common/config/subscription_impl_test.cc index d8e48bcb820c0..56155948006a3 100644 --- a/test/common/config/subscription_impl_test.cc +++ b/test/common/config/subscription_impl_test.cc @@ -76,7 +76,7 @@ class SubscriptionImplTest : public testing::TestWithParam { void callInitFetchTimeoutCb() { test_harness_->callInitFetchTimeoutCb(); } - std::unique_ptr test_harness_; + SubscriptionTestHarnessPtr test_harness_; }; class SubscriptionImplInitFetchTimeoutTest : public SubscriptionImplTest { diff --git a/test/common/formatter/substitution_formatter_speed_test.cc b/test/common/formatter/substitution_formatter_speed_test.cc index fd2b6c7fe7a92..bdc57642bf2ef 100644 --- a/test/common/formatter/substitution_formatter_speed_test.cc +++ b/test/common/formatter/substitution_formatter_speed_test.cc @@ -10,7 +10,7 @@ namespace Envoy { namespace { -std::unique_ptr makeJsonFormatter(bool typed) { +Envoy::Formatter::JsonFormatterImplPtr makeJsonFormatter(bool typed) { absl::flat_hash_map JsonLogFormat = { {"remote_address", "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%"}, {"start_time", "%START_TIME(%Y/%m/%dT%H:%M:%S%z %s)%"}, @@ -44,7 +44,7 @@ static void BM_AccessLogFormatter(benchmark::State& state) { "%REQ(X-FORWARDED-PROTO)%://%REQ(:AUTHORITY)%%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL% " "s%RESPONSE_CODE% %BYTES_SENT% %DURATION% %REQ(REFERER)% \"%REQ(USER-AGENT)%\" - - -\n"; - std::unique_ptr formatter = + Envoy::Formatter::FormatterImplPtr formatter = std::make_unique(LogFormat); size_t output_bytes = 0; @@ -64,7 +64,7 @@ BENCHMARK(BM_AccessLogFormatter); // NOLINTNEXTLINE(readability-identifier-naming) static void BM_JsonAccessLogFormatter(benchmark::State& state) { std::unique_ptr stream_info = makeStreamInfo(); - std::unique_ptr json_formatter = makeJsonFormatter(false); + Envoy::Formatter::JsonFormatterImplPtr json_formatter = makeJsonFormatter(false); size_t output_bytes = 0; Http::TestRequestHeaderMapImpl request_headers; @@ -84,8 +84,7 @@ BENCHMARK(BM_JsonAccessLogFormatter); // NOLINTNEXTLINE(readability-identifier-naming) static void BM_TypedJsonAccessLogFormatter(benchmark::State& state) { std::unique_ptr stream_info = makeStreamInfo(); - std::unique_ptr typed_json_formatter = - makeJsonFormatter(true); + Envoy::Formatter::JsonFormatterImplPtr typed_json_formatter = makeJsonFormatter(true); size_t output_bytes = 0; Http::TestRequestHeaderMapImpl request_headers; diff --git a/test/common/grpc/google_async_client_impl_test.cc b/test/common/grpc/google_async_client_impl_test.cc index 1fa083234e1dc..1474899621f10 100644 --- a/test/common/grpc/google_async_client_impl_test.cc +++ b/test/common/grpc/google_async_client_impl_test.cc @@ -72,7 +72,7 @@ class EnvoyGoogleAsyncClientImplTest : public testing::Test { Api::ApiPtr api_; Event::DispatcherPtr dispatcher_; Stats::ScopeSharedPtr scope_; - std::unique_ptr tls_; + GoogleAsyncClientThreadLocalPtr tls_; MockStubFactory stub_factory_; const Protobuf::MethodDescriptor* method_descriptor_; StatNames stat_names_; diff --git a/test/common/grpc/grpc_client_integration_test_harness.h b/test/common/grpc/grpc_client_integration_test_harness.h index 3e472fa67b371..411138c229120 100644 --- a/test/common/grpc/grpc_client_integration_test_harness.h +++ b/test/common/grpc/grpc_client_integration_test_harness.h @@ -346,7 +346,7 @@ class GrpcClientIntegrationTest : public GrpcClientIntegrationParamTest { virtual void expectExtraHeaders(FakeStream&) {} - std::unique_ptr createRequest(const TestMetadata& initial_metadata) { + HelloworldRequestPtr createRequest(const TestMetadata& initial_metadata) { auto request = std::make_unique(dispatcher_helper_); EXPECT_CALL(*request, onCreateInitialMetadata(_)) .WillOnce(Invoke([&initial_metadata](Http::HeaderMap& headers) { @@ -392,7 +392,7 @@ class GrpcClientIntegrationTest : public GrpcClientIntegrationParamTest { return request; } - std::unique_ptr createStream(const TestMetadata& initial_metadata) { + HelloworldStreamPtr createStream(const TestMetadata& initial_metadata) { auto stream = std::make_unique(dispatcher_helper_); EXPECT_CALL(*stream, onCreateInitialMetadata(_)) .WillOnce(Invoke([&initial_metadata](Http::HeaderMap& headers) { @@ -438,7 +438,7 @@ class GrpcClientIntegrationTest : public GrpcClientIntegrationParamTest { std::unique_ptr stream_headers_; std::vector> channel_args_; #ifdef ENVOY_GOOGLE_GRPC - std::unique_ptr google_tls_; + GoogleAsyncClientThreadLocalPtr google_tls_; #endif AsyncClient grpc_client_; Event::TimerPtr timeout_timer_; diff --git a/test/common/http/async_client_utility_test.cc b/test/common/http/async_client_utility_test.cc index afcfc0ef0d0e2..9ccbc38e79bbc 100644 --- a/test/common/http/async_client_utility_test.cc +++ b/test/common/http/async_client_utility_test.cc @@ -14,8 +14,7 @@ namespace { class AsyncClientRequestTrackerTest : public testing::Test { public: - std::unique_ptr active_requests_{ - std::make_unique()}; + AsyncClientRequestTrackerPtr active_requests_{std::make_unique()}; NiceMock async_client_; StrictMock request1_{&async_client_}; diff --git a/test/common/http/codec_client_test.cc b/test/common/http/codec_client_test.cc index 3316380030b93..30b857ae2ab61 100644 --- a/test/common/http/codec_client_test.cc +++ b/test/common/http/codec_client_test.cc @@ -65,7 +65,7 @@ class CodecClientTest : public testing::Test { Event::MockDispatcher dispatcher_; Network::MockClientConnection* connection_; Http::MockClientConnection* codec_; - std::unique_ptr client_; + CodecClientForTestPtr client_; Network::ConnectionCallbacks* connection_cb_; Network::ReadFilterSharedPtr filter_; std::shared_ptr cluster_{ @@ -350,7 +350,7 @@ class CodecNetworkTest : public testing::TestWithParam client_; + CodecClientForTestPtr client_; std::shared_ptr cluster_{new NiceMock()}; Upstream::HostDescriptionConstSharedPtr host_{ Upstream::makeTestHostDescription(cluster_, "tcp://127.0.0.1:80")}; diff --git a/test/common/http/conn_manager_impl_test.cc b/test/common/http/conn_manager_impl_test.cc index 7083b4f92d9dd..fffde19a87a96 100644 --- a/test/common/http/conn_manager_impl_test.cc +++ b/test/common/http/conn_manager_impl_test.cc @@ -374,7 +374,7 @@ class HttpConnectionManagerImplTest : public testing::Test, public ConnectionMan ConnectionManagerStats stats_; ConnectionManagerTracingStats tracing_stats_; NiceMock drain_close_; - std::unique_ptr conn_manager_; + ConnectionManagerImplPtr conn_manager_; std::string server_name_; HttpConnectionManagerProto::ServerHeaderTransformation server_transformation_{ HttpConnectionManagerProto::OVERWRITE}; diff --git a/test/common/http/conn_manager_utility_test.cc b/test/common/http/conn_manager_utility_test.cc index 3cb307cd6b718..998d37430285d 100644 --- a/test/common/http/conn_manager_utility_test.cc +++ b/test/common/http/conn_manager_utility_test.cc @@ -142,7 +142,7 @@ class MockConnectionManagerConfig : public ConnectionManagerConfig { headersWithUnderscoresAction, (), (const)); MOCK_METHOD(const LocalReply::LocalReply&, localReply, (), (const)); - std::unique_ptr internal_address_config_ = + Http::InternalAddressConfigPtr internal_address_config_ = std::make_unique(); }; diff --git a/test/common/http/header_map_impl_fuzz_test.cc b/test/common/http/header_map_impl_fuzz_test.cc index 5ab9e79ca2ed0..58e8ae004ea81 100644 --- a/test/common/http/header_map_impl_fuzz_test.cc +++ b/test/common/http/header_map_impl_fuzz_test.cc @@ -17,7 +17,7 @@ namespace Envoy { // Fuzz the header map implementation. DEFINE_PROTO_FUZZER(const test::common::http::HeaderMapImplFuzzTestCase& input) { auto header_map = Http::RequestHeaderMapImpl::create(); - std::vector> lower_case_strings; + std::vector lower_case_strings; std::vector> strings; uint64_t set_integer; constexpr auto max_actions = 128; diff --git a/test/common/http/header_map_impl_test.cc b/test/common/http/header_map_impl_test.cc index b283e214a0ab8..43764317794fc 100644 --- a/test/common/http/header_map_impl_test.cc +++ b/test/common/http/header_map_impl_test.cc @@ -735,7 +735,7 @@ TEST(HeaderMapImplTest, AddCopy) { TestRequestHeaderMapImpl headers; // Start with a string value. - std::unique_ptr lcKeyPtr(new LowerCaseString("hello")); + LowerCaseStringPtr lcKeyPtr(new LowerCaseString("hello")); headers.addCopy(*lcKeyPtr, "world"); const HeaderString& value = headers.get(*lcKeyPtr)->value(); diff --git a/test/common/http/http1/codec_impl_test.cc b/test/common/http/http1/codec_impl_test.cc index 3599912b47b05..5962aaae2774c 100644 --- a/test/common/http/http1/codec_impl_test.cc +++ b/test/common/http/http1/codec_impl_test.cc @@ -1827,7 +1827,7 @@ class Http1ClientConnectionImplTest : public Http1CodecTestBase { NiceMock connection_; NiceMock callbacks_; NiceMock codec_settings_; - std::unique_ptr codec_; + ClientConnectionImplPtr codec_; protected: Stats::TestUtil::TestStore store_; diff --git a/test/common/http/http1/conn_pool_test.cc b/test/common/http/http1/conn_pool_test.cc index d2f0843131956..271d45cb39e1c 100644 --- a/test/common/http/http1/conn_pool_test.cc +++ b/test/common/http/http1/conn_pool_test.cc @@ -144,7 +144,7 @@ class Http1ConnPoolImplTest : public testing::Test { NiceMock dispatcher_; std::shared_ptr cluster_{new NiceMock()}; NiceMock* upstream_ready_timer_; - std::unique_ptr conn_pool_; + ConnPoolImplForTestPtr conn_pool_; NiceMock runtime_; }; diff --git a/test/common/http/http2/metadata_encoder_decoder_test.cc b/test/common/http/http2/metadata_encoder_decoder_test.cc index 5cce5b40893fb..95c568b069783 100644 --- a/test/common/http/http2/metadata_encoder_decoder_test.cc +++ b/test/common/http/http2/metadata_encoder_decoder_test.cc @@ -142,7 +142,7 @@ class MetadataEncoderDecoderTest : public testing::Test { nghttp2_session* session_ = nullptr; nghttp2_session_callbacks* callbacks_; MetadataEncoder encoder_; - std::unique_ptr decoder_; + MetadataDecoderPtr decoder_; nghttp2_option* option_; int count_ = 0; @@ -204,7 +204,7 @@ TEST_F(MetadataEncoderDecoderTest, TestDecodeBadData) { // Checks if accumulated metadata size reaches size limit, returns failure. TEST_F(MetadataEncoderDecoderTest, VerifyEncoderDecoderMultipleMetadataReachSizeLimit) { MetadataMap metadata_map_empty = {}; - MetadataCallback cb = [](std::unique_ptr) -> void {}; + MetadataCallback cb = [](MetadataMapPtr) -> void {}; initialize(cb); ssize_t result = 0; diff --git a/test/common/network/connection_impl_test.cc b/test/common/network/connection_impl_test.cc index 72168e2a666d0..79ae05ccaaf6a 100644 --- a/test/common/network/connection_impl_test.cc +++ b/test/common/network/connection_impl_test.cc @@ -229,7 +229,7 @@ class ConnectionImplTest : public testing::TestWithParam { Event::SimulatedTimeSystem time_system_; Api::ApiPtr api_; Event::DispatcherPtr dispatcher_; - std::shared_ptr socket_{nullptr}; + Network::TcpListenSocketSharedPtr socket_{nullptr}; Network::MockListenerCallbacks listener_callbacks_; Network::MockConnectionHandler connection_handler_; Network::ListenerPtr listener_; @@ -758,7 +758,7 @@ TEST_P(ConnectionImplTest, WriteWatermarks) { EXPECT_FALSE(client_connection_->aboveHighWatermark()); // Stick 5 bytes in the connection buffer. - std::unique_ptr buffer(new Buffer::OwnedImpl("hello")); + Buffer::OwnedImplPtr buffer(new Buffer::OwnedImpl("hello")); int buffer_len = buffer->length(); EXPECT_CALL(*client_write_buffer_, write(_)) .WillOnce(Invoke(client_write_buffer_, &MockWatermarkBuffer::failWrite)); @@ -1419,7 +1419,7 @@ TEST_P(ConnectionImplTest, FlushWriteAndDelayConfigDisabledTest) { return new Buffer::WatermarkBuffer(below_low, above_high, above_overflow); })); IoHandlePtr io_handle = std::make_unique(0); - std::unique_ptr server_connection(new Network::ConnectionImpl( + Network::ConnectionImplPtr server_connection(new Network::ConnectionImpl( dispatcher, std::make_unique(std::move(io_handle), nullptr, nullptr), std::make_unique>(), stream_info_, true)); @@ -1632,7 +1632,7 @@ class MockTransportConnectionImplTest : public testing::Test { return {PostIoAction::KeepOpen, size, false}; } - std::unique_ptr connection_; + ConnectionImplPtr connection_; Event::MockDispatcher dispatcher_; NiceMock callbacks_; MockTransportSocket* transport_socket_; diff --git a/test/common/network/dns_impl_test.cc b/test/common/network/dns_impl_test.cc index d7b21618cdc2f..6e4554651c817 100644 --- a/test/common/network/dns_impl_test.cc +++ b/test/common/network/dns_impl_test.cc @@ -535,10 +535,10 @@ class DnsImplTest : public testing::TestWithParam { virtual bool tcp_only() const { return true; } virtual bool use_tcp_for_dns_lookups() const { return false; } std::unique_ptr server_; - std::unique_ptr peer_; + DnsResolverImplPeerPtr peer_; Network::MockConnectionHandler connection_handler_; - std::shared_ptr socket_; - std::unique_ptr listener_; + Network::TcpListenSocketSharedPtr socket_; + Network::ListenerPtr listener_; Api::ApiPtr api_; Event::DispatcherPtr dispatcher_; DnsResolverSharedPtr resolver_; diff --git a/test/common/network/filter_matcher_test.cc b/test/common/network/filter_matcher_test.cc index cd00d5cc71744..7e4a4c4d9f4be 100644 --- a/test/common/network/filter_matcher_test.cc +++ b/test/common/network/filter_matcher_test.cc @@ -19,7 +19,7 @@ struct CallbackHandle { } // namespace class ListenerFilterMatcherTest : public testing::Test { public: - std::unique_ptr createCallbackOnPort(int port) { + CallbackHandlePtr createCallbackOnPort(int port) { auto handle = std::make_unique(); handle->address_ = std::make_shared("127.0.0.1", port); handle->socket_ = std::make_unique(); diff --git a/test/common/network/lc_trie_speed_test.cc b/test/common/network/lc_trie_speed_test.cc index 632754af8cdee..3dc339bee7a32 100644 --- a/test/common/network/lc_trie_speed_test.cc +++ b/test/common/network/lc_trie_speed_test.cc @@ -15,18 +15,18 @@ std::vector>> tag_data_minimal; -std::unique_ptr> lc_trie; +Envoy::Network::LcTrie::LcTriePtr lc_trie; -std::unique_ptr> lc_trie_nested_prefixes; +Envoy::Network::LcTrie::LcTriePtr lc_trie_nested_prefixes; -std::unique_ptr> lc_trie_minimal; +Envoy::Network::LcTrie::LcTriePtr lc_trie_minimal; } // namespace namespace Envoy { static void BM_LcTrieConstruct(benchmark::State& state) { - std::unique_ptr> trie; + Envoy::Network::LcTrie::LcTriePtr trie; for (auto _ : state) { trie = std::make_unique>(tag_data); } @@ -36,7 +36,7 @@ static void BM_LcTrieConstruct(benchmark::State& state) { BENCHMARK(BM_LcTrieConstruct); static void BM_LcTrieConstructNested(benchmark::State& state) { - std::unique_ptr> trie; + Envoy::Network::LcTrie::LcTriePtr trie; for (auto _ : state) { trie = std::make_unique>(tag_data_nested_prefixes); } @@ -47,7 +47,7 @@ BENCHMARK(BM_LcTrieConstructNested); static void BM_LcTrieConstructMinimal(benchmark::State& state) { - std::unique_ptr> trie; + Envoy::Network::LcTrie::LcTriePtr trie; for (auto _ : state) { trie = std::make_unique>(tag_data_minimal); } diff --git a/test/common/network/lc_trie_test.cc b/test/common/network/lc_trie_test.cc index e0cf9ac43532c..dd9616cb47c4b 100644 --- a/test/common/network/lc_trie_test.cc +++ b/test/common/network/lc_trie_test.cc @@ -46,7 +46,7 @@ class LcTrieTest : public testing::Test { } } - std::unique_ptr> trie_; + LcTriePtr trie_; }; // Use the default constructor values. diff --git a/test/common/network/listen_socket_impl_test.cc b/test/common/network/listen_socket_impl_test.cc index ae595d3ced285..ee429a4f2f2c3 100644 --- a/test/common/network/listen_socket_impl_test.cc +++ b/test/common/network/listen_socket_impl_test.cc @@ -26,8 +26,7 @@ class ListenSocketImplTest : public testing::TestWithParam { ListenSocketImplTest() : version_(GetParam()) {} const Address::IpVersion version_; - template - std::unique_ptr createListenSocketPtr(Args&&... args) { + template ListenSocketImplPtr createListenSocketPtr(Args&&... args) { using NetworkSocketTraitType = NetworkSocketTrait; return std::make_unique>( @@ -63,7 +62,7 @@ class ListenSocketImplTest : public testing::TestWithParam { EXPECT_CALL(*option, setOption(_, envoy::config::core::v3::SocketOption::STATE_PREBIND)) .WillOnce(Return(true)); options->emplace_back(std::move(option)); - std::unique_ptr socket1; + ListenSocketImplPtr socket1; try { socket1 = createListenSocketPtr(addr, options, true); } catch (SocketBindException& e) { diff --git a/test/common/network/socket_option_factory_test.cc b/test/common/network/socket_option_factory_test.cc index 7ca08149bd939..a8e7c38a98664 100644 --- a/test/common/network/socket_option_factory_test.cc +++ b/test/common/network/socket_option_factory_test.cc @@ -52,7 +52,7 @@ class SocketOptionFactoryTest : public testing::Test { TEST_F(SocketOptionFactoryTest, TestBuildSocketMarkOptions) { // use a shared_ptr due to applyOptions requiring one - std::shared_ptr options = SocketOptionFactory::buildSocketMarkOptions(100); + Socket::OptionsSharedPtr options = SocketOptionFactory::buildSocketMarkOptions(100); const auto expected_option = ENVOY_SOCKET_SO_MARK; CHECK_OPTION_SUPPORTED(expected_option); @@ -76,7 +76,7 @@ TEST_F(SocketOptionFactoryTest, TestBuildIpv4TransparentOptions) { makeSocketV4(); // use a shared_ptr due to applyOptions requiring one - std::shared_ptr options = SocketOptionFactory::buildIpTransparentOptions(); + Socket::OptionsSharedPtr options = SocketOptionFactory::buildIpTransparentOptions(); const auto expected_option = ENVOY_SOCKET_IP_TRANSPARENT; CHECK_OPTION_SUPPORTED(expected_option); @@ -103,7 +103,7 @@ TEST_F(SocketOptionFactoryTest, TestBuildIpv6TransparentOptions) { makeSocketV6(); // use a shared_ptr due to applyOptions requiring one - std::shared_ptr options = SocketOptionFactory::buildIpTransparentOptions(); + Socket::OptionsSharedPtr options = SocketOptionFactory::buildIpTransparentOptions(); const auto expected_option = ENVOY_SOCKET_IPV6_TRANSPARENT; CHECK_OPTION_SUPPORTED(expected_option); diff --git a/test/common/network/udp_listener_impl_test.cc b/test/common/network/udp_listener_impl_test.cc index 7ba8311f0a673..ea33c0821f3ba 100644 --- a/test/common/network/udp_listener_impl_test.cc +++ b/test/common/network/udp_listener_impl_test.cc @@ -100,7 +100,7 @@ class UdpListenerImplTest : public ListenerImplTestBase { Network::Test::UdpSyncPeer client_{GetParam()}; Address::InstanceConstSharedPtr send_to_addr_; MockUdpListenerCallbacks listener_callbacks_; - std::unique_ptr listener_; + UdpListenerImplPtr listener_; size_t num_packets_received_by_listener_{0}; }; diff --git a/test/common/protobuf/utility_test.cc b/test/common/protobuf/utility_test.cc index 94f8e6aef158a..9ceedb1d50f03 100644 --- a/test/common/protobuf/utility_test.cc +++ b/test/common/protobuf/utility_test.cc @@ -1462,7 +1462,7 @@ class DeprecatedFieldsTest : public testing::TestWithParam { Runtime::MockRandomGenerator generator_; Api::ApiPtr api_; Runtime::MockRandomGenerator rand_; - std::unique_ptr loader_; + Runtime::ScopedLoaderSingletonPtr loader_; Stats::Counter& runtime_deprecated_feature_use_; Stats::Gauge& deprecated_feature_seen_since_process_start_; NiceMock local_info_; diff --git a/test/common/router/config_impl_test.cc b/test/common/router/config_impl_test.cc index 93caa4b5367c2..ff09fc3f9c95d 100644 --- a/test/common/router/config_impl_test.cc +++ b/test/common/router/config_impl_test.cc @@ -4579,8 +4579,7 @@ class BazFactory : public HttpRouteTypedMetadataFactory { public: std::string name() const override { return "baz"; } // Returns nullptr (conversion failure) if d is empty. - std::unique_ptr - parse(const ProtobufWkt::Struct& d) const override { + Envoy::Config::TypedMetadata::ObjectConstPtr parse(const ProtobufWkt::Struct& d) const override { if (d.fields().find("name") != d.fields().end()) { return std::make_unique(d.fields().at("name").string_value()); } diff --git a/test/common/router/rds_impl_test.cc b/test/common/router/rds_impl_test.cc index d5f87e046635a..f3be15e93c78f 100644 --- a/test/common/router/rds_impl_test.cc +++ b/test/common/router/rds_impl_test.cc @@ -120,7 +120,7 @@ stat_prefix: foo } NiceMock server_; - std::unique_ptr route_config_provider_manager_; + RouteConfigProviderManagerImplPtr route_config_provider_manager_; RouteConfigProviderSharedPtr rds_; }; @@ -284,7 +284,7 @@ class RdsRouteConfigSubscriptionTest : public RdsTestBase { server_factory_context_.thread_local_.shutdownThread(); } - std::unique_ptr route_config_provider_manager_; + RouteConfigProviderManagerImplPtr route_config_provider_manager_; }; // Verifies that maybeCreateInitManager() creates a noop init manager if the main init manager is in @@ -308,8 +308,8 @@ TEST_F(RdsRouteConfigSubscriptionTest, CreatesNoopInitManager) { (dynamic_cast(route_config_provider.get()))->subscription(); init_watcher_.expectReady().Times(1); // The parent_init_target_ will call once. outer_init_manager_.initialize(init_watcher_); - std::unique_ptr noop_init_manager; - std::unique_ptr init_vhds; + Init::ManagerImplPtr noop_init_manager; + CleanupPtr init_vhds; subscription.maybeCreateInitManager("version_info", noop_init_manager, init_vhds); // local_init_manager_ is not ready yet as the local_init_target_ is not ready. EXPECT_EQ(init_vhds, nullptr); @@ -347,7 +347,7 @@ class RouteConfigProviderManagerImplTest : public RdsTestBase { } envoy::extensions::filters::network::http_connection_manager::v3::Rds rds_; - std::unique_ptr route_config_provider_manager_; + RouteConfigProviderManagerImplPtr route_config_provider_manager_; RouteConfigProviderSharedPtr provider_; }; diff --git a/test/common/router/router_ratelimit_test.cc b/test/common/router/router_ratelimit_test.cc index 80c21f623efe3..365b6eab7c2a6 100644 --- a/test/common/router/router_ratelimit_test.cc +++ b/test/common/router/router_ratelimit_test.cc @@ -85,7 +85,7 @@ class RateLimitConfiguration : public testing::Test { NiceMock factory_context_; ProtobufMessage::NullValidationVisitorImpl any_validation_visitor_; - std::unique_ptr config_; + ConfigImplPtr config_; Http::TestRequestHeaderMapImpl header_; const RouteEntry* route_; Network::Address::Ipv4Instance default_remote_address_{"10.0.0.1"}; @@ -270,7 +270,7 @@ class RateLimitPolicyEntryTest : public testing::Test { descriptors_.clear(); } - std::unique_ptr rate_limit_entry_; + RateLimitPolicyEntryImplPtr rate_limit_entry_; Http::TestRequestHeaderMapImpl header_; NiceMock route_; std::vector descriptors_; diff --git a/test/common/router/router_upstream_log_test.cc b/test/common/router/router_upstream_log_test.cc index d62043effadb3..2bbd794517989 100644 --- a/test/common/router/router_upstream_log_test.cc +++ b/test/common/router/router_upstream_log_test.cc @@ -235,7 +235,7 @@ class RouterUpstreamLogTest : public testing::Test { Event::MockTimer* per_try_timeout_{}; NiceMock callbacks_; - std::shared_ptr config_; + FilterConfigSharedPtr config_; std::shared_ptr router_; NiceMock stream_info_; }; diff --git a/test/common/router/scoped_config_impl_test.cc b/test/common/router/scoped_config_impl_test.cc index e84540850b9b7..66a8fe22aa86e 100644 --- a/test/common/router/scoped_config_impl_test.cc +++ b/test/common/router/scoped_config_impl_test.cc @@ -116,7 +116,7 @@ TEST(HeaderValueExtractorImplTest, HeaderExtractionByIndex) { TestUtility::loadFromYaml(yaml_plain, config); HeaderValueExtractorImpl extractor(std::move(config)); - std::unique_ptr fragment = extractor.computeFragment( + ScopeKeyFragmentBasePtr fragment = extractor.computeFragment( TestRequestHeaderMapImpl{{"foo_header", "part-0,part-1:value_bluh"}}); EXPECT_NE(fragment, nullptr); @@ -159,10 +159,9 @@ TEST(HeaderValueExtractorImplTest, HeaderExtractionByKey) { TestUtility::loadFromYaml(yaml_plain, config); HeaderValueExtractorImpl extractor(std::move(config)); - std::unique_ptr fragment = - extractor.computeFragment(TestRequestHeaderMapImpl{ - {"foo_header", "part-0;bar=>bluh;foo=>foo_value"}, - }); + ScopeKeyFragmentBasePtr fragment = extractor.computeFragment(TestRequestHeaderMapImpl{ + {"foo_header", "part-0;bar=>bluh;foo=>foo_value"}, + }); EXPECT_NE(fragment, nullptr); EXPECT_EQ(*fragment, StringKeyFragment{"bluh"}); @@ -220,10 +219,9 @@ TEST(HeaderValueExtractorImplTest, ElementSeparatorEmpty) { TestUtility::loadFromYaml(yaml_plain, config); HeaderValueExtractorImpl extractor(std::move(config)); - std::unique_ptr fragment = - extractor.computeFragment(TestRequestHeaderMapImpl{ - {"foo_header", "bar=b;c=d;e=f"}, - }); + ScopeKeyFragmentBasePtr fragment = extractor.computeFragment(TestRequestHeaderMapImpl{ + {"foo_header", "bar=b;c=d;e=f"}, + }); EXPECT_NE(fragment, nullptr); EXPECT_EQ(*fragment, StringKeyFragment{"b;c=d;e=f"}); @@ -370,7 +368,7 @@ class ScopedRouteInfoTest : public testing::Test { envoy::config::route::v3::RouteConfiguration route_configuration_; envoy::config::route::v3::ScopedRouteConfiguration scoped_route_config_; std::shared_ptr route_config_; - std::unique_ptr info_; + ScopedRouteInfoPtr info_; }; TEST_F(ScopedRouteInfoTest, Creation) { @@ -425,7 +423,7 @@ class ScopedConfigImplTest : public testing::Test { - string_key: baz )EOF"); } - std::shared_ptr makeScopedRouteInfo(const std::string& route_config_yaml) { + ScopedRouteInfoSharedPtr makeScopedRouteInfo(const std::string& route_config_yaml) { envoy::config::route::v3::ScopedRouteConfiguration scoped_route_config; TestUtility::loadFromYaml(route_config_yaml, scoped_route_config); @@ -435,11 +433,11 @@ class ScopedConfigImplTest : public testing::Test { std::move(route_config)); } - std::shared_ptr scope_info_a_; - std::shared_ptr scope_info_a_v2_; - std::shared_ptr scope_info_b_; + ScopedRouteInfoSharedPtr scope_info_a_; + ScopedRouteInfoSharedPtr scope_info_a_v2_; + ScopedRouteInfoSharedPtr scope_info_b_; ScopedRoutes::ScopeKeyBuilder key_builder_config_; - std::unique_ptr scoped_config_impl_; + ScopedConfigImplPtr scoped_config_impl_; }; // Test a ScopedConfigImpl returns the correct route Config. diff --git a/test/common/router/scoped_rds_test.cc b/test/common/router/scoped_rds_test.cc index 4aa8b8012d4d8..db54579498bf6 100644 --- a/test/common/router/scoped_rds_test.cc +++ b/test/common/router/scoped_rds_test.cc @@ -105,8 +105,8 @@ class ScopedRoutesTestBase : public testing::Test { NiceMock validation_context_; // server_factory_context_ is used by rds NiceMock server_factory_context_; - std::unique_ptr route_config_provider_manager_; - std::unique_ptr config_provider_manager_; + RouteConfigProviderManagerPtr route_config_provider_manager_; + ScopedRoutesConfigProviderManagerPtr config_provider_manager_; Event::SimulatedTimeSystem time_system_; }; diff --git a/test/common/router/upstream_request_test.cc b/test/common/router/upstream_request_test.cc index 72705db133779..72e5312f901ea 100644 --- a/test/common/router/upstream_request_test.cc +++ b/test/common/router/upstream_request_test.cc @@ -95,7 +95,7 @@ class TcpConnPoolTest : public ::testing::Test { EXPECT_TRUE(conn_pool_->valid()); } - std::unique_ptr conn_pool_; + TcpConnPoolPtr conn_pool_; Tcp::ConnectionPool::MockInstance mock_pool_; MockGenericConnectionPoolCallbacks mock_generic_callbacks_; std::shared_ptr> host_; @@ -156,7 +156,7 @@ class TcpUpstreamTest : public ::testing::Test { NiceMock connection_; NiceMock mock_router_filter_; Tcp::ConnectionPool::MockConnectionData* mock_connection_data_; - std::unique_ptr tcp_upstream_; + TcpUpstreamPtr tcp_upstream_; Http::TestRequestHeaderMapImpl request_{{":method", "CONNECT"}, {":path", "/"}, {":protocol", "bytestream"}, diff --git a/test/common/runtime/runtime_impl_test.cc b/test/common/runtime/runtime_impl_test.cc index 8092dde805df5..af506941cc9a1 100644 --- a/test/common/runtime/runtime_impl_test.cc +++ b/test/common/runtime/runtime_impl_test.cc @@ -115,7 +115,7 @@ class LoaderImplTest : public testing::Test { NiceMock tls_; Stats::TestUtil::TestStore store_; MockRandomGenerator generator_; - std::unique_ptr loader_; + LoaderImplPtr loader_; Api::ApiPtr api_; Upstream::MockClusterManager cm_; NiceMock local_info_; diff --git a/test/common/secret/secret_manager_impl_test.cc b/test/common/secret/secret_manager_impl_test.cc index 3790fbdf7c95d..9f5e00373a24b 100644 --- a/test/common/secret/secret_manager_impl_test.cc +++ b/test/common/secret/secret_manager_impl_test.cc @@ -65,7 +65,7 @@ name: "abc.com" filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/selfsigned_key.pem" )EOF"; TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), secret_config); - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); secret_manager->addStaticSecret(secret_config); ASSERT_EQ(secret_manager->findStaticTlsCertificateProvider("undefined"), nullptr); @@ -98,7 +98,7 @@ TEST_F(SecretManagerImplTest, DuplicateStaticTlsCertificateSecret) { filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/selfsigned_key.pem" )EOF"; TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), secret_config); - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); secret_manager->addStaticSecret(secret_config); ASSERT_NE(secret_manager->findStaticTlsCertificateProvider("abc.com"), nullptr); @@ -117,7 +117,7 @@ TEST_F(SecretManagerImplTest, CertificateValidationContextSecretLoadSuccess) { allow_expired_certificate: true )EOF"; TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), secret_config); - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); secret_manager->addStaticSecret(secret_config); ASSERT_EQ(secret_manager->findStaticCertificateValidationContextProvider("undefined"), nullptr); @@ -142,7 +142,7 @@ TEST_F(SecretManagerImplTest, DuplicateStaticCertificateValidationContextSecret) allow_expired_certificate: true )EOF"; TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), secret_config); - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); secret_manager->addStaticSecret(secret_config); ASSERT_NE(secret_manager->findStaticCertificateValidationContextProvider("abc.com"), nullptr); @@ -164,7 +164,7 @@ name: "abc.com" TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), secret_config); - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); secret_manager->addStaticSecret(secret_config); @@ -193,7 +193,7 @@ name: "abc.com" TestUtility::loadFromYaml(TestEnvironment::substitute(yaml), secret_config); - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); secret_manager->addStaticSecret(secret_config); @@ -204,7 +204,7 @@ name: "abc.com" // Validate that secret manager adds static generic secret successfully. TEST_F(SecretManagerImplTest, GenericSecretLoadSuccess) { - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); envoy::extensions::transport_sockets::tls::v3::Secret secret; const std::string yaml = @@ -229,7 +229,7 @@ name: "encryption_key" // Validate that secret manager throws an exception when adding duplicated static generic secret. TEST_F(SecretManagerImplTest, DuplicateGenericSecret) { - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); envoy::extensions::transport_sockets::tls::v3::Secret secret; const std::string yaml = @@ -251,7 +251,7 @@ name: "encryption_key" // Regression test of https://github.com/envoyproxy/envoy/issues/5744 TEST_F(SecretManagerImplTest, DeduplicateDynamicTlsCertificateSecretProvider) { Server::MockInstance server; - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); NiceMock secret_context; @@ -334,7 +334,7 @@ header_key: x-token-bin TEST_F(SecretManagerImplTest, SdsDynamicSecretUpdateSuccess) { Server::MockInstance server; - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); NiceMock secret_context; @@ -386,7 +386,7 @@ name: "abc.com" TEST_F(SecretManagerImplTest, SdsDynamicGenericSecret) { Server::MockInstance server; - std::unique_ptr secret_manager(new SecretManagerImpl(config_tracker_)); + SecretManagerPtr secret_manager(new SecretManagerImpl(config_tracker_)); envoy::config::core::v3::ConfigSource config_source; NiceMock secret_context; diff --git a/test/common/shared_pool/shared_pool_test.cc b/test/common/shared_pool/shared_pool_test.cc index 8fbb564188523..540fe2c71ea60 100644 --- a/test/common/shared_pool/shared_pool_test.cc +++ b/test/common/shared_pool/shared_pool_test.cc @@ -32,7 +32,7 @@ class SharedPoolTest : public testing::Test { dispatcher_thread_->join(); } - void deferredDeleteSharedPoolOnMainThread(std::shared_ptr>& pool) { + void deferredDeleteSharedPoolOnMainThread(ObjectSharedPoolSharedPtr& pool) { absl::Notification go; dispatcher_->post([&pool, &go]() { pool.reset(); @@ -41,7 +41,7 @@ class SharedPoolTest : public testing::Test { go.WaitForNotification(); } - void createObjectSharedPool(std::shared_ptr>& pool) { + void createObjectSharedPool(ObjectSharedPoolSharedPtr& pool) { absl::Notification go; dispatcher_->post([&pool, &go, this]() { pool = std::make_shared>(*dispatcher_); @@ -50,8 +50,8 @@ class SharedPoolTest : public testing::Test { go.WaitForNotification(); } - void getObjectFromObjectSharedPool(std::shared_ptr>& pool, - std::shared_ptr& o, int value) { + void getObjectFromObjectSharedPool(ObjectSharedPoolSharedPtr& pool, std::shared_ptr& o, + int value) { absl::Notification go; dispatcher_->post([&pool, &o, &go, value]() { o = pool->getObject(value); @@ -85,13 +85,13 @@ TEST_F(SharedPoolTest, Basic) { } TEST_F(SharedPoolTest, NonThreadSafeForGetObjectDeathTest) { - std::shared_ptr> pool; + ObjectSharedPoolSharedPtr pool; createObjectSharedPool(pool); EXPECT_DEBUG_DEATH(pool->getObject(4), ".*"); } TEST_F(SharedPoolTest, ThreadSafeForDeleteObject) { - std::shared_ptr> pool; + ObjectSharedPoolSharedPtr pool; { // same thread createObjectSharedPool(pool); @@ -113,13 +113,13 @@ TEST_F(SharedPoolTest, ThreadSafeForDeleteObject) { } TEST_F(SharedPoolTest, NonThreadSafeForPoolSizeDeathTest) { - std::shared_ptr> pool; + ObjectSharedPoolSharedPtr pool; createObjectSharedPool(pool); EXPECT_DEBUG_DEATH(pool->poolSize(), ".*"); } TEST_F(SharedPoolTest, GetObjectAndDeleteObjectRaceForSameHashValue) { - std::shared_ptr> pool; + ObjectSharedPoolSharedPtr pool; std::shared_ptr o1; createObjectSharedPool(pool); getObjectFromObjectSharedPool(pool, o1, 4); @@ -150,7 +150,7 @@ TEST_F(SharedPoolTest, GetObjectAndDeleteObjectRaceForSameHashValue) { } TEST_F(SharedPoolTest, RaceCondtionForGetObjectWithObjectDeleter) { - std::shared_ptr> pool; + ObjectSharedPoolSharedPtr pool; std::shared_ptr o1; createObjectSharedPool(pool); getObjectFromObjectSharedPool(pool, o1, 4); diff --git a/test/common/stats/isolated_store_impl_test.cc b/test/common/stats/isolated_store_impl_test.cc index ee618669cb2cc..e5831e28d76b1 100644 --- a/test/common/stats/isolated_store_impl_test.cc +++ b/test/common/stats/isolated_store_impl_test.cc @@ -28,7 +28,7 @@ class StatsIsolatedStoreImplTest : public testing::Test { StatName makeStatName(absl::string_view name) { return pool_.add(name); } SymbolTablePtr symbol_table_; - std::unique_ptr store_; + IsolatedStoreImplPtr store_; StatNamePool pool_; }; diff --git a/test/common/stats/stat_test_utility.cc b/test/common/stats/stat_test_utility.cc index a195614e56821..8eafe4fc90ce0 100644 --- a/test/common/stats/stat_test_utility.cc +++ b/test/common/stats/stat_test_utility.cc @@ -200,9 +200,9 @@ Histogram& TestStore::histogramFromStatNameWithTags(const StatName& stat_name, } template -static absl::optional> -findByString(const std::string& name, const absl::flat_hash_map& map) { - absl::optional> ret; +static StatTypeOptConstRef findByString(const std::string& name, + const absl::flat_hash_map& map) { + StatTypeOptConstRef ret; auto iter = map.find(name); if (iter != map.end()) { ret = *iter->second; diff --git a/test/common/stats/stats_matcher_impl_test.cc b/test/common/stats/stats_matcher_impl_test.cc index 9f78387eaa4f4..43bf8631e6b12 100644 --- a/test/common/stats/stats_matcher_impl_test.cc +++ b/test/common/stats/stats_matcher_impl_test.cc @@ -33,7 +33,7 @@ class StatsMatcherTest : public testing::Test { } } - std::unique_ptr stats_matcher_impl_; + StatsMatcherImplPtr stats_matcher_impl_; private: envoy::config::metrics::v3::StatsConfig stats_config_; diff --git a/test/common/stats/symbol_table_impl_test.cc b/test/common/stats/symbol_table_impl_test.cc index 5913b47b4be6b..57b3bd18cd6f9 100644 --- a/test/common/stats/symbol_table_impl_test.cc +++ b/test/common/stats/symbol_table_impl_test.cc @@ -73,8 +73,8 @@ class StatNameTest : public testing::TestWithParam { FakeSymbolTableImpl* fake_symbol_table_{nullptr}; SymbolTableImpl* real_symbol_table_{nullptr}; - std::unique_ptr table_; - std::unique_ptr pool_; + SymbolTablePtr table_; + StatNamePoolPtr pool_; }; INSTANTIATE_TEST_SUITE_P(StatNameTest, StatNameTest, diff --git a/test/common/stats/thread_local_store_speed_test.cc b/test/common/stats/thread_local_store_speed_test.cc index 8ad68fd7ba0b7..d0e62b2b8f6c1 100644 --- a/test/common/stats/thread_local_store_speed_test.cc +++ b/test/common/stats/thread_local_store_speed_test.cc @@ -62,9 +62,9 @@ class ThreadLocalStorePerf { Stats::ThreadLocalStoreImpl store_; Api::ApiPtr api_; Event::DispatcherPtr dispatcher_; - std::unique_ptr tls_; + ThreadLocal::InstanceImplPtr tls_; envoy::config::metrics::v3::StatsConfig stats_config_; - std::vector> stat_names_; + std::vector stat_names_; }; } // namespace Envoy diff --git a/test/common/stats/thread_local_store_test.cc b/test/common/stats/thread_local_store_test.cc index 8bb02d1004d0a..335e2748cadc8 100644 --- a/test/common/stats/thread_local_store_test.cc +++ b/test/common/stats/thread_local_store_test.cc @@ -58,7 +58,7 @@ class StatsThreadLocalStoreTest : public testing::Test { NiceMock tls_; AllocatorImpl alloc_; MockSink sink_; - std::unique_ptr store_; + ThreadLocalStoreImplPtr store_; }; class HistogramWrapper { @@ -176,7 +176,7 @@ class HistogramTest : public testing::Test { NiceMock tls_; AllocatorImpl alloc_; MockSink sink_; - std::unique_ptr store_; + ThreadLocalStoreImplPtr store_; InSequence s; std::vector h1_cumulative_values_, h2_cumulative_values_, h1_interval_values_, h2_interval_values_; @@ -587,7 +587,7 @@ class ThreadLocalStoreNoMocksTestBase : public testing::Test { SymbolTablePtr symbol_table_; AllocatorImpl alloc_; - std::unique_ptr store_; + ThreadLocalStoreImplPtr store_; StatNamePool pool_; }; @@ -1079,8 +1079,8 @@ class StatsThreadLocalStoreTestNoFixture : public testing::Test { MockSink sink_; SymbolTablePtr symbol_table_; - std::unique_ptr alloc_; - std::unique_ptr store_; + AllocatorImplPtr alloc_; + ThreadLocalStoreImplPtr store_; NiceMock main_thread_dispatcher_; NiceMock tls_; TestUtil::SymbolTableCreatorTestPeer symbol_table_creator_test_peer_; @@ -1514,7 +1514,7 @@ class ClusterShutdownCleanupStarvationTest : public ThreadLocalStoreNoMocksTestB Event::DispatcherPtr main_dispatcher_; std::vector thread_dispatchers_; Thread::ThreadFactory& thread_factory_; - std::unique_ptr tls_; + ThreadLocal::InstanceImplPtr tls_; Thread::ThreadPtr main_thread_; std::vector threads_; StatNamePool pool_; diff --git a/test/common/stats/utility_test.cc b/test/common/stats/utility_test.cc index 8f4ec260d3bba..58186436fdb1f 100644 --- a/test/common/stats/utility_test.cc +++ b/test/common/stats/utility_test.cc @@ -30,7 +30,7 @@ class StatsUtilityTest : public testing::Test { } SymbolTablePtr symbol_table_; - std::unique_ptr store_; + IsolatedStoreImplPtr store_; StatNamePool pool_; StatNameTagVector tags_; }; diff --git a/test/common/stream_info/filter_state_impl_test.cc b/test/common/stream_info/filter_state_impl_test.cc index 24590fa7c3715..fb980f7321c4f 100644 --- a/test/common/stream_info/filter_state_impl_test.cc +++ b/test/common/stream_info/filter_state_impl_test.cc @@ -54,7 +54,7 @@ class FilterStateImplTest : public testing::Test { FilterState& filter_state() { return *filter_state_; } private: - std::unique_ptr filter_state_; + FilterStateImplPtr filter_state_; }; } // namespace diff --git a/test/common/tcp/conn_pool_test.cc b/test/common/tcp/conn_pool_test.cc index 2f2634ac14d0d..93143b8bdb9fa 100644 --- a/test/common/tcp/conn_pool_test.cc +++ b/test/common/tcp/conn_pool_test.cc @@ -200,8 +200,8 @@ class TcpConnPoolImplDestructorTest : public testing::Test { NiceMock* upstream_ready_timer_; NiceMock* connect_timer_; NiceMock* connection_; - std::unique_ptr conn_pool_; - std::unique_ptr callbacks_; + OriginalConnPoolImplPtr conn_pool_; + ConnPoolCallbacksPtr callbacks_; }; /** diff --git a/test/common/tcp_proxy/tcp_proxy_test.cc b/test/common/tcp_proxy/tcp_proxy_test.cc index 91a8b897c7ca5..a44d625d9b907 100644 --- a/test/common/tcp_proxy/tcp_proxy_test.cc +++ b/test/common/tcp_proxy/tcp_proxy_test.cc @@ -963,7 +963,7 @@ class TcpProxyTest : public testing::Test { NiceMock factory_context_; ConfigSharedPtr config_; NiceMock filter_callbacks_; - std::unique_ptr filter_; + FilterPtr filter_; std::vector>> upstream_hosts_{}; std::vector>> upstream_connections_{}; std::vector>> @@ -1768,7 +1768,7 @@ class TcpProxyRoutingTest : public testing::Test { ConfigSharedPtr config_; NiceMock connection_; NiceMock filter_callbacks_; - std::unique_ptr filter_; + FilterPtr filter_; }; TEST_F(TcpProxyRoutingTest, DEPRECATED_FEATURE_TEST(NonRoutableConnection)) { @@ -1960,7 +1960,7 @@ class TcpProxyHashingTest : public testing::Test { ConfigSharedPtr config_; NiceMock connection_; NiceMock filter_callbacks_; - std::unique_ptr filter_; + FilterPtr filter_; }; // Test TCP proxy use source IP to hash. diff --git a/test/common/tcp_proxy/upstream_test.cc b/test/common/tcp_proxy/upstream_test.cc index 9464d5d259705..a891194614bf0 100644 --- a/test/common/tcp_proxy/upstream_test.cc +++ b/test/common/tcp_proxy/upstream_test.cc @@ -27,7 +27,7 @@ class HttpUpstreamTest : public testing::Test { Http::MockRequestEncoder encoder_; NiceMock callbacks_; - std::unique_ptr upstream_; + HttpUpstreamPtr upstream_; std::string hostname_{"default.host.com"}; }; diff --git a/test/common/tracing/http_tracer_manager_impl_test.cc b/test/common/tracing/http_tracer_manager_impl_test.cc index f6e719fa434ef..6a79a1d4569ff 100644 --- a/test/common/tracing/http_tracer_manager_impl_test.cc +++ b/test/common/tracing/http_tracer_manager_impl_test.cc @@ -165,8 +165,8 @@ TEST_F(HttpTracerManagerImplCacheTest, ShouldCacheHttpTracersUsingWeakReferences // Expect HttpTracerManager to create a new HttpTracer. EXPECT_CALL(tracer_factory_, createHttpTracer(_, _)) - .WillOnce(InvokeWithoutArgs( - [expected_tracer] { return std::shared_ptr(expected_tracer); })); + .WillOnce( + InvokeWithoutArgs([expected_tracer] { return HttpTracerSharedPtr(expected_tracer); })); auto actual_tracer_one = http_tracer_manager_.getOrCreateHttpTracer(&tracing_config_one_); @@ -197,9 +197,8 @@ TEST_F(HttpTracerManagerImplCacheTest, ShouldCacheHttpTracersUsingWeakReferences // Expect HttpTracerManager to create a new HttpTracer once again. EXPECT_CALL(tracer_factory_, createHttpTracer(_, _)) - .WillOnce(InvokeWithoutArgs([expected_another_tracer] { - return std::shared_ptr(expected_another_tracer); - })); + .WillOnce(InvokeWithoutArgs( + [expected_another_tracer] { return HttpTracerSharedPtr(expected_another_tracer); })); // Use a different config to guarantee that a new cache entry will be added anyway. auto actual_tracer_three = http_tracer_manager_.getOrCreateHttpTracer(&tracing_config_two_); diff --git a/test/common/upstream/eds_speed_test.cc b/test/common/upstream/eds_speed_test.cc index 1f1c25c4ad9a2..84286405fc116 100644 --- a/test/common/upstream/eds_speed_test.cc +++ b/test/common/upstream/eds_speed_test.cc @@ -140,7 +140,7 @@ class EdsSpeedTest { envoy::config::cluster::v3::Cluster eds_cluster_; NiceMock cm_; NiceMock dispatcher_; - std::shared_ptr cluster_; + EdsClusterImplSharedPtr cluster_; Config::SubscriptionCallbacks* eds_callbacks_{}; NiceMock random_; NiceMock runtime_; @@ -152,8 +152,8 @@ class EdsSpeedTest { Api::ApiPtr api_; Grpc::MockAsyncClient* async_client_; NiceMock async_stream_; - std::shared_ptr grpc_mux_; - std::unique_ptr subscription_; + Config::GrpcMuxImplSharedPtr grpc_mux_; + Config::GrpcSubscriptionImplPtr subscription_; }; } // namespace Upstream diff --git a/test/common/upstream/eds_test.cc b/test/common/upstream/eds_test.cc index 865e05bd9f989..073c47aa6540f 100644 --- a/test/common/upstream/eds_test.cc +++ b/test/common/upstream/eds_test.cc @@ -119,7 +119,7 @@ class EdsTest : public testing::Test { envoy::config::cluster::v3::Cluster eds_cluster_; NiceMock cm_; NiceMock dispatcher_; - std::shared_ptr cluster_; + EdsClusterImplSharedPtr cluster_; Config::SubscriptionCallbacks* eds_callbacks_{}; NiceMock random_; NiceMock runtime_; diff --git a/test/common/upstream/hds_test.cc b/test/common/upstream/hds_test.cc index b7a15887d05b5..76ca259878a4e 100644 --- a/test/common/upstream/hds_test.cc +++ b/test/common/upstream/hds_test.cc @@ -109,7 +109,7 @@ class HdsTest : public testing::Test { Stats::IsolatedStoreImpl stats_store_; MockClusterInfoFactory test_factory_; - std::unique_ptr hds_delegate_; + Upstream::HdsDelegatePtr hds_delegate_; HdsDelegateFriend hds_delegate_friend_; Event::MockTimer* retry_timer_; diff --git a/test/common/upstream/health_checker_impl_test.cc b/test/common/upstream/health_checker_impl_test.cc index dc328cb18516a..1ce9189573eb3 100644 --- a/test/common/upstream/health_checker_impl_test.cc +++ b/test/common/upstream/health_checker_impl_test.cc @@ -870,7 +870,7 @@ TEST_F(HttpHealthCheckerImplTest, SuccessWithSpuriousMetadata) { enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); - std::unique_ptr metadata_map(new Http::MetadataMap()); + Http::MetadataMapPtr metadata_map(new Http::MetadataMap()); metadata_map->insert(std::make_pair("key", "value")); test_sessions_[0]->stream_response_callbacks_->decodeMetadata(std::move(metadata_map)); @@ -2558,12 +2558,11 @@ class TestProdHttpHealthChecker : public ProdHttpHealthCheckerImpl { public: using ProdHttpHealthCheckerImpl::ProdHttpHealthCheckerImpl; - std::unique_ptr - createCodecClientForTest(std::unique_ptr&& connection) { + Http::CodecClientPtr createCodecClientForTest(Network::ClientConnectionPtr&& connection) { Upstream::Host::CreateConnectionData data; data.connection_ = std::move(connection); data.host_description_ = std::make_shared>(); - return std::unique_ptr(createCodecClient(data)); + return Http::CodecClientPtr(createCodecClient(data)); } }; @@ -3052,7 +3051,7 @@ class TcpHealthCheckerImplTest : public testing::Test, public HealthCheckerTestB EXPECT_CALL(*connection_, addReadFilter(_)).WillOnce(SaveArg<0>(&read_filter_)); } - std::shared_ptr health_checker_; + TcpHealthCheckerImplSharedPtr health_checker_; Network::MockClientConnection* connection_{}; Event::MockTimer* timeout_timer_{}; Event::MockTimer* interval_timer_{}; diff --git a/test/common/upstream/load_balancer_benchmark.cc b/test/common/upstream/load_balancer_benchmark.cc index f8e1177da0f98..d5f38e2a46b2a 100644 --- a/test/common/upstream/load_balancer_benchmark.cc +++ b/test/common/upstream/load_balancer_benchmark.cc @@ -66,7 +66,7 @@ class RoundRobinTester : public BaseTester { runtime_, random_, common_config_); } - std::unique_ptr lb_; + RoundRobinLoadBalancerPtr lb_; }; class LeastRequestTester : public BaseTester { @@ -79,7 +79,7 @@ class LeastRequestTester : public BaseTester { runtime_, random_, common_config_, lr_lb_config); } - std::unique_ptr lb_; + LeastRequestLoadBalancerPtr lb_; }; void BM_RoundRobinLoadBalancerBuild(benchmark::State& state) { @@ -134,7 +134,7 @@ class RingHashTester : public BaseTester { } absl::optional config_; - std::unique_ptr ring_hash_lb_; + RingHashLoadBalancerPtr ring_hash_lb_; }; class MaglevTester : public BaseTester { @@ -145,7 +145,7 @@ class MaglevTester : public BaseTester { random_, common_config_); } - std::unique_ptr maglev_lb_; + MaglevLoadBalancerPtr maglev_lb_; }; uint64_t hashInt(uint64_t i) { diff --git a/test/common/upstream/load_balancer_impl_test.cc b/test/common/upstream/load_balancer_impl_test.cc index ced9ec06ae29b..1d61462188092 100644 --- a/test/common/upstream/load_balancer_impl_test.cc +++ b/test/common/upstream/load_balancer_impl_test.cc @@ -547,8 +547,8 @@ class RoundRobinLoadBalancerTest : public LoadBalancerTestBase { {}, empty_host_vector_, empty_host_vector_, absl::nullopt); } - std::shared_ptr local_priority_set_; - std::shared_ptr lb_; + PrioritySetImplSharedPtr local_priority_set_; + LoadBalancerSharedPtr lb_; HostsPerLocalityConstSharedPtr empty_locality_; HostVector empty_host_vector_; }; // namespace @@ -1564,7 +1564,7 @@ class RandomLoadBalancerTest : public LoadBalancerTestBase { lb_ = std::make_shared(priority_set_, nullptr, stats_, runtime_, random_, common_config_); } - std::shared_ptr lb_; + LoadBalancerSharedPtr lb_; }; TEST_P(RandomLoadBalancerTest, NoHosts) { diff --git a/test/common/upstream/load_stats_reporter_test.cc b/test/common/upstream/load_stats_reporter_test.cc index c22593a84f5c4..0f0fcab6a61af 100644 --- a/test/common/upstream/load_stats_reporter_test.cc +++ b/test/common/upstream/load_stats_reporter_test.cc @@ -73,7 +73,7 @@ class LoadStatsReporterTest : public testing::Test { NiceMock cm_; Event::MockDispatcher dispatcher_; Stats::IsolatedStoreImpl stats_store_; - std::unique_ptr load_stats_reporter_; + LoadStatsReporterPtr load_stats_reporter_; Event::MockTimer* retry_timer_; Event::TimerCb retry_timer_cb_; Event::MockTimer* response_timer_; diff --git a/test/common/upstream/logical_dns_cluster_test.cc b/test/common/upstream/logical_dns_cluster_test.cc index 74154fd825105..edf3a6c4f8434 100644 --- a/test/common/upstream/logical_dns_cluster_test.cc +++ b/test/common/upstream/logical_dns_cluster_test.cc @@ -200,7 +200,7 @@ class LogicalDnsClusterTest : public testing::Test { Network::DnsResolver::ResolveCb dns_callback_; NiceMock tls_; Event::MockTimer* resolve_timer_; - std::shared_ptr cluster_; + LogicalDnsClusterSharedPtr cluster_; ReadyWatcher membership_updated_; ReadyWatcher initialized_; NiceMock runtime_; diff --git a/test/common/upstream/maglev_lb_test.cc b/test/common/upstream/maglev_lb_test.cc index 3fce26252ac49..2afad28cc6145 100644 --- a/test/common/upstream/maglev_lb_test.cc +++ b/test/common/upstream/maglev_lb_test.cc @@ -54,7 +54,7 @@ class MaglevLoadBalancerTest : public testing::Test { envoy::config::cluster::v3::Cluster::CommonLbConfig common_config_; NiceMock runtime_; NiceMock random_; - std::unique_ptr lb_; + MaglevLoadBalancerPtr lb_; }; // Works correctly without any hosts. diff --git a/test/common/upstream/outlier_detection_impl_test.cc b/test/common/upstream/outlier_detection_impl_test.cc index a79b1a1b31d6d..01dd73a7b89c4 100644 --- a/test/common/upstream/outlier_detection_impl_test.cc +++ b/test/common/upstream/outlier_detection_impl_test.cc @@ -139,8 +139,8 @@ failure_percentage_threshold: 70 envoy::config::cluster::v3::OutlierDetection outlier_detection; TestUtility::loadFromYaml(yaml, outlier_detection); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100), _)); - std::shared_ptr detector(DetectorImpl::create( - cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_)); + DetectorImplSharedPtr detector(DetectorImpl::create(cluster_, outlier_detection, dispatcher_, + runtime_, time_system_, event_logger_)); EXPECT_EQ(100UL, detector->config().intervalMs()); EXPECT_EQ(10000UL, detector->config().baseEjectionTimeMs()); @@ -167,7 +167,7 @@ TEST_F(OutlierDetectorImplTest, DestroyWithActive) { addHosts({"tcp://127.0.0.1:80"}, true); addHosts({"tcp://127.0.0.1:81"}, false); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -198,7 +198,7 @@ TEST_F(OutlierDetectorImplTest, DestroyHostInUse) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -215,7 +215,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaHttpCodes) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -284,7 +284,7 @@ TEST_F(OutlierDetectorImplTest, ConnectSuccessWithOptionalHTTP_OK) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -308,7 +308,7 @@ TEST_F(OutlierDetectorImplTest, ExternalOriginEventsNonSplit) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -334,7 +334,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaNonHttpCodes) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -411,7 +411,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailure) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); ON_CALL(runtime_.snapshot_, @@ -508,7 +508,7 @@ TEST_F(OutlierDetectorImplTest, TimeoutWithHttpCode) { }); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -572,7 +572,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowLocalOriginFailure) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}, true); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, event_logger_)); ON_CALL(runtime_.snapshot_, @@ -654,7 +654,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailureAnd5xx) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); ON_CALL(runtime_.snapshot_, @@ -743,7 +743,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowNonHttpCodesExternalOrigin) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -795,7 +795,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateExternalOrigin) { }); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -894,7 +894,7 @@ TEST_F(OutlierDetectorImplTest, ExternalOriginEventsWithSplit) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}, true); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, event_logger_)); for (auto i = 0; i < 100; i++) { @@ -926,7 +926,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateLocalOrigin) { }); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1015,7 +1015,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateLocalOrigin) { // zero. This is a regression test for earlier divide-by-zero behavior. TEST_F(OutlierDetectorImplTest, EmptySuccessRate) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); loadRq(hosts_, 200, 503); @@ -1037,7 +1037,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowFailurePercentageExternalOrigin) { }); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1157,7 +1157,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowFailurePercentageLocalOrigin) { }); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1257,7 +1257,7 @@ TEST_F(OutlierDetectorImplTest, RemoveWhileEjected) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1286,7 +1286,7 @@ TEST_F(OutlierDetectorImplTest, Overflow) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80", "tcp://127.0.0.1:81"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1314,7 +1314,7 @@ TEST_F(OutlierDetectorImplTest, NotEnforcing) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1356,7 +1356,7 @@ TEST_F(OutlierDetectorImplTest, CrossThreadRemoveRace) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1378,7 +1378,7 @@ TEST_F(OutlierDetectorImplTest, CrossThreadDestroyRace) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1401,7 +1401,7 @@ TEST_F(OutlierDetectorImplTest, CrossThreadFailRace) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1428,7 +1428,7 @@ TEST_F(OutlierDetectorImplTest, Consecutive_5xxAlreadyEjected) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); diff --git a/test/common/upstream/ring_hash_lb_test.cc b/test/common/upstream/ring_hash_lb_test.cc index fbd4906e01fe0..7979573d2508a 100644 --- a/test/common/upstream/ring_hash_lb_test.cc +++ b/test/common/upstream/ring_hash_lb_test.cc @@ -72,7 +72,7 @@ class RingHashLoadBalancerTest : public testing::TestWithParam { envoy::config::cluster::v3::Cluster::CommonLbConfig common_config_; NiceMock runtime_; NiceMock random_; - std::unique_ptr lb_; + RingHashLoadBalancerPtr lb_; }; // For tests which don't need to be run in both primary and failover modes. diff --git a/test/common/upstream/subset_lb_test.cc b/test/common/upstream/subset_lb_test.cc index 40ae53bddf19c..ff4855974a1b4 100644 --- a/test/common/upstream/subset_lb_test.cc +++ b/test/common/upstream/subset_lb_test.cc @@ -32,7 +32,7 @@ namespace Upstream { class SubsetLoadBalancerDescribeMetadataTester { public: - SubsetLoadBalancerDescribeMetadataTester(std::shared_ptr lb) : lb_(lb) {} + SubsetLoadBalancerDescribeMetadataTester(SubsetLoadBalancerSharedPtr lb) : lb_(lb) {} using MetadataVector = std::vector>; @@ -42,7 +42,7 @@ class SubsetLoadBalancerDescribeMetadataTester { } private: - std::shared_ptr lb_; + SubsetLoadBalancerSharedPtr lb_; }; namespace SubsetLoadBalancerTest { @@ -113,7 +113,7 @@ class TestLoadBalancerContext : public LoadBalancerContextBase { const Http::RequestHeaderMap* downstreamHeaders() const override { return nullptr; } private: - const std::shared_ptr matches_; + const Router::MetadataMatchCriteriaSharedPtr matches_; }; enum class UpdateOrder { RemovesFirst, Simultaneous }; @@ -469,7 +469,7 @@ class SubsetLoadBalancerTest : public testing::TestWithParam { PrioritySetImpl local_priority_set_; HostVectorSharedPtr local_hosts_; HostsPerLocalitySharedPtr local_hosts_per_locality_; - std::shared_ptr lb_; + SubsetLoadBalancerSharedPtr lb_; }; TEST_F(SubsetLoadBalancerTest, NoFallback) { diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index 28c658c76b276..64fb7ad3c79f3 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -76,7 +76,7 @@ std::list hostListToAddresses(const HostVector& hosts) { } template -std::shared_ptr +HostsTConstSharedPtr makeHostsFromHostsPerLocality(HostsPerLocalityConstSharedPtr hosts_per_locality) { HostVector hosts; @@ -2049,7 +2049,7 @@ class ClusterInfoImplTest : public testing::Test { public: ClusterInfoImplTest() : api_(Api::createApiForTest(stats_)) {} - std::unique_ptr makeCluster(const std::string& yaml) { + StrictDnsClusterImplPtr makeCluster(const std::string& yaml) { cluster_config_ = parseClusterFromV2Yaml(yaml); scope_ = stats_.createScope(fmt::format("cluster.{}.", cluster_config_.alt_stat_name().empty() ? cluster_config_.name() @@ -2076,7 +2076,7 @@ class ClusterInfoImplTest : public testing::Test { ReadyWatcher initialized_; envoy::config::cluster::v3::Cluster cluster_config_; Envoy::Stats::ScopePtr scope_; - std::unique_ptr factory_context_; + Server::Configuration::TransportSocketFactoryContextImplPtr factory_context_; NiceMock validation_visitor_; Api::ApiPtr api_; }; @@ -2092,8 +2092,7 @@ class BazFactory : public ClusterTypedMetadataFactory { public: std::string name() const override { return "baz"; } // Returns nullptr (conversion failure) if d is empty. - std::unique_ptr - parse(const ProtobufWkt::Struct& d) const override { + Envoy::Config::TypedMetadata::ObjectConstPtr parse(const ProtobufWkt::Struct& d) const override { if (d.fields().find("name") != d.fields().end()) { return std::make_unique(d.fields().at("name").string_value()); } @@ -2557,7 +2556,7 @@ TEST_F(ClusterInfoImplTest, ExtensionProtocolOptionsForFilterWithOptions) { // This vector is used to gather clusters with extension_protocol_options from the different // types of extension factories (network, http). - std::vector> clusters; + std::vector clusters; { // Get the cluster with extension_protocol_options for a network filter factory. diff --git a/test/config_test/config_test.cc b/test/config_test/config_test.cc index 37e6f92f4605f..f25d6b0e384e0 100644 --- a/test/config_test/config_test.cc +++ b/test/config_test/config_test.cc @@ -138,7 +138,7 @@ class ConfigTest { Server::ServerFactoryContextImpl server_factory_context_{server_}; NiceMock ssl_context_manager_; OptionsImpl options_; - std::unique_ptr cluster_manager_factory_; + Upstream::ProdClusterManagerFactoryPtr cluster_manager_factory_; NiceMock component_factory_; NiceMock worker_factory_; Server::ListenerManagerImpl listener_manager_{server_, component_factory_, worker_factory_, diff --git a/test/exe/main_common_test.cc b/test/exe/main_common_test.cc index 3dcd35ea111ea..1fffa7cb432f1 100644 --- a/test/exe/main_common_test.cc +++ b/test/exe/main_common_test.cc @@ -129,7 +129,7 @@ TEST_P(MainCommonTest, RetryDynamicBaseIdFails) { EXPECT_THROW_WITH_MESSAGE( MainCommonBase(second_options, real_time_system, default_listener_hooks, - prod_component_factory, std::unique_ptr{mock_rng}, + prod_component_factory, Runtime::RandomGeneratorPtr{mock_rng}, platform.threadFactory(), platform.fileSystem(), nullptr), EnvoyException, "unable to select a dynamic base id"); #endif @@ -257,8 +257,8 @@ class AdminRequestTest : public MainCommonTest { } Stats::IsolatedStoreImpl stats_store_; - std::unique_ptr envoy_thread_; - std::unique_ptr main_common_; + Thread::ThreadPtr envoy_thread_; + MainCommonPtr main_common_; absl::Notification started_; absl::Notification finished_; absl::Notification resume_; diff --git a/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc b/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc index 4cb7054017b8a..6ea00508fc7fb 100644 --- a/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc +++ b/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc @@ -77,7 +77,7 @@ class GrpcAccessLoggerImplTest : public testing::Test { Event::MockTimer* timer_ = nullptr; Event::MockDispatcher dispatcher_; Grpc::MockAsyncClient* async_client_{new Grpc::MockAsyncClient}; - std::unique_ptr logger_; + GrpcAccessLoggerImplPtr logger_; }; // Test basic stream logging flow. @@ -372,7 +372,7 @@ class GrpcAccessLoggerCacheImplTest : public testing::Test { Grpc::MockAsyncClientManager async_client_manager_; Grpc::MockAsyncClient* async_client_ = nullptr; Grpc::MockAsyncClientFactory* factory_ = nullptr; - std::unique_ptr logger_cache_; + GrpcAccessLoggerCacheImplPtr logger_cache_; NiceMock scope_; }; diff --git a/test/extensions/access_loggers/grpc/http_grpc_access_log_impl_test.cc b/test/extensions/access_loggers/grpc/http_grpc_access_log_impl_test.cc index c39fb81655454..d6cf63b113953 100644 --- a/test/extensions/access_loggers/grpc/http_grpc_access_log_impl_test.cc +++ b/test/extensions/access_loggers/grpc/http_grpc_access_log_impl_test.cc @@ -122,7 +122,7 @@ response: {{}} envoy::extensions::access_loggers::grpc::v3::HttpGrpcAccessLogConfig config_; std::shared_ptr logger_{new MockGrpcAccessLogger()}; std::shared_ptr logger_cache_{new MockGrpcAccessLoggerCache()}; - std::unique_ptr access_log_; + HttpGrpcAccessLogPtr access_log_; }; class TestSerializedFilterState : public StreamInfo::FilterState::Object { diff --git a/test/extensions/clusters/aggregate/cluster_test.cc b/test/extensions/clusters/aggregate/cluster_test.cc index 916fe3df8b106..8d50e4bfb52af 100644 --- a/test/extensions/clusters/aggregate/cluster_test.cc +++ b/test/extensions/clusters/aggregate/cluster_test.cc @@ -131,7 +131,7 @@ class AggregateClusterTest : public testing::Test { Singleton::ManagerImpl singleton_manager_{Thread::threadFactoryForTest()}; NiceMock validation_visitor_; Api::ApiPtr api_{Api::createApiForTest(stats_store_)}; - std::shared_ptr cluster_; + ClusterSharedPtr cluster_; Upstream::ThreadAwareLoadBalancerPtr thread_aware_lb_; Upstream::LoadBalancerFactorySharedPtr lb_factory_; Upstream::LoadBalancerPtr lb_; diff --git a/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc b/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc index e44a7a7d18e91..6e6230e054c89 100644 --- a/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc +++ b/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc @@ -118,7 +118,7 @@ class ClusterTest : public testing::Test, Api::ApiPtr api_{Api::createApiForTest(stats_store_)}; std::shared_ptr dns_cache_manager_{ new Extensions::Common::DynamicForwardProxy::MockDnsCacheManager()}; - std::shared_ptr cluster_; + ClusterSharedPtr cluster_; Upstream::ThreadAwareLoadBalancerPtr thread_aware_lb_; Upstream::LoadBalancerFactorySharedPtr lb_factory_; Upstream::LoadBalancerPtr lb_; @@ -206,7 +206,7 @@ class ClusterFactoryTest : public testing::Test { cm_, stats_store_, tls_, nullptr, ssl_context_manager_, runtime_, random_, dispatcher_, log_manager_, local_info_, admin_, singleton_manager_, nullptr, true, validation_visitor_, *api_); - std::unique_ptr cluster_factory = std::make_unique(); + Upstream::ClusterFactoryPtr cluster_factory = std::make_unique(); std::tie(cluster_, thread_aware_lb_) = cluster_factory->create(cluster_config, cluster_factory_context); diff --git a/test/extensions/clusters/redis/redis_cluster_lb_test.cc b/test/extensions/clusters/redis/redis_cluster_lb_test.cc index bfc1ae6e16be4..2eddeb0aa6673 100644 --- a/test/extensions/clusters/redis/redis_cluster_lb_test.cc +++ b/test/extensions/clusters/redis/redis_cluster_lb_test.cc @@ -72,8 +72,8 @@ class RedisClusterLoadBalancerTest : public testing::Test { return map; } - std::shared_ptr factory_; - std::unique_ptr lb_; + RedisClusterLoadBalancerFactorySharedPtr factory_; + RedisClusterThreadAwareLoadBalancerPtr lb_; std::shared_ptr info_{new NiceMock()}; NiceMock random_; }; diff --git a/test/extensions/clusters/redis/redis_cluster_test.cc b/test/extensions/clusters/redis/redis_cluster_test.cc index 6b9a87ab778a3..c42d01ad954d6 100644 --- a/test/extensions/clusters/redis/redis_cluster_test.cc +++ b/test/extensions/clusters/redis/redis_cluster_test.cc @@ -560,7 +560,7 @@ class RedisClusterTest : public testing::Test, Extensions::NetworkFilters::Common::Redis::Client::MockClient* client_{}; Extensions::NetworkFilters::Common::Redis::Client::MockPoolRequest pool_request_; Extensions::NetworkFilters::Common::Redis::Client::ClientCallbacks* pool_callbacks_{}; - std::shared_ptr cluster_; + RedisClusterSharedPtr cluster_; std::shared_ptr> cluster_callback_; Network::MockActiveDnsQuery active_dns_query_; }; diff --git a/test/extensions/common/dynamic_forward_proxy/dns_cache_impl_test.cc b/test/extensions/common/dynamic_forward_proxy/dns_cache_impl_test.cc index d3bf78619891c..9dd58dc1e1018 100644 --- a/test/extensions/common/dynamic_forward_proxy/dns_cache_impl_test.cc +++ b/test/extensions/common/dynamic_forward_proxy/dns_cache_impl_test.cc @@ -60,7 +60,7 @@ class DnsCacheImplTest : public testing::Test, public Event::TestUsingSimulatedT NiceMock tls_; NiceMock random_; Stats::IsolatedStoreImpl store_; - std::unique_ptr dns_cache_; + DnsCachePtr dns_cache_; MockUpdateCallbacks update_callbacks_; DnsCache::AddUpdateCallbacksHandlePtr update_callbacks_handle_; }; diff --git a/test/extensions/common/proxy_protocol/proxy_protocol_regression_test.cc b/test/extensions/common/proxy_protocol/proxy_protocol_regression_test.cc index e51fbb8b6fa35..b5d9372d39315 100644 --- a/test/extensions/common/proxy_protocol/proxy_protocol_regression_test.cc +++ b/test/extensions/common/proxy_protocol/proxy_protocol_regression_test.cc @@ -154,7 +154,7 @@ class ProxyProtocolRegressionTest : public testing::TestWithParam socket_; + Network::TcpListenSocketSharedPtr socket_; Network::MockListenSocketFactory socket_factory_; Network::NopConnectionBalancerImpl connection_balancer_; Network::ConnectionHandlerPtr connection_handler_; diff --git a/test/extensions/common/redis/cluster_refresh_manager_test.cc b/test/extensions/common/redis/cluster_refresh_manager_test.cc index e58f6d6ca728f..109d8c976c9d0 100644 --- a/test/extensions/common/redis/cluster_refresh_manager_test.cc +++ b/test/extensions/common/redis/cluster_refresh_manager_test.cc @@ -106,7 +106,7 @@ class ClusterRefreshManagerTest : public testing::Test { Upstream::ClusterManager::ClusterInfoMap map_; Upstream::MockClusterMockPrioritySet mock_cluster_; Event::SimulatedTimeSystem time_system_; - std::shared_ptr refresh_manager_; + ClusterRefreshManagerImplSharedPtr refresh_manager_; ClusterRefreshManager::HandlePtr handle_; std::atomic callback_count_{}; std::atomic nthreads_waiting_{}; diff --git a/test/extensions/common/tap/admin_test.cc b/test/extensions/common/tap/admin_test.cc index 0ee2bc2af042f..7fb5ed6507693 100644 --- a/test/extensions/common/tap/admin_test.cc +++ b/test/extensions/common/tap/admin_test.cc @@ -38,7 +38,7 @@ class AdminHandlerTest : public testing::Test { Server::MockAdmin admin_; Event::MockDispatcher main_thread_dispatcher_{"test_main_thread"}; - std::unique_ptr handler_; + AdminHandlerPtr handler_; Server::Admin::HandlerCb cb_; Http::TestResponseHeaderMapImpl response_headers_; Buffer::OwnedImpl response_; diff --git a/test/extensions/common/wasm/wasm_vm_test.cc b/test/extensions/common/wasm/wasm_vm_test.cc index a628aa43baed4..9761a2c5faf4c 100644 --- a/test/extensions/common/wasm/wasm_vm_test.cc +++ b/test/extensions/common/wasm/wasm_vm_test.cc @@ -34,12 +34,12 @@ class PluginFactory : public Null::NullVmPluginFactory { PluginFactory() = default; std::string name() const override { return "test_null_vm_plugin"; } - std::unique_ptr create() const override; + Null::NullVmPluginPtr create() const override; }; TestNullVmPlugin* test_null_vm_plugin_ = nullptr; -std::unique_ptr PluginFactory::create() const { +Null::NullVmPluginPtr PluginFactory::create() const { auto result = std::make_unique(); test_null_vm_plugin_ = result.get(); return result; diff --git a/test/extensions/filters/common/ext_authz/ext_authz_grpc_impl_test.cc b/test/extensions/filters/common/ext_authz/ext_authz_grpc_impl_test.cc index 711680fa6394a..ab0f7b37d6fd2 100644 --- a/test/extensions/filters/common/ext_authz/ext_authz_grpc_impl_test.cc +++ b/test/extensions/filters/common/ext_authz/ext_authz_grpc_impl_test.cc @@ -63,7 +63,7 @@ class ExtAuthzGrpcClientTest : public testing::TestWithParam { Grpc::MockAsyncClient* async_client_; absl::optional timeout_; Grpc::MockAsyncRequest async_request_; - std::unique_ptr client_; + GrpcClientImplPtr client_; MockRequestCallbacks request_callbacks_; Tracing::MockSpan span_; bool use_alpha_{}; diff --git a/test/extensions/filters/common/ext_authz/ext_authz_http_impl_test.cc b/test/extensions/filters/common/ext_authz/ext_authz_http_impl_test.cc index 74851ee016d65..4ac4951f97551 100644 --- a/test/extensions/filters/common/ext_authz/ext_authz_http_impl_test.cc +++ b/test/extensions/filters/common/ext_authz/ext_authz_http_impl_test.cc @@ -130,7 +130,7 @@ class ExtAuthzHttpClientTest : public testing::Test { NiceMock async_request_; ClientConfigSharedPtr config_; TimeSource& time_source_; - std::unique_ptr client_; + RawHttpClientImplPtr client_; MockRequestCallbacks request_callbacks_; Tracing::MockSpan active_span_; NiceMock stream_info_; diff --git a/test/extensions/filters/common/lua/lua_test.cc b/test/extensions/filters/common/lua/lua_test.cc index b5770a0b20d79..f70fc2356114e 100644 --- a/test/extensions/filters/common/lua/lua_test.cc +++ b/test/extensions/filters/common/lua/lua_test.cc @@ -46,7 +46,7 @@ class LuaTest : public testing::Test { } NiceMock tls_; - std::unique_ptr state_; + ThreadLocalStatePtr state_; std::function yield_callback_; ReadyWatcher on_yield_; }; diff --git a/test/extensions/filters/common/lua/lua_wrappers.h b/test/extensions/filters/common/lua/lua_wrappers.h index 4791f9e5109a9..4b2e7f1f8b0a7 100644 --- a/test/extensions/filters/common/lua/lua_wrappers.h +++ b/test/extensions/filters/common/lua/lua_wrappers.h @@ -41,7 +41,7 @@ template class LuaWrappersTestBase : public testing::Test { MOCK_METHOD(void, testPrint, (const std::string&)); NiceMock tls_; - std::unique_ptr state_; + ThreadLocalStatePtr state_; std::function yield_callback_; CoroutinePtr coroutine_; }; diff --git a/test/extensions/filters/common/original_src/original_src_socket_option_test.cc b/test/extensions/filters/common/original_src/original_src_socket_option_test.cc index 2a8dbb2ffce88..c9422736a57cc 100644 --- a/test/extensions/filters/common/original_src/original_src_socket_option_test.cc +++ b/test/extensions/filters/common/original_src/original_src_socket_option_test.cc @@ -23,7 +23,7 @@ namespace { class OriginalSrcSocketOptionTest : public testing::Test { public: - std::unique_ptr + OriginalSrcSocketOptionPtr makeOptionByAddress(const Network::Address::InstanceConstSharedPtr& address) { return std::make_unique(address); } diff --git a/test/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter_test.cc b/test/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter_test.cc index 5742385d5cc57..073f57d52e5e9 100644 --- a/test/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter_test.cc +++ b/test/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter_test.cc @@ -63,7 +63,7 @@ class AdaptiveConcurrencyFilterTest : public testing::Test { std::shared_ptr controller_{new MockConcurrencyController()}; NiceMock decoder_callbacks_; NiceMock encoder_callbacks_; - std::unique_ptr filter_; + AdaptiveConcurrencyFilterPtr filter_; }; TEST_F(AdaptiveConcurrencyFilterTest, TestEnableOverriddenFromRuntime) { diff --git a/test/extensions/filters/http/admission_control/admission_control_filter_test.cc b/test/extensions/filters/http/admission_control/admission_control_filter_test.cc index ad1c3ca28543c..93f9183356790 100644 --- a/test/extensions/filters/http/admission_control/admission_control_filter_test.cc +++ b/test/extensions/filters/http/admission_control/admission_control_filter_test.cc @@ -49,7 +49,7 @@ class TestConfig : public AdmissionControlFilterConfig { TestConfig(const AdmissionControlProto& proto_config, Runtime::Loader& runtime, TimeSource& time_source, Runtime::RandomGenerator& random, Stats::Scope& scope, ThreadLocal::SlotPtr&& tls, MockThreadLocalController& controller, - std::shared_ptr evaluator) + ResponseEvaluatorSharedPtr evaluator) : AdmissionControlFilterConfig(proto_config, runtime, time_source, random, scope, std::move(tls), std::move(evaluator)), controller_(controller) {} @@ -63,7 +63,7 @@ class AdmissionControlTest : public testing::Test { public: AdmissionControlTest() = default; - std::shared_ptr makeConfig(const std::string& yaml) { + AdmissionControlFilterConfigSharedPtr makeConfig(const std::string& yaml) { AdmissionControlProto proto; TestUtility::loadFromYamlAndValidate(yaml, proto); auto tls = context_.threadLocal().allocateSlot(); @@ -73,7 +73,7 @@ class AdmissionControlTest : public testing::Test { std::move(tls), controller_, evaluator_); } - void setupFilter(std::shared_ptr config) { + void setupFilter(AdmissionControlFilterConfigSharedPtr config) { filter_ = std::make_shared(config, "test_prefix."); filter_->setDecoderFilterCallbacks(decoder_callbacks_); } @@ -105,7 +105,7 @@ class AdmissionControlTest : public testing::Test { Stats::IsolatedStoreImpl scope_; Event::SimulatedTimeSystem time_system_; NiceMock random_; - std::shared_ptr filter_; + AdmissionControlFilterSharedPtr filter_; NiceMock decoder_callbacks_; NiceMock controller_; std::shared_ptr evaluator_; diff --git a/test/extensions/filters/http/admission_control/config_test.cc b/test/extensions/filters/http/admission_control/config_test.cc index 2201b3c36cb11..9c89bb559663c 100644 --- a/test/extensions/filters/http/admission_control/config_test.cc +++ b/test/extensions/filters/http/admission_control/config_test.cc @@ -30,7 +30,7 @@ class AdmissionControlConfigTest : public testing::Test { public: AdmissionControlConfigTest() = default; - std::shared_ptr makeConfig(const std::string& yaml) { + AdmissionControlFilterConfigSharedPtr makeConfig(const std::string& yaml) { AdmissionControlProto proto; TestUtility::loadFromYamlAndValidate(yaml, proto); auto tls = context_.threadLocal().allocateSlot(); diff --git a/test/extensions/filters/http/admission_control/success_criteria_evaluator_test.cc b/test/extensions/filters/http/admission_control/success_criteria_evaluator_test.cc index 888497a1363e9..57d2f074cd0d4 100644 --- a/test/extensions/filters/http/admission_control/success_criteria_evaluator_test.cc +++ b/test/extensions/filters/http/admission_control/success_criteria_evaluator_test.cc @@ -70,7 +70,7 @@ class SuccessCriteriaTest : public testing::Test { } protected: - std::unique_ptr evaluator_; + SuccessCriteriaEvaluatorPtr evaluator_; }; // Ensure the HTTP code successful range configurations are honored. diff --git a/test/extensions/filters/http/aws_lambda/aws_lambda_filter_test.cc b/test/extensions/filters/http/aws_lambda/aws_lambda_filter_test.cc index 0144f67269c45..a05a855b9a068 100644 --- a/test/extensions/filters/http/aws_lambda/aws_lambda_filter_test.cc +++ b/test/extensions/filters/http/aws_lambda/aws_lambda_filter_test.cc @@ -50,7 +50,7 @@ class AwsLambdaFilterTest : public ::testing::Test { ON_CALL(*decoder_callbacks_.cluster_info_, metadata()).WillByDefault(ReturnRef(metadata_)); } - std::unique_ptr filter_; + FilterPtr filter_; std::shared_ptr> signer_; NiceMock decoder_callbacks_; NiceMock encoder_callbacks_; diff --git a/test/extensions/filters/http/aws_lambda/config_test.cc b/test/extensions/filters/http/aws_lambda/config_test.cc index 178fe1ff7c6ad..84cc2ea5aab6f 100644 --- a/test/extensions/filters/http/aws_lambda/config_test.cc +++ b/test/extensions/filters/http/aws_lambda/config_test.cc @@ -36,7 +36,7 @@ invocation_mode: asynchronous Http::FilterFactoryCb cb = factory.createFilterFactoryFromProto(proto_config, "stats", context); Http::MockFilterChainFactoryCallbacks filter_callbacks; - auto has_expected_settings = [](std::shared_ptr stream_filter) { + auto has_expected_settings = [](Envoy::Http::StreamFilterSharedPtr stream_filter) { auto filter = std::static_pointer_cast(stream_filter); const auto settings = filter->settingsForTest(); return settings.payloadPassthrough() && @@ -64,7 +64,7 @@ arn: "arn:aws:lambda:region:424242:function:fun" Http::FilterFactoryCb cb = factory.createFilterFactoryFromProto(proto_config, "stats", context); Http::MockFilterChainFactoryCallbacks filter_callbacks; - auto has_expected_settings = [](std::shared_ptr stream_filter) { + auto has_expected_settings = [](Envoy::Http::StreamFilterSharedPtr stream_filter) { auto filter = std::static_pointer_cast(stream_filter); const auto settings = filter->settingsForTest(); return settings.payloadPassthrough() == false && diff --git a/test/extensions/filters/http/aws_request_signing/aws_request_signing_filter_test.cc b/test/extensions/filters/http/aws_request_signing/aws_request_signing_filter_test.cc index e53ec917318a3..4ab721897893d 100644 --- a/test/extensions/filters/http/aws_request_signing/aws_request_signing_filter_test.cc +++ b/test/extensions/filters/http/aws_request_signing/aws_request_signing_filter_test.cc @@ -35,7 +35,7 @@ class AwsRequestSigningFilterTest : public testing::Test { } std::shared_ptr filter_config_; - std::unique_ptr filter_; + FilterPtr filter_; }; // Verify filter functionality when signing works. diff --git a/test/extensions/filters/http/common/compressor/compressor_filter_test.cc b/test/extensions/filters/http/common/compressor/compressor_filter_test.cc index 225edcaeaa321..47d4109c3da7d 100644 --- a/test/extensions/filters/http/common/compressor/compressor_filter_test.cc +++ b/test/extensions/filters/http/common/compressor/compressor_filter_test.cc @@ -82,7 +82,7 @@ class CompressorFilterTest : public testing::Test { } bool isAcceptEncodingAllowed(const std::string accept_encoding, - const std::unique_ptr& filter = nullptr) { + const CompressorFilterPtr& filter = nullptr) { Http::TestResponseHeaderMapImpl headers; if (filter) { filter->accept_encoding_ = std::make_unique(accept_encoding); @@ -174,7 +174,7 @@ class CompressorFilterTest : public testing::Test { } std::shared_ptr config_; - std::unique_ptr filter_; + CompressorFilterPtr filter_; Buffer::OwnedImpl data_; std::string expected_str_; Stats::TestUtil::TestStore stats_; @@ -389,7 +389,7 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { CompressorFilterConfigSharedPtr config2; config2 = std::make_shared(compressor, "test2.", stats, runtime, "test2"); - std::unique_ptr filter2 = std::make_unique(config2); + CompressorFilterPtr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter2->setDecoderFilterCallbacks(decoder_callbacks); @@ -422,7 +422,7 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { CompressorFilterConfigSharedPtr config2; config2 = std::make_shared(compressor, "test2.", stats, runtime, "gzip"); - std::unique_ptr gzip_filter = std::make_unique(config2); + CompressorFilterPtr gzip_filter = std::make_unique(config2); NiceMock decoder_callbacks; gzip_filter->setDecoderFilterCallbacks(decoder_callbacks); @@ -451,7 +451,7 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { CompressorFilterConfigSharedPtr config2; config2 = std::make_shared(compressor, "test2.", stats, runtime, "test"); - std::unique_ptr filter2 = std::make_unique(config2); + CompressorFilterPtr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter2->setDecoderFilterCallbacks(decoder_callbacks); @@ -480,7 +480,7 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { CompressorFilterConfigSharedPtr config2; config2 = std::make_shared(compressor, "test2.", stats, runtime, "test"); - std::unique_ptr filter2 = std::make_unique(config2); + CompressorFilterPtr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter2->setDecoderFilterCallbacks(decoder_callbacks); @@ -509,11 +509,11 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { CompressorFilterConfigSharedPtr config1; config1 = std::make_shared(compressor, "test1.", stats, runtime, "test1"); - std::unique_ptr filter1 = std::make_unique(config1); + CompressorFilterPtr filter1 = std::make_unique(config1); CompressorFilterConfigSharedPtr config2; config2 = std::make_shared(compressor, "test2.", stats, runtime, "test2"); - std::unique_ptr filter2 = std::make_unique(config2); + CompressorFilterPtr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter1->setDecoderFilterCallbacks(decoder_callbacks); filter2->setDecoderFilterCallbacks(decoder_callbacks); @@ -548,11 +548,11 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { CompressorFilterConfigSharedPtr config1; config1 = std::make_shared(compressor, "test1.", stats, runtime, "test1"); - std::unique_ptr filter1 = std::make_unique(config1); + CompressorFilterPtr filter1 = std::make_unique(config1); CompressorFilterConfigSharedPtr config2; config2 = std::make_shared(compressor, "test2.", stats, runtime, "test2"); - std::unique_ptr filter2 = std::make_unique(config2); + CompressorFilterPtr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter1->setDecoderFilterCallbacks(decoder_callbacks); filter2->setDecoderFilterCallbacks(decoder_callbacks); diff --git a/test/extensions/filters/http/common/jwks_fetcher_test.cc b/test/extensions/filters/http/common/jwks_fetcher_test.cc index 6cfcd8f14af46..d30df4455a5ea 100644 --- a/test/extensions/filters/http/common/jwks_fetcher_test.cc +++ b/test/extensions/filters/http/common/jwks_fetcher_test.cc @@ -63,7 +63,7 @@ TEST_F(JwksFetcherTest, TestGetSuccess) { // Setup MockUpstream mock_pubkey(mock_factory_ctx_.cluster_manager_, "200", publicKey); MockJwksReceiver receiver; - std::unique_ptr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); + JwksFetcherPtr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); EXPECT_TRUE(fetcher != nullptr); EXPECT_CALL(receiver, onJwksSuccessImpl(testing::_)).Times(1); EXPECT_CALL(receiver, onJwksError(testing::_)).Times(0); @@ -76,7 +76,7 @@ TEST_F(JwksFetcherTest, TestGet400) { // Setup MockUpstream mock_pubkey(mock_factory_ctx_.cluster_manager_, "400", "invalid"); MockJwksReceiver receiver; - std::unique_ptr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); + JwksFetcherPtr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); EXPECT_TRUE(fetcher != nullptr); EXPECT_CALL(receiver, onJwksSuccessImpl(testing::_)).Times(0); EXPECT_CALL(receiver, onJwksError(JwksFetcher::JwksReceiver::Failure::Network)).Times(1); @@ -89,7 +89,7 @@ TEST_F(JwksFetcherTest, TestGetNoBody) { // Setup MockUpstream mock_pubkey(mock_factory_ctx_.cluster_manager_, "200", ""); MockJwksReceiver receiver; - std::unique_ptr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); + JwksFetcherPtr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); EXPECT_TRUE(fetcher != nullptr); EXPECT_CALL(receiver, onJwksSuccessImpl(testing::_)).Times(0); EXPECT_CALL(receiver, onJwksError(JwksFetcher::JwksReceiver::Failure::Network)).Times(1); @@ -102,7 +102,7 @@ TEST_F(JwksFetcherTest, TestGetInvalidJwks) { // Setup MockUpstream mock_pubkey(mock_factory_ctx_.cluster_manager_, "200", "invalid"); MockJwksReceiver receiver; - std::unique_ptr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); + JwksFetcherPtr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); EXPECT_TRUE(fetcher != nullptr); EXPECT_CALL(receiver, onJwksSuccessImpl(testing::_)).Times(0); EXPECT_CALL(receiver, onJwksError(JwksFetcher::JwksReceiver::Failure::InvalidJwks)).Times(1); @@ -116,7 +116,7 @@ TEST_F(JwksFetcherTest, TestHttpFailure) { MockUpstream mock_pubkey(mock_factory_ctx_.cluster_manager_, Http::AsyncClient::FailureReason::Reset); MockJwksReceiver receiver; - std::unique_ptr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); + JwksFetcherPtr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); EXPECT_TRUE(fetcher != nullptr); EXPECT_CALL(receiver, onJwksSuccessImpl(testing::_)).Times(0); EXPECT_CALL(receiver, onJwksError(JwksFetcher::JwksReceiver::Failure::Network)).Times(1); @@ -130,7 +130,7 @@ TEST_F(JwksFetcherTest, TestCancel) { Http::MockAsyncClientRequest request(&(mock_factory_ctx_.cluster_manager_.async_client_)); MockUpstream mock_pubkey(mock_factory_ctx_.cluster_manager_, &request); MockJwksReceiver receiver; - std::unique_ptr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); + JwksFetcherPtr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); EXPECT_TRUE(fetcher != nullptr); EXPECT_CALL(request, cancel()).Times(1); EXPECT_CALL(receiver, onJwksSuccessImpl(testing::_)).Times(0); @@ -148,7 +148,7 @@ TEST_F(JwksFetcherTest, TestSpanPassedDown) { // Setup MockUpstream mock_pubkey(mock_factory_ctx_.cluster_manager_, "200", publicKey); NiceMock receiver; - std::unique_ptr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); + JwksFetcherPtr fetcher(JwksFetcher::create(mock_factory_ctx_.cluster_manager_)); // Expectations for span EXPECT_CALL(mock_factory_ctx_.cluster_manager_.async_client_, send_(_, _, _)) diff --git a/test/extensions/filters/http/decompressor/decompressor_filter_test.cc b/test/extensions/filters/http/decompressor/decompressor_filter_test.cc index 3917ad0545950..79aa5662fe4d3 100644 --- a/test/extensions/filters/http/decompressor/decompressor_filter_test.cc +++ b/test/extensions/filters/http/decompressor/decompressor_filter_test.cc @@ -49,8 +49,8 @@ class DecompressorFilterTest : public testing::TestWithParam { bool isRequestDirection() { return GetParam(); } - std::unique_ptr doHeaders(const Http::HeaderMap& headers, - const bool end_stream) { + Http::RequestOrResponseHeaderMapPtr doHeaders(const Http::HeaderMap& headers, + const bool end_stream) { if (isRequestDirection()) { auto request_headers = std::make_unique(headers); EXPECT_EQ(Http::FilterHeadersStatus::Continue, @@ -105,7 +105,7 @@ class DecompressorFilterTest : public testing::TestWithParam { EXPECT_CALL(*decompressor_factory_, createDecompressor()) .WillOnce(Return(ByMove(std::move(decompressor)))); - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, false /* end_stream */); // The filter removes Content-Length @@ -134,7 +134,7 @@ class DecompressorFilterTest : public testing::TestWithParam { Compression::Decompressor::MockDecompressorFactory* decompressor_factory_{}; DecompressorFilterConfigSharedPtr config_; - std::unique_ptr filter_; + DecompressorFilterPtr filter_; Stats::TestUtil::TestStore stats_; NiceMock runtime_; NiceMock decoder_callbacks_; @@ -234,7 +234,7 @@ TEST_P(DecompressorFilterTest, DecompressionDisabled) { EXPECT_CALL(*decompressor_factory_, createDecompressor()).Times(0); Http::TestRequestHeaderMapImpl headers_before_filter{{"content-encoding", "mock"}, {"content-length", "256"}}; - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, false /* end_stream */); TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); @@ -258,7 +258,7 @@ TEST_P(DecompressorFilterTest, RequestDecompressionDisabled) { if (isRequestDirection()) { EXPECT_CALL(*decompressor_factory_, createDecompressor()).Times(0); - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, false /* end_stream */); TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); expectNoDecompression(); @@ -290,7 +290,7 @@ TEST_P(DecompressorFilterTest, ResponseDecompressionDisabled) { absl::nullopt /* expected_accept_encoding */); } else { EXPECT_CALL(*decompressor_factory_, createDecompressor()).Times(0); - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, false /* end_stream */); TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); expectNoDecompression(); @@ -300,7 +300,7 @@ TEST_P(DecompressorFilterTest, ResponseDecompressionDisabled) { TEST_P(DecompressorFilterTest, NoDecompressionHeadersOnly) { EXPECT_CALL(*decompressor_factory_, createDecompressor()).Times(0); Http::TestRequestHeaderMapImpl headers_before_filter; - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, true /* end_stream */); TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); } @@ -308,7 +308,7 @@ TEST_P(DecompressorFilterTest, NoDecompressionHeadersOnly) { TEST_P(DecompressorFilterTest, NoDecompressionContentEncodingAbsent) { EXPECT_CALL(*decompressor_factory_, createDecompressor()).Times(0); Http::TestRequestHeaderMapImpl headers_before_filter{{"content-length", "256"}}; - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, false /* end_stream */); TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); @@ -319,7 +319,7 @@ TEST_P(DecompressorFilterTest, NoDecompressionContentEncodingDoesNotMatch) { EXPECT_CALL(*decompressor_factory_, createDecompressor()).Times(0); Http::TestRequestHeaderMapImpl headers_before_filter{{"content-encoding", "not-matching"}, {"content-length", "256"}}; - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, false /* end_stream */); TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); @@ -332,7 +332,7 @@ TEST_P(DecompressorFilterTest, NoDecompressionContentEncodingNotCurrent) { // Content-Encoding header. Therefore, compression will not occur. Http::TestRequestHeaderMapImpl headers_before_filter{{"content-encoding", "gzip,mock"}, {"content-length", "256"}}; - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, false /* end_stream */); TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); @@ -345,7 +345,7 @@ TEST_P(DecompressorFilterTest, NoResponseDecompressionNoTransformPresent) { {"cache-control", Http::Headers::get().CacheControlValues.NoTransform}, {"content-encoding", "mock"}, {"content-length", "256"}}; - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, false /* end_stream */); TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); @@ -359,7 +359,7 @@ TEST_P(DecompressorFilterTest, NoResponseDecompressionNoTransformPresentInList) Http::Headers::get().CacheControlValues.NoTransform)}, {"content-encoding", "mock"}, {"content-length", "256"}}; - std::unique_ptr headers_after_filter = + Http::RequestOrResponseHeaderMapPtr headers_after_filter = doHeaders(headers_before_filter, false /* end_stream */); TestUtility::headerMapEqualIgnoreOrder(headers_before_filter, *headers_after_filter); diff --git a/test/extensions/filters/http/dynamic_forward_proxy/proxy_filter_test.cc b/test/extensions/filters/http/dynamic_forward_proxy/proxy_filter_test.cc index 17dd35d8cd3ef..491c48561a54b 100644 --- a/test/extensions/filters/http/dynamic_forward_proxy/proxy_filter_test.cc +++ b/test/extensions/filters/http/dynamic_forward_proxy/proxy_filter_test.cc @@ -62,7 +62,7 @@ class ProxyFilterTest : public testing::Test, NiceMock* transport_socket_match_; Upstream::MockClusterManager cm_; ProxyFilterConfigSharedPtr filter_config_; - std::unique_ptr filter_; + ProxyFilterPtr filter_; Http::MockStreamDecoderFilterCallbacks callbacks_; Http::TestRequestHeaderMapImpl request_headers_{{":authority", "foo"}}; }; diff --git a/test/extensions/filters/http/dynamo/dynamo_filter_test.cc b/test/extensions/filters/http/dynamo/dynamo_filter_test.cc index 29df4be7e78c7..3bdaecbffcb0b 100644 --- a/test/extensions/filters/http/dynamo/dynamo_filter_test.cc +++ b/test/extensions/filters/http/dynamo/dynamo_filter_test.cc @@ -44,7 +44,7 @@ class DynamoFilterTest : public testing::Test { ~DynamoFilterTest() override { filter_->onDestroy(); } NiceMock stats_; - std::unique_ptr filter_; + DynamoFilterPtr filter_; NiceMock loader_; std::string stat_prefix_{"prefix."}; NiceMock decoder_callbacks_; diff --git a/test/extensions/filters/http/ext_authz/ext_authz_test.cc b/test/extensions/filters/http/ext_authz/ext_authz_test.cc index b5236920fb67e..1b164758d6add 100644 --- a/test/extensions/filters/http/ext_authz/ext_authz_test.cc +++ b/test/extensions/filters/http/ext_authz/ext_authz_test.cc @@ -76,7 +76,7 @@ template class HttpFilterTestBase : public T { NiceMock stats_store_; FilterConfigSharedPtr config_; Filters::Common::ExtAuthz::MockClient* client_; - std::unique_ptr filter_; + FilterPtr filter_; NiceMock filter_callbacks_; Filters::Common::ExtAuthz::RequestCallbacks* request_callbacks_; Http::TestRequestHeaderMapImpl request_headers_; diff --git a/test/extensions/filters/http/fault/fault_filter_test.cc b/test/extensions/filters/http/fault/fault_filter_test.cc index a29c5cc858161..24459e9af7c7a 100644 --- a/test/extensions/filters/http/fault/fault_filter_test.cc +++ b/test/extensions/filters/http/fault/fault_filter_test.cc @@ -148,7 +148,7 @@ class FaultFilterTest : public testing::Test { NiceMock stats_; FaultFilterConfigSharedPtr config_; - std::unique_ptr filter_; + FaultFilterPtr filter_; NiceMock decoder_filter_callbacks_; NiceMock encoder_filter_callbacks_; Http::TestRequestHeaderMapImpl request_headers_; diff --git a/test/extensions/filters/http/grpc_http1_reverse_bridge/reverse_bridge_test.cc b/test/extensions/filters/http/grpc_http1_reverse_bridge/reverse_bridge_test.cc index f78a81d6a3a56..43c32ca1d3f76 100644 --- a/test/extensions/filters/http/grpc_http1_reverse_bridge/reverse_bridge_test.cc +++ b/test/extensions/filters/http/grpc_http1_reverse_bridge/reverse_bridge_test.cc @@ -38,7 +38,7 @@ class ReverseBridgeTest : public testing::Test { filter_->setEncoderFilterCallbacks(encoder_callbacks_); } - std::unique_ptr filter_; + FilterPtr filter_; std::shared_ptr route_ = std::make_shared(); Router::RouteSpecificFilterConfig filter_config_; Http::MockStreamDecoderFilterCallbacks decoder_callbacks_; diff --git a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc index bb72aee464548..5067ec96722ef 100644 --- a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc +++ b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc @@ -195,7 +195,7 @@ TEST_F(GrpcJsonTranscoderConfigTest, CreateTranscoder) { Http::TestRequestHeaderMapImpl headers{{":method", "GET"}, {":path", "/shelves"}}; TranscoderInputStreamImpl request_in, response_in; - std::unique_ptr transcoder; + TranscoderPtr transcoder; MethodInfoSharedPtr method_info; const auto status = config.createTranscoder(headers, request_in, response_in, transcoder, method_info); @@ -216,7 +216,7 @@ TEST_F(GrpcJsonTranscoderConfigTest, CreateTranscoderAutoMap) { {":path", "/bookstore.Bookstore/DeleteShelf"}}; TranscoderInputStreamImpl request_in, response_in; - std::unique_ptr transcoder; + TranscoderPtr transcoder; MethodInfoSharedPtr method_info; const auto status = config.createTranscoder(headers, request_in, response_in, transcoder, method_info); @@ -235,7 +235,7 @@ TEST_F(GrpcJsonTranscoderConfigTest, InvalidQueryParameter) { Http::TestRequestHeaderMapImpl headers{{":method", "GET"}, {":path", "/shelves?foo=bar"}}; TranscoderInputStreamImpl request_in, response_in; - std::unique_ptr transcoder; + TranscoderPtr transcoder; MethodInfoSharedPtr method_info; const auto status = config.createTranscoder(headers, request_in, response_in, transcoder, method_info); @@ -255,7 +255,7 @@ TEST_F(GrpcJsonTranscoderConfigTest, UnknownQueryParameterIsIgnored) { Http::TestRequestHeaderMapImpl headers{{":method", "GET"}, {":path", "/shelves?foo=bar"}}; TranscoderInputStreamImpl request_in, response_in; - std::unique_ptr transcoder; + TranscoderPtr transcoder; MethodInfoSharedPtr method_info; const auto status = config.createTranscoder(headers, request_in, response_in, transcoder, method_info); @@ -274,7 +274,7 @@ TEST_F(GrpcJsonTranscoderConfigTest, IgnoredQueryParameter) { Http::TestRequestHeaderMapImpl headers{{":method", "GET"}, {":path", "/shelves?key=API_KEY"}}; TranscoderInputStreamImpl request_in, response_in; - std::unique_ptr transcoder; + TranscoderPtr transcoder; MethodInfoSharedPtr method_info; const auto status = config.createTranscoder(headers, request_in, response_in, transcoder, method_info); @@ -296,7 +296,7 @@ TEST_F(GrpcJsonTranscoderConfigTest, InvalidVariableBinding) { Http::TestRequestHeaderMapImpl headers{{":method", "GET"}, {":path", "/book/1"}}; TranscoderInputStreamImpl request_in, response_in; - std::unique_ptr transcoder; + TranscoderPtr transcoder; MethodInfoSharedPtr method_info; const auto status = config.createTranscoder(headers, request_in, response_in, transcoder, method_info); diff --git a/test/extensions/filters/http/grpc_stats/config_test.cc b/test/extensions/filters/http/grpc_stats/config_test.cc index b75737b06cd28..98667baf52b2a 100644 --- a/test/extensions/filters/http/grpc_stats/config_test.cc +++ b/test/extensions/filters/http/grpc_stats/config_test.cc @@ -64,7 +64,7 @@ class GrpcStatsFilterConfigTest : public testing::Test { envoy::extensions::filters::http::grpc_stats::v3::FilterConfig config_; NiceMock context_; - std::shared_ptr filter_; + Http::StreamFilterSharedPtr filter_; NiceMock decoder_callbacks_; NiceMock stream_info_; NiceMock stats_store_; diff --git a/test/extensions/filters/http/gzip/gzip_filter_test.cc b/test/extensions/filters/http/gzip/gzip_filter_test.cc index c576b6c1cb7fe..94a1065b81699 100644 --- a/test/extensions/filters/http/gzip/gzip_filter_test.cc +++ b/test/extensions/filters/http/gzip/gzip_filter_test.cc @@ -156,8 +156,8 @@ class GzipFilterTest : public testing::Test { EXPECT_EQ(1, stats_.counter("test.gzip.not_compressed").value()); } - std::shared_ptr config_; - std::unique_ptr filter_; + GzipFilterConfigSharedPtr config_; + Common::Compressors::CompressorFilterPtr filter_; Buffer::OwnedImpl data_; Compression::Gzip::Decompressor::ZlibDecompressorImpl decompressor_; Buffer::OwnedImpl decompressed_data_; diff --git a/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc b/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc index 493bdd465dca1..f180613f9e59d 100644 --- a/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc +++ b/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc @@ -83,7 +83,7 @@ class HeaderToMetadataTest : public testing::Test { const Config* getConfig() { return filter_->getConfig(); } ConfigSharedPtr config_; - std::shared_ptr filter_; + HeaderToMetadataFilterSharedPtr filter_; NiceMock decoder_callbacks_; NiceMock encoder_callbacks_; NiceMock req_info_; diff --git a/test/extensions/filters/http/health_check/health_check_test.cc b/test/extensions/filters/http/health_check/health_check_test.cc index 16393b403359a..27d98fbfddb42 100644 --- a/test/extensions/filters/http/health_check/health_check_test.cc +++ b/test/extensions/filters/http/health_check/health_check_test.cc @@ -61,7 +61,7 @@ class HealthCheckFilterTest : public testing::Test { Event::MockTimer* cache_timer_{}; Event::MockDispatcher dispatcher_; HealthCheckCacheManagerSharedPtr cache_manager_; - std::unique_ptr filter_; + HealthCheckFilterPtr filter_; NiceMock callbacks_; Http::TestRequestHeaderMapImpl request_headers_; Http::TestRequestHeaderMapImpl request_headers_no_hc_; diff --git a/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc b/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc index 492600503f607..b9019f0c08487 100644 --- a/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc +++ b/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc @@ -53,7 +53,7 @@ request_type: internal NiceMock stats_; IpTaggingFilterConfigSharedPtr config_; - std::unique_ptr filter_; + IpTaggingFilterPtr filter_; NiceMock filter_callbacks_; Buffer::OwnedImpl data_; NiceMock runtime_; diff --git a/test/extensions/filters/http/jwt_authn/all_verifier_test.cc b/test/extensions/filters/http/jwt_authn/all_verifier_test.cc index 148550c1a2ebb..cb2a34bba1efa 100644 --- a/test/extensions/filters/http/jwt_authn/all_verifier_test.cc +++ b/test/extensions/filters/http/jwt_authn/all_verifier_test.cc @@ -83,7 +83,7 @@ class AllVerifierTest : public testing::Test { } JwtAuthentication proto_config_; - std::shared_ptr filter_config_; + FilterConfigImplSharedPtr filter_config_; VerifierConstPtr verifier_; NiceMock mock_factory_ctx_; ContextSharedPtr context_; diff --git a/test/extensions/filters/http/jwt_authn/authenticator_test.cc b/test/extensions/filters/http/jwt_authn/authenticator_test.cc index 1cf6c1e893556..996a98e989175 100644 --- a/test/extensions/filters/http/jwt_authn/authenticator_test.cc +++ b/test/extensions/filters/http/jwt_authn/authenticator_test.cc @@ -77,7 +77,7 @@ class AuthenticatorTest : public testing::Test { JwtAuthentication proto_config_; ExtractorConstPtr extractor_; - std::shared_ptr filter_config_; + FilterConfigImplSharedPtr filter_config_; MockJwksFetcher* raw_fetcher_; JwksFetcherPtr fetcher_; AuthenticatorPtr auth_; diff --git a/test/extensions/filters/http/jwt_authn/filter_test.cc b/test/extensions/filters/http/jwt_authn/filter_test.cc index 9881cd25bab20..ff0439e0e841d 100644 --- a/test/extensions/filters/http/jwt_authn/filter_test.cc +++ b/test/extensions/filters/http/jwt_authn/filter_test.cc @@ -66,7 +66,7 @@ class FilterTest : public testing::Test { std::shared_ptr> mock_config_; NiceMock filter_callbacks_; - std::unique_ptr filter_; + FilterPtr filter_; std::unique_ptr mock_verifier_; NiceMock verifier_callback_; Http::TestRequestTrailerMapImpl trailers_; diff --git a/test/extensions/filters/http/jwt_authn/provider_verifier_test.cc b/test/extensions/filters/http/jwt_authn/provider_verifier_test.cc index ef6f24de8785a..41937856af57b 100644 --- a/test/extensions/filters/http/jwt_authn/provider_verifier_test.cc +++ b/test/extensions/filters/http/jwt_authn/provider_verifier_test.cc @@ -40,7 +40,7 @@ class ProviderVerifierTest : public testing::Test { } JwtAuthentication proto_config_; - std::shared_ptr filter_config_; + FilterConfigImplSharedPtr filter_config_; VerifierConstPtr verifier_; NiceMock mock_factory_ctx_; ContextSharedPtr context_; diff --git a/test/extensions/filters/http/lua/lua_filter_test.cc b/test/extensions/filters/http/lua/lua_filter_test.cc index a2ee0a2f03caa..20da49d00a7e3 100644 --- a/test/extensions/filters/http/lua/lua_filter_test.cc +++ b/test/extensions/filters/http/lua/lua_filter_test.cc @@ -95,7 +95,7 @@ class LuaHttpFilterTest : public testing::Test { NiceMock tls_; Upstream::MockClusterManager cluster_manager_; - std::shared_ptr config_; + FilterConfigSharedPtr config_; std::unique_ptr filter_; Http::MockStreamDecoderFilterCallbacks decoder_callbacks_; Http::MockStreamEncoderFilterCallbacks encoder_callbacks_; diff --git a/test/extensions/filters/http/on_demand/on_demand_filter_test.cc b/test/extensions/filters/http/on_demand/on_demand_filter_test.cc index d226ee4dcec60..77592f962d5e9 100644 --- a/test/extensions/filters/http/on_demand/on_demand_filter_test.cc +++ b/test/extensions/filters/http/on_demand/on_demand_filter_test.cc @@ -25,7 +25,7 @@ class OnDemandFilterTest : public testing::Test { filter_->setDecoderFilterCallbacks(decoder_callbacks_); } - std::unique_ptr filter_; + OnDemandRouteUpdatePtr filter_; NiceMock decoder_callbacks_; }; diff --git a/test/extensions/filters/http/original_src/original_src_test.cc b/test/extensions/filters/http/original_src/original_src_test.cc index def891c4094cb..9bebaadb125c3 100644 --- a/test/extensions/filters/http/original_src/original_src_test.cc +++ b/test/extensions/filters/http/original_src/original_src_test.cc @@ -28,19 +28,16 @@ namespace { class OriginalSrcHttpTest : public testing::Test { public: - std::unique_ptr makeDefaultFilter() { - return makeFilterWithCallbacks(callbacks_); - } + OriginalSrcFilterPtr makeDefaultFilter() { return makeFilterWithCallbacks(callbacks_); } - std::unique_ptr - makeFilterWithCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) { + OriginalSrcFilterPtr makeFilterWithCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) { const Config default_config; auto filter = std::make_unique(default_config); filter->setDecoderFilterCallbacks(callbacks); return filter; } - std::unique_ptr makeMarkingFilter(uint32_t mark) { + OriginalSrcFilterPtr makeMarkingFilter(uint32_t mark) { envoy::extensions::filters::http::original_src::v3::OriginalSrc proto_config; proto_config.set_mark(mark); diff --git a/test/extensions/filters/http/ratelimit/ratelimit_test.cc b/test/extensions/filters/http/ratelimit/ratelimit_test.cc index b177409534a5e..8df12b3cc3cfa 100644 --- a/test/extensions/filters/http/ratelimit/ratelimit_test.cc +++ b/test/extensions/filters/http/ratelimit/ratelimit_test.cc @@ -96,7 +96,7 @@ class HttpRateLimitFilterTest : public testing::Test { Buffer::OwnedImpl response_data_; NiceMock stats_store_; FilterConfigSharedPtr config_; - std::unique_ptr filter_; + FilterPtr filter_; NiceMock runtime_; NiceMock route_rate_limit_; NiceMock vh_rate_limit_; diff --git a/test/extensions/filters/http/squash/squash_filter_test.cc b/test/extensions/filters/http/squash/squash_filter_test.cc index d2cb53bf52b63..0ef37d46709df 100644 --- a/test/extensions/filters/http/squash/squash_filter_test.cc +++ b/test/extensions/filters/http/squash/squash_filter_test.cc @@ -252,7 +252,7 @@ class SquashFilterTest : public testing::Test { NiceMock cm_; Envoy::Http::MockAsyncClientRequest request_; SquashFilterConfigSharedPtr config_; - std::shared_ptr filter_; + SquashFilterSharedPtr filter_; std::deque callbacks_; }; diff --git a/test/extensions/filters/http/tap/tap_config_impl_test.cc b/test/extensions/filters/http/tap/tap_config_impl_test.cc index 2033c1cd240d3..db4488b879c34 100644 --- a/test/extensions/filters/http/tap/tap_config_impl_test.cc +++ b/test/extensions/filters/http/tap/tap_config_impl_test.cc @@ -34,7 +34,7 @@ class HttpPerRequestTapperImplTest : public testing::Test { // Raw pointer, returned via mock to unique_ptr. TapCommon::MockPerTapSinkHandleManager* sink_manager_ = new TapCommon::MockPerTapSinkHandleManager; - std::unique_ptr tapper_; + HttpPerRequestTapperImplPtr tapper_; std::vector matchers_{1}; TapCommon::MockMatcher matcher_{matchers_}; TapCommon::Matcher::MatchStatusVector* statuses_; diff --git a/test/extensions/filters/http/tap/tap_filter_test.cc b/test/extensions/filters/http/tap/tap_filter_test.cc index 1f305ddbe79e6..51289d95ba097 100644 --- a/test/extensions/filters/http/tap/tap_filter_test.cc +++ b/test/extensions/filters/http/tap/tap_filter_test.cc @@ -62,7 +62,7 @@ class TapFilterTest : public testing::Test { std::shared_ptr filter_config_{new MockFilterConfig()}; std::shared_ptr http_tap_config_; MockHttpPerRequestTapper* http_per_request_tapper_; - std::unique_ptr filter_; + FilterPtr filter_; StreamInfo::MockStreamInfo stream_info_; Http::MockStreamDecoderFilterCallbacks callbacks_; }; diff --git a/test/extensions/filters/listener/http_inspector/http_inspector_test.cc b/test/extensions/filters/listener/http_inspector/http_inspector_test.cc index 0467a35ef8446..2f376dfc75e82 100644 --- a/test/extensions/filters/listener/http_inspector/http_inspector_test.cc +++ b/test/extensions/filters/listener/http_inspector/http_inspector_test.cc @@ -59,7 +59,7 @@ class HttpInspectorTest : public testing::Test { TestThreadsafeSingletonInjector os_calls_{&os_sys_calls_}; Stats::IsolatedStoreImpl store_; ConfigSharedPtr cfg_; - std::unique_ptr filter_; + FilterPtr filter_; Network::MockListenerFilterCallbacks cb_; Network::MockConnectionSocket socket_; NiceMock dispatcher_; diff --git a/test/extensions/filters/listener/original_src/original_src_test.cc b/test/extensions/filters/listener/original_src/original_src_test.cc index 0e9180012fc27..bea0f195d43c8 100644 --- a/test/extensions/filters/listener/original_src/original_src_test.cc +++ b/test/extensions/filters/listener/original_src/original_src_test.cc @@ -25,12 +25,12 @@ namespace { class OriginalSrcTest : public testing::Test { public: - std::unique_ptr makeDefaultFilter() { + OriginalSrcFilterPtr makeDefaultFilter() { Config default_config; return std::make_unique(default_config); } - std::unique_ptr makeMarkingFilter(uint32_t mark) { + OriginalSrcFilterPtr makeMarkingFilter(uint32_t mark) { envoy::extensions::filters::listener::original_src::v3::OriginalSrc proto_config; proto_config.set_mark(mark); diff --git a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc index 75d52d3b42352..77c5b51e68b2c 100644 --- a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc +++ b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc @@ -174,7 +174,7 @@ class ProxyProtocolTest : public testing::TestWithParam socket_; + Network::TcpListenSocketSharedPtr socket_; Network::MockListenSocketFactory socket_factory_; Network::NopConnectionBalancerImpl connection_balancer_; Network::ConnectionHandlerPtr connection_handler_; @@ -1090,7 +1090,7 @@ class WildcardProxyProtocolTest : public testing::TestWithParam socket_; + Network::TcpListenSocketSharedPtr socket_; Network::Address::InstanceConstSharedPtr local_dst_address_; Network::NopConnectionBalancerImpl connection_balancer_; Network::ConnectionHandlerPtr connection_handler_; diff --git a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc index d16303dc8d5b8..d6fe3c103c34b 100644 --- a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc +++ b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc @@ -60,7 +60,7 @@ class TlsInspectorTest : public testing::TestWithParam os_calls_{&os_sys_calls_}; Stats::IsolatedStoreImpl store_; ConfigSharedPtr cfg_; - std::unique_ptr filter_; + FilterPtr filter_; Network::MockListenerFilterCallbacks cb_; Network::MockConnectionSocket socket_; NiceMock dispatcher_; diff --git a/test/extensions/filters/network/client_ssl_auth/client_ssl_auth_test.cc b/test/extensions/filters/network/client_ssl_auth/client_ssl_auth_test.cc index 634d780a01709..37c02989517e3 100644 --- a/test/extensions/filters/network/client_ssl_auth/client_ssl_auth_test.cc +++ b/test/extensions/filters/network/client_ssl_auth/client_ssl_auth_test.cc @@ -109,7 +109,7 @@ stat_prefix: vpn Http::MockAsyncClientRequest request_; ClientSslAuthConfigSharedPtr config_; NiceMock filter_callbacks_; - std::unique_ptr instance_; + ClientSslAuthFilterPtr instance_; Event::MockTimer* interval_timer_; Http::AsyncClient::Callbacks* callbacks_; Stats::TestUtil::TestStore stats_store_; diff --git a/test/extensions/filters/network/common/redis/client_impl_test.cc b/test/extensions/filters/network/common/redis/client_impl_test.cc index c9028a1da42ac..75016b589c279 100644 --- a/test/extensions/filters/network/common/redis/client_impl_test.cc +++ b/test/extensions/filters/network/common/redis/client_impl_test.cc @@ -56,7 +56,7 @@ class RedisClientImplTest : public testing::Test, finishSetup(); } - void setup(std::unique_ptr&& config) { + void setup(ConfigPtr&& config) { config_ = std::move(config); finishSetup(); } @@ -138,7 +138,7 @@ class RedisClientImplTest : public testing::Test, Common::Redis::DecoderCallbacks* callbacks_{}; NiceMock* upstream_connection_{}; Network::ReadFilterSharedPtr upstream_read_filter_; - std::unique_ptr config_; + ConfigPtr config_; ClientPtr client_; NiceMock stats_; Stats::ScopePtr stats_scope_; diff --git a/test/extensions/filters/network/dubbo_proxy/conn_manager_test.cc b/test/extensions/filters/network/dubbo_proxy/conn_manager_test.cc index 226a9bc5161b7..858c11e857af1 100644 --- a/test/extensions/filters/network/dubbo_proxy/conn_manager_test.cc +++ b/test/extensions/filters/network/dubbo_proxy/conn_manager_test.cc @@ -319,7 +319,7 @@ class ConnectionManagerTest : public testing::Test { Buffer::OwnedImpl write_buffer_; NiceMock filter_callbacks_; NiceMock random_; - std::unique_ptr conn_manager_; + ConnectionManagerPtr conn_manager_; MockSerializer* custom_serializer_{}; MockProtocol* custom_protocol_{}; }; diff --git a/test/extensions/filters/network/dubbo_proxy/dubbo_hessian2_serializer_impl_test.cc b/test/extensions/filters/network/dubbo_proxy/dubbo_hessian2_serializer_impl_test.cc index 17a500b4719bf..7be6bda337e0f 100644 --- a/test/extensions/filters/network/dubbo_proxy/dubbo_hessian2_serializer_impl_test.cc +++ b/test/extensions/filters/network/dubbo_proxy/dubbo_hessian2_serializer_impl_test.cc @@ -31,7 +31,7 @@ TEST(HessianProtocolTest, deserializeRpcInvocation) { 0x05, '0', '.', '0', '.', '0', // Service version 0x04, 't', 'e', 's', 't', // method name })); - std::shared_ptr context = std::make_shared(); + ContextImplSharedPtr context = std::make_shared(); context->set_body_size(buffer.length()); auto result = serializer.deserializeRpcInvocation(buffer, context); EXPECT_TRUE(result.second); @@ -53,7 +53,7 @@ TEST(HessianProtocolTest, deserializeRpcInvocation) { })); std::string exception_string = fmt::format("RpcInvocation size({}) large than body size({})", buffer.length(), buffer.length() - 1); - std::shared_ptr context = std::make_shared(); + ContextImplSharedPtr context = std::make_shared(); context->set_body_size(buffer.length() - 1); EXPECT_THROW_WITH_MESSAGE(serializer.deserializeRpcInvocation(buffer, context), EnvoyException, exception_string); @@ -62,7 +62,7 @@ TEST(HessianProtocolTest, deserializeRpcInvocation) { TEST(HessianProtocolTest, deserializeRpcResult) { DubboHessian2SerializerImpl serializer; - std::shared_ptr context = std::make_shared(); + ContextImplSharedPtr context = std::make_shared(); { Buffer::OwnedImpl buffer; @@ -179,7 +179,7 @@ TEST(HessianProtocolTest, serializeRpcResult) { EXPECT_EQ(buffer.length(), hessian_int_size + hessian_string_size); size_t body_size = mock_response.size() + sizeof(mock_response_type); - std::shared_ptr context = std::make_shared(); + ContextImplSharedPtr context = std::make_shared(); context->set_body_size(body_size); auto result = serializer.deserializeRpcResult(buffer, context); EXPECT_TRUE(result.first->hasException()); diff --git a/test/extensions/filters/network/dubbo_proxy/router_test.cc b/test/extensions/filters/network/dubbo_proxy/router_test.cc index 26405ea3a6b1f..f815b09cf3d62 100644 --- a/test/extensions/filters/network/dubbo_proxy/router_test.cc +++ b/test/extensions/filters/network/dubbo_proxy/router_test.cc @@ -220,7 +220,7 @@ class DubboRouterTestBase { Tcp::ConnectionPool::ConnectionStatePtr conn_state_; RouteConstSharedPtr route_ptr_; - std::unique_ptr router_; + RouterPtr router_; std::string cluster_name_{"cluster"}; diff --git a/test/extensions/filters/network/ext_authz/ext_authz_test.cc b/test/extensions/filters/network/ext_authz/ext_authz_test.cc index 47a208dc8c3bd..78053d6e02e29 100644 --- a/test/extensions/filters/network/ext_authz/ext_authz_test.cc +++ b/test/extensions/filters/network/ext_authz/ext_authz_test.cc @@ -78,7 +78,7 @@ class ExtAuthzFilterTest : public testing::Test { Stats::TestUtil::TestStore stats_store_; ConfigSharedPtr config_; Filters::Common::ExtAuthz::MockClient* client_; - std::unique_ptr filter_; + FilterPtr filter_; NiceMock filter_callbacks_; Network::Address::InstanceConstSharedPtr addr_; Filters::Common::ExtAuthz::RequestCallbacks* request_callbacks_{}; diff --git a/test/extensions/filters/network/kafka/request_codec_integration_test.cc b/test/extensions/filters/network/kafka/request_codec_integration_test.cc index 8a7ae9b7a7a36..efedd185c138a 100644 --- a/test/extensions/filters/network/kafka/request_codec_integration_test.cc +++ b/test/extensions/filters/network/kafka/request_codec_integration_test.cc @@ -51,7 +51,7 @@ TEST_F(RequestCodecIntegrationTest, ShouldProduceAbortedMessageOnUnknownData) { ASSERT_EQ(parse_failures.size(), sent_headers.size()); for (size_t i = 0; i < parse_failures.size(); ++i) { - const std::shared_ptr failure_data = + const RequestParseFailureSharedPtr failure_data = std::dynamic_pointer_cast(parse_failures[i]); ASSERT_NE(failure_data, nullptr); ASSERT_EQ(failure_data->request_header_, sent_headers[i]); diff --git a/test/extensions/filters/network/mysql_proxy/mysql_filter_test.cc b/test/extensions/filters/network/mysql_proxy/mysql_filter_test.cc index 968db699f72c9..06d9334878693 100644 --- a/test/extensions/filters/network/mysql_proxy/mysql_filter_test.cc +++ b/test/extensions/filters/network/mysql_proxy/mysql_filter_test.cc @@ -28,7 +28,7 @@ class MySQLFilterTest : public testing::Test, public MySQLTestUtils { } MySQLFilterConfigSharedPtr config_; - std::unique_ptr filter_; + MySQLFilterPtr filter_; Stats::IsolatedStoreImpl scope_; std::string stat_prefix_{"test."}; NiceMock filter_callbacks_; diff --git a/test/extensions/filters/network/postgres_proxy/postgres_decoder_test.cc b/test/extensions/filters/network/postgres_proxy/postgres_decoder_test.cc index 0714e5fd99749..82804ad5f54be 100644 --- a/test/extensions/filters/network/postgres_proxy/postgres_decoder_test.cc +++ b/test/extensions/filters/network/postgres_proxy/postgres_decoder_test.cc @@ -36,7 +36,7 @@ class PostgresProxyDecoderTestBase { protected: ::testing::NiceMock callbacks_; - std::unique_ptr decoder_; + DecoderImplPtr decoder_; // fields often used Buffer::OwnedImpl data_; diff --git a/test/extensions/filters/network/postgres_proxy/postgres_filter_test.cc b/test/extensions/filters/network/postgres_proxy/postgres_filter_test.cc index c44d32bf94c32..cd176b7c82d4c 100644 --- a/test/extensions/filters/network/postgres_proxy/postgres_filter_test.cc +++ b/test/extensions/filters/network/postgres_proxy/postgres_filter_test.cc @@ -37,7 +37,7 @@ class PostgresFilterTest Stats::IsolatedStoreImpl scope_; std::string stat_prefix_{"test."}; - std::unique_ptr filter_; + PostgresFilterPtr filter_; PostgresFilterConfigSharedPtr config_; NiceMock filter_callbacks_; diff --git a/test/extensions/filters/network/ratelimit/ratelimit_test.cc b/test/extensions/filters/network/ratelimit/ratelimit_test.cc index e77f6080cba8d..3334fba45ecd7 100644 --- a/test/extensions/filters/network/ratelimit/ratelimit_test.cc +++ b/test/extensions/filters/network/ratelimit/ratelimit_test.cc @@ -90,7 +90,7 @@ failure_mode_deny: true NiceMock runtime_; ConfigSharedPtr config_; Filters::Common::RateLimit::MockClient* client_; - std::unique_ptr filter_; + FilterPtr filter_; NiceMock filter_callbacks_; Filters::Common::RateLimit::RequestCallbacks* request_callbacks_{}; }; diff --git a/test/extensions/filters/network/rbac/filter_test.cc b/test/extensions/filters/network/rbac/filter_test.cc index 2e8fd2642da33..cd24b8f8a77cf 100644 --- a/test/extensions/filters/network/rbac/filter_test.cc +++ b/test/extensions/filters/network/rbac/filter_test.cc @@ -87,7 +87,7 @@ class RoleBasedAccessControlNetworkFilterTest : public testing::Test { Buffer::OwnedImpl data_; RoleBasedAccessControlFilterConfigSharedPtr config_; - std::unique_ptr filter_; + RoleBasedAccessControlFilterPtr filter_; Network::Address::InstanceConstSharedPtr address_; std::string requested_server_name_; }; diff --git a/test/extensions/filters/network/redis_proxy/conn_pool_impl_test.cc b/test/extensions/filters/network/redis_proxy/conn_pool_impl_test.cc index 639a9b8313c88..9c4aeb9f260ee 100644 --- a/test/extensions/filters/network/redis_proxy/conn_pool_impl_test.cc +++ b/test/extensions/filters/network/redis_proxy/conn_pool_impl_test.cc @@ -78,7 +78,7 @@ class RedisConnPoolImplTest : public testing::Test, public Common::Redis::Client std::make_shared>(); auto redis_command_stats = Common::Redis::RedisCommandStats::createRedisCommandStats(store->symbolTable()); - std::unique_ptr conn_pool_impl = std::make_unique( + InstanceImplPtr conn_pool_impl = std::make_unique( cluster_name_, cm_, *this, tls_, Common::Redis::Client::createConnPoolSettings(20, hashtagging, true, max_unknown_conns, read_policy_), @@ -269,7 +269,7 @@ class RedisConnPoolImplTest : public testing::Test, public Common::Redis::Client const std::string cluster_name_{"fake_cluster"}; NiceMock cm_; NiceMock tls_; - std::shared_ptr conn_pool_; + InstanceImplSharedPtr conn_pool_; Upstream::ClusterUpdateCallbacks* update_callbacks_{}; Common::Redis::Client::MockClient* client_{}; Network::Address::InstanceConstSharedPtr test_address_; @@ -574,7 +574,7 @@ TEST_F(RedisConnPoolImplTest, DeleteFollowedByClusterUpdateCallback) { setup(); conn_pool_.reset(); - std::shared_ptr host(new Upstream::MockHost()); + Upstream::HostSharedPtr host(new Upstream::MockHost()); cm_.thread_local_cluster_.cluster_.prioritySet().getMockHostSet(0)->runCallbacks({}, {host}); } diff --git a/test/extensions/filters/network/redis_proxy/proxy_filter_test.cc b/test/extensions/filters/network/redis_proxy/proxy_filter_test.cc index 72cebf97fcd28..f0cfcbe8c9914 100644 --- a/test/extensions/filters/network/redis_proxy/proxy_filter_test.cc +++ b/test/extensions/filters/network/redis_proxy/proxy_filter_test.cc @@ -144,7 +144,7 @@ class RedisProxyFilterTest : public testing::Test, public Common::Redis::Decoder NiceMock drain_decision_; NiceMock runtime_; ProxyFilterConfigSharedPtr config_; - std::unique_ptr filter_; + ProxyFilterPtr filter_; NiceMock filter_callbacks_; NiceMock api_; }; diff --git a/test/extensions/filters/network/rocketmq_proxy/codec_test.cc b/test/extensions/filters/network/rocketmq_proxy/codec_test.cc index 08d8dd5021a1b..069d909d6a1f5 100644 --- a/test/extensions/filters/network/rocketmq_proxy/codec_test.cc +++ b/test/extensions/filters/network/rocketmq_proxy/codec_test.cc @@ -500,7 +500,7 @@ TEST_F(RocketmqCodecTest, EncodeResponseSendMessageSuccess) { const int queue_id = 0; const int queue_offset = 0; - std::unique_ptr sendMessageResponseHeader = + SendMessageResponseHeaderPtr sendMessageResponseHeader = std::make_unique(msg_id, queue_id, queue_offset, EMPTY_STRING); CommandCustomHeaderPtr extHeader(sendMessageResponseHeader.release()); response->customHeader(extHeader); diff --git a/test/extensions/filters/network/rocketmq_proxy/conn_manager_test.cc b/test/extensions/filters/network/rocketmq_proxy/conn_manager_test.cc index 46f3af3adef3e..25729c64e7b66 100644 --- a/test/extensions/filters/network/rocketmq_proxy/conn_manager_test.cc +++ b/test/extensions/filters/network/rocketmq_proxy/conn_manager_test.cc @@ -83,7 +83,7 @@ class RocketmqConnectionManagerTest : public testing::Test { Buffer::OwnedImpl buffer_; NiceMock filter_callbacks_; - std::unique_ptr conn_manager_; + ConnectionManagerPtr conn_manager_; Encoder encoder_; Decoder decoder_; diff --git a/test/extensions/filters/network/rocketmq_proxy/router_test.cc b/test/extensions/filters/network/rocketmq_proxy/router_test.cc index a80d837d1b10f..05dce2ca5b624 100644 --- a/test/extensions/filters/network/rocketmq_proxy/router_test.cc +++ b/test/extensions/filters/network/rocketmq_proxy/router_test.cc @@ -84,7 +84,7 @@ class RocketmqRouterTestBase { RemotingCommandPtr request = std::make_unique(); request->code(static_cast(RequestCode::AckMessage)); request->flag(2); - std::unique_ptr header = std::make_unique(); + AckMessageRequestHeaderPtr header = std::make_unique(); header->consumerGroup("test_cg"); header->topic("test_topic"); header->queueId(0); @@ -142,9 +142,9 @@ class RocketmqRouterTestBase { NiceMock context_; ConfigImpl::RocketmqProxyConfig rocketmq_proxy_config_; ConfigImpl config_; - std::unique_ptr conn_manager_; + ConnectionManagerPtr conn_manager_; - std::unique_ptr router_; + RouterPtr router_; std::unique_ptr> active_message_; NiceMock upstream_connection_; diff --git a/test/extensions/filters/network/rocketmq_proxy/utility.cc b/test/extensions/filters/network/rocketmq_proxy/utility.cc index a44f0cd0acb37..3ebf27accd95d 100644 --- a/test/extensions/filters/network/rocketmq_proxy/utility.cc +++ b/test/extensions/filters/network/rocketmq_proxy/utility.cc @@ -24,7 +24,7 @@ void BufferUtility::fillRequestBuffer(Buffer::OwnedImpl& buffer, RequestCode cod switch (code) { case RequestCode::SendMessage: { - std::unique_ptr header = std::make_unique(); + SendMessageRequestHeaderPtr header = std::make_unique(); header->topic(topic_name_); header->version(SendMessageRequestVersion::V1); std::string msg_body = msg_body_; @@ -77,8 +77,7 @@ void BufferUtility::fillRequestBuffer(Buffer::OwnedImpl& buffer, RequestCode cod } break; case RequestCode::UnregisterClient: { - std::unique_ptr header = - std::make_unique(); + UnregisterClientRequestHeaderPtr header = std::make_unique(); header->clientId(client_id_); header->consumerGroup(consumer_group_); CommandCustomHeaderPtr ptr(header.release()); @@ -87,8 +86,7 @@ void BufferUtility::fillRequestBuffer(Buffer::OwnedImpl& buffer, RequestCode cod } case RequestCode::GetRouteInfoByTopic: { - std::unique_ptr header = - std::make_unique(); + GetRouteInfoRequestHeaderPtr header = std::make_unique(); header->topic(topic_name_); CommandCustomHeaderPtr ptr(header.release()); cmd->customHeader(ptr); @@ -96,7 +94,7 @@ void BufferUtility::fillRequestBuffer(Buffer::OwnedImpl& buffer, RequestCode cod } case RequestCode::GetConsumerListByGroup: { - std::unique_ptr header = + GetConsumerListByGroupRequestHeaderPtr header = std::make_unique(); header->consumerGroup(consumer_group_); CommandCustomHeaderPtr ptr(header.release()); @@ -105,7 +103,7 @@ void BufferUtility::fillRequestBuffer(Buffer::OwnedImpl& buffer, RequestCode cod } case RequestCode::SendMessageV2: { - std::unique_ptr header = std::make_unique(); + SendMessageRequestHeaderPtr header = std::make_unique(); header->topic(topic_name_); header->version(SendMessageRequestVersion::V2); header->producerGroup(producer_group_); @@ -117,7 +115,7 @@ void BufferUtility::fillRequestBuffer(Buffer::OwnedImpl& buffer, RequestCode cod } case RequestCode::PopMessage: { - std::unique_ptr header = std::make_unique(); + PopMessageRequestHeaderPtr header = std::make_unique(); header->consumerGroup(consumer_group_); header->topic(topic_name_); header->queueId(queue_id_); @@ -133,7 +131,7 @@ void BufferUtility::fillRequestBuffer(Buffer::OwnedImpl& buffer, RequestCode cod } case RequestCode::AckMessage: { - std::unique_ptr header = std::make_unique(); + AckMessageRequestHeaderPtr header = std::make_unique(); header->consumerGroup(consumer_group_); header->topic(topic_name_); header->queueId(queue_id_); @@ -160,8 +158,7 @@ void BufferUtility::fillResponseBuffer(Buffer::OwnedImpl& buffer, RequestCode re switch (req_code) { case RequestCode::SendMessageV2: { - std::unique_ptr header = - std::make_unique(); + SendMessageResponseHeaderPtr header = std::make_unique(); header->msgIdForTest("MSG_ID_01"); header->queueId(1); header->queueOffset(100); @@ -169,7 +166,7 @@ void BufferUtility::fillResponseBuffer(Buffer::OwnedImpl& buffer, RequestCode re break; } case RequestCode::PopMessage: { - std::unique_ptr header = std::make_unique(); + PopMessageResponseHeaderPtr header = std::make_unique(); header->popTime(1587386521445); header->invisibleTime(50000); header->reviveQid(5); diff --git a/test/extensions/filters/network/sni_dynamic_forward_proxy/proxy_filter_test.cc b/test/extensions/filters/network/sni_dynamic_forward_proxy/proxy_filter_test.cc index 12755253776da..7f80069d8032a 100644 --- a/test/extensions/filters/network/sni_dynamic_forward_proxy/proxy_filter_test.cc +++ b/test/extensions/filters/network/sni_dynamic_forward_proxy/proxy_filter_test.cc @@ -59,7 +59,7 @@ class SniDynamicProxyFilterTest new Extensions::Common::DynamicForwardProxy::MockDnsCacheManager()}; Upstream::MockClusterManager cm_; ProxyFilterConfigSharedPtr filter_config_; - std::unique_ptr filter_; + ProxyFilterPtr filter_; Network::MockReadFilterCallbacks callbacks_; NiceMock connection_; }; diff --git a/test/extensions/filters/network/thrift_proxy/conn_manager_test.cc b/test/extensions/filters/network/thrift_proxy/conn_manager_test.cc index 5de6de271950b..485693a095d98 100644 --- a/test/extensions/filters/network/thrift_proxy/conn_manager_test.cc +++ b/test/extensions/filters/network/thrift_proxy/conn_manager_test.cc @@ -305,7 +305,7 @@ class ThriftConnectionManagerTest : public testing::Test { Buffer::OwnedImpl write_buffer_; NiceMock filter_callbacks_; NiceMock random_; - std::unique_ptr filter_; + ConnectionManagerPtr filter_; MockTransport* custom_transport_{}; MockProtocol* custom_protocol_{}; ThriftFilters::DecoderFilterSharedPtr custom_filter_; diff --git a/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc b/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc index 292fad5500a64..d1cea46b44341 100644 --- a/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc +++ b/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc @@ -79,7 +79,7 @@ class ThriftRateLimitFilterTest : public testing::Test { NiceMock stats_store_; ConfigSharedPtr config_; Filters::Common::RateLimit::MockClient* client_; - std::unique_ptr filter_; + FilterPtr filter_; NiceMock filter_callbacks_; Filters::Common::RateLimit::RequestCallbacks* request_callbacks_{}; ThriftProxy::MessageMetadataSharedPtr request_metadata_; diff --git a/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc b/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc index 458412b7d0e05..a20ca86b20e17 100644 --- a/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc +++ b/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc @@ -43,7 +43,7 @@ class ThriftRateLimitConfigurationTest : public testing::Test { return *metadata_; } - std::unique_ptr config_; + ThriftProxy::ConfigImplPtr config_; NiceMock factory_context_; Network::Address::Ipv4Instance default_remote_address_{"10.0.0.1"}; MessageMetadataSharedPtr metadata_; @@ -180,7 +180,7 @@ class ThriftRateLimitPolicyEntryTest : public testing::Test { descriptors_.clear(); } - std::unique_ptr rate_limit_entry_; + RateLimitPolicyEntryImplPtr rate_limit_entry_; MessageMetadata metadata_; NiceMock route_; std::vector descriptors_; diff --git a/test/extensions/filters/network/thrift_proxy/router_test.cc b/test/extensions/filters/network/thrift_proxy/router_test.cc index ff7e57a5e14e2..a7c3a5b1a391c 100644 --- a/test/extensions/filters/network/thrift_proxy/router_test.cc +++ b/test/extensions/filters/network/thrift_proxy/router_test.cc @@ -321,7 +321,7 @@ class ThriftRouterTestBase { Tcp::ConnectionPool::ConnectionStatePtr conn_state_; RouteConstSharedPtr route_ptr_; - std::unique_ptr router_; + RouterPtr router_; std::string cluster_name_{"cluster"}; diff --git a/test/extensions/filters/network/zookeeper_proxy/filter_test.cc b/test/extensions/filters/network/zookeeper_proxy/filter_test.cc index f818f403a0af8..812c4cc5e9e6c 100644 --- a/test/extensions/filters/network/zookeeper_proxy/filter_test.cc +++ b/test/extensions/filters/network/zookeeper_proxy/filter_test.cc @@ -502,7 +502,7 @@ class ZooKeeperFilterTest : public testing::Test { Stats::TestUtil::TestStore scope_; ZooKeeperFilterConfigSharedPtr config_; - std::unique_ptr filter_; + ZooKeeperFilterPtr filter_; std::string stat_prefix_{"test.zookeeper"}; NiceMock filter_callbacks_; NiceMock stream_info_; diff --git a/test/extensions/filters/udp/dns_filter/dns_filter_integration_test.cc b/test/extensions/filters/udp/dns_filter/dns_filter_integration_test.cc index 46d1e8ff070f4..4fdfd1a3bd34d 100644 --- a/test/extensions/filters/udp/dns_filter/dns_filter_integration_test.cc +++ b/test/extensions/filters/udp/dns_filter/dns_filter_integration_test.cc @@ -188,7 +188,7 @@ name: listener_1 NiceMock mock_record_name_overflow_; NiceMock query_parsing_failure_; DnsParserCounters counters_; - std::unique_ptr response_parser_; + DnsMessageParserPtr response_parser_; DnsQueryContextPtr query_ctx_; }; diff --git a/test/extensions/filters/udp/dns_filter/dns_filter_test.cc b/test/extensions/filters/udp/dns_filter/dns_filter_test.cc index d0d1b151be7d7..d5809cc992a02 100644 --- a/test/extensions/filters/udp/dns_filter/dns_filter_test.cc +++ b/test/extensions/filters/udp/dns_filter/dns_filter_test.cc @@ -104,8 +104,8 @@ class DnsFilterTest : public testing::Test, public Event::TestUsingSimulatedTime NiceMock listener_factory_; Stats::IsolatedStoreImpl stats_store_; std::shared_ptr resolver_; - std::unique_ptr filter_; - std::unique_ptr response_parser_; + DnsFilterPtr filter_; + DnsMessageParserPtr response_parser_; const std::string forward_query_off_config = R"EOF( stat_prefix: "my_prefix" diff --git a/test/extensions/health_checkers/redis/redis_test.cc b/test/extensions/health_checkers/redis/redis_test.cc index 9d413879998ca..e2e4d920c490f 100644 --- a/test/extensions/health_checkers/redis/redis_test.cc +++ b/test/extensions/health_checkers/redis/redis_test.cc @@ -213,7 +213,7 @@ class RedisHealthCheckerTest Extensions::NetworkFilters::Common::Redis::Client::MockClient* client_{}; Extensions::NetworkFilters::Common::Redis::Client::MockPoolRequest pool_request_; Extensions::NetworkFilters::Common::Redis::Client::ClientCallbacks* pool_callbacks_{}; - std::shared_ptr health_checker_; + RedisHealthCheckerSharedPtr health_checker_; Api::ApiPtr api_; }; diff --git a/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc b/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc index b18a58be2e63e..5c5ad7e4664c1 100644 --- a/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc +++ b/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc @@ -248,11 +248,11 @@ class ActiveQuicListenerTest : public QuicMultiVersionTest { NiceMock listener_config_; quic::QuicConfig quic_config_; Server::ConnectionHandlerImpl connection_handler_; - std::unique_ptr quic_listener_; + ActiveQuicListenerPtr quic_listener_; Network::ActiveUdpListenerFactoryPtr listener_factory_; NiceMock socket_factory_; EnvoyQuicDispatcher* quic_dispatcher_; - std::unique_ptr loader_; + Runtime::ScopedLoaderSingletonPtr loader_; NiceMock tls_; Stats::TestUtil::TestStore store_; @@ -262,7 +262,7 @@ class ActiveQuicListenerTest : public QuicMultiVersionTest { Init::MockManager init_manager_; NiceMock validation_visitor_; - std::list> client_sockets_; + std::list client_sockets_; std::list> read_filters_; Network::MockFilterChainManager filter_chain_manager_; // The following two containers must guarantee pointer stability as addresses diff --git a/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc b/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc index c5b7a11d70e36..a742a89981dae 100644 --- a/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc +++ b/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc @@ -26,17 +26,15 @@ namespace quic { namespace test { namespace crypto_test_utils { // NOLINTNEXTLINE(readability-identifier-naming) -std::unique_ptr ProofSourceForTesting() { - return std::make_unique(); -} +ProofSourcePtr ProofSourceForTesting() { return std::make_unique(); } // NOLINTNEXTLINE(readability-identifier-naming) -std::unique_ptr ProofVerifierForTesting() { +ProofVerifierPtr ProofVerifierForTesting() { return std::make_unique(); } // NOLINTNEXTLINE(readability-identifier-naming) -std::unique_ptr ProofVerifyContextForTesting() { +ProofVerifyContextPtr ProofVerifyContextForTesting() { // No context needed for fake verifier. return nullptr; } diff --git a/test/extensions/quic_listeners/quiche/envoy_quic_client_session_test.cc b/test/extensions/quic_listeners/quiche/envoy_quic_client_session_test.cc index 5707ae2dbfca0..e46dea90fbd78 100644 --- a/test/extensions/quic_listeners/quiche/envoy_quic_client_session_test.cc +++ b/test/extensions/quic_listeners/quiche/envoy_quic_client_session_test.cc @@ -74,7 +74,7 @@ class TestEnvoyQuicClientSession : public EnvoyQuicClientSession { public: TestEnvoyQuicClientSession(const quic::QuicConfig& config, const quic::ParsedQuicVersionVector& supported_versions, - std::unique_ptr connection, + EnvoyQuicClientConnectionPtr connection, const quic::QuicServerId& server_id, quic::QuicCryptoClientConfig* crypto_config, quic::QuicClientPushPromiseIndex* push_promise_index, diff --git a/test/extensions/quic_listeners/quiche/envoy_quic_client_stream_test.cc b/test/extensions/quic_listeners/quiche/envoy_quic_client_stream_test.cc index ccd7d6a76d6d8..21e5129eab9f4 100644 --- a/test/extensions/quic_listeners/quiche/envoy_quic_client_stream_test.cc +++ b/test/extensions/quic_listeners/quiche/envoy_quic_client_stream_test.cc @@ -46,7 +46,7 @@ class EnvoyQuicClientStreamTest : public testing::TestWithParam { request_trailers_{{"trailer-key", "trailer-value"}} { quic_stream_->setResponseDecoder(stream_decoder_); quic_stream_->addCallbacks(stream_callbacks_); - quic_session_.ActivateStream(std::unique_ptr(quic_stream_)); + quic_session_.ActivateStream(EnvoyQuicClientStreamPtr(quic_stream_)); EXPECT_CALL(quic_session_, ShouldYield(_)).WillRepeatedly(testing::Return(false)); EXPECT_CALL(quic_session_, WritevData(_, _, _, _, _, _)) .WillRepeatedly(Invoke([](quic::QuicStreamId, size_t write_length, quic::QuicStreamOffset, diff --git a/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc b/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc index 84120cae913bf..83d5b6e6d2fad 100644 --- a/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc +++ b/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc @@ -51,7 +51,7 @@ class EnvoyQuicServerStreamTest : public testing::TestWithParam { {"trailer-key", "trailer-value"}} { quic_stream_->setRequestDecoder(stream_decoder_); quic_stream_->addCallbacks(stream_callbacks_); - quic_session_.ActivateStream(std::unique_ptr(quic_stream_)); + quic_session_.ActivateStream(EnvoyQuicServerStreamPtr(quic_stream_)); EXPECT_CALL(quic_session_, ShouldYield(_)).WillRepeatedly(testing::Return(false)); EXPECT_CALL(quic_session_, WritevData(_, _, _, _, _, _)) .WillRepeatedly(Invoke([](quic::QuicStreamId, size_t write_length, quic::QuicStreamOffset, diff --git a/test/extensions/quic_listeners/quiche/quic_io_handle_wrapper_test.cc b/test/extensions/quic_listeners/quiche/quic_io_handle_wrapper_test.cc index 4357d75edeae5..fa55fb91fef02 100644 --- a/test/extensions/quic_listeners/quiche/quic_io_handle_wrapper_test.cc +++ b/test/extensions/quic_listeners/quiche/quic_io_handle_wrapper_test.cc @@ -29,7 +29,7 @@ class QuicIoHandleWrapperTest : public testing::Test { protected: testing::NiceMock socket_; - std::unique_ptr wrapper_; + QuicIoHandleWrapperPtr wrapper_; testing::StrictMock os_sys_calls_; TestThreadsafeSingletonInjector os_calls_{&os_sys_calls_}; }; diff --git a/test/extensions/resource_monitors/fixed_heap/fixed_heap_monitor_test.cc b/test/extensions/resource_monitors/fixed_heap/fixed_heap_monitor_test.cc index 6b71e7bb5cede..9b47b061a955d 100644 --- a/test/extensions/resource_monitors/fixed_heap/fixed_heap_monitor_test.cc +++ b/test/extensions/resource_monitors/fixed_heap/fixed_heap_monitor_test.cc @@ -44,7 +44,7 @@ TEST(FixedHeapMonitorTest, ComputesCorrectUsage) { auto stats_reader = std::make_unique(); EXPECT_CALL(*stats_reader, reservedHeapBytes()).WillOnce(testing::Return(800)); EXPECT_CALL(*stats_reader, unmappedHeapBytes()).WillOnce(testing::Return(100)); - std::unique_ptr monitor(new FixedHeapMonitor(config, std::move(stats_reader))); + FixedHeapMonitorPtr monitor(new FixedHeapMonitor(config, std::move(stats_reader))); ResourcePressure resource; monitor->updateResourceUsage(resource); diff --git a/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc b/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc index e1a20bd147d48..bf546ab2dd753 100644 --- a/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc +++ b/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc @@ -60,7 +60,7 @@ class InjectedResourceMonitorTest : public testing::Test { void updateResource(double pressure) { updateResource(absl::StrCat(pressure)); } - std::unique_ptr createMonitor() { + InjectedResourceMonitorPtr createMonitor() { envoy::config::resource_monitor::injected_resource::v2alpha::InjectedResourceConfig config; config.set_filename(resource_filename_); Server::Configuration::ResourceMonitorFactoryContextImpl context( @@ -73,7 +73,7 @@ class InjectedResourceMonitorTest : public testing::Test { const std::string resource_filename_; AtomicFileUpdater file_updater_; MockedCallbacks cb_; - std::unique_ptr monitor_; + InjectedResourceMonitorPtr monitor_; }; TEST_F(InjectedResourceMonitorTest, ReportsCorrectPressure) { diff --git a/test/extensions/stats_sinks/common/statsd/statsd_test.cc b/test/extensions/stats_sinks/common/statsd/statsd_test.cc index a1e653fddad65..af91848b89795 100644 --- a/test/extensions/stats_sinks/common/statsd/statsd_test.cc +++ b/test/extensions/stats_sinks/common/statsd/statsd_test.cc @@ -54,7 +54,7 @@ class TcpStatsdSinkTest : public testing::Test { NiceMock tls_; NiceMock cluster_manager_; - std::unique_ptr sink_; + TcpStatsdSinkPtr sink_; NiceMock local_info_; Network::MockClientConnection* connection_{}; NiceMock snapshot_; diff --git a/test/extensions/stats_sinks/hystrix/hystrix_test.cc b/test/extensions/stats_sinks/hystrix/hystrix_test.cc index 5b88b4643df77..a8bf462cc2183 100644 --- a/test/extensions/stats_sinks/hystrix/hystrix_test.cc +++ b/test/extensions/stats_sinks/hystrix/hystrix_test.cc @@ -244,7 +244,7 @@ class HystrixSinkTest : public testing::Test { NiceMock server_; Upstream::ClusterManager::ClusterInfoMap cluster_map_; - std::unique_ptr sink_; + HystrixSinkPtr sink_; NiceMock snapshot_; NiceMock cluster_manager_; }; diff --git a/test/extensions/stats_sinks/metrics_service/grpc_metrics_service_impl_test.cc b/test/extensions/stats_sinks/metrics_service/grpc_metrics_service_impl_test.cc index 649b383496b65..ce940b650136d 100644 --- a/test/extensions/stats_sinks/metrics_service/grpc_metrics_service_impl_test.cc +++ b/test/extensions/stats_sinks/metrics_service/grpc_metrics_service_impl_test.cc @@ -49,7 +49,7 @@ class GrpcMetricsStreamerImplTest : public testing::Test { LocalInfo::MockLocalInfo local_info_; Grpc::MockAsyncClient* async_client_{new NiceMock}; Grpc::MockAsyncClientFactory* factory_{new Grpc::MockAsyncClientFactory}; - std::unique_ptr streamer_; + GrpcMetricsStreamerImplPtr streamer_; }; // Test basic metrics streaming flow. diff --git a/test/extensions/tracers/datadog/datadog_tracer_impl_test.cc b/test/extensions/tracers/datadog/datadog_tracer_impl_test.cc index 5043808dd78ba..e08c948978ddc 100644 --- a/test/extensions/tracers/datadog/datadog_tracer_impl_test.cc +++ b/test/extensions/tracers/datadog/datadog_tracer_impl_test.cc @@ -80,7 +80,7 @@ class DatadogDriverTest : public testing::Test { SystemTime start_time_; NiceMock tls_; - std::unique_ptr driver_; + DriverPtr driver_; NiceMock* timer_; Stats::TestUtil::TestStore stats_; NiceMock cm_; diff --git a/test/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl_test.cc b/test/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl_test.cc index 19a995d6e537a..67bcfd71c6f06 100644 --- a/test/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl_test.cc +++ b/test/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl_test.cc @@ -36,7 +36,7 @@ class DynamicOpenTracingDriverTest : public testing::Test { } )EOF", spans_file_); - std::unique_ptr driver_; + DynamicOpenTracingDriverPtr driver_; Stats::IsolatedStoreImpl stats_; const std::string operation_name_{"test"}; diff --git a/test/extensions/tracers/lightstep/lightstep_tracer_impl_test.cc b/test/extensions/tracers/lightstep/lightstep_tracer_impl_test.cc index 8b72f2cffaec9..f5fde45b76ca5 100644 --- a/test/extensions/tracers/lightstep/lightstep_tracer_impl_test.cc +++ b/test/extensions/tracers/lightstep/lightstep_tracer_impl_test.cc @@ -121,7 +121,7 @@ class LightStepDriverTest : public testing::Test { Grpc::ContextImpl grpc_context_; NiceMock tls_; NiceMock stats_; - std::unique_ptr driver_; + LightStepDriverPtr driver_; NiceMock* timer_; NiceMock cm_; NiceMock random_; diff --git a/test/extensions/tracers/opencensus/tracer_test.cc b/test/extensions/tracers/opencensus/tracer_test.cc index 6bc91183341af..f5ab367e5e0f7 100644 --- a/test/extensions/tracers/opencensus/tracer_test.cc +++ b/test/extensions/tracers/opencensus/tracer_test.cc @@ -103,7 +103,7 @@ TEST(OpenCensusTracerTest, Span) { registerSpanCatcher(); OpenCensusConfig oc_config; NiceMock local_info; - std::unique_ptr driver( + Tracing::DriverPtr driver( new OpenCensus::Driver(oc_config, local_info, *Api::createApiForTest())); NiceMock config; @@ -193,7 +193,7 @@ void testIncomingHeaders( oc_config.add_outgoing_trace_context(OpenCensusConfig::TRACE_CONTEXT); oc_config.add_outgoing_trace_context(OpenCensusConfig::GRPC_TRACE_BIN); oc_config.add_outgoing_trace_context(OpenCensusConfig::CLOUD_TRACE_CONTEXT); - std::unique_ptr driver( + Tracing::DriverPtr driver( new OpenCensus::Driver(oc_config, local_info, *Api::createApiForTest())); NiceMock config; Http::TestRequestHeaderMapImpl request_headers{ @@ -281,7 +281,7 @@ namespace { int SamplerTestHelper(const OpenCensusConfig& oc_config) { registerSpanCatcher(); NiceMock local_info; - std::unique_ptr driver( + Tracing::DriverPtr driver( new OpenCensus::Driver(oc_config, local_info, *Api::createApiForTest())); auto span = ::opencensus::trace::Span::StartSpan("test_span"); span.End(); diff --git a/test/extensions/tracers/zipkin/zipkin_tracer_impl_test.cc b/test/extensions/tracers/zipkin/zipkin_tracer_impl_test.cc index 7950d95198aa1..72f2161ddd2c6 100644 --- a/test/extensions/tracers/zipkin/zipkin_tracer_impl_test.cc +++ b/test/extensions/tracers/zipkin/zipkin_tracer_impl_test.cc @@ -140,7 +140,7 @@ class ZipkinDriverTest : public testing::Test { StreamInfo::MockStreamInfo stream_info_; NiceMock tls_; - std::unique_ptr driver_; + DriverPtr driver_; NiceMock* timer_; NiceMock stats_; NiceMock cm_; diff --git a/test/extensions/transport_sockets/alts/tsi_socket_test.cc b/test/extensions/transport_sockets/alts/tsi_socket_test.cc index 3fd39b5200206..4d6dcf2bedb68 100644 --- a/test/extensions/transport_sockets/alts/tsi_socket_test.cc +++ b/test/extensions/transport_sockets/alts/tsi_socket_test.cc @@ -173,7 +173,7 @@ class TsiSocketTest : public testing::Test { struct SocketForTest { HandshakerFactory handshaker_factory_; - std::unique_ptr tsi_socket_; + TsiSocketPtr tsi_socket_; NiceMock* raw_socket_{}; NiceMock callbacks_; Buffer::OwnedImpl read_buffer_; diff --git a/test/extensions/transport_sockets/tap/tap_config_impl_test.cc b/test/extensions/transport_sockets/tap/tap_config_impl_test.cc index ddf53b8258a56..469533ff99b90 100644 --- a/test/extensions/transport_sockets/tap/tap_config_impl_test.cc +++ b/test/extensions/transport_sockets/tap/tap_config_impl_test.cc @@ -72,7 +72,7 @@ class PerSocketTapperImplTest : public testing::Test { // Raw pointer, returned via mock to unique_ptr. TapCommon::MockPerTapSinkHandleManager* sink_manager_ = new TapCommon::MockPerTapSinkHandleManager; - std::unique_ptr tapper_; + PerSocketTapperImplPtr tapper_; std::vector matchers_{1}; TapCommon::MockMatcher matcher_{matchers_}; TapCommon::Matcher::MatchStatusVector* statuses_; diff --git a/test/extensions/transport_sockets/tls/integration/ssl_integration_test.h b/test/extensions/transport_sockets/tls/integration/ssl_integration_test.h index 133e73bd433e9..39d2916a0081c 100644 --- a/test/extensions/transport_sockets/tls/integration/ssl_integration_test.h +++ b/test/extensions/transport_sockets/tls/integration/ssl_integration_test.h @@ -38,7 +38,7 @@ class SslIntegrationTestBase : public HttpIntegrationTest { bool debug_with_s_client_{false}; private: - std::unique_ptr context_manager_; + ContextManagerPtr context_manager_; }; class SslIntegrationTest : public testing::TestWithParam, diff --git a/test/extensions/transport_sockets/tls/ssl_socket_test.cc b/test/extensions/transport_sockets/tls/ssl_socket_test.cc index b8481bc28a975..b5bf1691694d3 100644 --- a/test/extensions/transport_sockets/tls/ssl_socket_test.cc +++ b/test/extensions/transport_sockets/tls/ssl_socket_test.cc @@ -4449,7 +4449,7 @@ class SslReadBufferLimitTest : public SslSocketTest { Stats::TestUtil::TestStore server_stats_store_; Stats::TestUtil::TestStore client_stats_store_; - std::shared_ptr socket_; + Network::TcpListenSocketSharedPtr socket_; Network::MockListenerCallbacks listener_callbacks_; Network::MockConnectionHandler connection_handler_; const std::string server_ctx_yaml_ = R"EOF( @@ -4474,7 +4474,7 @@ class SslReadBufferLimitTest : public SslSocketTest { )EOF"; envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext downstream_tls_context_; - std::unique_ptr manager_; + ContextManagerImplPtr manager_; Network::TransportSocketFactoryPtr server_ssl_socket_factory_; Network::ListenerPtr listener_; envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext upstream_tls_context_; diff --git a/test/integration/fake_upstream.cc b/test/integration/fake_upstream.cc index 5b824a6c872ea..8bddbd7424155 100644 --- a/test/integration/fake_upstream.cc +++ b/test/integration/fake_upstream.cc @@ -74,14 +74,14 @@ void FakeStream::decodeMetadata(Http::MetadataMapPtr&& metadata_map_ptr) { } void FakeStream::encode100ContinueHeaders(const Http::ResponseHeaderMap& headers) { - std::shared_ptr headers_copy( + Http::ResponseHeaderMapSharedPtr headers_copy( Http::createHeaderMap(headers)); parent_.connection().dispatcher().post( [this, headers_copy]() -> void { encoder_.encode100ContinueHeaders(*headers_copy); }); } void FakeStream::encodeHeaders(const Http::HeaderMap& headers, bool end_stream) { - std::shared_ptr headers_copy( + Http::ResponseHeaderMapSharedPtr headers_copy( Http::createHeaderMap(headers)); if (add_served_by_header_) { headers_copy->addCopy(Http::LowerCaseString("x-served-by"), @@ -108,13 +108,13 @@ void FakeStream::encodeData(uint64_t size, bool end_stream) { } void FakeStream::encodeData(Buffer::Instance& data, bool end_stream) { - std::shared_ptr data_copy = std::make_shared(data); + Buffer::InstanceSharedPtr data_copy = std::make_shared(data); parent_.connection().dispatcher().post( [this, data_copy, end_stream]() -> void { encoder_.encodeData(*data_copy, end_stream); }); } void FakeStream::encodeTrailers(const Http::HeaderMap& trailers) { - std::shared_ptr trailers_copy( + Http::ResponseTrailerMapSharedPtr trailers_copy( Http::createHeaderMap(trailers)); parent_.connection().dispatcher().post( [this, trailers_copy]() -> void { encoder_.encodeTrailers(*trailers_copy); }); diff --git a/test/integration/filter_manager_integration_test.cc b/test/integration/filter_manager_integration_test.cc index 0acb10a78b44a..e1aee7735b3b8 100644 --- a/test/integration/filter_manager_integration_test.cc +++ b/test/integration/filter_manager_integration_test.cc @@ -127,8 +127,8 @@ class ThrottlerFilter : public Network::Filter, public Network::ConnectionCallba Network::ReadFilterCallbacks* read_callbacks_{}; Network::WriteFilterCallbacks* write_callbacks_{}; - std::unique_ptr read_throttler_; - std::unique_ptr write_throttler_; + ThrottlerPtr read_throttler_; + ThrottlerPtr write_throttler_; const std::chrono::milliseconds tick_interval_; const uint64_t max_chunk_length_; diff --git a/test/integration/integration.h b/test/integration/integration.h index 4b55c14b6a269..f9e2c6763c8f0 100644 --- a/test/integration/integration.h +++ b/test/integration/integration.h @@ -124,8 +124,8 @@ class IntegrationTcpClient { IntegrationTcpClient& parent_; }; - std::shared_ptr payload_reader_; - std::shared_ptr callbacks_; + WaitForPayloadReaderSharedPtr payload_reader_; + ConnectionCallbacksSharedPtr callbacks_; Network::ClientConnectionPtr connection_; bool disconnected_{}; MockWatermarkBuffer* client_write_buffer_; @@ -379,7 +379,7 @@ class BaseIntegrationTest : protected Logger::Loggable { * @param initial_data the data to send. * @param data_callback the callback on the received data. **/ - std::unique_ptr createConnectionDriver( + RawConnectionDriverPtr createConnectionDriver( uint32_t port, const std::string& initial_data, std::function&& data_callback) { Buffer::OwnedImpl buffer(initial_data); @@ -398,7 +398,7 @@ class BaseIntegrationTest : protected Logger::Loggable { bool initialized() const { return initialized_; } - std::unique_ptr upstream_stats_store_; + Stats::ScopePtr upstream_stats_store_; // The IpVersion (IPv4, IPv6) to use. Network::Address::IpVersion version_; diff --git a/test/integration/listener_filter_integration_test.cc b/test/integration/listener_filter_integration_test.cc index 425cf0edaae8e..e9170167ae159 100644 --- a/test/integration/listener_filter_integration_test.cc +++ b/test/integration/listener_filter_integration_test.cc @@ -98,7 +98,7 @@ class ListenerFilterIntegrationTest : public testing::TestWithParam context_manager_; + Ssl::ContextManagerPtr context_manager_; Network::TransportSocketFactoryPtr context_; ConnectionStatusCallbacks connect_callbacks_; testing::NiceMock secret_manager_; diff --git a/test/integration/server.cc b/test/integration/server.cc index 4b7d2beecb2e6..075f727601c95 100644 --- a/test/integration/server.cc +++ b/test/integration/server.cc @@ -207,7 +207,7 @@ void IntegrationTestServerImpl::createAndRunEnvoyServer( Server::HotRestartNopImpl restarter; ThreadLocal::InstanceImpl tls; Stats::ThreadLocalStoreImpl stat_store(*stats_allocator_); - std::unique_ptr process_context; + ProcessContextPtr process_context; if (process_object.has_value()) { process_context = std::make_unique(process_object->get()); } diff --git a/test/integration/server.h b/test/integration/server.h index d584dd61631b8..8543483b210b0 100644 --- a/test/integration/server.h +++ b/test/integration/server.h @@ -186,7 +186,7 @@ class NotifyingCounter : public Stats::Counter { const SymbolTable& constSymbolTable() const override { return counter_->constSymbolTable(); } private: - std::unique_ptr counter_; + Stats::CounterPtr counter_; absl::Mutex& mutex_; absl::CondVar& condvar_; }; @@ -538,7 +538,7 @@ class IntegrationTestServerImpl : public IntegrationTestServer { Network::Address::InstanceConstSharedPtr admin_address_; absl::Notification server_gone_; Stats::SymbolTablePtr symbol_table_; - std::unique_ptr stats_allocator_; + Stats::AllocatorImplPtr stats_allocator_; }; } // namespace Envoy diff --git a/test/integration/tcp_proxy_integration_test.h b/test/integration/tcp_proxy_integration_test.h index f6b119b86d1d5..98e6b0cd179bd 100644 --- a/test/integration/tcp_proxy_integration_test.h +++ b/test/integration/tcp_proxy_integration_test.h @@ -27,11 +27,11 @@ class TcpProxySslIntegrationTest : public TcpProxyIntegrationTest { void sendAndReceiveTlsData(const std::string& data_to_send_upstream, const std::string& data_to_send_downstream); - std::unique_ptr context_manager_; + Ssl::ContextManagerPtr context_manager_; Network::TransportSocketFactoryPtr context_; ConnectionStatusCallbacks connect_callbacks_; MockWatermarkBuffer* client_write_buffer_; - std::shared_ptr payload_reader_; + WaitForPayloadReaderSharedPtr payload_reader_; testing::NiceMock secret_manager_; Network::ClientConnectionPtr ssl_client_; FakeRawConnectionPtr fake_upstream_connection_; diff --git a/test/integration/utility.h b/test/integration/utility.h index 21235c2e2b424..fdac7b22f655f 100644 --- a/test/integration/utility.h +++ b/test/integration/utility.h @@ -119,7 +119,7 @@ class RawConnectionDriver { Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; Event::Dispatcher& dispatcher_; - std::unique_ptr callbacks_; + ConnectionCallbacksPtr callbacks_; Network::ClientConnectionPtr client_; }; diff --git a/test/integration/xds_integration_test.cc b/test/integration/xds_integration_test.cc index b76f8c476b4a9..72677f4141ab3 100644 --- a/test/integration/xds_integration_test.cc +++ b/test/integration/xds_integration_test.cc @@ -127,9 +127,9 @@ class LdsInplaceUpdateTcpProxyIntegrationTest context_ = Ssl::createClientSslTransportSocketFactory({}, *context_manager_, *api_); } - std::unique_ptr createConnectionAndWrite(const std::string& alpn, - const std::string& request, - std::string& response) { + RawConnectionDriverPtr createConnectionAndWrite(const std::string& alpn, + const std::string& request, + std::string& response) { Buffer::OwnedImpl buffer(request); return std::make_unique( lookupPort("tcp"), buffer, @@ -141,7 +141,7 @@ class LdsInplaceUpdateTcpProxyIntegrationTest absl::string_view(""), std::vector(), std::vector{alpn}))); } - std::unique_ptr context_manager_; + Ssl::ContextManagerPtr context_manager_; Network::TransportSocketFactoryPtr context_; testing::NiceMock secret_manager_; }; @@ -331,7 +331,7 @@ class LdsInplaceUpdateHttpIntegrationTest } } - std::unique_ptr context_manager_; + Ssl::ContextManagerPtr context_manager_; Network::TransportSocketFactoryPtr context_; testing::NiceMock secret_manager_; Network::Address::InstanceConstSharedPtr address_; diff --git a/test/integration/xfcc_integration_test.h b/test/integration/xfcc_integration_test.h index 538a1bc86d970..5e7ce11c0affd 100644 --- a/test/integration/xfcc_integration_test.h +++ b/test/integration/xfcc_integration_test.h @@ -59,7 +59,7 @@ class XfccIntegrationTest : public testing::TestWithParam context_manager_; + Ssl::ContextManagerPtr context_manager_; Network::TransportSocketFactoryPtr client_tls_ssl_ctx_; Network::TransportSocketFactoryPtr client_mtls_ssl_ctx_; Network::TransportSocketFactoryPtr upstream_ssl_ctx_; diff --git a/test/main.cc b/test/main.cc index eae6c3fc4f68f..8cb4ee5dc5682 100644 --- a/test/main.cc +++ b/test/main.cc @@ -16,7 +16,7 @@ int main(int argc, char** argv) { // Create a Runfiles object for runfiles lookup. // https://github.com/bazelbuild/bazel/blob/master/tools/cpp/runfiles/runfiles_src.h#L32 std::string error; - std::unique_ptr runfiles(Runfiles::Create(argv[0], &error)); + RunfilesPtr runfiles(Runfiles::Create(argv[0], &error)); RELEASE_ASSERT(Envoy::TestEnvironment::getOptionalEnvVar("NORUNFILES").has_value() || runfiles != nullptr, error); diff --git a/test/mocks/grpc/mocks.h b/test/mocks/grpc/mocks.h index 0a13f5a5fb082..2289d219a8122 100644 --- a/test/mocks/grpc/mocks.h +++ b/test/mocks/grpc/mocks.h @@ -42,9 +42,7 @@ class MockAsyncStream : public RawAsyncStream { template class MockAsyncRequestCallbacks : public AsyncRequestCallbacks { public: - void onSuccess(std::unique_ptr&& response, Tracing::Span& span) { - onSuccess_(*response, span); - } + void onSuccess(ResponseTypePtr&& response, Tracing::Span& span) { onSuccess_(*response, span); } MOCK_METHOD(void, onCreateInitialMetadata, (Http::RequestHeaderMap & metadata)); MOCK_METHOD(void, onSuccess_, (const ResponseType& response, Tracing::Span& span)); @@ -59,7 +57,7 @@ class MockAsyncStreamCallbacks : public AsyncStreamCallbacks { onReceiveInitialMetadata_(*metadata); } - void onReceiveMessage(std::unique_ptr&& message) { onReceiveMessage_(*message); } + void onReceiveMessage(ResponseTypePtr&& message) { onReceiveMessage_(*message); } void onReceiveTrailingMetadata(Http::ResponseTrailerMapPtr&& metadata) { onReceiveTrailingMetadata_(*metadata); diff --git a/test/mocks/router/mocks.h b/test/mocks/router/mocks.h index 4fe1103f84512..0ac4d6be83421 100644 --- a/test/mocks/router/mocks.h +++ b/test/mocks/router/mocks.h @@ -274,7 +274,7 @@ class MockVirtualHost : public VirtualHost { mutable Stats::TestSymbolTable symbol_table_; std::string name_{"fake_vhost"}; - mutable std::unique_ptr stat_name_; + mutable Stats::StatNameManagedStoragePtr stat_name_; testing::NiceMock rate_limit_policy_; TestCorsPolicy cors_policy_; }; @@ -536,8 +536,7 @@ class MockGenericConnectionPoolCallbacks : public GenericConnectionPoolCallbacks absl::string_view transport_failure_reason, Upstream::HostDescriptionConstSharedPtr host)); MOCK_METHOD(void, onPoolReady, - (std::unique_ptr && upstream, - Upstream::HostDescriptionConstSharedPtr host, + (GenericUpstreamPtr && upstream, Upstream::HostDescriptionConstSharedPtr host, const Network::Address::InstanceConstSharedPtr& upstream_local_address, const StreamInfo::StreamInfo& info)); MOCK_METHOD(UpstreamRequest*, upstreamRequest, ()); diff --git a/test/mocks/server/mocks.h b/test/mocks/server/mocks.h index 34ffef72e6156..e6a6a20582680 100644 --- a/test/mocks/server/mocks.h +++ b/test/mocks/server/mocks.h @@ -445,7 +445,7 @@ class MockInstance : public Instance { testing::NiceMock api_; testing::NiceMock admin_; Event::GlobalTimeSystem time_system_; - std::unique_ptr secret_manager_; + Secret::SecretManagerPtr secret_manager_; testing::NiceMock cluster_manager_; Thread::MutexBasicLockable access_log_lock_; testing::NiceMock runtime_loader_; @@ -615,7 +615,7 @@ class MockTransportSocketFactoryContext : public TransportSocketFactoryContext { testing::NiceMock cluster_manager_; testing::NiceMock api_; testing::NiceMock config_tracker_; - std::unique_ptr secret_manager_; + Secret::SecretManagerPtr secret_manager_; }; class MockListenerFactoryContext : public MockFactoryContext, public ListenerFactoryContext { diff --git a/test/mocks/stats/mocks.h b/test/mocks/stats/mocks.h index 272603041d98d..060026bcd320b 100644 --- a/test/mocks/stats/mocks.h +++ b/test/mocks/stats/mocks.h @@ -76,7 +76,7 @@ template class MockMetric : public BaseClass { private: MockMetric& mock_metric_; std::string name_; - std::unique_ptr stat_name_storage_; + StatNameStoragePtr stat_name_storage_; }; SymbolTable& symbolTable() override { return *symbol_table_; } @@ -140,7 +140,7 @@ template class MockMetric : public BaseClass { StatNameVec tag_names_and_values_; std::string tag_extracted_name_; StatNamePool tag_pool_; - std::unique_ptr tag_extracted_stat_name_; + StatNameManagedStoragePtr tag_extracted_stat_name_; }; template class MockStatWithRefcount : public MockMetric { @@ -252,8 +252,7 @@ class MockParentHistogram : public MockMetric { bool used_; Unit unit_{Histogram::Unit::Unspecified}; Store* store_{}; - std::shared_ptr histogram_stats_ = - std::make_shared(); + HistogramStatisticsSharedPtr histogram_stats_ = std::make_shared(); private: RefcountHelper refcount_helper_; diff --git a/test/mocks/upstream/cluster_info.h b/test/mocks/upstream/cluster_info.h index e3bce01c62826..109770558b11a 100644 --- a/test/mocks/upstream/cluster_info.h +++ b/test/mocks/upstream/cluster_info.h @@ -56,13 +56,11 @@ class MockClusterTypedMetadata : public Config::TypedMetadataImpl::TypedMetadataImpl; - void inject(const std::string& key, std::unique_ptr value) { + void inject(const std::string& key, TypedMetadata::ObjectConstPtr value) { data_[key] = std::move(value); } - std::unordered_map>& data() { - return data_; - } + std::unordered_map& data() { return data_; } }; class MockClusterInfo : public ClusterInfo { @@ -154,7 +152,7 @@ class MockClusterInfo : public ClusterInfo { absl::optional timeout_budget_stats_; ClusterCircuitBreakersStats circuit_breakers_stats_; NiceMock runtime_; - std::unique_ptr resource_manager_; + Upstream::ResourceManagerPtr resource_manager_; Network::Address::InstanceConstSharedPtr source_address_; LoadBalancerType lb_type_{LoadBalancerType::RoundRobin}; envoy::config::cluster::v3::Cluster::DiscoveryType type_{ @@ -169,7 +167,7 @@ class MockClusterInfo : public ClusterInfo { Network::ConnectionSocket::OptionsSharedPtr cluster_socket_options_; envoy::config::cluster::v3::Cluster::CommonLbConfig lb_config_; envoy::config::core::v3::Metadata metadata_; - std::unique_ptr typed_metadata_; + Envoy::Config::TypedMetadataPtr typed_metadata_; absl::optional max_stream_duration_; mutable Http::Http1::CodecStats::AtomicPtr http1_codec_stats_; mutable Http::Http2::CodecStats::AtomicPtr http2_codec_stats_; diff --git a/test/mocks/upstream/host.h b/test/mocks/upstream/host.h index 3c927b0208aa3..d57dc4f483ec0 100644 --- a/test/mocks/upstream/host.h +++ b/test/mocks/upstream/host.h @@ -113,7 +113,7 @@ class MockHostDescription : public HostDescription { testing::NiceMock cluster_; HostStats stats_; mutable Stats::TestSymbolTable symbol_table_; - mutable std::unique_ptr locality_zone_stat_name_; + mutable Stats::StatNameManagedStoragePtr locality_zone_stat_name_; }; class MockHost : public Host { @@ -198,7 +198,7 @@ class MockHost : public Host { testing::NiceMock outlier_detector_; HostStats stats_; mutable Stats::TestSymbolTable symbol_table_; - mutable std::unique_ptr locality_zone_stat_name_; + mutable Stats::StatNameManagedStoragePtr locality_zone_stat_name_; }; } // namespace Upstream diff --git a/test/server/admin/config_tracker_impl_test.cc b/test/server/admin/config_tracker_impl_test.cc index 9388c2e2ef112..9c91ebefabe20 100644 --- a/test/server/admin/config_tracker_impl_test.cc +++ b/test/server/admin/config_tracker_impl_test.cc @@ -45,7 +45,7 @@ TEST_F(ConfigTrackerImplTest, DestroyHandleBeforeTracker) { } TEST_F(ConfigTrackerImplTest, DestroyTrackerBeforeHandle) { - std::shared_ptr tracker_ptr = std::make_shared(); + ConfigTrackerSharedPtr tracker_ptr = std::make_shared(); auto entry_owner = tracker.add("test_key", test_cb); tracker_ptr.reset(); entry_owner.reset(); // Shouldn't explode diff --git a/test/server/admin/stats_handler_test.cc b/test/server/admin/stats_handler_test.cc index ce80844b635e8..623438013b97e 100644 --- a/test/server/admin/stats_handler_test.cc +++ b/test/server/admin/stats_handler_test.cc @@ -39,7 +39,7 @@ class AdminStatsTest : public testing::TestWithParam tls_; Stats::AllocatorImpl alloc_; Stats::MockSink sink_; - std::unique_ptr store_; + Stats::ThreadLocalStoreImplPtr store_; }; INSTANTIATE_TEST_SUITE_P(IpVersions, AdminStatsTest, diff --git a/test/server/api_listener_test.cc b/test/server/api_listener_test.cc index f229823c59c32..25416a1a89bb4 100644 --- a/test/server/api_listener_test.cc +++ b/test/server/api_listener_test.cc @@ -25,7 +25,7 @@ class ApiListenerTest : public testing::Test { NiceMock server_; NiceMock listener_factory_; NiceMock worker_factory_; - std::unique_ptr listener_manager_; + ListenerManagerImplPtr listener_manager_; }; TEST_F(ApiListenerTest, HttpApiListener) { diff --git a/test/server/config_validation/dispatcher_test.cc b/test/server/config_validation/dispatcher_test.cc index f0367a149ee12..796106b76907b 100644 --- a/test/server/config_validation/dispatcher_test.cc +++ b/test/server/config_validation/dispatcher_test.cc @@ -34,7 +34,7 @@ class ConfigValidation : public testing::TestWithParam validation_; + Api::ValidationImplPtr validation_; }; // Simple test which creates a connection to fake upstream client. This is to test if diff --git a/test/server/connection_handler_test.cc b/test/server/connection_handler_test.cc index 65703ba56dca1..d6f4b74fe2cab 100644 --- a/test/server/connection_handler_test.cc +++ b/test/server/connection_handler_test.cc @@ -111,7 +111,7 @@ class ConnectionHandlerTest : public testing::Test, protected Logger::Loggable udp_listener_factory_; + Network::ActiveUdpListenerFactoryPtr udp_listener_factory_; Network::ConnectionBalancerPtr connection_balancer_; const std::vector empty_access_logs_; std::shared_ptr> inline_filter_chain_manager_; diff --git a/test/server/guarddog_impl_test.cc b/test/server/guarddog_impl_test.cc index 067ee8403aafc..2093232958446 100644 --- a/test/server/guarddog_impl_test.cc +++ b/test/server/guarddog_impl_test.cc @@ -73,7 +73,7 @@ class GuardDogTestBase : public testing::TestWithParam { std::unique_ptr time_system_; Stats::TestUtil::TestStore stats_store_; Api::ApiPtr api_; - std::unique_ptr guard_dog_; + GuardDogImplPtr guard_dog_; }; INSTANTIATE_TEST_SUITE_P(TimeSystemType, GuardDogTestBase, diff --git a/test/server/hot_restart_impl_test.cc b/test/server/hot_restart_impl_test.cc index a3d431e6c6e28..cc8b951dc3f1b 100644 --- a/test/server/hot_restart_impl_test.cc +++ b/test/server/hot_restart_impl_test.cc @@ -56,7 +56,7 @@ class HotRestartImplTest : public testing::Test { TestThreadsafeSingletonInjector hot_restart_os_calls{ &hot_restart_os_sys_calls_}; std::vector buffer_; - std::unique_ptr hot_restart_; + HotRestartImplPtr hot_restart_; }; TEST_F(HotRestartImplTest, VersionString) { diff --git a/test/server/lds_api_test.cc b/test/server/lds_api_test.cc index 513cd9ab5e415..bd224b4cc51c7 100644 --- a/test/server/lds_api_test.cc +++ b/test/server/lds_api_test.cc @@ -96,7 +96,7 @@ class LdsApiTest : public testing::Test { Stats::IsolatedStoreImpl store_; MockListenerManager listener_manager_; Config::SubscriptionCallbacks* lds_callbacks_{}; - std::unique_ptr lds_; + LdsApiImplPtr lds_; NiceMock validation_visitor_; private: diff --git a/test/server/listener_manager_impl_test.h b/test/server/listener_manager_impl_test.h index d1f3256fd4a4a..9e7ed9c244391 100644 --- a/test/server/listener_manager_impl_test.h +++ b/test/server/listener_manager_impl_test.h @@ -127,7 +127,7 @@ class ListenerManagerImplTest : public testing::Test { const Protobuf::RepeatedPtrField&, Server::Configuration::FilterChainFactoryContext& filter_chain_factory_context) -> std::vector { - std::shared_ptr notifier(raw_listener); + ListenerHandleSharedPtr notifier(raw_listener); raw_listener->context_ = &filter_chain_factory_context; if (need_init) { filter_chain_factory_context.initManager().add(notifier->target_); @@ -154,7 +154,7 @@ class ListenerManagerImplTest : public testing::Test { const Protobuf::RepeatedPtrField&, Server::Configuration::FilterChainFactoryContext& filter_chain_factory_context) -> std::vector { - std::shared_ptr notifier(raw_listener); + ListenerHandleSharedPtr notifier(raw_listener); raw_listener->context_ = &filter_chain_factory_context; if (need_init) { filter_chain_factory_context.initManager().add(notifier->target_); @@ -282,7 +282,7 @@ class ListenerManagerImplTest : public testing::Test { NiceMock validation_visitor; MockWorker* worker_ = new MockWorker(); NiceMock worker_factory_; - std::unique_ptr manager_; + ListenerManagerImplPtr manager_; NiceMock guard_dog_; Event::SimulatedTimeSystem time_system_; Api::ApiPtr api_; diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index 83247306bc3e2..a1373be649ffd 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -43,13 +43,13 @@ class OptionsImplTest : public testing::Test { public: // Do the ugly work of turning a std::string into a vector and create an OptionsImpl. Args are // separated by a single space: no fancy quoting or escaping. - std::unique_ptr createOptionsImpl(const std::string& args) { + OptionsImplPtr createOptionsImpl(const std::string& args) { std::vector words = TestUtility::split(args, ' '); return std::make_unique( std::move(words), [](bool) { return "1"; }, spdlog::level::warn); } - std::unique_ptr createOptionsImpl(std::vector args) { + OptionsImplPtr createOptionsImpl(std::vector args) { return std::make_unique( std::move(args), [](bool) { return "1"; }, spdlog::level::warn); } @@ -70,7 +70,7 @@ TEST_F(OptionsImplTest, InvalidCommandLine) { } TEST_F(OptionsImplTest, V1Disallowed) { - std::unique_ptr options = createOptionsImpl( + OptionsImplPtr options = createOptionsImpl( "envoy --mode validate --concurrency 2 -c hello --admin-address-path path --restart-epoch 1 " "--local-address-ip-version v6 -l info --service-cluster cluster --service-node node " "--service-zone zone --file-flush-interval-msec 9000 --drain-time-s 60 --log-format [%v] " @@ -79,7 +79,7 @@ TEST_F(OptionsImplTest, V1Disallowed) { } TEST_F(OptionsImplTest, All) { - std::unique_ptr options = createOptionsImpl( + OptionsImplPtr options = createOptionsImpl( "envoy --mode validate --concurrency 2 -c hello --admin-address-path path --restart-epoch 0 " "--local-address-ip-version v6 -l info --component-log-level upstream:debug,connection:trace " "--service-cluster cluster --service-node node --service-zone zone " @@ -120,11 +120,11 @@ TEST_F(OptionsImplTest, All) { // Either variants of allow-unknown-[static-]-fields works. TEST_F(OptionsImplTest, AllowUnknownFields) { { - std::unique_ptr options = createOptionsImpl("envoy"); + OptionsImplPtr options = createOptionsImpl("envoy"); EXPECT_FALSE(options->allowUnknownStaticFields()); } { - std::unique_ptr options; + OptionsImplPtr options; EXPECT_LOG_CONTAINS( "warning", "--allow-unknown-fields is deprecated, use --allow-unknown-static-fields instead.", @@ -132,13 +132,13 @@ TEST_F(OptionsImplTest, AllowUnknownFields) { EXPECT_TRUE(options->allowUnknownStaticFields()); } { - std::unique_ptr options = createOptionsImpl("envoy --allow-unknown-static-fields"); + OptionsImplPtr options = createOptionsImpl("envoy --allow-unknown-static-fields"); EXPECT_TRUE(options->allowUnknownStaticFields()); } } TEST_F(OptionsImplTest, SetAll) { - std::unique_ptr options = createOptionsImpl("envoy -c hello"); + OptionsImplPtr options = createOptionsImpl("envoy -c hello"); bool hot_restart_disabled = options->hotRestartDisabled(); bool signal_handling_enabled = options->signalHandlingEnabled(); bool cpuset_threads_enabled = options->cpusetThreadsEnabled(); @@ -231,7 +231,7 @@ TEST_F(OptionsImplTest, SetAll) { } TEST_F(OptionsImplTest, DefaultParams) { - std::unique_ptr options = createOptionsImpl("envoy -c hello"); + OptionsImplPtr options = createOptionsImpl("envoy -c hello"); EXPECT_EQ(std::chrono::seconds(600), options->drainTime()); EXPECT_EQ(Server::DrainStrategy::Gradual, options->drainStrategy()); EXPECT_EQ(std::chrono::seconds(900), options->parentShutdownTime()); @@ -259,7 +259,7 @@ TEST_F(OptionsImplTest, DefaultParams) { // Validates that the server_info proto is in sync with the options. TEST_F(OptionsImplTest, OptionsAreInSyncWithProto) { - std::unique_ptr options = createOptionsImpl("envoy -c hello"); + OptionsImplPtr options = createOptionsImpl("envoy -c hello"); Server::CommandLineOptionsPtr command_line_options = options->toCommandLineOptions(); // Failure of this condition indicates that the server_info proto is not in sync with the options. // If an option is added/removed, please update server_info proto as well to keep it in sync. @@ -276,7 +276,7 @@ TEST_F(OptionsImplTest, OptionsAreInSyncWithProto) { TEST_F(OptionsImplTest, OptionsFromArgv) { const std::array args{"envoy", "-c", "hello"}; - std::unique_ptr options = std::make_unique( + OptionsImplPtr options = std::make_unique( static_cast(args.size()), args.data(), [](bool) { return "1"; }, spdlog::level::warn); // Spot check that the arguments were parsed. EXPECT_EQ("hello", options->configPath()); @@ -284,7 +284,7 @@ TEST_F(OptionsImplTest, OptionsFromArgv) { TEST_F(OptionsImplTest, OptionsFromArgvPrefix) { const std::array args{"envoy", "-c", "hello", "--admin-address-path", "goodbye"}; - std::unique_ptr options = std::make_unique( + OptionsImplPtr options = std::make_unique( static_cast(args.size()) - 2, // Pass in only a prefix of the args args.data(), [](bool) { return "1"; }, spdlog::level::warn); EXPECT_EQ("hello", options->configPath()); @@ -299,7 +299,7 @@ TEST_F(OptionsImplTest, BadCliOption) { } TEST_F(OptionsImplTest, ParseComponentLogLevels) { - std::unique_ptr options = createOptionsImpl("envoy --mode init_only"); + OptionsImplPtr options = createOptionsImpl("envoy --mode init_only"); options->parseComponentLogLevels("upstream:debug,connection:trace"); const std::vector>& component_log_levels = options->componentLogLevels(); @@ -311,38 +311,38 @@ TEST_F(OptionsImplTest, ParseComponentLogLevels) { } TEST_F(OptionsImplTest, ParseComponentLogLevelsWithBlank) { - std::unique_ptr options = createOptionsImpl("envoy --mode init_only"); + OptionsImplPtr options = createOptionsImpl("envoy --mode init_only"); options->parseComponentLogLevels(""); EXPECT_EQ(0, options->componentLogLevels().size()); } TEST_F(OptionsImplTest, InvalidComponent) { - std::unique_ptr options = createOptionsImpl("envoy --mode init_only"); + OptionsImplPtr options = createOptionsImpl("envoy --mode init_only"); EXPECT_THROW_WITH_REGEX(options->parseComponentLogLevels("blah:debug"), MalformedArgvException, "error: invalid component specified 'blah'"); } TEST_F(OptionsImplTest, InvalidComponentLogLevel) { - std::unique_ptr options = createOptionsImpl("envoy --mode init_only"); + OptionsImplPtr options = createOptionsImpl("envoy --mode init_only"); EXPECT_THROW_WITH_REGEX(options->parseComponentLogLevels("upstream:blah,connection:trace"), MalformedArgvException, "error: invalid log level specified 'blah'"); } TEST_F(OptionsImplTest, ComponentLogLevelContainsBlank) { - std::unique_ptr options = createOptionsImpl("envoy --mode init_only"); + OptionsImplPtr options = createOptionsImpl("envoy --mode init_only"); EXPECT_THROW_WITH_REGEX(options->parseComponentLogLevels("upstream:,connection:trace"), MalformedArgvException, "error: invalid log level specified ''"); } TEST_F(OptionsImplTest, InvalidComponentLogLevelStructure) { - std::unique_ptr options = createOptionsImpl("envoy --mode init_only"); + OptionsImplPtr options = createOptionsImpl("envoy --mode init_only"); EXPECT_THROW_WITH_REGEX(options->parseComponentLogLevels("upstream:foo:bar"), MalformedArgvException, "error: component log level not correctly specified 'upstream:foo:bar'"); } TEST_F(OptionsImplTest, IncompleteComponentLogLevel) { - std::unique_ptr options = createOptionsImpl("envoy --mode init_only"); + OptionsImplPtr options = createOptionsImpl("envoy --mode init_only"); EXPECT_THROW_WITH_REGEX(options->parseComponentLogLevels("upstream"), MalformedArgvException, "component log level not correctly specified 'upstream'"); } @@ -353,12 +353,12 @@ TEST_F(OptionsImplTest, InvalidLogLevel) { } TEST_F(OptionsImplTest, ValidLogLevel) { - std::unique_ptr options = createOptionsImpl("envoy -l critical"); + OptionsImplPtr options = createOptionsImpl("envoy -l critical"); EXPECT_EQ(spdlog::level::level_enum::critical, options->logLevel()); } TEST_F(OptionsImplTest, WarnIsValidLogLevel) { - std::unique_ptr options = createOptionsImpl("envoy -l warn"); + OptionsImplPtr options = createOptionsImpl("envoy -l warn"); EXPECT_EQ(spdlog::level::level_enum::warn, options->logLevel()); } @@ -369,7 +369,7 @@ TEST_F(OptionsImplTest, AllowedLogLevels) { // Test that the test constructor comes up with the same default values as the main constructor. TEST_F(OptionsImplTest, SaneTestConstructor) { - std::unique_ptr regular_options_impl(createOptionsImpl("envoy")); + OptionsImplPtr regular_options_impl(createOptionsImpl("envoy")); OptionsImpl test_options_impl("service_cluster", "service_node", "service_zone", spdlog::level::level_enum::info); @@ -407,34 +407,34 @@ TEST_F(OptionsImplTest, SetBothConcurrencyAndCpuset) { EXPECT_LOG_CONTAINS( "warning", "Both --concurrency and --cpuset-threads options are set; not applying --cpuset-threads.", - std::unique_ptr options = + OptionsImplPtr options = createOptionsImpl("envoy -c hello --concurrency 42 --cpuset-threads")); } TEST_F(OptionsImplTest, SetCpusetOnly) { - std::unique_ptr options = createOptionsImpl("envoy -c hello --cpuset-threads"); + OptionsImplPtr options = createOptionsImpl("envoy -c hello --cpuset-threads"); EXPECT_NE(options->concurrency(), 0); } TEST_F(OptionsImplTest, LogFormatDefault) { - std::unique_ptr options = createOptionsImpl({"envoy", "-c", "hello"}); + OptionsImplPtr options = createOptionsImpl({"envoy", "-c", "hello"}); EXPECT_EQ(options->logFormat(), "[%Y-%m-%d %T.%e][%t][%l][%n] [%g:%#] %v"); } TEST_F(OptionsImplTest, LogFormatDefaultNoPrefix) { - std::unique_ptr options = + OptionsImplPtr options = createOptionsImpl({"envoy", "-c", "hello", "--log-format-prefix-with-location", "0"}); EXPECT_EQ(options->logFormat(), "[%Y-%m-%d %T.%e][%t][%l][%n] %v"); } TEST_F(OptionsImplTest, LogFormatOverride) { - std::unique_ptr options = + OptionsImplPtr options = createOptionsImpl({"envoy", "-c", "hello", "--log-format", "%%v %v %t %v"}); EXPECT_EQ(options->logFormat(), "%%v [%g:%#] %v %t [%g:%#] %v"); } TEST_F(OptionsImplTest, LogFormatOverrideNoPrefix) { - std::unique_ptr options = + OptionsImplPtr options = createOptionsImpl({"envoy", "-c", "hello", "--log-format", "%%v %v %t %v", "--log-format-prefix-with-location 0"}); EXPECT_EQ(options->logFormat(), "%%v %v %t %v"); @@ -442,7 +442,7 @@ TEST_F(OptionsImplTest, LogFormatOverrideNoPrefix) { // Test that --base-id and --restart-epoch with non-default values are accepted. TEST_F(OptionsImplTest, SetBaseIdAndRestartEpoch) { - std::unique_ptr options = + OptionsImplPtr options = createOptionsImpl({"envoy", "-c", "hello", "--base-id", "99", "--restart-epoch", "999"}); EXPECT_EQ(99U, options->baseId()); EXPECT_EQ(999U, options->restartEpoch()); diff --git a/test/server/overload_manager_impl_test.cc b/test/server/overload_manager_impl_test.cc index 73715e249c07b..5c14d52bfb6eb 100644 --- a/test/server/overload_manager_impl_test.cc +++ b/test/server/overload_manager_impl_test.cc @@ -150,7 +150,7 @@ class OverloadManagerImplTest : public testing::Test { )EOF"; } - std::unique_ptr createOverloadManager(const std::string& config) { + OverloadManagerImplPtr createOverloadManager(const std::string& config) { return std::make_unique(dispatcher_, stats_, thread_local_, parseConfig(config), validation_visitor_, *api_); } diff --git a/test/server/server_fuzz_test.cc b/test/server/server_fuzz_test.cc index d070444fdac83..7a1f629c1b274 100644 --- a/test/server/server_fuzz_test.cc +++ b/test/server/server_fuzz_test.cc @@ -95,7 +95,7 @@ DEFINE_PROTO_FUZZER(const envoy::config::bootstrap::v3::Bootstrap& input) { options.log_level_ = Fuzz::Runner::logLevel(); } - std::unique_ptr server; + InstanceImplPtr server; try { server = std::make_unique( init_manager, options, test_time.timeSystem(), diff --git a/test/server/server_test.cc b/test/server/server_test.cc index 806ef87a58374..92cf5e83b6fb5 100644 --- a/test/server/server_test.cc +++ b/test/server/server_test.cc @@ -118,7 +118,7 @@ class RunHelperTest : public testing::Test { NiceMock overload_manager_; Init::ManagerImpl init_manager_{""}; ReadyWatcher start_workers_; - std::unique_ptr helper_; + RunHelperPtr helper_; std::function cm_init_callback_; #ifndef WIN32 Event::MockSignalEvent* sigterm_; @@ -253,16 +253,16 @@ class ServerInstanceImplTestBase { testing::NiceMock options_; DefaultListenerHooks hooks_; testing::NiceMock restart_; - std::unique_ptr thread_local_; + ThreadLocal::InstanceImplPtr thread_local_; Stats::TestIsolatedStoreImpl stats_store_; Thread::MutexBasicLockable fakelock_; TestComponentFactory component_factory_; Event::GlobalTimeSystem time_system_; ProcessObject* process_object_ = nullptr; - std::unique_ptr process_context_; - std::unique_ptr init_manager_; + ProcessContextImplPtr process_context_; + Init::ManagerPtr init_manager_; - std::unique_ptr server_; + InstanceImplPtr server_; }; class ServerInstanceImplTest : public ServerInstanceImplTestBase, diff --git a/test/test_common/global.h b/test/test_common/global.h index 872f81e520eba..7289e2a05c594 100644 --- a/test/test_common/global.h +++ b/test/test_common/global.h @@ -63,7 +63,7 @@ class Globals { void* ptrHelper() override { return ptr_.get(); } private: - std::unique_ptr ptr_{std::make_unique()}; + TypePtr ptr_{std::make_unique()}; }; Globals() = default; // Construct via Globals::instance(). diff --git a/test/test_common/registry.h b/test/test_common/registry.h index 0060417a06ead..4304b7a224cdd 100644 --- a/test/test_common/registry.h +++ b/test/test_common/registry.h @@ -60,7 +60,7 @@ template class InjectFactoryCategory { } private: - std::unique_ptr> proxy_; + FactoryRegistryProxyImplPtr proxy_; Base& instance_; }; diff --git a/test/test_common/test_runtime.h b/test/test_common/test_runtime.h index 0532b5529f9f2..05faf60ba347e 100644 --- a/test/test_common/test_runtime.h +++ b/test/test_common/test_runtime.h @@ -47,7 +47,7 @@ class TestScopedRuntime { Api::ApiPtr api_; testing::NiceMock local_info_; testing::NiceMock validation_visitor_; - std::unique_ptr loader_; + Runtime::ScopedLoaderSingletonPtr loader_; }; } // namespace Envoy diff --git a/test/test_common/utility.h b/test/test_common/utility.h index b45b229dd4e52..a6f78ed0e41ca 100644 --- a/test/test_common/utility.h +++ b/test/test_common/utility.h @@ -898,7 +898,7 @@ template class TestHeaderMapImplBase : public Inte return rc; } - std::unique_ptr header_map_{Impl::create()}; + ImplPtr header_map_{Impl::create()}; }; /** diff --git a/test/test_runner.cc b/test/test_runner.cc index 5eedad5ae23f6..0c424dc5f8fea 100644 --- a/test/test_runner.cc +++ b/test/test_runner.cc @@ -124,7 +124,7 @@ int TestRunner::RunTests(int argc, char** argv) { // Allocate fake log access manager. testing::NiceMock access_log_manager; - std::unique_ptr file_logger; + Logger::FileSinkDelegatePtr file_logger; // Redirect all logs to fake file when --log-path arg is specified in command line. if (!TestEnvironment::getOptions().logPath().empty()) { diff --git a/test/tools/router_check/coverage.cc b/test/tools/router_check/coverage.cc index f079f0319fd72..f6c05cc12a90c 100644 --- a/test/tools/router_check/coverage.cc +++ b/test/tools/router_check/coverage.cc @@ -112,8 +112,7 @@ RouteCoverage& Coverage::coveredRoute(const Envoy::Router::Route& route) { return *route_coverage; } } - std::unique_ptr new_coverage = - std::make_unique(route_entry, route_name); + RouteCoveragePtr new_coverage = std::make_unique(route_entry, route_name); covered_routes_.push_back(std::move(new_coverage)); return coveredRoute(route); } else if (route.directResponseEntry() != nullptr) { @@ -124,7 +123,7 @@ RouteCoverage& Coverage::coveredRoute(const Envoy::Router::Route& route) { return *route_coverage; } } - std::unique_ptr new_coverage = + RouteCoveragePtr new_coverage = std::make_unique(direct_response_entry, route_name); covered_routes_.push_back(std::move(new_coverage)); return coveredRoute(route); diff --git a/test/tools/router_check/coverage.h b/test/tools/router_check/coverage.h index 13019eec1af5d..576fb526e3842 100644 --- a/test/tools/router_check/coverage.h +++ b/test/tools/router_check/coverage.h @@ -55,7 +55,7 @@ class Coverage : Logger::Loggable { RouteCoverage& coveredRoute(const Envoy::Router::Route& route); void printMissingTests(const std::set& all_route_names, const std::set& covered_route_names); - std::vector> covered_routes_; + std::vector covered_routes_; const envoy::config::route::v3::RouteConfiguration route_config_; }; } // namespace Envoy diff --git a/test/tools/router_check/router.cc b/test/tools/router_check/router.cc index 74520ac641b88..7944f3d53a9d8 100644 --- a/test/tools/router_check/router.cc +++ b/test/tools/router_check/router.cc @@ -126,8 +126,8 @@ void RouterCheckTool::finalizeHeaders(ToolConfig& tool_config, RouterCheckTool::RouterCheckTool( std::unique_ptr> factory_context, - std::unique_ptr config, std::unique_ptr stats, - Api::ApiPtr api, Coverage coverage) + Router::ConfigImplPtr config, Stats::IsolatedStoreImplPtr stats, Api::ApiPtr api, + Coverage coverage) : factory_context_(std::move(factory_context)), config_(std::move(config)), stats_(std::move(stats)), api_(std::move(api)), coverage_(std::move(coverage)) { ON_CALL(factory_context_->runtime_loader_.snapshot_, diff --git a/test/tools/router_check/router.h b/test/tools/router_check/router.h index 19d2f86d746e7..b47189d483775 100644 --- a/test/tools/router_check/router.h +++ b/test/tools/router_check/router.h @@ -90,8 +90,8 @@ class RouterCheckTool : Logger::Loggable { private: RouterCheckTool( std::unique_ptr> factory_context, - std::unique_ptr config, std::unique_ptr stats, - Api::ApiPtr api, Coverage coverage); + Router::ConfigImplPtr config, Stats::IsolatedStoreImplPtr stats, Api::ApiPtr api, + Coverage coverage); /** * Set UUID as the name for each route for detecting missing tests during the coverage check. @@ -163,8 +163,8 @@ class RouterCheckTool : Logger::Loggable { // TODO(hennna): Switch away from mocks following work done by @rlazarus in github issue #499. std::unique_ptr> factory_context_; - std::unique_ptr config_; - std::unique_ptr stats_; + Router::ConfigImplPtr config_; + Stats::IsolatedStoreImplPtr stats_; Api::ApiPtr api_; std::string active_runtime_; Coverage coverage_; From 3cfca333700141168396fce9574e2e689e06926d Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 2 Jul 2020 18:13:14 +0000 Subject: [PATCH 19/36] declare type aliases Signed-off-by: tomocy --- include/envoy/config/grpc_mux.h | 4 +++- include/envoy/config/typed_metadata.h | 2 ++ include/envoy/event/dispatcher.h | 4 ++++ include/envoy/filesystem/filesystem.h | 2 ++ include/envoy/http/message.h | 4 +++- include/envoy/http/metadata_interface.h | 2 ++ include/envoy/init/manager.h | 4 ++++ include/envoy/network/connection.h | 2 ++ include/envoy/network/socket.h | 1 + include/envoy/router/router.h | 2 ++ include/envoy/router/router_ratelimit.h | 2 ++ include/envoy/runtime/runtime.h | 1 + include/envoy/secret/secret_manager.h | 3 +++ include/envoy/server/config_tracker.h | 1 + include/envoy/server/factory_context.h | 3 +++ include/envoy/server/guarddog.h | 4 ++++ include/envoy/server/health_checker_config.h | 4 ++++ include/envoy/server/listener_manager.h | 3 +++ include/envoy/server/process_context.h | 3 +++ include/envoy/ssl/context_config.h | 1 + include/envoy/stream_info/filter_state.h | 2 ++ include/envoy/thread/thread.h | 2 ++ include/envoy/tracing/http_tracer.h | 1 + include/envoy/upstream/cluster_manager.h | 2 ++ include/envoy/upstream/load_balancer.h | 2 ++ include/envoy/upstream/types.h | 5 +++++ include/envoy/upstream/upstream.h | 11 +++++++++-- source/common/buffer/buffer_impl.h | 5 +++++ source/common/common/cleanup.h | 3 +++ source/common/common/logger.h | 2 ++ source/common/common/logger_delegates.h | 2 ++ source/common/common/thread_synchronizer.h | 7 +++++++ source/common/common/utility.h | 7 ++++++- source/common/config/grpc_stream.h | 5 ++++- source/common/config/new_grpc_mux_impl.h | 4 ++++ source/common/config/watch_map.h | 3 +++ .../formatter/substitution_formatter.cc | 5 +++++ source/common/grpc/async_client_impl.h | 4 ++++ source/common/grpc/google_async_client_impl.h | 3 +++ source/common/grpc/typed_async_client.h | 11 +++++++---- source/common/http/async_client_impl.h | 6 ++++++ source/common/http/conn_manager_impl.h | 2 ++ source/common/http/hash_policy.h | 4 ++++ source/common/http/header_map_impl.h | 16 ++++++++++++++++ source/common/http/http2/metadata_decoder.h | 3 +++ source/common/http/http2/metadata_encoder.h | 3 +++ source/common/http/message_impl.h | 19 +++++++++++++++---- source/common/http/user_agent.h | 2 ++ source/common/init/target_impl.h | 3 +++ source/common/init/watcher_impl.h | 3 +++ source/common/memory/heap_shrinker.h | 4 ++++ source/common/network/dns_impl.h | 3 +++ source/common/network/hash_policy.h | 4 ++++ source/common/network/lc_trie.h | 13 +++++++++++-- source/common/network/socket_option_impl.h | 4 ++++ .../network/transport_socket_options_impl.h | 3 +++ source/common/router/config_impl.h | 6 ++++++ source/common/router/scoped_config_impl.h | 4 ++++ source/common/runtime/runtime_impl.h | 1 + source/common/runtime/runtime_protos.h | 3 +++ source/common/secret/secret_manager_impl.h | 13 ++++++++----- source/common/stats/stat_merger.h | 4 ++++ source/common/stats/symbol_table_impl.h | 2 ++ source/common/stats/thread_local_store.cc | 5 ++++- source/common/stats/thread_local_store.h | 5 ++++- source/common/stream_info/filter_state_impl.h | 4 ++++ source/common/tcp_proxy/tcp_proxy.h | 5 +++++ source/common/tcp_proxy/upstream.h | 6 ++++++ .../common/thread_local/thread_local_impl.h | 3 +++ source/common/upstream/edf_scheduler.h | 4 ++++ .../upstream/health_checker_base_impl.h | 5 +++++ source/common/upstream/health_checker_impl.h | 4 ++++ source/common/upstream/load_balancer_impl.cc | 1 + source/common/upstream/original_dst_cluster.h | 7 +++++-- .../common/upstream/outlier_detection_impl.h | 4 ++++ source/common/upstream/thread_aware_lb_impl.h | 6 +++++- source/common/upstream/upstream_impl.h | 6 ++++++ .../redis/cluster_refresh_manager_impl.h | 5 +++++ .../filters/common/rbac/engine_impl.h | 4 ++++ .../extensions/filters/common/rbac/matchers.h | 2 ++ .../evaluators/response_evaluator.h | 3 +++ .../http/common/compressor/compressor.h | 4 ++++ .../filters/http/fault/fault_filter.h | 2 ++ .../json_transcoder_filter.cc | 5 +++++ .../filters/http/jwt_authn/filter_config.h | 6 ++++++ .../filters/network/common/redis/codec.h | 4 ++++ .../common/redis/redis_command_stats.h | 4 ++++ .../network/dubbo_proxy/conn_manager.h | 4 ++++ .../dubbo_proxy/router/route_matcher.h | 2 ++ .../network/dubbo_proxy/router/router_impl.h | 2 ++ .../filters/network/mongo_proxy/bson_impl.h | 4 ++++ .../filters/network/mongo_proxy/codec_impl.h | 15 +++++++++++++++ .../network/thrift_proxy/conn_manager.h | 4 ++++ .../thrift_proxy/router/router_impl.cc | 1 + .../network/thrift_proxy/router/router_impl.h | 4 ++++ .../thrift_proxy/router/router_ratelimit.h | 2 ++ .../fixed_heap/fixed_heap_monitor.h | 4 ++++ .../stat_sinks/common/statsd/statsd.h | 3 +++ source/server/admin/admin.h | 3 +++ source/server/filter_chain_manager_impl.h | 1 + source/server/hot_restarting_base.cc | 3 +++ source/server/hot_restarting_child.cc | 3 +++ source/server/listener_impl.h | 9 +++++++++ source/server/listener_manager_impl.h | 2 +- source/server/overload_manager_impl.h | 3 +++ source/server/server.h | 2 ++ 106 files changed, 411 insertions(+), 27 deletions(-) diff --git a/include/envoy/config/grpc_mux.h b/include/envoy/config/grpc_mux.h index c529cc893ebc0..1a7ec5d36a465 100644 --- a/include/envoy/config/grpc_mux.h +++ b/include/envoy/config/grpc_mux.h @@ -6,6 +6,7 @@ #include "envoy/stats/stats_macros.h" #include "common/protobuf/protobuf.h" +#include namespace Envoy { namespace Config { @@ -124,6 +125,7 @@ class GrpcMux { using GrpcMuxPtr = std::unique_ptr; using GrpcMuxSharedPtr = std::shared_ptr; +template using ResponseProtoPtr = std::unique_ptr; /** * A grouping of callbacks that a GrpcMux should provide to its GrpcStream. */ @@ -146,7 +148,7 @@ template class GrpcStreamCallbacks { /** * For the GrpcStream to pass received protos to the context. */ - virtual void onDiscoveryResponse(ResponseProtoPtr&& message, + virtual void onDiscoveryResponse(ResponseProtoPtr&& message, ControlPlaneStats& control_plane_stats) PURE; /** diff --git a/include/envoy/config/typed_metadata.h b/include/envoy/config/typed_metadata.h index e7b7a355a195e..cb21a3b13bb1e 100644 --- a/include/envoy/config/typed_metadata.h +++ b/include/envoy/config/typed_metadata.h @@ -21,6 +21,8 @@ class TypedMetadata { virtual ~Object() = default; }; + using ObjectConstPtr = std::unique_ptr; + virtual ~TypedMetadata() = default; /** diff --git a/include/envoy/event/dispatcher.h b/include/envoy/event/dispatcher.h index 1cad39e3d1f5c..9e5303c3f888b 100644 --- a/include/envoy/event/dispatcher.h +++ b/include/envoy/event/dispatcher.h @@ -40,11 +40,15 @@ struct DispatcherStats { ALL_DISPATCHER_STATS(GENERATE_HISTOGRAM_STRUCT) }; +using DispatcherStatsPtr = std::unique_ptr; + /** * Callback invoked when a dispatcher post() runs. */ using PostCb = std::function; +using PostCbSharedPtr = std::shared_ptr; + /** * Abstract event dispatching loop. */ diff --git a/include/envoy/filesystem/filesystem.h b/include/envoy/filesystem/filesystem.h index 503eb4d87d9c2..28fb6a6383f87 100644 --- a/include/envoy/filesystem/filesystem.h +++ b/include/envoy/filesystem/filesystem.h @@ -130,6 +130,8 @@ class Instance { virtual bool illegalPath(const std::string& path) PURE; }; +using InstancePtr = std::unique_ptr; + enum class FileType { Regular, Directory, Other }; struct DirectoryEntry { diff --git a/include/envoy/http/message.h b/include/envoy/http/message.h index e2a5bb15bb92c..f8d1572296397 100644 --- a/include/envoy/http/message.h +++ b/include/envoy/http/message.h @@ -9,6 +9,8 @@ namespace Envoy { namespace Http { +template using TrailerTypePtr = std::unique_ptr; + /** * Wraps an HTTP message including its headers, body, and any trailers. */ @@ -36,7 +38,7 @@ template class Message { * Set the trailers. * @param trailers supplies the new trailers. */ - virtual void trailers(TrailerTypePtr&& trailers) PURE; + virtual void trailers(TrailerTypePtr&& trailers) PURE; /** * @return std::string the message body as a std::string. diff --git a/include/envoy/http/metadata_interface.h b/include/envoy/http/metadata_interface.h index dc8dc0e4e65c5..98878e2ac5574 100644 --- a/include/envoy/http/metadata_interface.h +++ b/include/envoy/http/metadata_interface.h @@ -52,6 +52,8 @@ class MetadataMapVector : public VectorMetadataMapPtr { } }; +using MetadataMapVectorPtr = std::unique_ptr; + using MetadataCallback = std::function; } // namespace Http diff --git a/include/envoy/init/manager.h b/include/envoy/init/manager.h index 94cf0dbb25e1a..803f9c0da58be 100644 --- a/include/envoy/init/manager.h +++ b/include/envoy/init/manager.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/pure.h" #include "envoy/init/target.h" #include "envoy/init/watcher.h" @@ -75,5 +77,7 @@ struct Manager { virtual void initialize(const Watcher& watcher) PURE; }; +using ManagerPtr = std::unique_ptr; + } // namespace Init } // namespace Envoy diff --git a/include/envoy/network/connection.h b/include/envoy/network/connection.h index 6e9667f778043..3309a8ba95cc8 100644 --- a/include/envoy/network/connection.h +++ b/include/envoy/network/connection.h @@ -93,6 +93,8 @@ class Connection : public Event::DeferredDeletable, public FilterManager { Stats::Counter* delayed_close_timeouts_; }; + using ConnectionStatsPtr = std::unique_ptr; + ~Connection() override = default; /** diff --git a/include/envoy/network/socket.h b/include/envoy/network/socket.h index 0951f0a046172..2dcb6e5cf1d8d 100644 --- a/include/envoy/network/socket.h +++ b/include/envoy/network/socket.h @@ -192,6 +192,7 @@ class Socket { using OptionConstSharedPtr = std::shared_ptr; using Options = std::vector; + using OptionsPtr = std::unique_ptr; using OptionsSharedPtr = std::shared_ptr; static OptionsSharedPtr& appendOptions(OptionsSharedPtr& to, const OptionsSharedPtr& from) { diff --git a/include/envoy/router/router.h b/include/envoy/router/router.h index 3115fae29422e..2a7378e0a5fcd 100644 --- a/include/envoy/router/router.h +++ b/include/envoy/router/router.h @@ -1099,6 +1099,8 @@ class GenericConnectionPoolCallbacks; class UpstreamRequest; class GenericUpstream; +using GenericUpstreamPtr = std::unique_ptr; + /** * An API for wrapping either an HTTP or a TCP connection pool. * diff --git a/include/envoy/router/router_ratelimit.h b/include/envoy/router/router_ratelimit.h index 246c177bd47b7..8d5dbc5b3e409 100644 --- a/include/envoy/router/router_ratelimit.h +++ b/include/envoy/router/router_ratelimit.h @@ -67,6 +67,8 @@ class RateLimitPolicyEntry { const Network::Address::Instance& remote_address) const PURE; }; +using RateLimitPolicyEntryPtr = std::unique_ptr; + /** * Rate limiting policy. */ diff --git a/include/envoy/runtime/runtime.h b/include/envoy/runtime/runtime.h index 89f904ffac084..4e52b8707d1ed 100644 --- a/include/envoy/runtime/runtime.h +++ b/include/envoy/runtime/runtime.h @@ -314,6 +314,7 @@ using LoaderPtr = std::unique_ptr; // protos being enabled or disabled by default. using LoaderSingleton = InjectableSingleton; using ScopedLoaderSingleton = ScopedInjectableLoader; +using ScopedLoaderSingletonPtr = std::unique_ptr; } // namespace Runtime } // namespace Envoy diff --git a/include/envoy/secret/secret_manager.h b/include/envoy/secret/secret_manager.h index 666ce325244c4..8f6c19c08ac21 100644 --- a/include/envoy/secret/secret_manager.h +++ b/include/envoy/secret/secret_manager.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/config/core/v3/config_source.pb.h" @@ -156,5 +157,7 @@ class SecretManager { Server::Configuration::TransportSocketFactoryContext& secret_provider_context) PURE; }; +using SecretManagerPtr = std::unique_ptr; + } // namespace Secret } // namespace Envoy diff --git a/include/envoy/server/config_tracker.h b/include/envoy/server/config_tracker.h index 53bcb11121e9f..d4443e9367854 100644 --- a/include/envoy/server/config_tracker.h +++ b/include/envoy/server/config_tracker.h @@ -23,6 +23,7 @@ class ConfigTracker { public: using Cb = std::function; using CbsMap = std::map; + using CbsMapSharedPtr = std::shared_ptr; /** * EntryOwner supplies RAII semantics for entries in the map. diff --git a/include/envoy/server/factory_context.h b/include/envoy/server/factory_context.h index 56dac952be3e9..6180f7c564a2d 100644 --- a/include/envoy/server/factory_context.h +++ b/include/envoy/server/factory_context.h @@ -104,6 +104,8 @@ class CommonFactoryContext { virtual Api::Api& api() PURE; }; +using CommonFactoryContextPtr = std::unique_ptr; + /** * ServerFactoryContext is an specialization of common interface for downstream and upstream network * filters. The implementation guarantees the lifetime is no shorter than server. It could be used @@ -248,6 +250,7 @@ class FilterChainFactoryContext : public virtual FactoryContext { }; using FilterChainFactoryContextPtr = std::unique_ptr; +using FilterChainFactoryContextSharedPtr = std::shared_ptr; /** * An implementation of FactoryContext. The life time should cover the lifetime of the filter chains diff --git a/include/envoy/server/guarddog.h b/include/envoy/server/guarddog.h index 08b8f53646a00..6111250db1ed0 100644 --- a/include/envoy/server/guarddog.h +++ b/include/envoy/server/guarddog.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/pure.h" #include "envoy/server/watchdog.h" @@ -42,5 +44,7 @@ class GuardDog { virtual void stopWatching(WatchDogSharedPtr wd) PURE; }; +using GuardDogPtr = std::unique_ptr; + } // namespace Server } // namespace Envoy diff --git a/include/envoy/server/health_checker_config.h b/include/envoy/server/health_checker_config.h index 5994e37f231bf..2addf3c938094 100644 --- a/include/envoy/server/health_checker_config.h +++ b/include/envoy/server/health_checker_config.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/core/v3/health_check.pb.h" #include "envoy/config/typed_config.h" #include "envoy/runtime/runtime.h" @@ -52,6 +54,8 @@ class HealthCheckerFactoryContext { virtual Api::Api& api() PURE; }; +using HealthCheckerFactoryContextPtr = std::unique_ptr; + /** * Implemented by each custom health checker and registered via Registry::registerFactory() * or the convenience class RegisterFactory. diff --git a/include/envoy/server/listener_manager.h b/include/envoy/server/listener_manager.h index 956a89264ac45..3a1a8a587f059 100644 --- a/include/envoy/server/listener_manager.h +++ b/include/envoy/server/listener_manager.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/admin/v3/config_dump.pb.h" @@ -223,5 +224,7 @@ class ListenerManager { virtual ApiListenerOptRef apiListener() PURE; }; +using ListenerManagerPtr = std::unique_ptr; + } // namespace Server } // namespace Envoy diff --git a/include/envoy/server/process_context.h b/include/envoy/server/process_context.h index 556941642d990..195a4366c2a1b 100644 --- a/include/envoy/server/process_context.h +++ b/include/envoy/server/process_context.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/pure.h" #include "absl/types/optional.h" @@ -30,6 +32,7 @@ class ProcessContext { virtual ProcessObject& get() const PURE; }; +using ProcessContextPtr = std::unique_ptr; using ProcessContextOptRef = absl::optional>; } // namespace Envoy diff --git a/include/envoy/ssl/context_config.h b/include/envoy/ssl/context_config.h index 9196a5a294a9e..cd74bf8487bb9 100644 --- a/include/envoy/ssl/context_config.h +++ b/include/envoy/ssl/context_config.h @@ -137,6 +137,7 @@ class ServerContextConfig : public virtual ContextConfig { }; using ServerContextConfigPtr = std::unique_ptr; +using ServerContextConfigConstPtr = std::unique_ptr; } // namespace Ssl } // namespace Envoy diff --git a/include/envoy/stream_info/filter_state.h b/include/envoy/stream_info/filter_state.h index 3566f9d7b647d..f831d9663944a 100644 --- a/include/envoy/stream_info/filter_state.h +++ b/include/envoy/stream_info/filter_state.h @@ -65,6 +65,8 @@ class FilterState { virtual absl::optional serializeAsString() const { return absl::nullopt; } }; + using ObjectSharedPtr = std::shared_ptr; + virtual ~FilterState() = default; /** diff --git a/include/envoy/thread/thread.h b/include/envoy/thread/thread.h index 8633c03e1ebed..bcc6864d14664 100644 --- a/include/envoy/thread/thread.h +++ b/include/envoy/thread/thread.h @@ -81,6 +81,8 @@ class ThreadFactory { virtual ThreadId currentThreadId() PURE; }; +using ThreadFactoryPtr = std::unique_ptr; + /** * Like the C++11 "basic lockable concept" but a pure virtual interface vs. a template, and * with thread annotations. diff --git a/include/envoy/tracing/http_tracer.h b/include/envoy/tracing/http_tracer.h index 63da639e84ee8..c4f0073530719 100644 --- a/include/envoy/tracing/http_tracer.h +++ b/include/envoy/tracing/http_tracer.h @@ -73,6 +73,7 @@ class CustomTag { using CustomTagConstSharedPtr = std::shared_ptr; using CustomTagMap = absl::flat_hash_map; +using CustomTagMapPtr = std::unique_ptr; /** * Tracing configuration, it carries additional data needed to populate the span. diff --git a/include/envoy/upstream/cluster_manager.h b/include/envoy/upstream/cluster_manager.h index e3eea850f0005..318541953bfa8 100644 --- a/include/envoy/upstream/cluster_manager.h +++ b/include/envoy/upstream/cluster_manager.h @@ -344,6 +344,8 @@ class ClusterManagerFactory { virtual Secret::SecretManager& secretManager() PURE; }; +using ClusterManagerFactoryPtr = std::unique_ptr; + /** * Factory for creating ClusterInfo */ diff --git a/include/envoy/upstream/load_balancer.h b/include/envoy/upstream/load_balancer.h index 031daffc8ad20..cc846cc5bed57 100644 --- a/include/envoy/upstream/load_balancer.h +++ b/include/envoy/upstream/load_balancer.h @@ -85,6 +85,8 @@ class LoadBalancerContext { virtual Network::TransportSocketOptionsSharedPtr upstreamTransportSocketOptions() const PURE; }; +using LoadBalancerContextPtr = std::unique_ptr; + /** * Abstract load balancing interface. */ diff --git a/include/envoy/upstream/types.h b/include/envoy/upstream/types.h index dafc0f22f6bf8..82ecd281e3dce 100644 --- a/include/envoy/upstream/types.h +++ b/include/envoy/upstream/types.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "common/common/phantom.h" @@ -23,11 +24,15 @@ struct DegradedLoad : PriorityLoad { using PriorityLoad::PriorityLoad; }; +using DegradedLoadSharedPtr = std::shared_ptr; + // PriorityLoad specific to healthy hosts. struct HealthyLoad : PriorityLoad { using PriorityLoad::PriorityLoad; }; +using HealthyLoadSharedPtr = std::shared_ptr; + struct HealthyAndDegradedLoad { HealthyLoad healthy_priority_load_; DegradedLoad degraded_priority_load_; diff --git a/include/envoy/upstream/upstream.h b/include/envoy/upstream/upstream.h index 3d7aebddba81c..37fd00d5012c0 100644 --- a/include/envoy/upstream/upstream.h +++ b/include/envoy/upstream/upstream.h @@ -208,6 +208,7 @@ class Host : virtual public HostDescription { using HostConstSharedPtr = std::shared_ptr; using HostVector = std::vector; +using HostVectorPtr = std::unique_ptr; using HealthyHostVector = Phantom; using DegradedHostVector = Phantom; using ExcludedHostVector = Phantom; @@ -224,6 +225,10 @@ using LocalityWeightsMap = std::unordered_map; using PriorityState = std::vector>; +class HostsPerLocality; + +using HostsPerLocalityConstSharedPtr = std::shared_ptr; + /** * Bucket hosts by locality. */ @@ -264,7 +269,6 @@ class HostsPerLocality { }; using HostsPerLocalitySharedPtr = std::shared_ptr; -using HostsPerLocalityConstSharedPtr = std::shared_ptr; // Weight for each locality index in HostsPerLocality. using LocalityWeights = std::vector; @@ -735,6 +739,8 @@ class ClusterInfo { virtual const envoy::config::core::v3::HttpProtocolOptions& commonHttpProtocolOptions() const PURE; + template using DerivedConstSharedPtr = std::shared_ptr; + /** * @param name std::string containing the well-known name of the extension for which protocol * options are desired @@ -742,7 +748,8 @@ class ClusterInfo { * and contains extension-specific protocol options for upstream connections. */ template - const DerivedConstSharedPtr extensionProtocolOptionsTyped(const std::string& name) const { + const DerivedConstSharedPtr + extensionProtocolOptionsTyped(const std::string& name) const { return std::dynamic_pointer_cast(extensionProtocolOptions(name)); } diff --git a/source/common/buffer/buffer_impl.h b/source/common/buffer/buffer_impl.h index 076b16f60440f..0772f5ea8a7fa 100644 --- a/source/common/buffer/buffer_impl.h +++ b/source/common/buffer/buffer_impl.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "envoy/buffer/buffer.h" @@ -212,6 +213,10 @@ class Slice { using SlicePtr = std::unique_ptr; +class OwnedSlice; + +using OwnedSlicePtr = std::unique_ptr; + // OwnedSlice can not be derived from as it has variable sized array as member. class OwnedSlice final : public Slice, public InlineStorage { public: diff --git a/source/common/common/cleanup.h b/source/common/common/cleanup.h index adf37cef68616..c5135d01fa490 100644 --- a/source/common/common/cleanup.h +++ b/source/common/common/cleanup.h @@ -2,6 +2,7 @@ #include #include +#include #include "common/common/assert.h" @@ -25,6 +26,8 @@ class Cleanup { bool cancelled_; }; +using CleanupPtr = std::unique_ptr; + // RAII helper class to add an element to an std::list on construction and erase // it on destruction, unless the cancel method has been called. template class RaiiListElement { diff --git a/source/common/common/logger.h b/source/common/common/logger.h index 5a7a166f9bdef..5815f5e574a0d 100644 --- a/source/common/common/logger.h +++ b/source/common/common/logger.h @@ -129,6 +129,8 @@ class StderrSinkDelegate : public SinkDelegate { Thread::BasicLockable* lock_{}; }; +using StderrSinkDelegatePtr = std::unique_ptr; + /** * Stacks logging sinks, so you can temporarily override the logging mechanism, restoring * the previous state when the DelegatingSink is destructed. diff --git a/source/common/common/logger_delegates.h b/source/common/common/logger_delegates.h index 504855d58f442..28c79902657d8 100644 --- a/source/common/common/logger_delegates.h +++ b/source/common/common/logger_delegates.h @@ -33,6 +33,8 @@ class FileSinkDelegate : public SinkDelegate { AccessLog::AccessLogFileSharedPtr log_file_; }; +using FileSinkDelegatePtr = std::unique_ptr; + } // namespace Logger } // namespace Envoy diff --git a/source/common/common/thread_synchronizer.h b/source/common/common/thread_synchronizer.h index 6b5ab2bece68e..575b4a1d030f2 100644 --- a/source/common/common/thread_synchronizer.h +++ b/source/common/common/thread_synchronizer.h @@ -1,11 +1,14 @@ #pragma once +#include + #include "common/common/assert.h" #include "common/common/logger.h" #include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" +#include namespace Envoy { namespace Thread { @@ -78,11 +81,15 @@ class ThreadSynchronizer : Logger::Loggable { bool at_barrier_ ABSL_GUARDED_BY(mutex_){}; }; + using SynchronizerEntryPtr = std::unique_ptr; + struct SynchronizerData { absl::Mutex mutex_; absl::flat_hash_map entries_ ABSL_GUARDED_BY(mutex_); }; + using SynchronizerDataPtr = std::unique_ptr; + SynchronizerEntry& getOrCreateEntry(absl::string_view event_name); void syncPointWorker(absl::string_view event_name); void waitOnWorker(absl::string_view event_name); diff --git a/source/common/common/utility.h b/source/common/common/utility.h index 283982407eecf..8b79d4e0dd216 100644 --- a/source/common/common/utility.h +++ b/source/common/common/utility.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -535,9 +536,13 @@ class WelfordStandardDeviation { double m2_{0}; }; +template struct TrieEntry; + +template using TrieEntryPtr = std::unique_ptr>; + template struct TrieEntry { Value value_{}; - std::array entries_; + std::array, 256> entries_; }; /** diff --git a/source/common/config/grpc_stream.h b/source/common/config/grpc_stream.h index 52bb7aedef63f..6d7a9c1edebde 100644 --- a/source/common/config/grpc_stream.h +++ b/source/common/config/grpc_stream.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/config/grpc_mux.h" #include "envoy/grpc/async_client.h" @@ -13,6 +14,8 @@ namespace Envoy { namespace Config { +template using ResponseProtoPtr = std::unique_ptr; + // Oversees communication for gRPC xDS implementations (parent to both regular xDS and delta // xDS variants). Reestablishes the gRPC channel when necessary, and provides rate limiting of // requests. @@ -74,7 +77,7 @@ class GrpcStream : public Grpc::AsyncStreamCallbacks, UNREFERENCED_PARAMETER(metadata); } - void onReceiveMessage(ResponseProtoPtr&& message) override { + void onReceiveMessage(ResponseProtoPtr&& message) override { // Reset here so that it starts with fresh backoff interval on next disconnect. backoff_strategy_->reset(); // Sometimes during hot restarts this stat's value becomes inconsistent and will continue to diff --git a/source/common/config/new_grpc_mux_impl.h b/source/common/config/new_grpc_mux_impl.h index 0f3fb6a903cab..6b02611162a8e 100644 --- a/source/common/config/new_grpc_mux_impl.h +++ b/source/common/config/new_grpc_mux_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/api/v2/discovery.pb.h" #include "envoy/common/token_bucket.h" #include "envoy/config/grpc_mux.h" @@ -70,6 +72,8 @@ class NewGrpcMuxImpl SubscriptionStuff& operator=(const SubscriptionStuff&) = delete; }; + using SubscriptionStuffPtr = std::unique_ptr; + // for use in tests only const absl::flat_hash_map& subscriptions() { return subscriptions_; diff --git a/source/common/config/watch_map.h b/source/common/config/watch_map.h index c2bafc1756d2a..1dbc4493f3f91 100644 --- a/source/common/config/watch_map.h +++ b/source/common/config/watch_map.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -33,6 +34,8 @@ struct Watch { bool state_of_the_world_empty_{true}; }; +using WatchPtr = std::unique_ptr; + // NOTE: Users are responsible for eventually calling removeWatch() on the Watch* returned // by addWatch(). We don't expect there to be new users of this class beyond // NewGrpcMuxImpl and DeltaSubscriptionImpl (TODO(fredlas) to be renamed). diff --git a/source/common/formatter/substitution_formatter.cc b/source/common/formatter/substitution_formatter.cc index 193d91cdb5528..f9ce6435bff45 100644 --- a/source/common/formatter/substitution_formatter.cc +++ b/source/common/formatter/substitution_formatter.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -454,6 +455,10 @@ class StreamInfoUInt64FieldExtractor : public StreamInfoFormatter::FieldExtracto FieldExtractor field_extractor_; }; +class StreamInfoAddressFieldExtractor; + +using StreamInfoAddressFieldExtractorPtr = std::unique_ptr; + // StreamInfo Envoy::Network::Address::InstanceConstSharedPtr field extractor. class StreamInfoAddressFieldExtractor : public StreamInfoFormatter::FieldExtractor { public: diff --git a/source/common/grpc/async_client_impl.h b/source/common/grpc/async_client_impl.h index d1af191cdafdd..9b49826eb6927 100644 --- a/source/common/grpc/async_client_impl.h +++ b/source/common/grpc/async_client_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/core/v3/base.pb.h" #include "envoy/config/core/v3/grpc_service.pb.h" #include "envoy/grpc/async_client.h" @@ -13,7 +15,9 @@ namespace Envoy { namespace Grpc { class AsyncRequestImpl; + class AsyncStreamImpl; +using AsyncStreamImplPtr = std::unique_ptr; class AsyncClientImpl final : public RawAsyncClient { public: diff --git a/source/common/grpc/google_async_client_impl.h b/source/common/grpc/google_async_client_impl.h index 8aaf4b688580e..7339cf1d74a9f 100644 --- a/source/common/grpc/google_async_client_impl.h +++ b/source/common/grpc/google_async_client_impl.h @@ -29,6 +29,9 @@ namespace Envoy { namespace Grpc { class GoogleAsyncStreamImpl; + +using GoogleAsyncStreamImplPtr = std::unique_ptr; + class GoogleAsyncRequestImpl; struct GoogleAsyncTag { diff --git a/source/common/grpc/typed_async_client.h b/source/common/grpc/typed_async_client.h index 012013a6c998d..241926ee4ed70 100644 --- a/source/common/grpc/typed_async_client.h +++ b/source/common/grpc/typed_async_client.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/grpc/async_client.h" @@ -62,17 +63,19 @@ template class AsyncStream /* : public RawAsyncStream */ { RawAsyncStream* stream_{}; }; +template using ResponsePtr = std::unique_ptr; + /** * Convenience subclasses for AsyncRequestCallbacks. */ template class AsyncRequestCallbacks : public RawAsyncRequestCallbacks { public: ~AsyncRequestCallbacks() override = default; - virtual void onSuccess(ResponsePtr&& response, Tracing::Span& span) PURE; + virtual void onSuccess(ResponsePtr&& response, Tracing::Span& span) PURE; private: void onSuccessRaw(Buffer::InstancePtr&& response, Tracing::Span& span) override { - auto message = ResponsePtr(dynamic_cast( + auto message = ResponsePtr(dynamic_cast( Internal::parseMessageUntyped(std::make_unique(), std::move(response)) .release())); if (!message) { @@ -138,11 +141,11 @@ class VersionedMethods { template class AsyncStreamCallbacks : public RawAsyncStreamCallbacks { public: ~AsyncStreamCallbacks() override = default; - virtual void onReceiveMessage(ResponsePtr&& message) PURE; + virtual void onReceiveMessage(ResponsePtr&& message) PURE; private: bool onReceiveMessageRaw(Buffer::InstancePtr&& response) override { - auto message = ResponsePtr(dynamic_cast( + auto message = ResponsePtr(dynamic_cast( Internal::parseMessageUntyped(std::make_unique(), std::move(response)) .release())); if (!message) { diff --git a/source/common/http/async_client_impl.h b/source/common/http/async_client_impl.h index 75de512b15740..9162a8f6ac4f5 100644 --- a/source/common/http/async_client_impl.h +++ b/source/common/http/async_client_impl.h @@ -17,6 +17,7 @@ #include "envoy/http/async_client.h" #include "envoy/http/codec.h" #include "envoy/http/context.h" +#include "envoy/http/hash_policy.h" #include "envoy/http/header_map.h" #include "envoy/http/message.h" #include "envoy/router/router.h" @@ -40,6 +41,9 @@ namespace Envoy { namespace Http { class AsyncStreamImpl; + +using AsyncStreamImplPtr = std::unique_ptr; + class AsyncRequestImpl; class AsyncClientImpl final : public AsyncClient { @@ -322,6 +326,8 @@ class AsyncStreamImpl : public AsyncClient::Stream, RouteEntryImpl route_entry_; }; + using RouteImplSharedPtr = std::shared_ptr; + void cleanup(); void closeRemote(bool end_stream); bool complete() { return local_closed_ && remote_closed_; } diff --git a/source/common/http/conn_manager_impl.h b/source/common/http/conn_manager_impl.h index 9f30365a41796..a8dad0c7a3862 100644 --- a/source/common/http/conn_manager_impl.h +++ b/source/common/http/conn_manager_impl.h @@ -426,6 +426,8 @@ class ConnectionManagerImpl : Logger::Loggable, }; }; + using RouteConfigUpdateRequesterPtr = std::unique_ptr; + class RdsRouteConfigUpdateRequester : public RouteConfigUpdateRequester { public: RdsRouteConfigUpdateRequester(Router::RouteConfigProvider* route_config_provider) diff --git a/source/common/http/hash_policy.h b/source/common/http/hash_policy.h index 31368e552408c..8a1395f0f6060 100644 --- a/source/common/http/hash_policy.h +++ b/source/common/http/hash_policy.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/route/v3/route_components.pb.h" #include "envoy/http/hash_policy.h" #include "envoy/stream_info/filter_state.h" @@ -40,5 +42,7 @@ class HashPolicyImpl : public HashPolicy { std::vector hash_impls_; }; +using HashPolicyImplConstPtr = std::unique_ptr; + } // namespace Http } // namespace Envoy diff --git a/source/common/http/header_map_impl.h b/source/common/http/header_map_impl.h index 8f3e7ef6a99ec..591e5ead01910 100644 --- a/source/common/http/header_map_impl.h +++ b/source/common/http/header_map_impl.h @@ -371,6 +371,10 @@ template class TypedHeaderMapImpl : public HeaderMapImpl, publ Handle name = \ CustomInlineHeaderRegistry::getInlineHeader(Headers::get().name).value(); +class RequestHeaderMapImpl; + +using RequestHeaderMapImplPtr = std::unique_ptr; + /** * Concrete implementation of RequestHeaderMap which allows for variable custom registered inline * headers. @@ -407,6 +411,10 @@ class RequestHeaderMapImpl final : public TypedHeaderMapImpl, HeaderEntryImpl* inline_headers_[]; }; +class RequestTrailerMapImpl; + +using RequestTrailerMapImplPtr = std::unique_ptr; + /** * Concrete implementation of RequestTrailerMap which allows for variable custom registered inline * headers. @@ -430,6 +438,10 @@ class RequestTrailerMapImpl final : public TypedHeaderMapImpl HeaderEntryImpl* inline_headers_[]; }; +class ResponseHeaderMapImpl; + +using ResponseHeaderMapImplPtr = std::unique_ptr; + /** * Concrete implementation of ResponseHeaderMap which allows for variable custom registered inline * headers. @@ -465,6 +477,10 @@ class ResponseHeaderMapImpl final : public TypedHeaderMapImpl HeaderEntryImpl* inline_headers_[]; }; +class ResponseTrailerMapImpl; + +using ResponseTrailerMapImplPtr = std::unique_ptr; + /** * Concrete implementation of ResponseTrailerMap which allows for variable custom registered * inline headers. diff --git a/source/common/http/http2/metadata_decoder.h b/source/common/http/http2/metadata_decoder.h index 16510776e5635..33e2526982f39 100644 --- a/source/common/http/http2/metadata_decoder.h +++ b/source/common/http/http2/metadata_decoder.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "envoy/http/codec.h" @@ -74,6 +75,8 @@ class MetadataDecoder : Logger::Loggable { Inflater inflater_; }; +using MetadataDecoderPtr = std::unique_ptr; + } // namespace Http2 } // namespace Http } // namespace Envoy diff --git a/source/common/http/http2/metadata_encoder.h b/source/common/http/http2/metadata_encoder.h index 64e520e0cded5..1f729aff7af8b 100644 --- a/source/common/http/http2/metadata_encoder.h +++ b/source/common/http/http2/metadata_encoder.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -90,6 +91,8 @@ class MetadataEncoder : Logger::Loggable { std::deque payload_size_queue_; }; +using MetadataEncoderPtr = std::unique_ptr; + } // namespace Http2 } // namespace Http } // namespace Envoy diff --git a/source/common/http/message_impl.h b/source/common/http/message_impl.h index d44dc075bd9ee..12ef098bdede1 100644 --- a/source/common/http/message_impl.h +++ b/source/common/http/message_impl.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/http/header_map.h" @@ -12,6 +13,12 @@ namespace Envoy { namespace Http { +template +using HeadersInterfaceTypePtr = std::unique_ptr; + +template +using TrailersInterfaceTypePtr = std::unique_ptr; + /** * Implementation of Http::Message. This implementation does not support streaming. */ @@ -20,13 +27,16 @@ template { public: MessageImpl() : headers_(HeadersImplType::create()) {} - MessageImpl(HeadersInterfaceTypePtr&& headers) : headers_(std::move(headers)) {} + MessageImpl(HeadersInterfaceTypePtr&& headers) + : headers_(std::move(headers)) {} // Http::Message HeadersInterfaceType& headers() override { return *headers_; } Buffer::InstancePtr& body() override { return body_; } TrailersInterfaceType* trailers() override { return trailers_.get(); } - void trailers(TrailersInterfaceTypePtr&& trailers) override { trailers_ = std::move(trailers); } + void trailers(TrailersInterfaceTypePtr&& trailers) override { + trailers_ = std::move(trailers); + } std::string bodyAsString() const override { if (body_) { return body_->toString(); @@ -36,15 +46,16 @@ class MessageImpl : public Message } private: - HeadersInterfaceTypePtr headers_; + HeadersInterfaceTypePtr headers_; Buffer::InstancePtr body_; - TrailersInterfaceTypePtr trailers_; + TrailersInterfaceTypePtr trailers_; }; using RequestMessageImpl = MessageImpl; using ResponseMessageImpl = MessageImpl; +using ResponseMessageImplPtr = std::unique_ptr; } // namespace Http } // namespace Envoy diff --git a/source/common/http/user_agent.h b/source/common/http/user_agent.h index 35727dbdd01b7..5e846c50245b4 100644 --- a/source/common/http/user_agent.h +++ b/source/common/http/user_agent.h @@ -48,6 +48,8 @@ struct UserAgentStats { Stats::Histogram& downstream_cx_length_ms_; }; +using UserAgentStatsPtr = std::unique_ptr; + /** * Stats support for specific user agents. */ diff --git a/source/common/init/target_impl.h b/source/common/init/target_impl.h index 4b3c2abb28e89..b20df16566328 100644 --- a/source/common/init/target_impl.h +++ b/source/common/init/target_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/init/target.h" @@ -22,6 +23,8 @@ using InitializeFn = std::function; */ using InternalInitalizeFn = std::function; +using InternalInitalizeFnSharedPtr = std::shared_ptr; + /** * A TargetHandleImpl functions as a weak reference to a TargetImpl. It is how a ManagerImpl safely * tells a target to `initialize` with no guarantees about the target's lifetime. diff --git a/source/common/init/watcher_impl.h b/source/common/init/watcher_impl.h index 2a7349a602315..0e4992452fad0 100644 --- a/source/common/init/watcher_impl.h +++ b/source/common/init/watcher_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/init/watcher.h" @@ -15,6 +16,8 @@ namespace Init { */ using ReadyFn = std::function; +using ReadyFnSharedPtr = std::shared_ptr; + /** * A WatcherHandleImpl functions as a weak reference to a Watcher. It is how a TargetImpl safely * notifies a ManagerImpl that it has initialized, and likewise it's how ManagerImpl safely tells diff --git a/source/common/memory/heap_shrinker.h b/source/common/memory/heap_shrinker.h index 6c4a88bfbbb20..f0cc9c232c44a 100644 --- a/source/common/memory/heap_shrinker.h +++ b/source/common/memory/heap_shrinker.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/event/dispatcher.h" #include "envoy/server/overload_manager.h" #include "envoy/stats/scope.h" @@ -25,5 +27,7 @@ class HeapShrinker { Envoy::Event::TimerPtr timer_; }; +using HeapShrinkerPtr = std::unique_ptr; + } // namespace Memory } // namespace Envoy diff --git a/source/common/network/dns_impl.h b/source/common/network/dns_impl.h index 44588fc4f52c3..40a5e1e3aa9b4 100644 --- a/source/common/network/dns_impl.h +++ b/source/common/network/dns_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -82,6 +83,8 @@ class DnsResolverImpl : public DnsResolver, protected Logger::Loggable; + struct AresOptions { ares_options options_; int optmask_; diff --git a/source/common/network/hash_policy.h b/source/common/network/hash_policy.h index b0c2c4894cc4e..619b8c3cd499b 100644 --- a/source/common/network/hash_policy.h +++ b/source/common/network/hash_policy.h @@ -4,6 +4,7 @@ #include "envoy/type/v3/hash_policy.pb.h" #include "common/common/hash.h" +#include namespace Envoy { namespace Network { @@ -32,5 +33,8 @@ class HashPolicyImpl : public Network::HashPolicy { private: HashMethodPtr hash_impl_; }; + +using HashPolicyImplConstPtr = std::unique_ptr; + } // namespace Network } // namespace Envoy diff --git a/source/common/network/lc_trie.h b/source/common/network/lc_trie.h index 1b039ec4695dc..572097f030371 100644 --- a/source/common/network/lc_trie.h +++ b/source/common/network/lc_trie.h @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -388,11 +389,14 @@ template class LcTrie { } private: + struct Node; + using NodePtr = std::unique_ptr; + struct Node { NodePtr children[2]; DataSetSharedPtr data; }; - using NodePtr = std::unique_ptr; + NodePtr root_; bool exclusive_; }; @@ -407,7 +411,7 @@ template class LcTrie { * 'http://www.csc.kth.se/~snilsson/software/router/C/' were used as reference during * implementation. * - * Note: The trie can only support up 524288(2^19) prefixes with a fill_factor of 1 and + * Note: The trie can only support up 524288(2^19) prefixes with a fill_factor of: 1 and * root_branching_factor not set. Refer to LcTrieInternal::build() method for more details. */ template class LcTrieInternal { @@ -692,10 +696,15 @@ template class LcTrie { const uint32_t root_branching_factor_; }; + template + using LcTrieInternalPtr = std::unique_ptr>; + LcTrieInternalPtr ipv4_trie_; LcTrieInternalPtr ipv6_trie_; }; +template using LcTriePtr = std::unique_ptr>; + template template LcTrie::LcTrieInternal::LcTrieInternal(std::vector>& data, diff --git a/source/common/network/socket_option_impl.h b/source/common/network/socket_option_impl.h index 95338adf6f9d3..e859665c598d6 100644 --- a/source/common/network/socket_option_impl.h +++ b/source/common/network/socket_option_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/api/os_sys_calls.h" #include "envoy/common/platform.h" #include "envoy/config/core/v3/base.pb.h" @@ -153,6 +155,8 @@ class SocketOptionImpl : public Socket::Option, Logger::Loggable value_; }; +using SocketOptionImplPtr = std::unique_ptr; + using SocketOptionImplOptRef = absl::optional>; } // namespace Network diff --git a/source/common/network/transport_socket_options_impl.h b/source/common/network/transport_socket_options_impl.h index a181676db176f..855eb91f5c36d 100644 --- a/source/common/network/transport_socket_options_impl.h +++ b/source/common/network/transport_socket_options_impl.h @@ -2,6 +2,7 @@ #include "envoy/network/transport_socket.h" #include "envoy/stream_info/filter_state.h" +#include namespace Envoy { namespace Network { @@ -66,6 +67,8 @@ class TransportSocketOptionsImpl : public TransportSocketOptions { const absl::optional alpn_fallback_; }; +using TransportSocketOptionsImplConstSharedPtr = std::shared_ptr; + class TransportSocketOptionsUtility { public: /** diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index cf8dedb757531..9678d31c97e28 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -108,6 +108,8 @@ class SslRedirectRoute : public Route { static const SslRedirector SSL_REDIRECTOR; }; +using SslRedirectRouteConstSharedPtr = std::shared_ptr; + /** * Implementation of CorsPolicy that reads from the proto route and virtual host config. */ @@ -153,6 +155,8 @@ class CorsPolicyImpl : public CorsPolicy { const bool legacy_enabled_; }; +using CorsPolicyImplConstPtr = std::unique_ptr; + class ConfigImpl; /** * Holds all routing configuration for an entire virtual host. @@ -940,6 +944,8 @@ class RouteMatcher { VirtualHostSharedPtr default_virtual_host_; }; +using RouteMatcherPtr = std::unique_ptr; + /** * Implementation of Config that reads from a proto file. */ diff --git a/source/common/router/scoped_config_impl.h b/source/common/router/scoped_config_impl.h index ee4424beac79a..fa7201f7e19ad 100644 --- a/source/common/router/scoped_config_impl.h +++ b/source/common/router/scoped_config_impl.h @@ -41,6 +41,8 @@ class ScopeKeyFragmentBase { virtual uint64_t hash() const PURE; }; +using ScopeKeyFragmentBasePtr = std::unique_ptr; + /** * Scope Key is composed of non-null fragments. **/ @@ -110,6 +112,8 @@ class FragmentBuilderBase { const ScopedRoutes::ScopeKeyBuilder::FragmentBuilder config_; }; +using FragmentBuilderBasePtr = std::unique_ptr; + class HeaderValueExtractorImpl : public FragmentBuilderBase { public: explicit HeaderValueExtractorImpl(ScopedRoutes::ScopeKeyBuilder::FragmentBuilder&& config); diff --git a/source/common/runtime/runtime_impl.h b/source/common/runtime/runtime_impl.h index 5bec747b93f7c..5ed6d72533987 100644 --- a/source/common/runtime/runtime_impl.h +++ b/source/common/runtime/runtime_impl.h @@ -131,6 +131,7 @@ class SnapshotImpl : public Snapshot, }; using SnapshotImplPtr = std::unique_ptr; +using SnapshotImplSharedPtr = std::shared_ptr; /** * Base implementation of OverrideLayer that by itself provides an empty values map. diff --git a/source/common/runtime/runtime_protos.h b/source/common/runtime/runtime_protos.h index 06b0e5816d5a2..daa33ffbc8be6 100644 --- a/source/common/runtime/runtime_protos.h +++ b/source/common/runtime/runtime_protos.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/config/core/v3/base.pb.h" @@ -43,6 +44,8 @@ class Double { Runtime::Loader& runtime_; }; +using DoublePtr = std::unique_ptr; + // Helper class for runtime-derived fractional percent flags. class FractionalPercent { public: diff --git a/source/common/secret/secret_manager_impl.h b/source/common/secret/secret_manager_impl.h index 89b2cb50e6082..f02aafcc942a3 100644 --- a/source/common/secret/secret_manager_impl.h +++ b/source/common/secret/secret_manager_impl.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/config/core/v3/config_source.pb.h" @@ -70,18 +71,20 @@ class SecretManagerImpl : public SecretManager { private: ProtobufTypes::MessagePtr dumpSecretConfigs(); + template using SecretTypeSharedPtr = std::shared_ptr; + template class DynamicSecretProviders : public Logger::Loggable { public: // Finds or creates SdsApi object. - SecretTypeSharedPtr + SecretTypeSharedPtr findOrCreate(const envoy::config::core::v3::ConfigSource& sds_config_source, const std::string& config_name, Server::Configuration::TransportSocketFactoryContext& secret_provider_context) { const std::string map_key = absl::StrCat(MessageUtil::hash(sds_config_source), ".", config_name); - SecretTypeSharedPtr secret_provider = dynamic_secret_providers_[map_key].lock(); + SecretTypeSharedPtr secret_provider = dynamic_secret_providers_[map_key].lock(); if (!secret_provider) { // SdsApi is owned by ListenerImpl and ClusterInfo which are destroyed before // SecretManagerImpl. It is safe to invoke this callback at the destructor of SdsApi. @@ -95,10 +98,10 @@ class SecretManagerImpl : public SecretManager { return secret_provider; } - std::vector allSecretProviders() { - std::vector providers; + std::vector> allSecretProviders() { + std::vector> providers; for (const auto& secret_entry : dynamic_secret_providers_) { - SecretTypeSharedPtr secret_provider = secret_entry.second.lock(); + SecretTypeSharedPtr secret_provider = secret_entry.second.lock(); if (secret_provider) { providers.push_back(std::move(secret_provider)); } diff --git a/source/common/stats/stat_merger.h b/source/common/stats/stat_merger.h index 6dbf01d25aa3a..b447ecea117f1 100644 --- a/source/common/stats/stat_merger.h +++ b/source/common/stats/stat_merger.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/stats/store.h" #include "common/protobuf/protobuf.h" @@ -99,5 +101,7 @@ class StatMerger { ScopePtr temp_scope_; }; +using StatMergerPtr = std::unique_ptr; + } // namespace Stats } // namespace Envoy diff --git a/source/common/stats/symbol_table_impl.h b/source/common/stats/symbol_table_impl.h index baf8622672274..6edba39cdc81f 100644 --- a/source/common/stats/symbol_table_impl.h +++ b/source/common/stats/symbol_table_impl.h @@ -523,6 +523,8 @@ class StatNameDynamicStorage : public StatNameStorageBase { : StatNameStorageBase(std::move(src)) {} }; +using StatNameDynamicStoragePtr = std::unique_ptr; + /** * Maintains storage for a collection of StatName objects. Like * StatNameManagedStorage, this has an RAII usage model, taking diff --git a/source/common/stats/thread_local_store.cc b/source/common/stats/thread_local_store.cc index cd7c9bf22a623..b90173d4c9bee 100644 --- a/source/common/stats/thread_local_store.cc +++ b/source/common/stats/thread_local_store.cc @@ -391,7 +391,10 @@ StatType& ThreadLocalStoreImpl::ScopeImpl::safeMakeStat( } template -StatTypeOptConstRef ThreadLocalStoreImpl::ScopeImpl::findStatLockHeld( +using StatTypeOptConstRef = absl::optional>; + +template +StatTypeOptConstRef ThreadLocalStoreImpl::ScopeImpl::findStatLockHeld( StatName name, StatNameHashMap>& central_cache_map) const { auto iter = central_cache_map.find(name); if (iter == central_cache_map.end()) { diff --git a/source/common/stats/thread_local_store.h b/source/common/stats/thread_local_store.h index d7de158fb0aff..b801f47b00838 100644 --- a/source/common/stats/thread_local_store.h +++ b/source/common/stats/thread_local_store.h @@ -375,6 +375,9 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo MakeStatFn make_stat, StatRefMap* tls_cache, StatNameHashSet* tls_rejected_stats, StatType& null_stat); + template + using StatTypeOptConstRef = absl::optional>; + /** * Looks up an existing stat, populating the local cache if necessary. Does * not check the TLS or rejects, and does not create a stat if it does not @@ -385,7 +388,7 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo * @return a reference to the stat, if it exists. */ template - StatTypeOptConstRef + StatTypeOptConstRef findStatLockHeld(StatName name, StatNameHashMap>& central_cache_map) const; diff --git a/source/common/stream_info/filter_state_impl.h b/source/common/stream_info/filter_state_impl.h index 45f5a43624485..e0cf02e1e562d 100644 --- a/source/common/stream_info/filter_state_impl.h +++ b/source/common/stream_info/filter_state_impl.h @@ -56,6 +56,10 @@ class FilterStateImpl : public FilterState { enum class ParentAccessMode { ReadOnly, ReadWrite }; void maybeCreateParent(ParentAccessMode parent_access_mode); + struct FilterObject; + + using FilterObjectPtr = std::unique_ptr; + struct FilterObject { ObjectSharedPtr data_; FilterState::StateType state_type_; diff --git a/source/common/tcp_proxy/tcp_proxy.h b/source/common/tcp_proxy/tcp_proxy.h index 433de50e4418f..c3f02af3acc5b 100644 --- a/source/common/tcp_proxy/tcp_proxy.h +++ b/source/common/tcp_proxy/tcp_proxy.h @@ -11,6 +11,7 @@ #include "envoy/extensions/filters/network/tcp_proxy/v3/tcp_proxy.pb.h" #include "envoy/network/connection.h" #include "envoy/network/filter.h" +#include "envoy/network/hash_policy.h" #include "envoy/runtime/runtime.h" #include "envoy/server/filter_config.h" #include "envoy/stats/scope.h" @@ -294,6 +295,10 @@ class Filter : public Network::ReadFilter, void readDisableUpstream(bool disable); void readDisableDownstream(bool disable); + struct UpstreamCallbacks; + + using UpstreamCallbacksSharedPtr = std::shared_ptr; + struct UpstreamCallbacks : public Tcp::ConnectionPool::UpstreamCallbacks { UpstreamCallbacks(Filter* parent) : parent_(parent) {} diff --git a/source/common/tcp_proxy/upstream.h b/source/common/tcp_proxy/upstream.h index 8d2a301d71377..8d82bda4d4100 100644 --- a/source/common/tcp_proxy/upstream.h +++ b/source/common/tcp_proxy/upstream.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/http/conn_pool.h" #include "envoy/network/connection.h" #include "envoy/tcp/conn_pool.h" @@ -17,6 +19,8 @@ class ConnectionHandle { virtual void cancel() PURE; }; +using ConnectionHandleSharedPtr = std::shared_ptr; + // An implementation of ConnectionHandle which works with the Tcp::ConnectionPool. class TcpConnectionHandle : public ConnectionHandle { public: @@ -59,6 +63,8 @@ class GenericUpstream { onDownstreamEvent(Network::ConnectionEvent event) PURE; }; +using GenericUpstreamPtr = std::unique_ptr; + class TcpUpstream : public GenericUpstream { public: TcpUpstream(Tcp::ConnectionPool::ConnectionDataPtr&& data, diff --git a/source/common/thread_local/thread_local_impl.h b/source/common/thread_local/thread_local_impl.h index f285f1900cdbe..e06a8df6383c9 100644 --- a/source/common/thread_local/thread_local_impl.h +++ b/source/common/thread_local/thread_local_impl.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "envoy/thread_local/thread_local.h" @@ -50,6 +51,8 @@ class InstanceImpl : Logger::Loggable, public NonCopyable, pub const uint64_t index_; }; + using SlotImplPtr = std::unique_ptr; + // A Wrapper of SlotImpl which on destruction returns the SlotImpl to the deferred delete queue // (detaches it). struct Bookkeeper : public Slot { diff --git a/source/common/upstream/edf_scheduler.h b/source/common/upstream/edf_scheduler.h index fc135dfc14901..14ade7f02a090 100644 --- a/source/common/upstream/edf_scheduler.h +++ b/source/common/upstream/edf_scheduler.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "common/common/assert.h" @@ -100,6 +101,9 @@ template class EdfScheduler { std::priority_queue queue_; }; +template using EdfSchedulerPtr = std::unique_ptr>; +template using EdfSchedulerConstPtr = std::unique_ptr>; + #undef EDF_DEBUG } // namespace Upstream diff --git a/source/common/upstream/health_checker_base_impl.h b/source/common/upstream/health_checker_base_impl.h index 652228dbcbd8a..c4bc7f5f94a0d 100644 --- a/source/common/upstream/health_checker_base_impl.h +++ b/source/common/upstream/health_checker_base_impl.h @@ -12,6 +12,7 @@ #include "common/common/logger.h" #include "common/common/matchers.h" #include "common/network/transport_socket_options_impl.h" +#include namespace Envoy { namespace Upstream { @@ -36,6 +37,10 @@ struct HealthCheckerStats { ALL_HEALTH_CHECKER_STATS(GENERATE_COUNTER_STRUCT, GENERATE_GAUGE_STRUCT) }; +class HealthCheckerImplBase; + +using HealthCheckerImplBaseSharedPtr = std::shared_ptr; + /** * Base implementation for all health checkers. */ diff --git a/source/common/upstream/health_checker_impl.h b/source/common/upstream/health_checker_impl.h index ecfd1ce8ce762..5fd96a1c0bc6d 100644 --- a/source/common/upstream/health_checker_impl.h +++ b/source/common/upstream/health_checker_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/access_log/access_log.h" #include "envoy/api/api.h" #include "envoy/config/core/v3/health_check.pb.h" @@ -245,6 +247,8 @@ class TcpHealthCheckerImpl : public HealthCheckerImplBase { TcpActiveHealthCheckSession& parent_; }; + using TcpSessionCallbacksSharedPtr = std::shared_ptr; + struct TcpActiveHealthCheckSession : public ActiveHealthCheckSession { TcpActiveHealthCheckSession(TcpHealthCheckerImpl& parent, const HostSharedPtr& host) : ActiveHealthCheckSession(parent, host), parent_(parent) {} diff --git a/source/common/upstream/load_balancer_impl.cc b/source/common/upstream/load_balancer_impl.cc index 68866dbaf0e39..13e02439fd696 100644 --- a/source/common/upstream/load_balancer_impl.cc +++ b/source/common/upstream/load_balancer_impl.cc @@ -5,6 +5,7 @@ #include #include +#include "common/upstream/edf_scheduler.h" #include "envoy/config/cluster/v3/cluster.pb.h" #include "envoy/runtime/runtime.h" #include "envoy/upstream/upstream.h" diff --git a/source/common/upstream/original_dst_cluster.h b/source/common/upstream/original_dst_cluster.h index b71954aa8e4d9..186419dfa06f5 100644 --- a/source/common/upstream/original_dst_cluster.h +++ b/source/common/upstream/original_dst_cluster.h @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -24,6 +25,10 @@ namespace Upstream { using HostMapSharedPtr = std::shared_ptr; using HostMapConstSharedPtr = std::shared_ptr; +class OriginalDstCluster; + +using OriginalDstClusterSharedPtr = std::shared_ptr; + /** * The OriginalDstCluster is a dynamic cluster that automatically adds hosts as needed based on the * original destination address of the downstream connection. These hosts are also automatically @@ -114,8 +119,6 @@ class OriginalDstCluster : public ClusterImplBase { friend class OriginalDstClusterFactory; }; -using OriginalDstClusterSharedPtr = std::shared_ptr; - class OriginalDstClusterFactory : public ClusterFactoryImplBase { public: OriginalDstClusterFactory() diff --git a/source/common/upstream/outlier_detection_impl.h b/source/common/upstream/outlier_detection_impl.h index 6e6e541029ef0..61bea2c5527a9 100644 --- a/source/common/upstream/outlier_detection_impl.h +++ b/source/common/upstream/outlier_detection_impl.h @@ -69,6 +69,8 @@ struct SuccessRateAccumulatorBucket { std::atomic total_request_counter_; }; +using SuccessRateAccumulatorBucketPtr = std::unique_ptr; + /** * The SuccessRateAccumulator uses the SuccessRateAccumulatorBucket to get per host success rate * stats. This implementation has a fixed window size of time, and thus only needs a @@ -132,6 +134,8 @@ class SuccessRateMonitor { class DetectorImpl; +using DetectorImplSharedPtr = std::shared_ptr; + /** * Implementation of DetectorHostMonitor for the generic detector. */ diff --git a/source/common/upstream/thread_aware_lb_impl.h b/source/common/upstream/thread_aware_lb_impl.h index ecf1ed7527d9f..494a52dbcb146 100644 --- a/source/common/upstream/thread_aware_lb_impl.h +++ b/source/common/upstream/thread_aware_lb_impl.h @@ -1,10 +1,13 @@ #pragma once +#include + #include "envoy/config/cluster/v3/cluster.pb.h" #include "common/upstream/load_balancer_impl.h" #include "absl/synchronization/mutex.h" +#include "envoy/upstream/types.h" namespace Envoy { namespace Upstream { @@ -82,11 +85,12 @@ class ThreadAwareLoadBalancerBase : public LoadBalancerBase, public ThreadAwareL DegradedLoadSharedPtr degraded_per_priority_load_ ABSL_GUARDED_BY(mutex_); }; + using LoadBalancerFactoryImplSharedPtr = std::shared_ptr; + virtual HashingLoadBalancerSharedPtr createLoadBalancer(const NormalizedHostWeightVector& normalized_host_weights, double min_normalized_weight, double max_normalized_weight) PURE; void refresh(); - LoadBalancerFactoryImplSharedPtr factory_; }; diff --git a/source/common/upstream/upstream_impl.h b/source/common/upstream/upstream_impl.h index 59f97ef16efca..2e4121aa21c21 100644 --- a/source/common/upstream/upstream_impl.h +++ b/source/common/upstream/upstream_impl.h @@ -251,6 +251,10 @@ class HostImpl : public HostDescriptionImpl, std::atomic used_; }; +class HostsPerLocalityImpl; + +using HostsPerLocalityImplSharedPtr = std::shared_ptr; + class HostsPerLocalityImpl : public HostsPerLocality { public: HostsPerLocalityImpl() : HostsPerLocalityImpl(std::vector(), false) {} @@ -396,6 +400,8 @@ class HostSetImpl : public HostSet { const double effective_weight_; }; + using LocalityEntrySharedPtr = std::shared_ptr; + // Rebuilds the provided locality scheduler with locality entries based on the locality weights // and eligible hosts. // diff --git a/source/extensions/common/redis/cluster_refresh_manager_impl.h b/source/extensions/common/redis/cluster_refresh_manager_impl.h index 200fb7e9f3286..2a865a8c4ceed 100644 --- a/source/extensions/common/redis/cluster_refresh_manager_impl.h +++ b/source/extensions/common/redis/cluster_refresh_manager_impl.h @@ -2,6 +2,7 @@ #include #include +#include #include #include "envoy/event/dispatcher.h" @@ -18,6 +19,10 @@ namespace Extensions { namespace Common { namespace Redis { +class ClusterRefreshManagerImpl; + +using ClusterRefreshManagerImplSharedPtr = std::shared_ptr; + class ClusterRefreshManagerImpl : public ClusterRefreshManager, public Envoy::Singleton::Instance, public std::enable_shared_from_this { diff --git a/source/extensions/filters/common/rbac/engine_impl.h b/source/extensions/filters/common/rbac/engine_impl.h index 1091e1676f6e1..c36d04e76e409 100644 --- a/source/extensions/filters/common/rbac/engine_impl.h +++ b/source/extensions/filters/common/rbac/engine_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/rbac/v3/rbac.pb.h" #include "extensions/filters/common/rbac/engine.h" @@ -30,6 +32,8 @@ class RoleBasedAccessControlEngineImpl : public RoleBasedAccessControlEngine, No Expr::BuilderPtr builder_; }; +using RoleBasedAccessControlEngineImplPtr = std::unique_ptr; + } // namespace RBAC } // namespace Common } // namespace Filters diff --git a/source/extensions/filters/common/rbac/matchers.h b/source/extensions/filters/common/rbac/matchers.h index a73bcf3732665..3379294a50067 100644 --- a/source/extensions/filters/common/rbac/matchers.h +++ b/source/extensions/filters/common/rbac/matchers.h @@ -208,6 +208,8 @@ class PolicyMatcher : public Matcher, NonCopyable { Expr::ExpressionPtr expr_; }; +using PolicyMatcherPtr = std::unique_ptr; + class MetadataMatcher : public Matcher { public: MetadataMatcher(const Envoy::Matchers::MetadataMatcher& matcher) : matcher_(matcher) {} diff --git a/source/extensions/filters/http/admission_control/evaluators/response_evaluator.h b/source/extensions/filters/http/admission_control/evaluators/response_evaluator.h index 9915014fdede2..fd852009832a9 100644 --- a/source/extensions/filters/http/admission_control/evaluators/response_evaluator.h +++ b/source/extensions/filters/http/admission_control/evaluators/response_evaluator.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/common/pure.h" @@ -27,6 +28,8 @@ class ResponseEvaluator { virtual bool isGrpcSuccess(uint32_t status) const PURE; }; +using ResponseEvaluatorSharedPtr = std::shared_ptr; + } // namespace AdmissionControl } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/common/compressor/compressor.h b/source/extensions/filters/http/common/compressor/compressor.h index 09ad099ad0757..62fb93d6883f6 100644 --- a/source/extensions/filters/http/common/compressor/compressor.h +++ b/source/extensions/filters/http/common/compressor/compressor.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/compression/compressor/compressor.h" #include "envoy/extensions/filters/http/compressor/v3/compressor.pb.h" #include "envoy/stats/scope.h" @@ -145,6 +147,8 @@ class CompressorFilter : public Http::PassThroughFilter { const HeaderStat stat_; }; + using EncodingDecisionPtr = std::unique_ptr; + EncodingDecisionPtr chooseEncoding(const Http::ResponseHeaderMap& headers) const; bool shouldCompress(const EncodingDecision& decision) const; diff --git a/source/extensions/filters/http/fault/fault_filter.h b/source/extensions/filters/http/fault/fault_filter.h index 979613ec34cb6..2f1c844b85f66 100644 --- a/source/extensions/filters/http/fault/fault_filter.h +++ b/source/extensions/filters/http/fault/fault_filter.h @@ -206,6 +206,8 @@ class StreamRateLimiter : Logger::Loggable { Buffer::WatermarkBuffer buffer_; }; +using StreamRateLimiterPtr = std::unique_ptr; + using AbortHttpAndGrpcStatus = std::pair, absl::optional>; /** diff --git a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc index 82e215acd026d..3faac991b45d7 100644 --- a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc +++ b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc @@ -31,14 +31,19 @@ using Envoy::ProtobufUtil::Status; using Envoy::ProtobufUtil::error::Code; using google::api::HttpRule; using google::grpc::transcoding::JsonRequestTranslator; +using JsonRequestTranslatorPtr = std::unique_ptr; using google::grpc::transcoding::MessageStream; using google::grpc::transcoding::PathMatcherBuilder; using google::grpc::transcoding::PathMatcherUtility; using google::grpc::transcoding::RequestInfo; using google::grpc::transcoding::RequestMessageTranslator; +using RequestMessageTranslatorPtr = std::unique_ptr; using google::grpc::transcoding::ResponseToJsonTranslator; +using ResponseToJsonTranslatorPtr = std::unique_ptr; using google::grpc::transcoding::Transcoder; +using TranscoderPtr = std::unique_ptr; using google::grpc::transcoding::TranscoderInputStream; +using TranscoderInputStreamPtr = std::unique_ptr; namespace Envoy { namespace Extensions { diff --git a/source/extensions/filters/http/jwt_authn/filter_config.h b/source/extensions/filters/http/jwt_authn/filter_config.h index 7e7d4bca116c4..1454250d62763 100644 --- a/source/extensions/filters/http/jwt_authn/filter_config.h +++ b/source/extensions/filters/http/jwt_authn/filter_config.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/api/api.h" #include "envoy/extensions/filters/http/jwt_authn/v3/config.pb.h" #include "envoy/router/string_accessor.h" @@ -71,6 +73,10 @@ class FilterConfig { }; using FilterConfigSharedPtr = std::shared_ptr; +class FilterConfigImpl; + +using FilterConfigImplSharedPtr = std::shared_ptr; + /** * The filter config object to hold config and relevant objects. */ diff --git a/source/extensions/filters/network/common/redis/codec.h b/source/extensions/filters/network/common/redis/codec.h index 946c14f6acaff..1521c40de7667 100644 --- a/source/extensions/filters/network/common/redis/codec.h +++ b/source/extensions/filters/network/common/redis/codec.h @@ -24,6 +24,10 @@ namespace Redis { */ enum class RespType { Null, SimpleString, BulkString, Integer, Error, Array, CompositeArray }; +class RespValue; + +using RespValueSharedPtr = std::shared_ptr; + /** * A variant implementation of a RESP value optimized for performance. A C++11 union is used for * the underlying type so that no unnecessary allocations/constructions are needed. diff --git a/source/extensions/filters/network/common/redis/redis_command_stats.h b/source/extensions/filters/network/common/redis/redis_command_stats.h index 0790a046ca08e..9090762002f85 100644 --- a/source/extensions/filters/network/common/redis/redis_command_stats.h +++ b/source/extensions/filters/network/common/redis/redis_command_stats.h @@ -16,6 +16,10 @@ namespace NetworkFilters { namespace Common { namespace Redis { +class RedisCommandStats; + +using RedisCommandStatsSharedPtr = std::shared_ptr; + class RedisCommandStats { public: RedisCommandStats(Stats::SymbolTable& symbol_table, const std::string& prefix); diff --git a/source/extensions/filters/network/dubbo_proxy/conn_manager.h b/source/extensions/filters/network/dubbo_proxy/conn_manager.h index 246df5aebfc76..5a4a126ddce99 100644 --- a/source/extensions/filters/network/dubbo_proxy/conn_manager.h +++ b/source/extensions/filters/network/dubbo_proxy/conn_manager.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/time.h" #include "envoy/extensions/filters/network/dubbo_proxy/v3/dubbo_proxy.pb.h" #include "envoy/network/connection.h" @@ -37,6 +39,8 @@ class Config { virtual Router::Config& routerConfig() PURE; }; +using ConfigSharedPtr = std::shared_ptr; + // class ActiveMessagePtr; class ConnectionManager : public Network::ReadFilter, public Network::ConnectionCallbacks, diff --git a/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h b/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h index 947ee2413b442..7a4f36c2beea4 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h +++ b/source/extensions/filters/network/dubbo_proxy/router/route_matcher.h @@ -113,6 +113,8 @@ class ParameterRouteEntryImpl : public RouteEntryImplBase { std::vector parameter_data_list_; }; +using ParameterRouteEntryImplSharedPtr = std::shared_ptr; + class MethodRouteEntryImpl : public RouteEntryImplBase { public: MethodRouteEntryImpl(const envoy::extensions::filters::network::dubbo_proxy::v3::Route& route); diff --git a/source/extensions/filters/network/dubbo_proxy/router/router_impl.h b/source/extensions/filters/network/dubbo_proxy/router/router_impl.h index e9dbf3f61b575..bb860cb82b9a5 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/router_impl.h +++ b/source/extensions/filters/network/dubbo_proxy/router/router_impl.h @@ -81,6 +81,8 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, bool stream_reset_ : 1; }; + using UpstreamRequestPtr = std::unique_ptr; + void cleanup(); Upstream::ClusterManager& cluster_manager_; diff --git a/source/extensions/filters/network/mongo_proxy/bson_impl.h b/source/extensions/filters/network/mongo_proxy/bson_impl.h index 7d19b5a6c06a4..acc7ae139555c 100644 --- a/source/extensions/filters/network/mongo_proxy/bson_impl.h +++ b/source/extensions/filters/network/mongo_proxy/bson_impl.h @@ -177,6 +177,10 @@ class FieldImpl : public Field { Value value_; }; +class DocumentImpl; + +using DocumentImplSharedPtr = std::shared_ptr; + class DocumentImpl : public Document, Logger::Loggable, public std::enable_shared_from_this { diff --git a/source/extensions/filters/network/mongo_proxy/codec_impl.h b/source/extensions/filters/network/mongo_proxy/codec_impl.h index 4a404d14089ea..e54e71b054cde 100644 --- a/source/extensions/filters/network/mongo_proxy/codec_impl.h +++ b/source/extensions/filters/network/mongo_proxy/codec_impl.h @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -59,6 +60,8 @@ class GetMoreMessageImpl : public MessageImpl, int64_t cursor_id_{}; }; +using GetMoreMessageImplPtr = std::unique_ptr; + class InsertMessageImpl : public MessageImpl, public InsertMessage, Logger::Loggable { @@ -86,6 +89,8 @@ class InsertMessageImpl : public MessageImpl, std::list documents_; }; +using InsertMessageImplPtr = std::unique_ptr; + class KillCursorsMessageImpl : public MessageImpl, public KillCursorsMessage, Logger::Loggable { @@ -114,6 +119,8 @@ class KillCursorsMessageImpl : public MessageImpl, std::vector cursor_ids_; }; +using KillCursorsMessageImplPtr = std::unique_ptr; + class QueryMessageImpl : public MessageImpl, public QueryMessage, Logger::Loggable { @@ -154,6 +161,8 @@ class QueryMessageImpl : public MessageImpl, Bson::DocumentSharedPtr return_fields_selector_; }; +using QueryMessageImplPtr = std::unique_ptr; + class ReplyMessageImpl : public MessageImpl, public ReplyMessage, Logger::Loggable { @@ -187,6 +196,8 @@ class ReplyMessageImpl : public MessageImpl, std::list documents_; }; +using ReplyMessageImplPtr = std::unique_ptr; + // OP_COMMAND message. class CommandMessageImpl : public MessageImpl, public CommandMessage, @@ -221,6 +232,8 @@ class CommandMessageImpl : public MessageImpl, std::list input_docs_; }; +using CommandMessageImplPtr = std::unique_ptr; + // OP_COMMANDREPLY message. class CommandReplyMessageImpl : public MessageImpl, public CommandReplyMessage, @@ -249,6 +262,8 @@ class CommandReplyMessageImpl : public MessageImpl, std::list output_docs_; }; +using CommandReplyMessageImplPtr = std::unique_ptr; + class DecoderImpl : public Decoder, Logger::Loggable { public: DecoderImpl(DecoderCallbacks& callbacks) : callbacks_(callbacks) {} diff --git a/source/extensions/filters/network/thrift_proxy/conn_manager.h b/source/extensions/filters/network/thrift_proxy/conn_manager.h index 7bbf35710ced4..a827c2bd70540 100644 --- a/source/extensions/filters/network/thrift_proxy/conn_manager.h +++ b/source/extensions/filters/network/thrift_proxy/conn_manager.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/pure.h" #include "envoy/event/deferred_deletable.h" #include "envoy/network/connection.h" @@ -52,6 +54,8 @@ class ProtocolOptionsConfig : public Upstream::ProtocolOptionsConfig { virtual ProtocolType protocol(ProtocolType downstream_protocol) const PURE; }; +using ProtocolOptionsConfigConstSharedPtr = std::shared_ptr; + /** * ConnectionManager is a Network::Filter that will perform Thrift request handling on a connection. */ diff --git a/source/extensions/filters/network/thrift_proxy/router/router_impl.cc b/source/extensions/filters/network/thrift_proxy/router/router_impl.cc index 936f386a9a2d3..cff8eeb188f31 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_impl.cc +++ b/source/extensions/filters/network/thrift_proxy/router/router_impl.cc @@ -10,6 +10,7 @@ #include "common/router/metadatamatchcriteria_impl.h" #include "extensions/filters/network/thrift_proxy/app_exception_impl.h" +#include "extensions/filters/network/thrift_proxy/conn_manager.h" #include "extensions/filters/network/well_known_names.h" #include "absl/strings/match.h" diff --git a/source/extensions/filters/network/thrift_proxy/router/router_impl.h b/source/extensions/filters/network/thrift_proxy/router/router_impl.h index d30073594d411..a9c485f74f5f5 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_impl.h +++ b/source/extensions/filters/network/thrift_proxy/router/router_impl.h @@ -86,6 +86,8 @@ class RouteEntryImplBase : public RouteEntry, const uint64_t cluster_weight_; Envoy::Router::MetadataMatchCriteriaConstPtr metadata_match_criteria_; }; + + using WeightedClusterEntryPtr = std::unique_ptr; using WeightedClusterEntrySharedPtr = std::shared_ptr; class DynamicRouteEntry : public RouteEntry, public Route { @@ -247,6 +249,8 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, bool response_complete_ : 1; }; + using UpstreamRequestPtr = std::unique_ptr; + void convertMessageBegin(MessageMetadataSharedPtr metadata); void cleanup(); RouterStats generateStats(const std::string& prefix, Stats::Scope& scope) { diff --git a/source/extensions/filters/network/thrift_proxy/router/router_ratelimit.h b/source/extensions/filters/network/thrift_proxy/router/router_ratelimit.h index aca46cd330361..26f367714c0dd 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_ratelimit.h +++ b/source/extensions/filters/network/thrift_proxy/router/router_ratelimit.h @@ -73,6 +73,8 @@ class RateLimitPolicyEntry { const Network::Address::Instance& remote_address) const PURE; }; +using RateLimitPolicyEntryPtr = std::unique_ptr; + /** * Rate limiting policy. */ diff --git a/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h b/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h index eee62144ad08f..b741edb5b913b 100644 --- a/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h +++ b/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/resource_monitor/fixed_heap/v2alpha/fixed_heap.pb.h" #include "envoy/server/resource_monitor.h" @@ -22,6 +24,8 @@ class MemoryStatsReader { virtual uint64_t unmappedHeapBytes(); }; +using MemoryStatsReaderPtr = std::unique_ptr; + /** * Heap memory monitor with a statically configured maximum. */ diff --git a/source/extensions/stat_sinks/common/statsd/statsd.h b/source/extensions/stat_sinks/common/statsd/statsd.h index 429b8dff89892..d08d0c3398dc8 100644 --- a/source/extensions/stat_sinks/common/statsd/statsd.h +++ b/source/extensions/stat_sinks/common/statsd/statsd.h @@ -14,6 +14,7 @@ #include "common/buffer/buffer_impl.h" #include "common/common/macros.h" #include "common/network/io_socket_handle_impl.h" +#include namespace Envoy { namespace Extensions { @@ -36,6 +37,8 @@ class UdpStatsdSink : public Stats::Sink { virtual void write(const std::string& message) PURE; }; + using WriterSharedPtr = std::shared_ptr; + UdpStatsdSink(ThreadLocal::SlotAllocator& tls, Network::Address::InstanceConstSharedPtr address, const bool use_tag, const std::string& prefix = getDefaultPrefix()); // For testing. diff --git a/source/server/admin/admin.h b/source/server/admin/admin.h index 439cacf0013ea..f55da19ecb62f 100644 --- a/source/server/admin/admin.h +++ b/source/server/admin/admin.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -413,5 +414,7 @@ class AdminImpl : public Admin, const LocalReply::LocalReplyPtr local_reply_; }; +using AdminImplPtr = std::unique_ptr; + } // namespace Server } // namespace Envoy diff --git a/source/server/filter_chain_manager_impl.h b/source/server/filter_chain_manager_impl.h index 0ca672e2da57b..f78d75528b643 100644 --- a/source/server/filter_chain_manager_impl.h +++ b/source/server/filter_chain_manager_impl.h @@ -6,6 +6,7 @@ #include "envoy/config/listener/v3/listener_components.pb.h" #include "envoy/network/drain_decision.h" +#include "envoy/server/factory_context.h" #include "envoy/server/filter_config.h" #include "envoy/server/instance.h" #include "envoy/server/transport_socket_config.h" diff --git a/source/server/hot_restarting_base.cc b/source/server/hot_restarting_base.cc index ba7b2443b4d19..bf4a5949696c6 100644 --- a/source/server/hot_restarting_base.cc +++ b/source/server/hot_restarting_base.cc @@ -1,5 +1,7 @@ #include "server/hot_restarting_base.h" +#include + #include "common/api/os_sys_calls_impl.h" #include "common/common/utility.h" #include "common/stats/utility.h" @@ -8,6 +10,7 @@ namespace Envoy { namespace Server { using HotRestartMessage = envoy::HotRestartMessage; +using HotRestartMessagePtr = std::unique_ptr; static constexpr uint64_t MaxSendmsgSize = 4096; diff --git a/source/server/hot_restarting_child.cc b/source/server/hot_restarting_child.cc index 4adc059173209..81104e7c64c7b 100644 --- a/source/server/hot_restarting_child.cc +++ b/source/server/hot_restarting_child.cc @@ -1,11 +1,14 @@ #include "server/hot_restarting_child.h" +#include + #include "common/common/utility.h" namespace Envoy { namespace Server { using HotRestartMessage = envoy::HotRestartMessage; +using HotRestartMessagePtr = std::unique_ptr; HotRestartingChild::HotRestartingChild(int base_id, int restart_epoch) : HotRestartingBase(base_id), restart_epoch_(restart_epoch) { diff --git a/source/server/listener_impl.h b/source/server/listener_impl.h index 96d01f77ae4b4..3e0d7d0c196fa 100644 --- a/source/server/listener_impl.h +++ b/source/server/listener_impl.h @@ -5,6 +5,7 @@ #include "envoy/access_log/access_log.h" #include "envoy/config/core/v3/base.pb.h" #include "envoy/config/listener/v3/listener.pb.h" +#include "envoy/init/manager.h" #include "envoy/network/drain_decision.h" #include "envoy/network/filter.h" #include "envoy/server/drain_manager.h" @@ -140,6 +141,8 @@ class ListenerFactoryContextBaseImpl final : public Configuration::FactoryContex const Server::DrainManagerPtr drain_manager_; }; +using ListenerFactoryContextBaseImplSharedPtr = std::shared_ptr; + class ListenerImpl; // TODO(lambdai): Strip the interface since ListenerFactoryContext only need to support @@ -203,6 +206,12 @@ class PerListenerFactoryContextImpl : public Configuration::ListenerFactoryConte ListenerImpl& listener_impl_; }; +using PerListenerFactoryContextImplSharedPtr = std::shared_ptr; + +class ListenerImpl; + +using ListenerImplPtr = std::unique_ptr; + /** * Maps proto config to runtime config for a listener with a network filter chain. */ diff --git a/source/server/listener_manager_impl.h b/source/server/listener_manager_impl.h index 27595cf9a2a37..0bb548cc30df6 100644 --- a/source/server/listener_manager_impl.h +++ b/source/server/listener_manager_impl.h @@ -303,7 +303,7 @@ class ListenerManagerImpl : public ListenerManager, Logger::Loggable; absl::flat_hash_map error_state_tracker_; FailureStates overall_error_state_; }; diff --git a/source/server/overload_manager_impl.h b/source/server/overload_manager_impl.h index d76eedc3659f4..55a214e2ee144 100644 --- a/source/server/overload_manager_impl.h +++ b/source/server/overload_manager_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -114,5 +115,7 @@ class OverloadManagerImpl : Logger::Loggable, public OverloadM ActionToCallbackMap action_to_callbacks_; }; +using OverloadManagerImplPtr = std::unique_ptr; + } // namespace Server } // namespace Envoy diff --git a/source/server/server.h b/source/server/server.h index da1598ee1981e..2154b724c15b5 100644 --- a/source/server/server.h +++ b/source/server/server.h @@ -76,6 +76,8 @@ struct ServerStats { ALL_SERVER_STATS(GENERATE_COUNTER_STRUCT, GENERATE_GAUGE_STRUCT, GENERATE_HISTOGRAM_STRUCT) }; +using ServerStatsPtr = std::unique_ptr; + /** * Interface for creating service components during boot. */ From 3818a4426af113638617043756b521df84f58a58 Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 2 Jul 2020 18:19:51 +0000 Subject: [PATCH 20/36] fix format Signed-off-by: tomocy --- include/envoy/config/grpc_mux.h | 3 ++- source/common/common/thread_synchronizer.h | 1 - source/common/network/hash_policy.h | 3 ++- source/common/network/transport_socket_options_impl.h | 3 ++- source/common/upstream/health_checker_base_impl.h | 3 ++- source/common/upstream/load_balancer_impl.cc | 2 +- source/common/upstream/thread_aware_lb_impl.h | 2 +- source/extensions/stat_sinks/common/statsd/statsd.h | 3 ++- 8 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/envoy/config/grpc_mux.h b/include/envoy/config/grpc_mux.h index 1a7ec5d36a465..9395e23eed3c7 100644 --- a/include/envoy/config/grpc_mux.h +++ b/include/envoy/config/grpc_mux.h @@ -1,12 +1,13 @@ #pragma once +#include + #include "envoy/common/exception.h" #include "envoy/common/pure.h" #include "envoy/config/subscription.h" #include "envoy/stats/stats_macros.h" #include "common/protobuf/protobuf.h" -#include namespace Envoy { namespace Config { diff --git a/source/common/common/thread_synchronizer.h b/source/common/common/thread_synchronizer.h index 575b4a1d030f2..db5645eca1206 100644 --- a/source/common/common/thread_synchronizer.h +++ b/source/common/common/thread_synchronizer.h @@ -8,7 +8,6 @@ #include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" -#include namespace Envoy { namespace Thread { diff --git a/source/common/network/hash_policy.h b/source/common/network/hash_policy.h index 619b8c3cd499b..6f7072a810a0d 100644 --- a/source/common/network/hash_policy.h +++ b/source/common/network/hash_policy.h @@ -1,10 +1,11 @@ #pragma once +#include + #include "envoy/network/hash_policy.h" #include "envoy/type/v3/hash_policy.pb.h" #include "common/common/hash.h" -#include namespace Envoy { namespace Network { diff --git a/source/common/network/transport_socket_options_impl.h b/source/common/network/transport_socket_options_impl.h index 855eb91f5c36d..fa1a3c53ef098 100644 --- a/source/common/network/transport_socket_options_impl.h +++ b/source/common/network/transport_socket_options_impl.h @@ -1,8 +1,9 @@ #pragma once +#include + #include "envoy/network/transport_socket.h" #include "envoy/stream_info/filter_state.h" -#include namespace Envoy { namespace Network { diff --git a/source/common/upstream/health_checker_base_impl.h b/source/common/upstream/health_checker_base_impl.h index c4bc7f5f94a0d..bd5df28950211 100644 --- a/source/common/upstream/health_checker_base_impl.h +++ b/source/common/upstream/health_checker_base_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/access_log/access_log.h" #include "envoy/config/core/v3/health_check.pb.h" #include "envoy/data/core/v3/health_check_event.pb.h" @@ -12,7 +14,6 @@ #include "common/common/logger.h" #include "common/common/matchers.h" #include "common/network/transport_socket_options_impl.h" -#include namespace Envoy { namespace Upstream { diff --git a/source/common/upstream/load_balancer_impl.cc b/source/common/upstream/load_balancer_impl.cc index 13e02439fd696..db739ae04e9b7 100644 --- a/source/common/upstream/load_balancer_impl.cc +++ b/source/common/upstream/load_balancer_impl.cc @@ -5,13 +5,13 @@ #include #include -#include "common/upstream/edf_scheduler.h" #include "envoy/config/cluster/v3/cluster.pb.h" #include "envoy/runtime/runtime.h" #include "envoy/upstream/upstream.h" #include "common/common/assert.h" #include "common/protobuf/utility.h" +#include "common/upstream/edf_scheduler.h" #include "absl/container/fixed_array.h" diff --git a/source/common/upstream/thread_aware_lb_impl.h b/source/common/upstream/thread_aware_lb_impl.h index 494a52dbcb146..2200478b1bb73 100644 --- a/source/common/upstream/thread_aware_lb_impl.h +++ b/source/common/upstream/thread_aware_lb_impl.h @@ -3,11 +3,11 @@ #include #include "envoy/config/cluster/v3/cluster.pb.h" +#include "envoy/upstream/types.h" #include "common/upstream/load_balancer_impl.h" #include "absl/synchronization/mutex.h" -#include "envoy/upstream/types.h" namespace Envoy { namespace Upstream { diff --git a/source/extensions/stat_sinks/common/statsd/statsd.h b/source/extensions/stat_sinks/common/statsd/statsd.h index d08d0c3398dc8..65de7a935d1ca 100644 --- a/source/extensions/stat_sinks/common/statsd/statsd.h +++ b/source/extensions/stat_sinks/common/statsd/statsd.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/platform.h" #include "envoy/local_info/local_info.h" #include "envoy/network/connection.h" @@ -14,7 +16,6 @@ #include "common/buffer/buffer_impl.h" #include "common/common/macros.h" #include "common/network/io_socket_handle_impl.h" -#include namespace Envoy { namespace Extensions { From 2f6214e9885427637695bd161038b7974b39615a Mon Sep 17 00:00:00 2001 From: tomocy Date: Fri, 3 Jul 2020 10:45:13 +0000 Subject: [PATCH 21/36] declare type aliases Signed-off-by: tomocy --- .../envoy/router/route_config_provider_manager.h | 3 +++ include/envoy/server/hot_restart.h | 3 +++ include/envoy/server/overload_manager.h | 3 +++ include/envoy/ssl/context_config.h | 2 ++ include/envoy/stream_info/stream_info.h | 3 +++ include/envoy/tracing/http_tracer_manager.h | 2 ++ source/common/common/logger.h | 2 ++ source/common/config/config_provider_impl.h | 2 ++ source/common/http/conn_manager_config.h | 4 ++++ source/common/http/date_provider_impl.h | 3 +++ source/common/init/manager_impl.h | 3 +++ source/common/router/rds_impl.h | 3 +++ source/common/router/scoped_rds.h | 6 ++++++ source/common/stats/thread_local_store.h | 3 +++ source/common/stats/timespan_impl.h | 4 ++++ source/common/thread_local/thread_local_impl.h | 4 ++++ source/common/upstream/cluster_manager_impl.h | 3 +++ source/common/upstream/conn_pool_map.h | 7 +++++-- source/common/upstream/priority_conn_pool_map.h | 3 +++ source/exe/main_common.h | 4 ++++ .../clusters/dynamic_forward_proxy/cluster.cc | 6 +++--- .../clusters/dynamic_forward_proxy/cluster.h | 13 +++++++------ source/extensions/common/aws/region_provider.h | 3 +++ source/extensions/common/aws/signer.h | 3 +++ source/extensions/filters/common/rbac/engine_impl.h | 2 ++ .../filters/http/adaptive_concurrency/config.cc | 1 + .../adaptive_concurrency/controller/controller.h | 3 +++ .../network/http_connection_manager/config.h | 4 ++++ .../filters/network/redis_proxy/command_splitter.h | 2 ++ .../network/redis_proxy/command_splitter_impl.h | 11 +++++++++++ .../filters/network/redis_proxy/config.cc | 1 + .../filters/network/rocketmq_proxy/config.h | 2 ++ .../filters/network/thrift_proxy/conn_manager.h | 2 ++ .../network/thrift_proxy/router/router_impl.h | 2 ++ .../network/thrift_proxy/thrift_object_impl.h | 4 ++++ source/server/config_validation/cluster_manager.h | 4 ++++ source/server/config_validation/dns.h | 4 ++++ source/server/hot_restarting_parent.cc | 3 +++ source/server/hot_restarting_parent.h | 6 ++++++ source/server/listener_manager_impl.h | 3 +++ source/server/server.h | 2 ++ 41 files changed, 137 insertions(+), 11 deletions(-) diff --git a/include/envoy/router/route_config_provider_manager.h b/include/envoy/router/route_config_provider_manager.h index f266407a36515..3e64aa396a24b 100644 --- a/include/envoy/router/route_config_provider_manager.h +++ b/include/envoy/router/route_config_provider_manager.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/config/route/v3/route.pb.h" @@ -55,5 +56,7 @@ class RouteConfigProviderManager { ProtobufMessage::ValidationVisitor& validator) PURE; }; +using RouteConfigProviderManagerSharedPtr = std::shared_ptr; + } // namespace Router } // namespace Envoy diff --git a/include/envoy/server/hot_restart.h b/include/envoy/server/hot_restart.h index 7525fa6a0f4fb..3490c80762f0d 100644 --- a/include/envoy/server/hot_restart.h +++ b/include/envoy/server/hot_restart.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "envoy/common/pure.h" @@ -101,6 +102,8 @@ class HotRestart { virtual Thread::BasicLockable& accessLogLock() PURE; }; +using HotRestartPtr = std::unique_ptr; + /** * HotRestartDomainSocketInUseException is thrown during HotRestart construction only when the * underlying domain socket is in use. diff --git a/include/envoy/server/overload_manager.h b/include/envoy/server/overload_manager.h index 010ac8ee94686..88a4a46a06e02 100644 --- a/include/envoy/server/overload_manager.h +++ b/include/envoy/server/overload_manager.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -119,5 +120,7 @@ class OverloadManager { } }; +using OverloadManagerPtr = std::unique_ptr; + } // namespace Server } // namespace Envoy diff --git a/include/envoy/ssl/context_config.h b/include/envoy/ssl/context_config.h index cd74bf8487bb9..f69d479f788e9 100644 --- a/include/envoy/ssl/context_config.h +++ b/include/envoy/ssl/context_config.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -103,6 +104,7 @@ class ClientContextConfig : public virtual ContextConfig { }; using ClientContextConfigPtr = std::unique_ptr; +using ClientContextConfigConstPtr = std::unique_ptr; class ServerContextConfig : public virtual ContextConfig { public: diff --git a/include/envoy/stream_info/stream_info.h b/include/envoy/stream_info/stream_info.h index fbec2554d380c..b494fa775539c 100644 --- a/include/envoy/stream_info/stream_info.h +++ b/include/envoy/stream_info/stream_info.h @@ -2,6 +2,7 @@ #include #include +#include #include #include "envoy/common/pure.h" @@ -564,5 +565,7 @@ class StreamInfo { virtual Http::RequestIDExtensionSharedPtr getRequestIDExtension() const PURE; }; +using StreamInfoPtr = std::unique_ptr; + } // namespace StreamInfo } // namespace Envoy diff --git a/include/envoy/tracing/http_tracer_manager.h b/include/envoy/tracing/http_tracer_manager.h index a19d384bb34fa..06faba8cc138b 100644 --- a/include/envoy/tracing/http_tracer_manager.h +++ b/include/envoy/tracing/http_tracer_manager.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/trace/v3/http_tracer.pb.h" #include "envoy/tracing/http_tracer.h" diff --git a/source/common/common/logger.h b/source/common/common/logger.h index 5815f5e574a0d..04b594349b56f 100644 --- a/source/common/common/logger.h +++ b/source/common/common/logger.h @@ -218,6 +218,8 @@ class Context { Context* const save_context_; }; +using ContextPtr = std::unique_ptr; + /** * A registry of all named loggers in envoy. Usable for adjusting levels of each logger * individually. diff --git a/source/common/config/config_provider_impl.h b/source/common/config/config_provider_impl.h index 135c377195d45..2337ca8eba4d9 100644 --- a/source/common/config/config_provider_impl.h +++ b/source/common/config/config_provider_impl.h @@ -15,6 +15,7 @@ #include "common/init/target_impl.h" #include "common/init/watcher_impl.h" #include "common/protobuf/protobuf.h" +#include namespace Envoy { namespace Config { @@ -391,6 +392,7 @@ class ConfigProviderManagerImplBase : public ConfigProviderManager, public Singl protected: // Ordered set for deterministic config dump output. using ConfigProviderSet = std::set; + using ConfigProviderSetPtr = std::unique_ptr; using ConfigProviderMap = std::unordered_map; using ConfigSubscriptionMap = diff --git a/source/common/http/conn_manager_config.h b/source/common/http/conn_manager_config.h index faf691b6fc20c..8e90e2d22ab65 100644 --- a/source/common/http/conn_manager_config.h +++ b/source/common/http/conn_manager_config.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/config_provider.h" #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.pb.h" #include "envoy/http/filter.h" @@ -175,6 +177,8 @@ class InternalAddressConfig { virtual bool isInternalAddress(const Network::Address::Instance& address) const PURE; }; +using InternalAddressConfigPtr = std::unique_ptr; + /** * Determines if an address is internal based on whether it is an RFC1918 ip address. */ diff --git a/source/common/http/date_provider_impl.h b/source/common/http/date_provider_impl.h index 08ff1bfe6f2e7..362e5801a1191 100644 --- a/source/common/http/date_provider_impl.h +++ b/source/common/http/date_provider_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "envoy/event/dispatcher.h" @@ -50,6 +51,8 @@ class TlsCachingDateProviderImpl : public DateProviderImplBase, public Singleton Event::TimerPtr refresh_timer_; }; +using TlsCachingDateProviderImplSharedPtr = std::shared_ptr; + /** * A basic provider that just creates the date string every time. */ diff --git a/source/common/init/manager_impl.h b/source/common/init/manager_impl.h index b92ac102fd729..57d66f5ef1fc8 100644 --- a/source/common/init/manager_impl.h +++ b/source/common/init/manager_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/init/manager.h" @@ -58,5 +59,7 @@ class ManagerImpl : public Manager, Logger::Loggable { std::list target_handles_; }; +using ManagerImplPtr = std::unique_ptr; + } // namespace Init } // namespace Envoy diff --git a/source/common/router/rds_impl.h b/source/common/router/rds_impl.h index a22138b11429b..c205c561eeeb9 100644 --- a/source/common/router/rds_impl.h +++ b/source/common/router/rds_impl.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -230,6 +231,8 @@ class RdsRouteConfigProviderImpl : public RouteConfigProvider, friend class RouteConfigProviderManagerImpl; }; +using RdsRouteConfigProviderImplSharedPtr = std::shared_ptr; + class RouteConfigProviderManagerImpl : public RouteConfigProviderManager, public Singleton::Instance { public: diff --git a/source/common/router/scoped_rds.h b/source/common/router/scoped_rds.h index 184d7cc0b0b81..8df9169a7317f 100644 --- a/source/common/router/scoped_rds.h +++ b/source/common/router/scoped_rds.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/common/callback.h" @@ -128,6 +129,8 @@ class ScopedRdsConfigSubscription Common::CallbackHandle* rds_update_callback_handle_; }; + using RdsRouteConfigProviderHelperPtr = std::unique_ptr; + // Adds or updates scopes, create a new RDS provider for each resource, if an exception is thrown // during updating, the exception message is collected via the exception messages vector. // Returns true if any scope updated, false otherwise. @@ -245,6 +248,9 @@ class ScopedRoutesConfigProviderManager : public Envoy::Config::ConfigProviderMa RouteConfigProviderManager& route_config_provider_manager_; }; +using ScopedRoutesConfigProviderManagerSharedPtr = + std::shared_ptr; + // The optional argument passed to the ConfigProviderManager::create*() functions. class ScopedRoutesConfigProviderManagerOptArg : public Envoy::Config::ConfigProviderManager::OptionalArg { diff --git a/source/common/stats/thread_local_store.h b/source/common/stats/thread_local_store.h index b801f47b00838..9a11482584f83 100644 --- a/source/common/stats/thread_local_store.h +++ b/source/common/stats/thread_local_store.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "envoy/stats/tag.h" @@ -459,5 +460,7 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo std::atomic next_scope_id_{}; }; +using ThreadLocalStoreImplPtr = std::unique_ptr; + } // namespace Stats } // namespace Envoy diff --git a/source/common/stats/timespan_impl.h b/source/common/stats/timespan_impl.h index baca0e5174d27..da53d5eec375b 100644 --- a/source/common/stats/timespan_impl.h +++ b/source/common/stats/timespan_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/time.h" #include "envoy/stats/histogram.h" #include "envoy/stats/stats.h" @@ -34,5 +36,7 @@ class HistogramCompletableTimespanImpl : public CompletableTimespan { const MonotonicTime start_; }; +using HistogramCompletableTimespanImplPtr = std::unique_ptr; + } // namespace Stats } // namespace Envoy diff --git a/source/common/thread_local/thread_local_impl.h b/source/common/thread_local/thread_local_impl.h index e06a8df6383c9..6489d4aa24b51 100644 --- a/source/common/thread_local/thread_local_impl.h +++ b/source/common/thread_local/thread_local_impl.h @@ -51,6 +51,8 @@ class InstanceImpl : Logger::Loggable, public NonCopyable, pub const uint64_t index_; }; + using InstanceImplPtr = std::unique_ptr; + using SlotImplPtr = std::unique_ptr; // A Wrapper of SlotImpl which on destruction returns the SlotImpl to the deferred delete queue @@ -107,5 +109,7 @@ class InstanceImpl : Logger::Loggable, public NonCopyable, pub friend class ThreadLocalInstanceImplTest; }; +using InstanceImplPtr = std::unique_ptr; + } // namespace ThreadLocal } // namespace Envoy diff --git a/source/common/upstream/cluster_manager_impl.h b/source/common/upstream/cluster_manager_impl.h index b40efda4b5086..40ed94a3ff60b 100644 --- a/source/common/upstream/cluster_manager_impl.h +++ b/source/common/upstream/cluster_manager_impl.h @@ -281,6 +281,7 @@ class ClusterManagerImpl : public ClusterManager, Logger::Loggable(dispatcher, host)} {} using ConnPools = PriorityConnPoolMap, Http::ConnectionPool::Instance>; + using ConnPoolsSharedPtr = std::shared_ptr; // This is a shared_ptr so we can keep it alive while cleaning up. ConnPoolsSharedPtr pools_; @@ -319,6 +320,8 @@ class ClusterManagerImpl : public ClusterManager, Logger::Loggable; using TcpConnectionsMap = std::unordered_map; struct ClusterEntry : public ThreadLocalCluster { diff --git a/source/common/upstream/conn_pool_map.h b/source/common/upstream/conn_pool_map.h index b496ef69c0876..5b8a80d75107b 100644 --- a/source/common/upstream/conn_pool_map.h +++ b/source/common/upstream/conn_pool_map.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "envoy/event/dispatcher.h" @@ -14,12 +15,14 @@ namespace Envoy { namespace Upstream { +template using POOL_TYPEPtr = std::unique_ptr; + /** * A class mapping keys to connection pools, with some recycling logic built in. */ template class ConnPoolMap { public: - using PoolFactory = std::function; + using PoolFactory = std::function()>; using DrainedCb = std::function; using PoolOptRef = absl::optional>; @@ -68,7 +71,7 @@ template class ConnPoolMap { **/ void clearActivePools(); - absl::flat_hash_map active_pools_; + absl::flat_hash_map> active_pools_; Event::Dispatcher& thread_local_dispatcher_; std::vector cached_callbacks_; Common::DebugRecursionChecker recursion_checker_; diff --git a/source/common/upstream/priority_conn_pool_map.h b/source/common/upstream/priority_conn_pool_map.h index 7527e86816198..230e0b7a320ba 100644 --- a/source/common/upstream/priority_conn_pool_map.h +++ b/source/common/upstream/priority_conn_pool_map.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/event/dispatcher.h" #include "envoy/upstream/resource_manager.h" #include "envoy/upstream/upstream.h" @@ -14,6 +16,7 @@ namespace Upstream { template class PriorityConnPoolMap { public: using ConnPoolMapType = ConnPoolMap; + using ConnPoolMapTypePtr = std::unique_ptr; using PoolFactory = typename ConnPoolMapType::PoolFactory; using DrainedCb = typename ConnPoolMapType::DrainedCb; using PoolOptRef = typename ConnPoolMapType::PoolOptRef; diff --git a/source/exe/main_common.h b/source/exe/main_common.h index 796dbbacfb7f1..bf2a00190c015 100644 --- a/source/exe/main_common.h +++ b/source/exe/main_common.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/event/timer.h" #include "envoy/runtime/runtime.h" @@ -152,4 +154,6 @@ class MainCommon { MainCommonBase base_; }; +using MainCommonPtr = std::unique_ptr; + } // namespace Envoy diff --git a/source/extensions/clusters/dynamic_forward_proxy/cluster.cc b/source/extensions/clusters/dynamic_forward_proxy/cluster.cc index 0d70dc1c82419..cfb913d21893d 100644 --- a/source/extensions/clusters/dynamic_forward_proxy/cluster.cc +++ b/source/extensions/clusters/dynamic_forward_proxy/cluster.cc @@ -70,7 +70,7 @@ void Cluster::addOrUpdateWorker( // marginal memory cost above that already used by connections and requests, so relying on // connection/request circuit breakers is sufficient. We may have to revisit this in the future. - HostInfoMapSharedPtr current_map = getCurrentHostMap(); + HostInfoMapConstSharedPtr current_map = getCurrentHostMap(); const auto host_map_it = current_map->find(host); if (host_map_it != current_map->end()) { // If we only have an address change, we can do that swap inline without any other updates. @@ -128,7 +128,7 @@ void Cluster::onDnsHostAddOrUpdate( } } -void Cluster::swapAndUpdateMap(const HostInfoMapSharedPtr& new_hosts_map, +void Cluster::swapAndUpdateMap(const HostInfoMapConstSharedPtr& new_hosts_map, const Upstream::HostVector& hosts_added, const Upstream::HostVector& hosts_removed) { { @@ -148,7 +148,7 @@ void Cluster::swapAndUpdateMap(const HostInfoMapSharedPtr& new_hosts_map, } void Cluster::onDnsHostRemove(const std::string& host) { - HostInfoMapSharedPtr current_map = getCurrentHostMap(); + HostInfoMapConstSharedPtr current_map = getCurrentHostMap(); const auto host_map_it = current_map->find(host); ASSERT(host_map_it != current_map->end()); const auto new_host_map = std::make_shared(*current_map); diff --git a/source/extensions/clusters/dynamic_forward_proxy/cluster.h b/source/extensions/clusters/dynamic_forward_proxy/cluster.h index 8916bc7d85ff0..2409ff96716bd 100644 --- a/source/extensions/clusters/dynamic_forward_proxy/cluster.h +++ b/source/extensions/clusters/dynamic_forward_proxy/cluster.h @@ -52,15 +52,16 @@ class Cluster : public Upstream::BaseDynamicClusterImpl, }; using HostInfoMap = absl::flat_hash_map; - using HostInfoMapSharedPtr = std::shared_ptr; + using HostInfoMapSharedPtr = std::shared_ptr; + using HostInfoMapConstSharedPtr = std::shared_ptr; struct LoadBalancer : public Upstream::LoadBalancer { - LoadBalancer(const HostInfoMapSharedPtr& host_map) : host_map_(host_map) {} + LoadBalancer(const HostInfoMapConstSharedPtr& host_map) : host_map_(host_map) {} // Upstream::LoadBalancer Upstream::HostConstSharedPtr chooseHost(Upstream::LoadBalancerContext* context) override; - const HostInfoMapSharedPtr host_map_; + const HostInfoMapConstSharedPtr host_map_; }; struct LoadBalancerFactory : public Upstream::LoadBalancerFactory { @@ -86,7 +87,7 @@ class Cluster : public Upstream::BaseDynamicClusterImpl, Cluster& cluster_; }; - HostInfoMapSharedPtr getCurrentHostMap() { + HostInfoMapConstSharedPtr getCurrentHostMap() { absl::ReaderMutexLock lock(&host_map_lock_); return host_map_; } @@ -95,7 +96,7 @@ class Cluster : public Upstream::BaseDynamicClusterImpl, addOrUpdateWorker(const std::string& host, const Extensions::Common::DynamicForwardProxy::DnsHostInfoSharedPtr& host_info, HostInfoMapSharedPtr& new_host_map, Upstream::HostVectorPtr& hosts_added); - void swapAndUpdateMap(const HostInfoMapSharedPtr& new_hosts_map, + void swapAndUpdateMap(const HostInfoMapConstSharedPtr& new_hosts_map, const Upstream::HostVector& hosts_added, const Upstream::HostVector& hosts_removed); @@ -108,7 +109,7 @@ class Cluster : public Upstream::BaseDynamicClusterImpl, const LocalInfo::LocalInfo& local_info_; absl::Mutex host_map_lock_; - HostInfoMapSharedPtr host_map_ ABSL_GUARDED_BY(host_map_lock_); + HostInfoMapConstSharedPtr host_map_ ABSL_GUARDED_BY(host_map_lock_); friend class ClusterFactory; friend class ClusterTest; diff --git a/source/extensions/common/aws/region_provider.h b/source/extensions/common/aws/region_provider.h index aa87f90c173db..33a4fa2803b2c 100644 --- a/source/extensions/common/aws/region_provider.h +++ b/source/extensions/common/aws/region_provider.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/pure.h" #include "absl/types/optional.h" @@ -23,6 +25,7 @@ class RegionProvider { virtual absl::optional getRegion() PURE; }; +using RegionProviderPtr = std::unique_ptr; using RegionProviderSharedPtr = std::shared_ptr; } // namespace Aws diff --git a/source/extensions/common/aws/signer.h b/source/extensions/common/aws/signer.h index 34a892c9efb2f..4056649413852 100644 --- a/source/extensions/common/aws/signer.h +++ b/source/extensions/common/aws/signer.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/pure.h" #include "envoy/http/message.h" @@ -37,6 +39,7 @@ class Signer { }; using SignerPtr = std::unique_ptr; +using SignerSharedPtr = std::shared_ptr; } // namespace Aws } // namespace Common diff --git a/source/extensions/filters/common/rbac/engine_impl.h b/source/extensions/filters/common/rbac/engine_impl.h index c36d04e76e409..d089d8859cfc6 100644 --- a/source/extensions/filters/common/rbac/engine_impl.h +++ b/source/extensions/filters/common/rbac/engine_impl.h @@ -33,6 +33,8 @@ class RoleBasedAccessControlEngineImpl : public RoleBasedAccessControlEngine, No }; using RoleBasedAccessControlEngineImplPtr = std::unique_ptr; +using RoleBasedAccessControlEngineImplConstPtr = + std::unique_ptr; } // namespace RBAC } // namespace Common diff --git a/source/extensions/filters/http/adaptive_concurrency/config.cc b/source/extensions/filters/http/adaptive_concurrency/config.cc index 805bce4ef7288..9742a1c58dbdf 100644 --- a/source/extensions/filters/http/adaptive_concurrency/config.cc +++ b/source/extensions/filters/http/adaptive_concurrency/config.cc @@ -5,6 +5,7 @@ #include "envoy/registry/registry.h" #include "extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h" +#include "extensions/filters/http/adaptive_concurrency/controller/controller.h" #include "extensions/filters/http/adaptive_concurrency/controller/gradient_controller.h" namespace Envoy { diff --git a/source/extensions/filters/http/adaptive_concurrency/controller/controller.h b/source/extensions/filters/http/adaptive_concurrency/controller/controller.h index a6ba79f55a425..9ace17be01c72 100644 --- a/source/extensions/filters/http/adaptive_concurrency/controller/controller.h +++ b/source/extensions/filters/http/adaptive_concurrency/controller/controller.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/common/pure.h" #include "envoy/common/time.h" @@ -58,6 +59,8 @@ class ConcurrencyController { virtual uint32_t concurrencyLimit() const PURE; }; +using ConcurrencyControllerSharedPtr = std::shared_ptr; + } // namespace Controller } // namespace AdaptiveConcurrency } // namespace HttpFilters diff --git a/source/extensions/filters/network/http_connection_manager/config.h b/source/extensions/filters/network/http_connection_manager/config.h index 8f471f0254db9..cddaac7b4adf5 100644 --- a/source/extensions/filters/network/http_connection_manager/config.h +++ b/source/extensions/filters/network/http_connection_manager/config.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "envoy/config/config_provider_manager.h" @@ -93,6 +94,7 @@ class HttpConnectionManagerConfig : Logger::Loggable, // Http::FilterChainFactory void createFilterChain(Http::FilterChainFactoryCallbacks& callbacks) override; using FilterFactoriesList = std::list; + using FilterFactoriesListPtr = std::unique_ptr; struct FilterConfig { FilterFactoriesListPtr filter_factories; bool allow_upgrade; @@ -242,6 +244,8 @@ class HttpConnectionManagerConfig : Logger::Loggable, static const uint64_t RequestTimeoutMs = 0; }; +using HttpConnectionManagerConfigSharedPtr = std::shared_ptr; + /** * Factory to create an HttpConnectionManager outside of a Network Filter Chain. */ diff --git a/source/extensions/filters/network/redis_proxy/command_splitter.h b/source/extensions/filters/network/redis_proxy/command_splitter.h index 5e1248d3b5001..3777c81c0ed03 100644 --- a/source/extensions/filters/network/redis_proxy/command_splitter.h +++ b/source/extensions/filters/network/redis_proxy/command_splitter.h @@ -73,6 +73,8 @@ class Instance { SplitCallbacks& callbacks) PURE; }; +using InstanceSharedPtr = std::shared_ptr; + } // namespace CommandSplitter } // namespace RedisProxy } // namespace NetworkFilters diff --git a/source/extensions/filters/network/redis_proxy/command_splitter_impl.h b/source/extensions/filters/network/redis_proxy/command_splitter_impl.h index 8057f9a91b2ca..9165c54edd196 100644 --- a/source/extensions/filters/network/redis_proxy/command_splitter_impl.h +++ b/source/extensions/filters/network/redis_proxy/command_splitter_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -123,6 +124,8 @@ class SimpleRequest : public SingleServerRequest { : SingleServerRequest(callbacks, command_stats, time_source) {} }; +using SimpleRequestPtr = std::unique_ptr; + /** * EvalRequest hashes the fourth argument as the key. */ @@ -137,6 +140,8 @@ class EvalRequest : public SingleServerRequest { : SingleServerRequest(callbacks, command_stats, time_source) {} }; +using EvalRequestPtr = std::unique_ptr; + /** * FragmentedRequest is a base class for requests that contains multiple keys. An individual request * is sent to the appropriate server for each key. The responses from all servers are combined and @@ -196,6 +201,8 @@ class MGETRequest : public FragmentedRequest, Logger::Loggable; + /** * SplitKeysSumResultRequest takes each key from the command and sends the same incoming command * with each key to the appropriate Redis server. The response from each Redis (which must be an @@ -219,6 +226,8 @@ class SplitKeysSumResultRequest : public FragmentedRequest, Logger::Loggable; + /** * MSETRequest takes each key and value pair from the command and sends a SET for each to the * appropriate Redis server. The response is an OK if all commands succeeded or an ERR if any @@ -238,6 +247,8 @@ class MSETRequest : public FragmentedRequest, Logger::Loggable; + /** * CommandHandlerFactory is placed in the command lookup map for each supported command and is used * to create Request objects. diff --git a/source/extensions/filters/network/redis_proxy/config.cc b/source/extensions/filters/network/redis_proxy/config.cc index 974283a7105a8..4b5ef0643e518 100644 --- a/source/extensions/filters/network/redis_proxy/config.cc +++ b/source/extensions/filters/network/redis_proxy/config.cc @@ -5,6 +5,7 @@ #include "extensions/common/redis/cluster_refresh_manager_impl.h" #include "extensions/filters/network/common/redis/client_impl.h" +#include "extensions/filters/network/redis_proxy/command_splitter.h" #include "extensions/filters/network/redis_proxy/command_splitter_impl.h" #include "extensions/filters/network/redis_proxy/proxy_filter.h" #include "extensions/filters/network/redis_proxy/router_impl.h" diff --git a/source/extensions/filters/network/rocketmq_proxy/config.h b/source/extensions/filters/network/rocketmq_proxy/config.h index df5cbe7c97113..89ff063d19c98 100644 --- a/source/extensions/filters/network/rocketmq_proxy/config.h +++ b/source/extensions/filters/network/rocketmq_proxy/config.h @@ -66,6 +66,8 @@ class ConfigImpl : public Config, public Router::Config, Logger::Loggable; + } // namespace RocketmqProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/thrift_proxy/conn_manager.h b/source/extensions/filters/network/thrift_proxy/conn_manager.h index a827c2bd70540..83fa25254b16c 100644 --- a/source/extensions/filters/network/thrift_proxy/conn_manager.h +++ b/source/extensions/filters/network/thrift_proxy/conn_manager.h @@ -43,6 +43,8 @@ class Config { virtual Router::Config& routerConfig() PURE; }; +using ConfigSharedPtr = std::shared_ptr; + /** * Extends Upstream::ProtocolOptionsConfig with Thrift-specific cluster options. */ diff --git a/source/extensions/filters/network/thrift_proxy/router/router_impl.h b/source/extensions/filters/network/thrift_proxy/router/router_impl.h index a9c485f74f5f5..d5c77e45f66e0 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_impl.h +++ b/source/extensions/filters/network/thrift_proxy/router/router_impl.h @@ -162,6 +162,8 @@ class RouteMatcher { std::vector routes_; }; +using RouteMatcherPtr = std::unique_ptr; + #define ALL_THRIFT_ROUTER_STATS(COUNTER, GAUGE, HISTOGRAM) \ COUNTER(route_missing) \ COUNTER(unknown_cluster) \ diff --git a/source/extensions/filters/network/thrift_proxy/thrift_object_impl.h b/source/extensions/filters/network/thrift_proxy/thrift_object_impl.h index d6961ce873577..af3ee006ee251 100644 --- a/source/extensions/filters/network/thrift_proxy/thrift_object_impl.h +++ b/source/extensions/filters/network/thrift_proxy/thrift_object_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "extensions/filters/network/thrift_proxy/decoder.h" #include "extensions/filters/network/thrift_proxy/filters/filter.h" #include "extensions/filters/network/thrift_proxy/thrift_object.h" @@ -70,6 +72,8 @@ class ThriftValueBase : public ThriftValue, public ThriftBase { const FieldType value_type_; }; +using ThriftValueBasePtr = std::unique_ptr; + class ThriftStructValueImpl; /** diff --git a/source/server/config_validation/cluster_manager.h b/source/server/config_validation/cluster_manager.h index 07ea8f3f8c1c1..c7d84897e518f 100644 --- a/source/server/config_validation/cluster_manager.h +++ b/source/server/config_validation/cluster_manager.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/bootstrap/v3/bootstrap.pb.h" #include "envoy/config/core/v3/config_source.pb.h" #include "envoy/secret/secret_manager.h" @@ -49,6 +51,8 @@ class ValidationClusterManagerFactory : public ProdClusterManagerFactory { Event::TimeSystem& time_system_; }; +using ValidationClusterManagerFactoryPtr = std::unique_ptr; + /** * Config-validation-only implementation of ClusterManager, which opens no upstream connections. */ diff --git a/source/server/config_validation/dns.h b/source/server/config_validation/dns.h index 3777256579b02..2558196348d75 100644 --- a/source/server/config_validation/dns.h +++ b/source/server/config_validation/dns.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/event/dispatcher.h" #include "envoy/network/dns.h" @@ -19,5 +21,7 @@ class ValidationDnsResolver : public DnsResolver { ResolveCb callback) override; }; +using ValidationDnsResolverSharedPtr = std::shared_ptr; + } // namespace Network } // namespace Envoy diff --git a/source/server/hot_restarting_parent.cc b/source/server/hot_restarting_parent.cc index 53961352cb5d5..d2f38a119c161 100644 --- a/source/server/hot_restarting_parent.cc +++ b/source/server/hot_restarting_parent.cc @@ -1,5 +1,7 @@ #include "server/hot_restarting_parent.h" +#include + #include "envoy/server/instance.h" #include "common/memory/stats.h" @@ -14,6 +16,7 @@ namespace Envoy { namespace Server { using HotRestartMessage = envoy::HotRestartMessage; +using HotRestartMessagePtr = std::unique_ptr; HotRestartingParent::HotRestartingParent(int base_id, int restart_epoch) : HotRestartingBase(base_id), restart_epoch_(restart_epoch) { diff --git a/source/server/hot_restarting_parent.h b/source/server/hot_restarting_parent.h index 208eb0508131b..adffa2ae7c2d2 100644 --- a/source/server/hot_restarting_parent.h +++ b/source/server/hot_restarting_parent.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "common/common/hash.h" #include "server/hot_restarting_base.h" @@ -18,6 +20,10 @@ class HotRestartingParent : HotRestartingBase, Logger::Loggable; + // The hot restarting parent's hot restart logic. Each function is meant to be called to fulfill a // request from the child for that action. class Internal { diff --git a/source/server/listener_manager_impl.h b/source/server/listener_manager_impl.h index 0bb548cc30df6..dcc027dcfe4b8 100644 --- a/source/server/listener_manager_impl.h +++ b/source/server/listener_manager_impl.h @@ -303,11 +303,14 @@ class ListenerManagerImpl : public ListenerManager, Logger::Loggable; absl::flat_hash_map error_state_tracker_; FailureStates overall_error_state_; }; +using ListenerManagerImplPtr = std::unique_ptr; + class ListenerFilterChainFactoryBuilder : public FilterChainFactoryBuilder { public: ListenerFilterChainFactoryBuilder( diff --git a/source/server/server.h b/source/server/server.h index 2154b724c15b5..542311437d9e4 100644 --- a/source/server/server.h +++ b/source/server/server.h @@ -371,6 +371,8 @@ class InstanceImpl final : Logger::Loggable, }; }; +using InstanceImplPtr = std::unique_ptr; + // Local implementation of Stats::MetricSnapshot used to flush metrics to sinks. We could // potentially have a single class instance held in a static and have a clear() method to avoid some // vector constructions and reservations, but I'm not sure it's worth the extra complexity until it From 9fc4db128df185228b1aefdfd13bd02917de92d1 Mon Sep 17 00:00:00 2001 From: tomocy Date: Fri, 3 Jul 2020 12:01:35 +0000 Subject: [PATCH 22/36] delete line format check Signed-off-by: tomocy --- support/hooks/pre-push | 14 ---- tools/code_format/check_format_test_helper.py | 43 ---------- tools/code_format/check_line_format.py | 78 ------------------- .../check_format/non_type_alias_types.cc | 2 +- 4 files changed, 1 insertion(+), 136 deletions(-) delete mode 100755 tools/code_format/check_line_format.py diff --git a/support/hooks/pre-push b/support/hooks/pre-push index 32ad458af920b..5d0ff8f42d9dc 100755 --- a/support/hooks/pre-push +++ b/support/hooks/pre-push @@ -52,20 +52,6 @@ do # our `relpath` helper. SCRIPT_DIR="$(dirname "$(realpath "$0")")/../../tools" - git diff $RANGE -- '*.cc' '*.h' | grep -v -E '^\+\+\+' | grep -E '^\+' | sed -e 's/^\+//g' | while IFS='' read -r line - do - if [ -z "$line" ] - then - continue - fi - - echo -ne " Checking format for $line - " - "$SCRIPT_DIR"/code_format/check_line_format.py "$line" - if [[ $? -ne 0 ]]; then - exit 1 - fi - done - # TODO(hausdorff): We should have a more graceful failure story when the # user does not have all the tools set up correctly. This script assumes # `$CLANG_FORMAT` and `$BUILDIFY` are defined, or that the default values it diff --git a/tools/code_format/check_format_test_helper.py b/tools/code_format/check_format_test_helper.py index e3b7bbce969e1..ac090966294f0 100755 --- a/tools/code_format/check_format_test_helper.py +++ b/tools/code_format/check_format_test_helper.py @@ -19,7 +19,6 @@ tools = os.path.dirname(curr_dir) src = os.path.join(tools, 'testdata', 'check_format') check_format = sys.executable + " " + os.path.join(curr_dir, 'check_format.py') -check_line_format = sys.executable + " " + os.path.join(curr_dir, 'check_line_format.py') errors = 0 @@ -35,12 +34,6 @@ def runCheckFormat(operation, filename, options=None): return (command, status, stdout + stderr) -def runCheckLineFormat(line): - command = f"{check_line_format} \"{line}\"" - status, stdout, stderr = runCommand(command) - return (command, status, stdout + stderr) - - def getInputFile(filename, extra_input_files=None): files_to_copy = [filename] if extra_input_files is not None: @@ -135,11 +128,6 @@ def checkFileExpectingError(filename, expected_substring, extra_input_files=None return expectError(filename, status, stdout, expected_substring) -def checkLineExpectingError(line, expected_error): - command, status, stdout = runCheckLineFormat(line) - return expectLineError(line, status, stdout, expected_error) - - def checkAndFixError(filename, expected_substring, extra_input_files=None, options=None): errors = checkFileExpectingError(filename, expected_substring, @@ -168,10 +156,6 @@ def checkUnfixableError(filename, expected_substring): return errors -def checkUnfixableLineError(line, expected_error): - return checkLineExpectingError(line, expected_error) - - def checkFileExpectingOK(filename): command, status, stdout = runCheckFormat("check", getInputFile(filename)) if status != 0: @@ -180,15 +164,6 @@ def checkFileExpectingOK(filename): return status + fixFileExpectingNoChange(filename) -def checkLineExpectingOK(line): - command, status, stdout = runCheckLineFormat(line) - if status != 0: - logging.error(f"Expected '{line}' to have no errors; status={status}, output:\n") - emitStdoutAsError(stdout) - - return status - - def runChecks(): errors = 0 @@ -329,24 +304,6 @@ def runChecks(): errors += checkFileExpectingOK("using_type_alias.cc") errors += checkFileExpectingOK("non_type_alias_allowed_type.cc") - errors += checkUnfixableLineError( - "std::unique_ptr a() { return nullptr; }", - "Use type alias for 'Network::Connection' instead. See STYLE.md") - errors += checkUnfixableLineError( - ("absl::optional> a() {" - " return nullptr;" - "}"), "Use type alias for 'ConnectionHandlerImpl::ActiveTcpListener' instead. See STYLE.md") - - errors += checkLineExpectingOK( - ("using ConnectionPtr = std::unique_ptr;" - "class A {" - "using ConnectionSharedPtr = std::shared_ptr;" - "using ConnectionOptRef = absl::optional>;" - "};")) - errors += checkLineExpectingOK(("void a(std::unique_ptr, std::shared_ptr," - "absl::optional>," - "absl::optional>>) {}")) - return errors diff --git a/tools/code_format/check_line_format.py b/tools/code_format/check_line_format.py deleted file mode 100755 index 91628727098e3..0000000000000 --- a/tools/code_format/check_line_format.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import re -import sys - -NON_TYPE_ALIAS_ALLOWED_TYPES = { - "^(?![A-Z].*).*$", - "^(.*::){,1}(StrictMock<|NiceMock<).*$", - "^(.*::){,1}(Test|Mock|Fake).*$", - "^Protobuf.*::.*$", - "^[A-Z]$", - "^.*, .*", - r"^.*\[\]$", -} - -USING_TYPE_ALIAS_REGEX = re.compile("using .* = .*;") -SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>(?!;)") -OPTIONAL_REF_REGEX = re.compile("absl::optional>(?!;)") -NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(f"({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})") - - -def whitelistedForNonTypeAlias(name): - return NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX.match(name) - - -def checkSourceLine(line, reportError): - if not USING_TYPE_ALIAS_REGEX.search(line): - smart_ptrs = SMART_PTR_REGEX.finditer(line) - for smart_ptr in smart_ptrs: - if not whitelistedForNonTypeAlias(smart_ptr.group(2)): - reportError(f"Use type alias for '{smart_ptr.group(2)}' instead. See STYLE.md") - - optional_refs = OPTIONAL_REF_REGEX.finditer(line) - for optional_ref in optional_refs: - if not whitelistedForNonTypeAlias(optional_ref.group(1)): - reportError(f"Use type alias for '{optional_ref.group(1)}' instead. See STYLE.md") - - -def printError(error): - print(f"ERROR: {error}") - - -def checkFormat(line): - error_messages = [] - - def reportError(message): - error_messages.append(f"'{line}': {message}") - - checkSourceLine(line, reportError) - - return error_messages - - -def checkErrors(errors): - if errors: - for e in errors: - printError(e) - return True - - return False - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Check line format.") - parser.add_argument("target_line", type=str, help="specify the line to check the format of") - - args = parser.parse_args() - - target_line = args.target_line - - errors = checkFormat(target_line) - - if checkErrors(errors): - printError("check format failed.") - sys.exit(1) - - print("PASS") diff --git a/tools/testdata/check_format/non_type_alias_types.cc b/tools/testdata/check_format/non_type_alias_types.cc index 8434c6c2f530a..6802be663b2fc 100644 --- a/tools/testdata/check_format/non_type_alias_types.cc +++ b/tools/testdata/check_format/non_type_alias_types.cc @@ -7,4 +7,4 @@ void a(std::unique_ptr, std::unique_ptr, std::shared_ptr, std::unique_ptr>, std::shared_ptr>, std::shared_ptr>, absl::optional>>, absl::optional>>) {} -} // namespace Envoy +} // namespace Envoy \ No newline at end of file From f40c5c00daeba3ad9c7ac7bd8604fd0d95cd3d40 Mon Sep 17 00:00:00 2001 From: tomocy Date: Fri, 3 Jul 2020 12:29:46 +0000 Subject: [PATCH 23/36] replace with type aliases Signed-off-by: tomocy --- source/common/common/basic_resource_impl.h | 3 +++ source/common/config/config_provider_impl.h | 3 ++- source/extensions/filters/http/admission_control/config.cc | 2 +- .../http/admission_control/evaluators/response_evaluator.h | 1 + .../extensions/filters/network/redis_proxy/conn_pool_impl.cc | 2 +- .../extensions/filters/network/redis_proxy/conn_pool_impl.h | 4 +++- source/server/listener_impl.h | 2 +- test/common/tcp/conn_pool_test.cc | 2 +- test/common/upstream/outlier_detection_impl_test.cc | 2 +- .../dynamic_forward_proxy/dns_cache_resource_manager_test.cc | 2 +- test/extensions/common/dynamic_forward_proxy/mocks.h | 2 +- test/extensions/filters/http/lua/lua_filter_test.cc | 2 +- 12 files changed, 17 insertions(+), 10 deletions(-) diff --git a/source/common/common/basic_resource_impl.h b/source/common/common/basic_resource_impl.h index 8fe93aaabcb9f..541b42de41e96 100644 --- a/source/common/common/basic_resource_impl.h +++ b/source/common/common/basic_resource_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/common/resource.h" #include "envoy/runtime/runtime.h" @@ -57,4 +58,6 @@ class BasicResourceLimitImpl : public ResourceLimit { const absl::optional runtime_key_; }; +using BasicResourceLimitImplSharedPtr = std::shared_ptr; + } // namespace Envoy diff --git a/source/common/config/config_provider_impl.h b/source/common/config/config_provider_impl.h index 2337ca8eba4d9..eb623a73bfe41 100644 --- a/source/common/config/config_provider_impl.h +++ b/source/common/config/config_provider_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/config_provider.h" #include "envoy/config/config_provider_manager.h" #include "envoy/init/manager.h" @@ -15,7 +17,6 @@ #include "common/init/target_impl.h" #include "common/init/watcher_impl.h" #include "common/protobuf/protobuf.h" -#include namespace Envoy { namespace Config { diff --git a/source/extensions/filters/http/admission_control/config.cc b/source/extensions/filters/http/admission_control/config.cc index 297fabf4f6d71..fe4d3e50939a4 100644 --- a/source/extensions/filters/http/admission_control/config.cc +++ b/source/extensions/filters/http/admission_control/config.cc @@ -33,7 +33,7 @@ Http::FilterFactoryCb AdmissionControlFilterFactory::createFilterFactoryFromProt return std::make_shared(context.timeSource(), sampling_window); }); - std::unique_ptr response_evaluator; + ResponseEvaluatorPtr response_evaluator; switch (config.evaluation_criteria_case()) { case AdmissionControlProto::EvaluationCriteriaCase::kSuccessCriteria: response_evaluator = std::make_unique(config.success_criteria()); diff --git a/source/extensions/filters/http/admission_control/evaluators/response_evaluator.h b/source/extensions/filters/http/admission_control/evaluators/response_evaluator.h index fd852009832a9..7dcf7698addfd 100644 --- a/source/extensions/filters/http/admission_control/evaluators/response_evaluator.h +++ b/source/extensions/filters/http/admission_control/evaluators/response_evaluator.h @@ -28,6 +28,7 @@ class ResponseEvaluator { virtual bool isGrpcSuccess(uint32_t status) const PURE; }; +using ResponseEvaluatorPtr = std::unique_ptr; using ResponseEvaluatorSharedPtr = std::shared_ptr; } // namespace AdmissionControl diff --git a/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc b/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc index 8e9ac6f186a63..8c5ca61e8f1fe 100644 --- a/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc +++ b/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc @@ -81,7 +81,7 @@ InstanceImpl::makeRequestToHost(const std::string& host_address, return tls_->getTyped().makeRequestToHost(host_address, request, callbacks); } -InstanceImpl::ThreadLocalPool::ThreadLocalPool(std::shared_ptr parent, +InstanceImpl::ThreadLocalPool::ThreadLocalPool(InstanceImplSharedPtr parent, Event::Dispatcher& dispatcher, std::string cluster_name) : parent_(parent), dispatcher_(dispatcher), cluster_name_(std::move(cluster_name)), diff --git a/source/extensions/filters/network/redis_proxy/conn_pool_impl.h b/source/extensions/filters/network/redis_proxy/conn_pool_impl.h index aaa25c2385102..ca31b413d53ef 100644 --- a/source/extensions/filters/network/redis_proxy/conn_pool_impl.h +++ b/source/extensions/filters/network/redis_proxy/conn_pool_impl.h @@ -101,6 +101,8 @@ class InstanceImpl : public Instance, public std::enable_shared_from_this; + using ThreadLocalActiveClientPtr = std::unique_ptr; struct PendingRequest : public Common::Redis::Client::ClientCallbacks, @@ -126,7 +128,7 @@ class InstanceImpl : public Instance, public std::enable_shared_from_this parent, Event::Dispatcher& dispatcher, + ThreadLocalPool(InstanceImplSharedPtr parent, Event::Dispatcher& dispatcher, std::string cluster_name); ~ThreadLocalPool() override; ThreadLocalActiveClientPtr& threadLocalActiveClient(Upstream::HostConstSharedPtr host); diff --git a/source/server/listener_impl.h b/source/server/listener_impl.h index a41f7a3be72b0..99af211bb34ae 100644 --- a/source/server/listener_impl.h +++ b/source/server/listener_impl.h @@ -402,7 +402,7 @@ class ListenerImpl final : public Network::ListenerConfig, // // TODO (tonya11en): Move this functionality into the overload manager. const std::string cx_limit_runtime_key_; - std::shared_ptr open_connections_; + BasicResourceLimitImplSharedPtr open_connections_; // This init watcher, if workers_started_ is false, notifies the "parent" listener manager when // listener initialization is complete. diff --git a/test/common/tcp/conn_pool_test.cc b/test/common/tcp/conn_pool_test.cc index 84877e9c2a68d..9bd31b0cdd5f8 100644 --- a/test/common/tcp/conn_pool_test.cc +++ b/test/common/tcp/conn_pool_test.cc @@ -113,7 +113,7 @@ class ConnPoolBase : public Tcp::ConnectionPool::Instance { void expectEnableUpstreamReady(bool run); - std::unique_ptr conn_pool_; + Tcp::ConnectionPool::InstancePtr conn_pool_; Event::MockDispatcher& mock_dispatcher_; NiceMock* mock_upstream_ready_cb_; std::vector test_conns_; diff --git a/test/common/upstream/outlier_detection_impl_test.cc b/test/common/upstream/outlier_detection_impl_test.cc index 7492e1d61721b..b419a2631501d 100644 --- a/test/common/upstream/outlier_detection_impl_test.cc +++ b/test/common/upstream/outlier_detection_impl_test.cc @@ -1356,7 +1356,7 @@ TEST_F(OutlierDetectorImplTest, EjectionActiveValueIsAccountedWithoutMetricStora EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80", "tcp://127.0.0.1:81"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( + DetectorImplSharedPtr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); diff --git a/test/extensions/common/dynamic_forward_proxy/dns_cache_resource_manager_test.cc b/test/extensions/common/dynamic_forward_proxy/dns_cache_resource_manager_test.cc index 04127f486fff0..0b38f0b13b85d 100644 --- a/test/extensions/common/dynamic_forward_proxy/dns_cache_resource_manager_test.cc +++ b/test/extensions/common/dynamic_forward_proxy/dns_cache_resource_manager_test.cc @@ -38,7 +38,7 @@ class DnsCacheResourceManagerTest : public testing::Test { } } - std::unique_ptr resource_manager_; + DnsCacheResourceManagerPtr resource_manager_; NiceMock store_; NiceMock gauge_; NiceMock loader_; diff --git a/test/extensions/common/dynamic_forward_proxy/mocks.h b/test/extensions/common/dynamic_forward_proxy/mocks.h index 1a9e8c77e7c2d..6dd1d04ba99a2 100644 --- a/test/extensions/common/dynamic_forward_proxy/mocks.h +++ b/test/extensions/common/dynamic_forward_proxy/mocks.h @@ -44,7 +44,7 @@ class MockDnsCache : public DnsCache { Upstream::ResourceAutoIncDecPtr canCreateDnsRequest(ResourceLimitOptRef pending_requests) override { Upstream::ResourceAutoIncDec* raii_ptr = canCreateDnsRequest_(pending_requests); - return std::unique_ptr(raii_ptr); + return Upstream::ResourceAutoIncDecPtr(raii_ptr); } MOCK_METHOD(MockLoadDnsCacheEntryResult, loadDnsCacheEntry_, (absl::string_view host, uint16_t default_port, diff --git a/test/extensions/filters/http/lua/lua_filter_test.cc b/test/extensions/filters/http/lua/lua_filter_test.cc index 062fd403a9748..b4e756b585593 100644 --- a/test/extensions/filters/http/lua/lua_filter_test.cc +++ b/test/extensions/filters/http/lua/lua_filter_test.cc @@ -113,7 +113,7 @@ class LuaHttpFilterTest : public testing::Test { NiceMock api_; Upstream::MockClusterManager cluster_manager_; FilterConfigSharedPtr config_; - std::shared_ptr per_route_config_; + FilterConfigPerRouteSharedPtr per_route_config_; std::unique_ptr filter_; Http::MockStreamDecoderFilterCallbacks decoder_callbacks_; Http::MockStreamEncoderFilterCallbacks encoder_callbacks_; From 344eb82a85ed3b2514b6efe9300d18a3a8d36889 Mon Sep 17 00:00:00 2001 From: tomocy Date: Fri, 3 Jul 2020 12:41:01 +0000 Subject: [PATCH 24/36] fix not to replace type alias decl with template Signed-off-by: tomocy --- tools/code_format/check_format.py | 2 +- tools/testdata/check_format/using_type_alias.cc | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index eb985bca91246..3df89ff4e3305 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -617,7 +617,7 @@ def fixSourceLine(line, line_number): for invalid_construct, valid_construct in LIBCXX_REPLACEMENTS.items(): line = line.replace(invalid_construct, valid_construct) - if aggressive and not USING_TYPE_ALIAS_REGEX.match(line): + if aggressive and not USING_TYPE_ALIAS_REGEX.search(line): line = replaceWithTypeAlias(line) return line diff --git a/tools/testdata/check_format/using_type_alias.cc b/tools/testdata/check_format/using_type_alias.cc index 3acf022ca8e04..34f737222e9cf 100644 --- a/tools/testdata/check_format/using_type_alias.cc +++ b/tools/testdata/check_format/using_type_alias.cc @@ -6,6 +6,8 @@ class Connection; using ConnectionPtr = std::unique_ptr; +template using EdfSchedulerPtr = std::unique_ptr>; + class A { using ConnectionSharedPtr = std::shared_ptr; using ConnectionOptRef = absl::optional>; From 6ace91caddcac0139481661057d7427f28c3fad0 Mon Sep 17 00:00:00 2001 From: tomocy Date: Tue, 7 Jul 2020 10:46:59 +0000 Subject: [PATCH 25/36] replace with type aliases Signed-off-by: tomocy --- include/envoy/config/typed_metadata.h | 2 ++ include/envoy/stats/histogram.h | 2 ++ include/envoy/upstream/resource_manager.h | 2 ++ source/common/buffer/buffer_impl.h | 2 ++ source/common/stats/symbol_table_impl.h | 4 ++++ source/common/tcp/conn_pool.h | 2 +- test/common/stats/stat_test_utility.cc | 9 ++++++--- test/integration/utility.h | 2 ++ test/main.cc | 3 +++ test/mocks/grpc/mocks.h | 9 +++++++-- test/mocks/server/instance.h | 2 +- test/mocks/server/transport_socket_factory_context.h | 2 +- test/test_common/global.h | 3 +++ test/test_common/utility.h | 3 +++ 14 files changed, 39 insertions(+), 8 deletions(-) diff --git a/include/envoy/config/typed_metadata.h b/include/envoy/config/typed_metadata.h index cb21a3b13bb1e..e90f769a72594 100644 --- a/include/envoy/config/typed_metadata.h +++ b/include/envoy/config/typed_metadata.h @@ -49,6 +49,8 @@ class TypedMetadata { virtual const Object* getData(const std::string& key) const PURE; }; +using TypedMetadataPtr = std::unique_ptr; + /** * Typed metadata should implement this factory and register via Registry::registerFactory or the * convenience class RegisterFactory. diff --git a/include/envoy/stats/histogram.h b/include/envoy/stats/histogram.h index 719a83fea6e27..de58fe7319a75 100644 --- a/include/envoy/stats/histogram.h +++ b/include/envoy/stats/histogram.h @@ -65,6 +65,8 @@ class HistogramStatistics { virtual double sampleSum() const PURE; }; +using HistogramStatisticsSharedPtr = std::shared_ptr; + /** * A histogram that records values one at a time. * Note: Histograms now incorporate what used to be timers because the only diff --git a/include/envoy/upstream/resource_manager.h b/include/envoy/upstream/resource_manager.h index 5cac59a1a0ad6..4c00d71106e6f 100644 --- a/include/envoy/upstream/resource_manager.h +++ b/include/envoy/upstream/resource_manager.h @@ -68,5 +68,7 @@ class ResourceManager { virtual ResourceLimit& connectionPools() PURE; }; +using ResourceManagerPtr = std::unique_ptr; + } // namespace Upstream } // namespace Envoy diff --git a/source/common/buffer/buffer_impl.h b/source/common/buffer/buffer_impl.h index edcf2dd805f54..9f98260fca6fa 100644 --- a/source/common/buffer/buffer_impl.h +++ b/source/common/buffer/buffer_impl.h @@ -489,6 +489,8 @@ class BufferFragmentImpl : NonCopyable, public BufferFragment { const std::function releasor_; }; +using BufferFragmentImplPtr = std::unique_ptr; + class LibEventInstance : public Instance { public: // Called after accessing the memory in buffer() directly to allow any post-processing. diff --git a/source/common/stats/symbol_table_impl.h b/source/common/stats/symbol_table_impl.h index 403d35fd53d5a..7945a5354b259 100644 --- a/source/common/stats/symbol_table_impl.h +++ b/source/common/stats/symbol_table_impl.h @@ -357,6 +357,8 @@ class StatNameStorage : public StatNameStorageBase { void free(SymbolTable& table); }; +using StatNameStoragePtr = std::unique_ptr; + /** * Efficiently represents a stat name using a variable-length array of uint8_t. * This class does not own the backing store for this array; the backing-store @@ -506,6 +508,8 @@ class StatNameManagedStorage : public StatNameStorage { SymbolTable& symbol_table_; }; +using StatNameManagedStoragePtr = std::unique_ptr; + /** * Holds backing-store for a dynamic stat, where are no global locks needed * to create a StatName from a string, but there is no sharing of token data diff --git a/source/common/tcp/conn_pool.h b/source/common/tcp/conn_pool.h index d267ac24ed064..82d00e25ecc70 100644 --- a/source/common/tcp/conn_pool.h +++ b/source/common/tcp/conn_pool.h @@ -181,7 +181,7 @@ class ConnPoolImpl : public Envoy::ConnectionPool::ConnPoolImplBase, Envoy::ConnectionPool::AttachContext& context) override { ActiveTcpClient* tcp_client = static_cast(&client); auto* callbacks = typedContext(context).callbacks_; - std::unique_ptr connection_data = + Envoy::Tcp::ConnectionPool::ConnectionDataPtr connection_data = std::make_unique(*tcp_client, *tcp_client->connection_); callbacks->onPoolReady(std::move(connection_data), tcp_client->real_host_description_); } diff --git a/test/common/stats/stat_test_utility.cc b/test/common/stats/stat_test_utility.cc index 4e78763e98c47..85a0baa1cd141 100644 --- a/test/common/stats/stat_test_utility.cc +++ b/test/common/stats/stat_test_utility.cc @@ -203,9 +203,12 @@ Histogram& TestStore::histogramFromStatNameWithTags(const StatName& stat_name, } template -static StatTypeOptConstRef findByString(const std::string& name, - const absl::flat_hash_map& map) { - StatTypeOptConstRef ret; +using StatTypeOptConstRef = absl::optional>; + +template +static StatTypeOptConstRef +findByString(const std::string& name, const absl::flat_hash_map& map) { + StatTypeOptConstRef ret; auto iter = map.find(name); if (iter != map.end()) { ret = *iter->second; diff --git a/test/integration/utility.h b/test/integration/utility.h index fdac7b22f655f..ada44f9329e0c 100644 --- a/test/integration/utility.h +++ b/test/integration/utility.h @@ -116,6 +116,8 @@ class RawConnectionDriver { bool closed_{false}; }; + using ConnectionCallbacksPtr = std::unique_ptr; + Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; Event::Dispatcher& dispatcher_; diff --git a/test/main.cc b/test/main.cc index 8cb4ee5dc5682..327483c3913dd 100644 --- a/test/main.cc +++ b/test/main.cc @@ -1,4 +1,6 @@ // NOLINT(namespace-envoy) +#include + #include "envoy/thread/thread.h" #include "test/test_common/environment.h" @@ -8,6 +10,7 @@ #include "tools/cpp/runfiles/runfiles.h" using bazel::tools::cpp::runfiles::Runfiles; +using RunfilesPtr = std::unique_ptr; // The main entry point (and the rest of this file) should have no logic in it, // this allows overriding by site specific versions of main.cc. int main(int argc, char** argv) { diff --git a/test/mocks/grpc/mocks.h b/test/mocks/grpc/mocks.h index 2289d219a8122..476ba677f9453 100644 --- a/test/mocks/grpc/mocks.h +++ b/test/mocks/grpc/mocks.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "envoy/config/core/v3/grpc_service.pb.h" @@ -39,10 +40,14 @@ class MockAsyncStream : public RawAsyncStream { MOCK_METHOD(bool, isAboveWriteBufferHighWatermark, (), (const)); }; +template using ResponseTypePtr = std::unique_ptr; + template class MockAsyncRequestCallbacks : public AsyncRequestCallbacks { public: - void onSuccess(ResponseTypePtr&& response, Tracing::Span& span) { onSuccess_(*response, span); } + void onSuccess(ResponseTypePtr&& response, Tracing::Span& span) { + onSuccess_(*response, span); + } MOCK_METHOD(void, onCreateInitialMetadata, (Http::RequestHeaderMap & metadata)); MOCK_METHOD(void, onSuccess_, (const ResponseType& response, Tracing::Span& span)); @@ -57,7 +62,7 @@ class MockAsyncStreamCallbacks : public AsyncStreamCallbacks { onReceiveInitialMetadata_(*metadata); } - void onReceiveMessage(ResponseTypePtr&& message) { onReceiveMessage_(*message); } + void onReceiveMessage(ResponseTypePtr&& message) { onReceiveMessage_(*message); } void onReceiveTrailingMetadata(Http::ResponseTrailerMapPtr&& metadata) { onReceiveTrailingMetadata_(*metadata); diff --git a/test/mocks/server/instance.h b/test/mocks/server/instance.h index 67da777947726..bd6112c5f7dda 100644 --- a/test/mocks/server/instance.h +++ b/test/mocks/server/instance.h @@ -98,7 +98,7 @@ class MockInstance : public Instance { testing::NiceMock api_; testing::NiceMock admin_; Event::GlobalTimeSystem time_system_; - std::unique_ptr secret_manager_; + Secret::SecretManagerPtr secret_manager_; testing::NiceMock cluster_manager_; Thread::MutexBasicLockable access_log_lock_; testing::NiceMock runtime_loader_; diff --git a/test/mocks/server/transport_socket_factory_context.h b/test/mocks/server/transport_socket_factory_context.h index a86f2b348485f..f23eb13c6af48 100644 --- a/test/mocks/server/transport_socket_factory_context.h +++ b/test/mocks/server/transport_socket_factory_context.h @@ -37,7 +37,7 @@ class MockTransportSocketFactoryContext : public TransportSocketFactoryContext { testing::NiceMock cluster_manager_; testing::NiceMock api_; testing::NiceMock config_tracker_; - std::unique_ptr secret_manager_; + Secret::SecretManagerPtr secret_manager_; }; } // namespace Configuration } // namespace Server diff --git a/test/test_common/global.h b/test/test_common/global.h index 7289e2a05c594..8b1571dbb27cb 100644 --- a/test/test_common/global.h +++ b/test/test_common/global.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "common/common/lock_guard.h" #include "common/common/thread.h" @@ -63,6 +65,7 @@ class Globals { void* ptrHelper() override { return ptr_.get(); } private: + using TypePtr = std::unique_ptr; TypePtr ptr_{std::make_unique()}; }; diff --git a/test/test_common/utility.h b/test/test_common/utility.h index aa47e87012bf7..8ccc5c3035846 100644 --- a/test/test_common/utility.h +++ b/test/test_common/utility.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -959,6 +960,8 @@ template class TestHeaderMapImplBase : public Inte return rc; } + using ImplPtr = std::unique_ptr; + ImplPtr header_map_{Impl::create()}; }; From e45a2a39a8f7b760808d54a3cd07cdd94c14a5a7 Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 9 Jul 2020 08:09:33 +0000 Subject: [PATCH 26/36] fix Signed-off-by: tomocy --- include/envoy/buffer/buffer.h | 1 + include/envoy/http/header_map.h | 8 ++++++++ include/envoy/registry/registry.h | 4 ++++ include/envoy/ssl/tls_certificate_config.h | 2 ++ include/envoy/stats/scope.h | 1 + include/envoy/upstream/cluster_factory.h | 2 ++ source/common/config/grpc_mux_impl.h | 3 +++ source/common/config/grpc_subscription_impl.h | 5 +++++ source/common/network/listen_socket_impl.h | 1 + source/common/shared_pool/shared_pool.h | 4 ++++ source/common/stats/allocator_impl.h | 3 +++ source/common/stats/symbol_table_impl.h | 2 ++ source/common/upstream/health_checker_impl.h | 2 ++ source/common/upstream/load_balancer_impl.h | 5 +++++ source/common/upstream/maglev_lb.h | 4 ++++ source/common/upstream/ring_hash_lb.h | 3 +++ .../extensions/clusters/dynamic_forward_proxy/cluster.h | 4 ++++ .../extensions/common/dynamic_forward_proxy/dns_cache.h | 5 +++++ .../filters/http/aws_lambda/aws_lambda_filter.h | 3 +++ .../http/aws_request_signing/aws_request_signing_filter.h | 4 ++++ .../filters/http/decompressor/decompressor_filter.h | 3 +++ .../http/header_to_metadata/header_to_metadata_filter.h | 3 +++ .../filters/listener/original_src/original_src.h | 4 ++++ .../filters/network/thrift_proxy/conn_manager.h | 2 ++ .../quic_listeners/quiche/envoy_quic_fake_proof_source.h | 3 +++ .../metrics_service/grpc_metrics_service_impl.h | 4 ++++ source/server/config_validation/api.h | 4 ++++ test/common/network/dns_impl_test.cc | 2 ++ test/common/network/filter_matcher_test.cc | 4 ++++ test/integration/integration.h | 3 +++ test/integration/utility.h | 4 ++++ 31 files changed, 102 insertions(+) diff --git a/include/envoy/buffer/buffer.h b/include/envoy/buffer/buffer.h index 1f78f380f6b60..56f357a44a5ab 100644 --- a/include/envoy/buffer/buffer.h +++ b/include/envoy/buffer/buffer.h @@ -368,6 +368,7 @@ class Instance { }; using InstancePtr = std::unique_ptr; +using InstanceSharedPtr = std::shared_ptr; /** * A factory for creating buffers which call callbacks when reaching high and low watermarks. diff --git a/include/envoy/http/header_map.h b/include/envoy/http/header_map.h index 82a79d4fa6e55..b1ba6cc6138ce 100644 --- a/include/envoy/http/header_map.h +++ b/include/envoy/http/header_map.h @@ -70,6 +70,8 @@ class LowerCaseString { std::string string_; }; +using LowerCaseStringPtr = std::unique_ptr; + /** * Convenient type for a vector of lower case string and string pair. */ @@ -717,6 +719,8 @@ class RequestOrResponseHeaderMap : public HeaderMap { INLINE_REQ_RESP_HEADERS(DEFINE_INLINE_HEADER) }; +using RequestOrResponseHeaderMapPtr = std::unique_ptr; + // Request headers. class RequestHeaderMap : public RequestOrResponseHeaderMap, @@ -748,14 +752,18 @@ class ResponseHeaderMap public: INLINE_RESP_HEADERS(DEFINE_INLINE_HEADER) }; + using ResponseHeaderMapPtr = std::unique_ptr; +using ResponseHeaderMapSharedPtr = std::shared_ptr; // Response trailers. class ResponseTrailerMap : public ResponseHeaderOrTrailerMap, public HeaderMap, public CustomInlineHeaderBase {}; + using ResponseTrailerMapPtr = std::unique_ptr; +using ResponseTrailerMapSharedPtr = std::shared_ptr; /** * Convenient container type for storing Http::LowerCaseString and std::string key/value pairs. diff --git a/include/envoy/registry/registry.h b/include/envoy/registry/registry.h index d48a48dd0b665..491b0d4d019c2 100644 --- a/include/envoy/registry/registry.h +++ b/include/envoy/registry/registry.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,9 @@ template class FactoryRegistryProxyImpl : public FactoryRegistryPro } }; +template +using FactoryRegistryProxyImplPtr = std::unique_ptr>; + /** * BaseFactoryCategoryRegistry holds the static factory map for * FactoryCategoryRegistry, ensuring that friends of that class diff --git a/include/envoy/ssl/tls_certificate_config.h b/include/envoy/ssl/tls_certificate_config.h index 882d40fe133d4..35c1901de18e8 100644 --- a/include/envoy/ssl/tls_certificate_config.h +++ b/include/envoy/ssl/tls_certificate_config.h @@ -53,6 +53,8 @@ class TlsCertificateConfig { }; using TlsCertificateConfigPtr = std::unique_ptr; +using TlsCertificateConfigOptConstRef = + absl::optional>; } // namespace Ssl } // namespace Envoy diff --git a/include/envoy/stats/scope.h b/include/envoy/stats/scope.h index 408655bbb8a5c..d30c48b45de9c 100644 --- a/include/envoy/stats/scope.h +++ b/include/envoy/stats/scope.h @@ -21,6 +21,7 @@ class NullGaugeImpl; class Scope; class TextReadout; +using CounterPtr = std::unique_ptr; using CounterOptConstRef = absl::optional>; using GaugeOptConstRef = absl::optional>; using HistogramOptConstRef = absl::optional>; diff --git a/include/envoy/upstream/cluster_factory.h b/include/envoy/upstream/cluster_factory.h index 389a804ba0441..f882d129e1d8c 100644 --- a/include/envoy/upstream/cluster_factory.h +++ b/include/envoy/upstream/cluster_factory.h @@ -142,5 +142,7 @@ class ClusterFactory : public Config::UntypedFactory { std::string category() const override { return "envoy.clusters"; } }; +using ClusterFactoryPtr = std::unique_ptr; + } // namespace Upstream } // namespace Envoy diff --git a/source/common/config/grpc_mux_impl.h b/source/common/config/grpc_mux_impl.h index bb1d87e97fcdc..57312228799a0 100644 --- a/source/common/config/grpc_mux_impl.h +++ b/source/common/config/grpc_mux_impl.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -143,6 +144,8 @@ class GrpcMuxImpl : public GrpcMux, const envoy::config::core::v3::ApiVersion transport_api_version_; }; +using GrpcMuxImplPtr = std::unique_ptr; + class NullGrpcMuxImpl : public GrpcMux, GrpcStreamCallbacks { public: diff --git a/source/common/config/grpc_subscription_impl.h b/source/common/config/grpc_subscription_impl.h index a9a9f7b77f708..eae2da47fcd60 100644 --- a/source/common/config/grpc_subscription_impl.h +++ b/source/common/config/grpc_subscription_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/grpc_mux.h" #include "envoy/config/subscription.h" #include "envoy/event/dispatcher.h" @@ -55,5 +57,8 @@ class GrpcSubscriptionImpl : public Subscription, const bool is_aggregated_; }; +using GrpcSubscriptionImplPtr = std::unique_ptr; +using GrpcSubscriptionImplSharedPtr = std::shared_ptr; + } // namespace Config } // namespace Envoy diff --git a/source/common/network/listen_socket_impl.h b/source/common/network/listen_socket_impl.h index c0786536a67e3..0f4e3cf831fdb 100644 --- a/source/common/network/listen_socket_impl.h +++ b/source/common/network/listen_socket_impl.h @@ -66,6 +66,7 @@ template class NetworkListenSocket : public ListenSocketImpl { using TcpListenSocket = NetworkListenSocket>; using TcpListenSocketPtr = std::unique_ptr; +using TcpListenSocketSharedPtr = std::shared_ptr; using UdpListenSocket = NetworkListenSocket>; using UdpListenSocketPtr = std::unique_ptr; diff --git a/source/common/shared_pool/shared_pool.h b/source/common/shared_pool/shared_pool.h index d7119d17140f7..44dc11fee86ba 100644 --- a/source/common/shared_pool/shared_pool.h +++ b/source/common/shared_pool/shared_pool.h @@ -106,6 +106,10 @@ class ObjectSharedPool : public Singleton::Instance, Thread::ThreadSynchronizer sync_; }; +template , + class V = typename std::enable_if::value>::type> +using ObjectSharedPoolSharedPtr = std::shared_ptr>; + template const char ObjectSharedPool::DeleteObjectOnMainThread[] = "delete-object-on-main"; diff --git a/source/common/stats/allocator_impl.h b/source/common/stats/allocator_impl.h index 3242d0de5fefc..de2b035091d92 100644 --- a/source/common/stats/allocator_impl.h +++ b/source/common/stats/allocator_impl.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/stats/allocator.h" @@ -96,5 +97,7 @@ class AllocatorImpl : public Allocator { Thread::ThreadSynchronizer sync_; }; +using AllocatorImplPtr = std::unique_ptr; + } // namespace Stats } // namespace Envoy diff --git a/source/common/stats/symbol_table_impl.h b/source/common/stats/symbol_table_impl.h index 7945a5354b259..6fd24c3a07873 100644 --- a/source/common/stats/symbol_table_impl.h +++ b/source/common/stats/symbol_table_impl.h @@ -584,6 +584,8 @@ class StatNamePool { std::vector storage_vector_; }; +using StatNamePoolPtr = std::unique_ptr; + /** * Maintains storage for a collection of StatName objects constructed from * dynamically discovered strings. Like StatNameDynamicStorage, this has an RAII diff --git a/source/common/upstream/health_checker_impl.h b/source/common/upstream/health_checker_impl.h index 36a29a47f89c2..91b49d178cd02 100644 --- a/source/common/upstream/health_checker_impl.h +++ b/source/common/upstream/health_checker_impl.h @@ -284,6 +284,8 @@ class TcpHealthCheckerImpl : public HealthCheckerImplBase { const TcpHealthCheckMatcher::MatchSegments receive_bytes_; }; +using TcpHealthCheckerImplSharedPtr = std::shared_ptr; + /** * gRPC health checker implementation. */ diff --git a/source/common/upstream/load_balancer_impl.h b/source/common/upstream/load_balancer_impl.h index 62b92d210ea51..80d84440ad274 100644 --- a/source/common/upstream/load_balancer_impl.h +++ b/source/common/upstream/load_balancer_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -420,6 +421,8 @@ class RoundRobinLoadBalancer : public EdfLoadBalancerBase { std::unordered_map rr_indexes_; }; +using RoundRobinLoadBalancerPtr = std::unique_ptr; + /** * Weighted Least Request load balancer. * @@ -472,6 +475,8 @@ class LeastRequestLoadBalancer : public EdfLoadBalancerBase { const uint32_t choice_count_; }; +using LeastRequestLoadBalancerPtr = std::unique_ptr; + /** * Random load balancer that picks a random host out of all hosts. */ diff --git a/source/common/upstream/maglev_lb.h b/source/common/upstream/maglev_lb.h index 12a71e4fcb2d7..3a20fcb0ca182 100644 --- a/source/common/upstream/maglev_lb.h +++ b/source/common/upstream/maglev_lb.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/cluster/v3/cluster.pb.h" #include "envoy/stats/scope.h" #include "envoy/stats/stats_macros.h" @@ -93,5 +95,7 @@ class MaglevLoadBalancer : public ThreadAwareLoadBalancerBase { const bool use_hostname_for_hashing_; }; +using MaglevLoadBalancerPtr = std::unique_ptr; + } // namespace Upstream } // namespace Envoy diff --git a/source/common/upstream/ring_hash_lb.h b/source/common/upstream/ring_hash_lb.h index 9353d34715a7a..41a89a015e6fb 100644 --- a/source/common/upstream/ring_hash_lb.h +++ b/source/common/upstream/ring_hash_lb.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/config/cluster/v3/cluster.pb.h" @@ -92,5 +93,7 @@ class RingHashLoadBalancer : public ThreadAwareLoadBalancerBase, const bool use_hostname_for_hashing_; }; +using RingHashLoadBalancerPtr = std::unique_ptr; + } // namespace Upstream } // namespace Envoy diff --git a/source/extensions/clusters/dynamic_forward_proxy/cluster.h b/source/extensions/clusters/dynamic_forward_proxy/cluster.h index 2409ff96716bd..996975ea87190 100644 --- a/source/extensions/clusters/dynamic_forward_proxy/cluster.h +++ b/source/extensions/clusters/dynamic_forward_proxy/cluster.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/cluster/v3/cluster.pb.h" #include "envoy/config/endpoint/v3/endpoint_components.pb.h" #include "envoy/extensions/clusters/dynamic_forward_proxy/v3/cluster.pb.h" @@ -115,6 +117,8 @@ class Cluster : public Upstream::BaseDynamicClusterImpl, friend class ClusterTest; }; +using ClusterSharedPtr = std::shared_ptr; + class ClusterFactory : public Upstream::ConfigurableClusterFactoryBase< envoy::extensions::clusters::dynamic_forward_proxy::v3::ClusterConfig> { public: diff --git a/source/extensions/common/dynamic_forward_proxy/dns_cache.h b/source/extensions/common/dynamic_forward_proxy/dns_cache.h index 2b9d0263fb9f4..daf085d195447 100644 --- a/source/extensions/common/dynamic_forward_proxy/dns_cache.h +++ b/source/extensions/common/dynamic_forward_proxy/dns_cache.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/event/dispatcher.h" #include "envoy/extensions/common/dynamic_forward_proxy/v3/dns_cache.pb.h" #include "envoy/singleton/manager.h" @@ -70,6 +72,8 @@ class DnsCacheResourceManager { virtual DnsCacheCircuitBreakersStats& stats() PURE; }; +using DnsCacheResourceManagerPtr = std::unique_ptr; + /** * A cache of DNS hosts. Hosts will re-resolve their addresses or be automatically purged * depending on configured policy. @@ -186,6 +190,7 @@ class DnsCache { canCreateDnsRequest(ResourceLimitOptRef pending_request) PURE; }; +using DnsCachePtr = std::unique_ptr; using DnsCacheSharedPtr = std::shared_ptr; /** diff --git a/source/extensions/filters/http/aws_lambda/aws_lambda_filter.h b/source/extensions/filters/http/aws_lambda/aws_lambda_filter.h index 597b336e5adf1..a7de0db4806c5 100644 --- a/source/extensions/filters/http/aws_lambda/aws_lambda_filter.h +++ b/source/extensions/filters/http/aws_lambda/aws_lambda_filter.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/http/filter.h" @@ -136,6 +137,8 @@ class Filter : public Http::PassThroughFilter, Logger::Loggable; + } // namespace AwsLambdaFilter } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.h b/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.h index b096e6453d199..caed866b276a9 100644 --- a/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.h +++ b/source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/extensions/filters/http/aws_request_signing/v3/aws_request_signing.pb.h" #include "envoy/http/filter.h" #include "envoy/stats/scope.h" @@ -88,6 +90,8 @@ class Filter : public Http::PassThroughDecoderFilter, Logger::Loggable; + } // namespace AwsRequestSigningFilter } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/decompressor/decompressor_filter.h b/source/extensions/filters/http/decompressor/decompressor_filter.h index ec6df0b35539b..e7f5fe4eb8b5f 100644 --- a/source/extensions/filters/http/decompressor/decompressor_filter.h +++ b/source/extensions/filters/http/decompressor/decompressor_filter.h @@ -10,6 +10,7 @@ #include "common/runtime/runtime_protos.h" #include "extensions/filters/http/common/pass_through_filter.h" +#include namespace Envoy { namespace Extensions { @@ -202,6 +203,8 @@ class DecompressorFilter : public Http::PassThroughFilter, Compression::Decompressor::DecompressorPtr response_decompressor_{}; }; +using DecompressorFilterPtr = std::unique_ptr; + } // namespace Decompressor } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.h b/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.h index 4cc3e117c4ff2..00b9c945f7435 100644 --- a/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.h +++ b/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -148,6 +149,8 @@ class HeaderToMetadataFilter : public Http::StreamFilter, const Config* getConfig() const; }; +using HeaderToMetadataFilterSharedPtr = std::shared_ptr; + } // namespace HeaderToMetadataFilter } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/listener/original_src/original_src.h b/source/extensions/filters/listener/original_src/original_src.h index f201644f88106..403b4abd6c225 100644 --- a/source/extensions/filters/listener/original_src/original_src.h +++ b/source/extensions/filters/listener/original_src/original_src.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/network/address.h" #include "envoy/network/filter.h" @@ -28,6 +30,8 @@ class OriginalSrcFilter : public Network::ListenerFilter, Logger::Loggable; + } // namespace OriginalSrc } // namespace ListenerFilters } // namespace Extensions diff --git a/source/extensions/filters/network/thrift_proxy/conn_manager.h b/source/extensions/filters/network/thrift_proxy/conn_manager.h index 83fa25254b16c..b38bbfce3af09 100644 --- a/source/extensions/filters/network/thrift_proxy/conn_manager.h +++ b/source/extensions/filters/network/thrift_proxy/conn_manager.h @@ -279,6 +279,8 @@ class ConnectionManager : public Network::ReadFilter, TimeSource& time_source_; }; +using ConnectionManagerPtr = std::unique_ptr; + } // namespace ThriftProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h b/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h index b179f496327b7..a9e6dc7e55216 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "common/common/assert.h" @@ -62,6 +63,8 @@ class EnvoyQuicFakeProofSource : public quic::ProofSource { FakeSignatureCallback(bool& success, std::string& signature) : success_(success), signature_(signature) {} + using DetailsPtr = std::unique_ptr
; + // quic::ProofSource::SignatureCallback void Run(bool ok, std::string signature, DetailsPtr /*details*/) override { success_ = ok; diff --git a/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.h b/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.h index 0e35d3b063048..d65bae27f9bb8 100644 --- a/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.h +++ b/source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/grpc/async_client.h" #include "envoy/local_info/local_info.h" #include "envoy/network/connection.h" @@ -69,6 +71,8 @@ class GrpcMetricsStreamerImpl : public Singleton::Instance, public GrpcMetricsSt const envoy::config::core::v3::ApiVersion transport_api_version_; }; +using GrpcMetricsStreamerImplPtr = std::unique_ptr; + /** * Stat Sink implementation of Metrics Service. */ diff --git a/source/server/config_validation/api.h b/source/server/config_validation/api.h index f5cbd292e6252..5401065887966 100644 --- a/source/server/config_validation/api.h +++ b/source/server/config_validation/api.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/api/api.h" #include "envoy/event/timer.h" #include "envoy/filesystem/filesystem.h" @@ -26,5 +28,7 @@ class ValidationImpl : public Impl { Event::TimeSystem& time_system_; }; +using ValidationImplPtr = std::unique_ptr; + } // namespace Api } // namespace Envoy diff --git a/test/common/network/dns_impl_test.cc b/test/common/network/dns_impl_test.cc index 8a683194e341d..296473cf78cd2 100644 --- a/test/common/network/dns_impl_test.cc +++ b/test/common/network/dns_impl_test.cc @@ -341,6 +341,8 @@ class DnsResolverImplPeer { DnsResolverImpl* resolver_; }; +using DnsResolverImplPeerPtr = std::unique_ptr; + class DnsImplConstructor : public testing::Test { protected: DnsImplConstructor() diff --git a/test/common/network/filter_matcher_test.cc b/test/common/network/filter_matcher_test.cc index 7e4a4c4d9f4be..70f0a497ddd78 100644 --- a/test/common/network/filter_matcher_test.cc +++ b/test/common/network/filter_matcher_test.cc @@ -1,3 +1,5 @@ +#include + #include "common/network/address_impl.h" #include "common/network/filter_matcher.h" @@ -16,6 +18,8 @@ struct CallbackHandle { std::unique_ptr socket_; Address::InstanceConstSharedPtr address_; }; + +using CallbackHandlePtr = std::unique_ptr; } // namespace class ListenerFilterMatcherTest : public testing::Test { public: diff --git a/test/integration/integration.h b/test/integration/integration.h index 3ac2bf6e43f24..7f24980d65e23 100644 --- a/test/integration/integration.h +++ b/test/integration/integration.h @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -128,6 +129,8 @@ class IntegrationTcpClient { IntegrationTcpClient& parent_; }; + using ConnectionCallbacksSharedPtr = std::shared_ptr; + Event::TestTimeSystem& time_system_; WaitForPayloadReaderSharedPtr payload_reader_; ConnectionCallbacksSharedPtr callbacks_; diff --git a/test/integration/utility.h b/test/integration/utility.h index ada44f9329e0c..9199183336a37 100644 --- a/test/integration/utility.h +++ b/test/integration/utility.h @@ -125,6 +125,8 @@ class RawConnectionDriver { Network::ClientConnectionPtr client_; }; +using RawConnectionDriverPtr = std::unique_ptr; + /** * Utility routines for integration tests. */ @@ -218,4 +220,6 @@ class WaitForPayloadReader : public Network::ReadFilterBaseImpl { bool wait_for_length_{false}; }; +using WaitForPayloadReaderSharedPtr = std::shared_ptr; + } // namespace Envoy From 5da95c98fc61af3999d15b15aba7301dcd1206f4 Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 9 Jul 2020 08:15:36 +0000 Subject: [PATCH 27/36] fix Signed-off-by: tomocy --- .../extensions/filters/http/decompressor/decompressor_filter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/extensions/filters/http/decompressor/decompressor_filter.h b/source/extensions/filters/http/decompressor/decompressor_filter.h index e7f5fe4eb8b5f..f3750bbb450de 100644 --- a/source/extensions/filters/http/decompressor/decompressor_filter.h +++ b/source/extensions/filters/http/decompressor/decompressor_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/compression/decompressor/config.h" #include "envoy/compression/decompressor/decompressor.h" #include "envoy/extensions/filters/http/decompressor/v3/decompressor.pb.h" @@ -10,7 +12,6 @@ #include "common/runtime/runtime_protos.h" #include "extensions/filters/http/common/pass_through_filter.h" -#include namespace Envoy { namespace Extensions { From d7a323c3fd739d1b5abe8a6444db5d274bd91be2 Mon Sep 17 00:00:00 2001 From: tomocy Date: Thu, 9 Jul 2020 09:02:54 +0000 Subject: [PATCH 28/36] fix Signed-off-by: tomocy --- .../filters/network/ext_authz/ext_authz_fuzz_test.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/extensions/filters/network/ext_authz/ext_authz_fuzz_test.cc b/test/extensions/filters/network/ext_authz/ext_authz_fuzz_test.cc index b70ca28272b85..8b7a526af9f4e 100644 --- a/test/extensions/filters/network/ext_authz/ext_authz_fuzz_test.cc +++ b/test/extensions/filters/network/ext_authz/ext_authz_fuzz_test.cc @@ -72,8 +72,7 @@ DEFINE_PROTO_FUZZER(const envoy::extensions::filters::network::ext_authz::ExtAut envoy::extensions::filters::network::ext_authz::v3::ExtAuthz proto_config = input.config(); ConfigSharedPtr config = std::make_shared(proto_config, stats_store); - std::unique_ptr filter = - std::make_unique(config, Filters::Common::ExtAuthz::ClientPtr{client}); + FilterPtr filter = std::make_unique(config, Filters::Common::ExtAuthz::ClientPtr{client}); NiceMock filter_callbacks; filter->initializeReadFilterCallbacks(filter_callbacks); From 934e9d34f4f55b174afa7f99aecc726228644044 Mon Sep 17 00:00:00 2001 From: tomocy Date: Fri, 10 Jul 2020 10:10:26 +0000 Subject: [PATCH 29/36] replace with type aliases Signed-off-by: tomocy --- include/envoy/router/route_config_provider_manager.h | 1 + include/envoy/router/router.h | 1 + include/envoy/server/config_tracker.h | 2 ++ include/envoy/upstream/load_balancer.h | 1 + source/common/buffer/buffer_impl.h | 2 ++ source/common/config/grpc_mux_impl.h | 1 + source/common/config/http_subscription_impl.h | 4 ++++ source/common/config/new_grpc_mux_impl.h | 1 + source/common/grpc/google_async_client_impl.h | 2 ++ source/common/http/async_client_utility.h | 4 ++++ source/common/http/conn_manager_impl.h | 2 ++ source/common/http/http1/codec_impl.h | 2 ++ source/common/network/connection_impl.h | 2 ++ source/common/network/listen_socket_impl.h | 2 ++ source/common/network/udp_listener_impl.h | 3 +++ source/common/router/config_impl.h | 2 ++ source/common/router/rds_impl.h | 2 ++ source/common/router/router_ratelimit.h | 2 ++ source/common/router/scoped_config_impl.h | 5 +++++ source/common/router/scoped_rds.h | 1 + source/common/runtime/runtime_impl.h | 2 ++ source/common/stats/isolated_store_impl.h | 3 +++ source/common/stats/stats_matcher_impl.h | 3 +++ source/common/stream_info/filter_state_impl.h | 2 ++ source/common/tcp/original_conn_pool.h | 2 ++ source/common/tcp_proxy/upstream.h | 2 ++ source/common/upstream/cluster_manager_impl.h | 2 ++ source/common/upstream/eds.h | 4 ++++ source/common/upstream/logical_dns_cluster.h | 3 +++ source/common/upstream/strict_dns_cluster.h | 4 ++++ source/common/upstream/subset_lb.h | 2 ++ source/common/upstream/upstream_impl.h | 2 ++ .../evaluators/success_criteria_evaluator.h | 3 +++ .../quic_listeners/quiche/envoy_quic_dispatcher.h | 4 ++++ source/server/guarddog_impl.h | 3 +++ source/server/hot_restart_impl.h | 3 +++ source/server/lds_api.h | 3 +++ source/server/options_impl.h | 3 +++ source/server/process_context_impl.h | 4 ++++ source/server/server.h | 2 ++ source/server/transport_socket_config_impl.h | 4 ++++ test/common/common/utility_test.cc | 3 +++ test/common/config/config_provider_impl_test.cc | 4 ++++ test/common/config/subscription_test_harness.h | 4 ++++ test/common/grpc/grpc_client_integration_test_harness.h | 6 ++++++ test/common/http/common.h | 3 +++ test/common/http/http1/conn_pool_test.cc | 2 ++ test/common/tcp/conn_pool_test.cc | 4 +++- test/common/tcp_proxy/tcp_proxy_test.cc | 2 ++ test/common/upstream/upstream_impl_test.cc | 5 ++++- test/integration/filter_manager_integration_test.cc | 3 +++ test/server/listener_manager_impl_test.h | 2 ++ test/tools/router_check/coverage.h | 4 ++++ 53 files changed, 142 insertions(+), 2 deletions(-) diff --git a/include/envoy/router/route_config_provider_manager.h b/include/envoy/router/route_config_provider_manager.h index 3e64aa396a24b..67a184f2ba8e6 100644 --- a/include/envoy/router/route_config_provider_manager.h +++ b/include/envoy/router/route_config_provider_manager.h @@ -56,6 +56,7 @@ class RouteConfigProviderManager { ProtobufMessage::ValidationVisitor& validator) PURE; }; +using RouteConfigProviderManagerPtr = std::unique_ptr; using RouteConfigProviderManagerSharedPtr = std::shared_ptr; } // namespace Router diff --git a/include/envoy/router/router.h b/include/envoy/router/router.h index 01f1759978725..d59f038c75393 100644 --- a/include/envoy/router/router.h +++ b/include/envoy/router/router.h @@ -574,6 +574,7 @@ using MetadataMatchCriterionConstSharedPtr = std::shared_ptr; +using MetadataMatchCriteriaSharedPtr = std::shared_ptr; class MetadataMatchCriteria { public: diff --git a/include/envoy/server/config_tracker.h b/include/envoy/server/config_tracker.h index d4443e9367854..76fe876ceee0c 100644 --- a/include/envoy/server/config_tracker.h +++ b/include/envoy/server/config_tracker.h @@ -56,5 +56,7 @@ class ConfigTracker { virtual EntryOwnerPtr add(const std::string& key, Cb cb) PURE; }; +using ConfigTrackerSharedPtr = std::shared_ptr; + } // namespace Server } // namespace Envoy diff --git a/include/envoy/upstream/load_balancer.h b/include/envoy/upstream/load_balancer.h index cc846cc5bed57..0144f55feefb7 100644 --- a/include/envoy/upstream/load_balancer.h +++ b/include/envoy/upstream/load_balancer.h @@ -104,6 +104,7 @@ class LoadBalancer { }; using LoadBalancerPtr = std::unique_ptr; +using LoadBalancerSharedPtr = std::shared_ptr; /** * Factory for load balancers. diff --git a/source/common/buffer/buffer_impl.h b/source/common/buffer/buffer_impl.h index 9f98260fca6fa..f1c6419aca4de 100644 --- a/source/common/buffer/buffer_impl.h +++ b/source/common/buffer/buffer_impl.h @@ -604,6 +604,8 @@ class OwnedImpl : public LibEventInstance { OverflowDetectingUInt64 length_; }; +using OwnedImplPtr = std::unique_ptr; + using BufferFragmentPtr = std::unique_ptr; /** diff --git a/source/common/config/grpc_mux_impl.h b/source/common/config/grpc_mux_impl.h index 57312228799a0..dde5fe31bd0d0 100644 --- a/source/common/config/grpc_mux_impl.h +++ b/source/common/config/grpc_mux_impl.h @@ -145,6 +145,7 @@ class GrpcMuxImpl : public GrpcMux, }; using GrpcMuxImplPtr = std::unique_ptr; +using GrpcMuxImplSharedPtr = std::shared_ptr; class NullGrpcMuxImpl : public GrpcMux, GrpcStreamCallbacks { diff --git a/source/common/config/http_subscription_impl.h b/source/common/config/http_subscription_impl.h index 9f2c01bda9f6a..b986de1590253 100644 --- a/source/common/config/http_subscription_impl.h +++ b/source/common/config/http_subscription_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/api/v2/discovery.pb.h" #include "envoy/config/subscription.h" #include "envoy/event/dispatcher.h" @@ -59,5 +61,7 @@ class HttpSubscriptionImpl : public Http::RestApiFetcher, const envoy::config::core::v3::ApiVersion transport_api_version_; }; +using HttpSubscriptionImplPtr = std::unique_ptr; + } // namespace Config } // namespace Envoy diff --git a/source/common/config/new_grpc_mux_impl.h b/source/common/config/new_grpc_mux_impl.h index 4b5d268c263e2..f30c304abf99a 100644 --- a/source/common/config/new_grpc_mux_impl.h +++ b/source/common/config/new_grpc_mux_impl.h @@ -150,6 +150,7 @@ class NewGrpcMuxImpl const envoy::config::core::v3::ApiVersion transport_api_version_; }; +using NewGrpcMuxImplPtr = std::unique_ptr; using NewGrpcMuxImplSharedPtr = std::shared_ptr; } // namespace Config diff --git a/source/common/grpc/google_async_client_impl.h b/source/common/grpc/google_async_client_impl.h index 536ca5793e660..6a576df3497af 100644 --- a/source/common/grpc/google_async_client_impl.h +++ b/source/common/grpc/google_async_client_impl.h @@ -112,6 +112,8 @@ class GoogleAsyncClientThreadLocal : public ThreadLocal::ThreadLocalObject, std::unordered_set streams_; }; +using GoogleAsyncClientThreadLocalPtr = std::unique_ptr; + // Google gRPC client stats. TODO(htuch): consider how a wider set of stats collected by the // library, such as the census related ones, can be externalized as needed. struct GoogleAsyncClientStats { diff --git a/source/common/http/async_client_utility.h b/source/common/http/async_client_utility.h index 41a98873904c1..6ce3bbb262f89 100644 --- a/source/common/http/async_client_utility.h +++ b/source/common/http/async_client_utility.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/http/async_client.h" namespace Envoy { @@ -39,5 +41,7 @@ class AsyncClientRequestTracker { absl::flat_hash_set active_requests_; }; +using AsyncClientRequestTrackerPtr = std::unique_ptr; + } // namespace Http } // namespace Envoy diff --git a/source/common/http/conn_manager_impl.h b/source/common/http/conn_manager_impl.h index 494d0d317cbe3..83abf244171b5 100644 --- a/source/common/http/conn_manager_impl.h +++ b/source/common/http/conn_manager_impl.h @@ -808,5 +808,7 @@ class ConnectionManagerImpl : Logger::Loggable, StreamInfo::FilterStateSharedPtr filter_state_; }; +using ConnectionManagerImplPtr = std::unique_ptr; + } // namespace Http } // namespace Envoy diff --git a/source/common/http/http1/codec_impl.h b/source/common/http/http1/codec_impl.h index 994873701f855..473812042aecd 100644 --- a/source/common/http/http1/codec_impl.h +++ b/source/common/http/http1/codec_impl.h @@ -598,6 +598,8 @@ class ClientConnectionImpl : public ClientConnection, public ConnectionImpl { static constexpr uint32_t MAX_RESPONSE_HEADERS_KB = 80; }; +using ClientConnectionImplPtr = std::unique_ptr; + } // namespace Http1 } // namespace Http } // namespace Envoy diff --git a/source/common/network/connection_impl.h b/source/common/network/connection_impl.h index b464e2af96d10..3f8c5f91ddaf2 100644 --- a/source/common/network/connection_impl.h +++ b/source/common/network/connection_impl.h @@ -197,6 +197,8 @@ class ConnectionImpl : public ConnectionImplBase, public TransportSocketCallback bool dispatch_buffered_data_ : 1; }; +using ConnectionImplPtr = std::unique_ptr; + /** * libevent implementation of Network::ClientConnection. */ diff --git a/source/common/network/listen_socket_impl.h b/source/common/network/listen_socket_impl.h index 0f4e3cf831fdb..8f7772a350c4d 100644 --- a/source/common/network/listen_socket_impl.h +++ b/source/common/network/listen_socket_impl.h @@ -26,6 +26,8 @@ class ListenSocketImpl : public SocketImpl { Api::SysCallIntResult bind(Network::Address::InstanceConstSharedPtr address) override; }; +using ListenSocketImplPtr = ::std::unique_ptr; + /** * Wraps a unix socket. */ diff --git a/source/common/network/udp_listener_impl.h b/source/common/network/udp_listener_impl.h index 2184b4419c105..20f3125296dd0 100644 --- a/source/common/network/udp_listener_impl.h +++ b/source/common/network/udp_listener_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/common/time.h" @@ -59,5 +60,7 @@ class UdpListenerImpl : public BaseListenerImpl, Event::FileEventPtr file_event_; }; +using UdpListenerImplPtr = std::unique_ptr; + } // namespace Network } // namespace Envoy diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index 39eeae67ebd70..22d55bf686ab5 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -998,6 +998,8 @@ class ConfigImpl : public Config { const bool most_specific_header_mutations_wins_; }; +using ConfigImplPtr = std::unique_ptr; + /** * Implementation of Config that is empty. */ diff --git a/source/common/router/rds_impl.h b/source/common/router/rds_impl.h index 5e46491db28ad..42d0986114d9f 100644 --- a/source/common/router/rds_impl.h +++ b/source/common/router/rds_impl.h @@ -260,5 +260,7 @@ class RouteConfigProviderManagerImpl : public RouteConfigProviderManager, friend class StaticRouteConfigProviderImpl; }; +using RouteConfigProviderManagerImplPtr = std::unique_ptr; + } // namespace Router } // namespace Envoy diff --git a/source/common/router/router_ratelimit.h b/source/common/router/router_ratelimit.h index 7a7ad5a402fab..4ff8d803598ed 100644 --- a/source/common/router/router_ratelimit.h +++ b/source/common/router/router_ratelimit.h @@ -171,6 +171,8 @@ class RateLimitPolicyEntryImpl : public RateLimitPolicyEntry { absl::optional limit_override_ = absl::nullopt; }; +using RateLimitPolicyEntryImplPtr = std::unique_ptr; + /** * Implementation of RateLimitPolicy that reads from the JSON route config. */ diff --git a/source/common/router/scoped_config_impl.h b/source/common/router/scoped_config_impl.h index fa7201f7e19ad..35837b99ca4d0 100644 --- a/source/common/router/scoped_config_impl.h +++ b/source/common/router/scoped_config_impl.h @@ -169,6 +169,9 @@ class ScopedRouteInfo { ScopeKey scope_key_; ConfigConstSharedPtr route_config_; }; + +using ScopedRouteInfoPtr = std::unique_ptr; +using ScopedRouteInfoSharedPtr = std::shared_ptr; using ScopedRouteInfoConstSharedPtr = std::shared_ptr; // Ordered map for consistent config dumping. using ScopedRouteMap = std::map; @@ -199,6 +202,8 @@ class ScopedConfigImpl : public ScopedConfig { absl::flat_hash_map scoped_route_info_by_key_; }; +using ScopedConfigImplPtr = std::unique_ptr; + /** * A NULL implementation of the scoped routing configuration. */ diff --git a/source/common/router/scoped_rds.h b/source/common/router/scoped_rds.h index 376e0ea9ea3bd..390f524be1921 100644 --- a/source/common/router/scoped_rds.h +++ b/source/common/router/scoped_rds.h @@ -242,6 +242,7 @@ class ScopedRoutesConfigProviderManager : public Envoy::Config::ConfigProviderMa RouteConfigProviderManager& route_config_provider_manager_; }; +using ScopedRoutesConfigProviderManagerPtr = std::unique_ptr; using ScopedRoutesConfigProviderManagerSharedPtr = std::shared_ptr; diff --git a/source/common/runtime/runtime_impl.h b/source/common/runtime/runtime_impl.h index 3508bea8ac807..6cb7490c42fe6 100644 --- a/source/common/runtime/runtime_impl.h +++ b/source/common/runtime/runtime_impl.h @@ -284,5 +284,7 @@ class LoaderImpl : public Loader, Logger::Loggable { SnapshotConstSharedPtr thread_safe_snapshot_ ABSL_GUARDED_BY(snapshot_mutex_); }; +using LoaderImplPtr = std::unique_ptr; + } // namespace Runtime } // namespace Envoy diff --git a/source/common/stats/isolated_store_impl.h b/source/common/stats/isolated_store_impl.h index f71b42b9e3269..18273c798d017 100644 --- a/source/common/stats/isolated_store_impl.h +++ b/source/common/stats/isolated_store_impl.h @@ -2,6 +2,7 @@ #include #include +#include #include #include "envoy/stats/stats.h" @@ -201,5 +202,7 @@ class IsolatedStoreImpl : public StoreImpl { RefcountPtr null_gauge_; }; +using IsolatedStoreImplPtr = std::unique_ptr; + } // namespace Stats } // namespace Envoy diff --git a/source/common/stats/stats_matcher_impl.h b/source/common/stats/stats_matcher_impl.h index a47b2a7b9f25a..dcb7f39755b4d 100644 --- a/source/common/stats/stats_matcher_impl.h +++ b/source/common/stats/stats_matcher_impl.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/config/metrics/v3/stats.pb.h" @@ -36,5 +37,7 @@ class StatsMatcherImpl : public StatsMatcher { std::vector matchers_; }; +using StatsMatcherImplPtr = std::unique_ptr; + } // namespace Stats } // namespace Envoy diff --git a/source/common/stream_info/filter_state_impl.h b/source/common/stream_info/filter_state_impl.h index e0cf02e1e562d..0a3b37b30b384 100644 --- a/source/common/stream_info/filter_state_impl.h +++ b/source/common/stream_info/filter_state_impl.h @@ -71,5 +71,7 @@ class FilterStateImpl : public FilterState { absl::flat_hash_map data_storage_; }; +using FilterStateImplPtr = std::unique_ptr; + } // namespace StreamInfo } // namespace Envoy diff --git a/source/common/tcp/original_conn_pool.h b/source/common/tcp/original_conn_pool.h index 2c0af2d50680b..31ade8d37c42c 100644 --- a/source/common/tcp/original_conn_pool.h +++ b/source/common/tcp/original_conn_pool.h @@ -164,5 +164,7 @@ class OriginalConnPoolImpl : Logger::Loggable, public Connecti bool upstream_ready_enabled_{false}; }; +using OriginalConnPoolImplPtr = std::unique_ptr; + } // namespace Tcp } // namespace Envoy diff --git a/source/common/tcp_proxy/upstream.h b/source/common/tcp_proxy/upstream.h index 8d82bda4d4100..08b3d5e130b15 100644 --- a/source/common/tcp_proxy/upstream.h +++ b/source/common/tcp_proxy/upstream.h @@ -140,5 +140,7 @@ class HttpUpstream : public GenericUpstream, Http::StreamCallbacks { bool write_half_closed_{}; }; +using HttpUpstreamPtr = std::unique_ptr; + } // namespace TcpProxy } // namespace Envoy diff --git a/source/common/upstream/cluster_manager_impl.h b/source/common/upstream/cluster_manager_impl.h index 089dba69fb092..1e6e853f375f0 100644 --- a/source/common/upstream/cluster_manager_impl.h +++ b/source/common/upstream/cluster_manager_impl.h @@ -92,6 +92,8 @@ class ProdClusterManagerFactory : public ClusterManagerFactory { Singleton::Manager& singleton_manager_; }; +using ProdClusterManagerFactoryPtr = std::unique_ptr; + // For friend declaration in ClusterManagerInitHelper. class ClusterManagerImpl; diff --git a/source/common/upstream/eds.h b/source/common/upstream/eds.h index 89da22e8cf76e..b1eab5a109725 100644 --- a/source/common/upstream/eds.h +++ b/source/common/upstream/eds.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/cluster/v3/cluster.pb.h" #include "envoy/config/core/v3/base.pb.h" #include "envoy/config/core/v3/config_source.pb.h" @@ -83,6 +85,8 @@ class EdsClusterImpl InitializePhase initialize_phase_; }; +using EdsClusterImplSharedPtr = std::shared_ptr; + class EdsClusterFactory : public ClusterFactoryImplBase { public: EdsClusterFactory() : ClusterFactoryImplBase(Extensions::Clusters::ClusterTypes::get().Eds) {} diff --git a/source/common/upstream/logical_dns_cluster.h b/source/common/upstream/logical_dns_cluster.h index c0503cd891fdb..5fb054cdcec4e 100644 --- a/source/common/upstream/logical_dns_cluster.h +++ b/source/common/upstream/logical_dns_cluster.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "envoy/config/cluster/v3/cluster.pb.h" @@ -78,6 +79,8 @@ class LogicalDnsCluster : public ClusterImplBase { const envoy::config::endpoint::v3::ClusterLoadAssignment load_assignment_; }; +using LogicalDnsClusterSharedPtr = std::shared_ptr; + class LogicalDnsClusterFactory : public ClusterFactoryImplBase { public: LogicalDnsClusterFactory() diff --git a/source/common/upstream/strict_dns_cluster.h b/source/common/upstream/strict_dns_cluster.h index 4a23e876380ac..bb955b18c1807 100644 --- a/source/common/upstream/strict_dns_cluster.h +++ b/source/common/upstream/strict_dns_cluster.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/cluster/v3/cluster.pb.h" #include "envoy/config/endpoint/v3/endpoint_components.pb.h" @@ -61,6 +63,8 @@ class StrictDnsClusterImpl : public BaseDynamicClusterImpl { uint32_t overprovisioning_factor_; }; +using StrictDnsClusterImplPtr = std::unique_ptr; + /** * Factory for StrictDnsClusterImpl */ diff --git a/source/common/upstream/subset_lb.h b/source/common/upstream/subset_lb.h index 9d90671d1f94d..b2dd99815aa19 100644 --- a/source/common/upstream/subset_lb.h +++ b/source/common/upstream/subset_lb.h @@ -261,5 +261,7 @@ class SubsetLoadBalancer : public LoadBalancer, Logger::Loggable; + } // namespace Upstream } // namespace Envoy diff --git a/source/common/upstream/upstream_impl.h b/source/common/upstream/upstream_impl.h index 721646c9c66d9..973e8855f2772 100644 --- a/source/common/upstream/upstream_impl.h +++ b/source/common/upstream/upstream_impl.h @@ -512,6 +512,8 @@ class PrioritySetImpl : public PrioritySet { }; }; +using PrioritySetImplSharedPtr = std::shared_ptr; + /** * Implementation of ClusterInfo that reads from JSON. */ diff --git a/source/extensions/filters/http/admission_control/evaluators/success_criteria_evaluator.h b/source/extensions/filters/http/admission_control/evaluators/success_criteria_evaluator.h index 511d54408f42e..ec5967e4479dc 100644 --- a/source/extensions/filters/http/admission_control/evaluators/success_criteria_evaluator.h +++ b/source/extensions/filters/http/admission_control/evaluators/success_criteria_evaluator.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/extensions/filters/http/admission_control/v3alpha/admission_control.pb.h" @@ -30,6 +31,8 @@ class SuccessCriteriaEvaluator : public ResponseEvaluator { std::vector grpc_success_codes_; }; +using SuccessCriteriaEvaluatorPtr = std::unique_ptr; + } // namespace AdmissionControl } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_dispatcher.h b/source/extensions/quic_listeners/quiche/envoy_quic_dispatcher.h index ede0c5b42625a..39b72a3a7ff36 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_dispatcher.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_dispatcher.h @@ -1,5 +1,7 @@ #pragma once +#include + #pragma GCC diagnostic push // QUICHE allows unused parameters. #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -71,5 +73,7 @@ class EnvoyQuicDispatcher : public quic::QuicDispatcher { Network::Socket& listen_socket_; }; +using EnvoyQuicDispatcherPtr = std::unique_ptr; + } // namespace Quic } // namespace Envoy diff --git a/source/server/guarddog_impl.h b/source/server/guarddog_impl.h index b570043bcbf3a..780c3ad51e368 100644 --- a/source/server/guarddog_impl.h +++ b/source/server/guarddog_impl.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "envoy/api/api.h" @@ -132,5 +133,7 @@ class GuardDogImpl : public GuardDog { bool run_thread_ ABSL_GUARDED_BY(mutex_); }; +using GuardDogImplPtr = std::unique_ptr; + } // namespace Server } // namespace Envoy diff --git a/source/server/hot_restart_impl.h b/source/server/hot_restart_impl.h index 9b91e892d104a..7dbee0a593412 100644 --- a/source/server/hot_restart_impl.h +++ b/source/server/hot_restart_impl.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "envoy/common/platform.h" @@ -131,5 +132,7 @@ class HotRestartImpl : public HotRestart { ProcessSharedMutex access_log_lock_; }; +using HotRestartImplPtr = std::unique_ptr; + } // namespace Server } // namespace Envoy diff --git a/source/server/lds_api.h b/source/server/lds_api.h index 0ace5e7b937c2..db6274d54b675 100644 --- a/source/server/lds_api.h +++ b/source/server/lds_api.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/config/core/v3/config_source.pb.h" #include "envoy/config/listener/v3/listener.pb.h" @@ -51,5 +52,7 @@ class LdsApiImpl : public LdsApi, Init::TargetImpl init_target_; }; +using LdsApiImplPtr = std::unique_ptr; + } // namespace Server } // namespace Envoy diff --git a/source/server/options_impl.h b/source/server/options_impl.h index bb8fd78eaadd7..a2ced06e6606a 100644 --- a/source/server/options_impl.h +++ b/source/server/options_impl.h @@ -2,6 +2,7 @@ #include #include +#include #include #include "envoy/common/exception.h" @@ -203,6 +204,8 @@ class OptionsImpl : public Server::Options, protected Logger::Loggable; + /** * Thrown when an OptionsImpl was not constructed because all of Envoy's work is done (for example, * it was started with --help and it's already printed a help message) so all that's left to do is diff --git a/source/server/process_context_impl.h b/source/server/process_context_impl.h index 352d40b49f5a6..83b3470bed8fd 100644 --- a/source/server/process_context_impl.h +++ b/source/server/process_context_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/server/process_context.h" namespace Envoy { @@ -14,4 +16,6 @@ class ProcessContextImpl : public ProcessContext { ProcessObject& process_object_; }; +using ProcessContextImplPtr = std::unique_ptr; + } // namespace Envoy diff --git a/source/server/server.h b/source/server/server.h index 492b66fa22c36..7f9cfb5cb2450 100644 --- a/source/server/server.h +++ b/source/server/server.h @@ -148,6 +148,8 @@ class RunHelper : Logger::Loggable { Event::SignalEventPtr sig_hup_; }; +using RunHelperPtr = std::unique_ptr; + // ServerFactoryContextImpl implements both ServerFactoryContext and // TransportSocketFactoryContext for convenience as these two contexts // share common member functions and member variables. diff --git a/source/server/transport_socket_config_impl.h b/source/server/transport_socket_config_impl.h index 6a7a8ec17613c..9529831ad3746 100644 --- a/source/server/transport_socket_config_impl.h +++ b/source/server/transport_socket_config_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/server/transport_socket_config.h" #include "envoy/stats/scope.h" @@ -68,6 +70,8 @@ class TransportSocketFactoryContextImpl : public TransportSocketFactoryContext { Api::Api& api_; }; +using TransportSocketFactoryContextImplPtr = std::unique_ptr; + } // namespace Configuration } // namespace Server } // namespace Envoy diff --git a/test/common/common/utility_test.cc b/test/common/common/utility_test.cc index d4820a3bdc286..b2c9b251135e4 100644 --- a/test/common/common/utility_test.cc +++ b/test/common/common/utility_test.cc @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -456,6 +457,8 @@ class WeightedClusterEntry { const std::string name_; const uint64_t weight_; }; + +using WeightedClusterEntryPtr = std::unique_ptr; using WeightedClusterEntrySharedPtr = std::shared_ptr; TEST(WeightedClusterUtil, pickCluster) { diff --git a/test/common/config/config_provider_impl_test.cc b/test/common/config/config_provider_impl_test.cc index 0c825f02b34d5..aaf403a022625 100644 --- a/test/common/config/config_provider_impl_test.cc +++ b/test/common/config/config_provider_impl_test.cc @@ -205,6 +205,8 @@ class DummyConfigProviderManager : public ConfigProviderManagerImplBase { } }; +using DummyConfigProviderManagerPtr = std::unique_ptr; + DummyConfigSubscription::DummyConfigSubscription( const uint64_t manager_identifier, Server::Configuration::ServerFactoryContext& factory_context, DummyConfigProviderManager& config_provider_manager) @@ -647,6 +649,8 @@ class DeltaDummyConfigProviderManager : public ConfigProviderManagerImplBase { } }; +using DeltaDummyConfigProviderManagerPtr = std::unique_ptr; + DeltaDummyConfigSubscription::DeltaDummyConfigSubscription( const uint64_t manager_identifier, Server::Configuration::ServerFactoryContext& factory_context, DeltaDummyConfigProviderManager& config_provider_manager) diff --git a/test/common/config/subscription_test_harness.h b/test/common/config/subscription_test_harness.h index 57342a11af92c..19f178333a11a 100644 --- a/test/common/config/subscription_test_harness.h +++ b/test/common/config/subscription_test_harness.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "common/config/utility.h" #include "test/mocks/stats/mocks.h" @@ -114,6 +116,8 @@ class SubscriptionTestHarness : public Event::TestUsingSimulatedTime { ControlPlaneStats control_plane_stats_; }; +using SubscriptionTestHarnessPtr = std::unique_ptr; + ACTION_P(ThrowOnRejectedConfig, accept) { if (!accept) { throw EnvoyException("bad config"); diff --git a/test/common/grpc/grpc_client_integration_test_harness.h b/test/common/grpc/grpc_client_integration_test_harness.h index 411138c229120..48c20c4172e27 100644 --- a/test/common/grpc/grpc_client_integration_test_harness.h +++ b/test/common/grpc/grpc_client_integration_test_harness.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/core/v3/base.pb.h" #include "envoy/config/core/v3/grpc_service.pb.h" #include "envoy/extensions/transport_sockets/tls/v3/cert.pb.h" @@ -199,6 +201,8 @@ class HelloworldStream : public MockAsyncStreamCallbacks const TestMetadata empty_metadata_; }; +using HelloworldStreamPtr = std::unique_ptr; + // Request related test utilities. class HelloworldRequest : public MockAsyncRequestCallbacks { public: @@ -222,6 +226,8 @@ class HelloworldRequest : public MockAsyncRequestCallbacks; + class GrpcClientIntegrationTest : public GrpcClientIntegrationParamTest { public: GrpcClientIntegrationTest() diff --git a/test/common/http/common.h b/test/common/http/common.h index 2cd5a9db335b6..5be5317ee320e 100644 --- a/test/common/http/common.h +++ b/test/common/http/common.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/http/conn_pool.h" @@ -34,6 +35,8 @@ class CodecClientForTest : public Http::CodecClient { DestroyCb destroy_cb_; }; +using CodecClientForTestPtr = std::unique_ptr; + /** * Mock callbacks used for conn pool testing. */ diff --git a/test/common/http/http1/conn_pool_test.cc b/test/common/http/http1/conn_pool_test.cc index d758887882ea2..1ee4b6f181ff0 100644 --- a/test/common/http/http1/conn_pool_test.cc +++ b/test/common/http/http1/conn_pool_test.cc @@ -129,6 +129,8 @@ class ConnPoolImplForTest : public ConnPoolImpl { std::vector test_clients_; }; +using ConnPoolImplForTestPtr = std::unique_ptr; + /** * Test fixture for all connection pool tests. */ diff --git a/test/common/tcp/conn_pool_test.cc b/test/common/tcp/conn_pool_test.cc index 17d4ea0126cdd..9d64add099b07 100644 --- a/test/common/tcp/conn_pool_test.cc +++ b/test/common/tcp/conn_pool_test.cc @@ -65,6 +65,8 @@ struct ConnPoolCallbacks : public Tcp::ConnectionPool::Callbacks { Upstream::HostDescriptionConstSharedPtr host_; }; +using ConnPoolCallbacksPtr = std::unique_ptr; + /** * A wrapper around a ConnectionPoolImpl which tracks when the bridge between * the pool and the consumer of the connection is released and destroyed. @@ -269,7 +271,7 @@ class TcpConnPoolImplDestructorTest : public testing::TestWithParam { NiceMock* upstream_ready_cb_; NiceMock* connect_timer_; NiceMock* connection_; - OriginalConnPoolImplPtr conn_pool_; + Tcp::ConnectionPool::InstancePtr conn_pool_; ConnPoolCallbacksPtr callbacks_; }; diff --git a/test/common/tcp_proxy/tcp_proxy_test.cc b/test/common/tcp_proxy/tcp_proxy_test.cc index 5c83dd20e98f0..302b91c7e842d 100644 --- a/test/common/tcp_proxy/tcp_proxy_test.cc +++ b/test/common/tcp_proxy/tcp_proxy_test.cc @@ -821,6 +821,8 @@ TEST(ConfigTest, AccessLogConfig) { EXPECT_EQ(2, config_obj.accessLogs().size()); } +using FilterPtr = std::unique_ptr; + class TcpProxyTest : public testing::Test { public: TcpProxyTest() { diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index 333616238bf82..bb01a4bdc06ee 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -76,8 +77,10 @@ std::list hostListToAddresses(const HostVector& hosts) { return addresses; } +template using HostsTConstSharedPtr = std::shared_ptr; + template -HostsTConstSharedPtr +HostsTConstSharedPtr makeHostsFromHostsPerLocality(HostsPerLocalityConstSharedPtr hosts_per_locality) { HostVector hosts; diff --git a/test/integration/filter_manager_integration_test.cc b/test/integration/filter_manager_integration_test.cc index 9bba03a4d9f66..f5ec80518e8f0 100644 --- a/test/integration/filter_manager_integration_test.cc +++ b/test/integration/filter_manager_integration_test.cc @@ -1,3 +1,4 @@ +#include #include #include "envoy/config/bootstrap/v3/bootstrap.pb.h" @@ -57,6 +58,8 @@ class Throttler { const std::function next_chunk_cb_; }; +using ThrottlerPtr = std::unique_ptr; + void Throttler::throttle(Buffer::Instance& data, bool end_stream) { buffer_.move(data); end_stream_ |= end_stream; diff --git a/test/server/listener_manager_impl_test.h b/test/server/listener_manager_impl_test.h index 9e7ed9c244391..576938a38a0f9 100644 --- a/test/server/listener_manager_impl_test.h +++ b/test/server/listener_manager_impl_test.h @@ -46,6 +46,8 @@ class ListenerHandle { Configuration::FactoryContext* context_{}; }; +using ListenerHandleSharedPtr = std::shared_ptr; + class ListenerManagerImplTest : public testing::Test { protected: ListenerManagerImplTest() : api_(Api::createApiForTest()) {} diff --git a/test/tools/router_check/coverage.h b/test/tools/router_check/coverage.h index 576fb526e3842..4139414f225f5 100644 --- a/test/tools/router_check/coverage.h +++ b/test/tools/router_check/coverage.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/route/v3/route.pb.h" #include "envoy/router/router.h" @@ -39,6 +41,8 @@ class RouteCoverage : Logger::Loggable { std::vector coverageFields(); }; +using RouteCoveragePtr = std::unique_ptr; + class Coverage : Logger::Loggable { public: Coverage(envoy::config::route::v3::RouteConfiguration config) : route_config_(config){}; From 91db93f0eed8c214d6005c41a36efa1d20709f11 Mon Sep 17 00:00:00 2001 From: tomocy Date: Sun, 12 Jul 2020 10:47:22 +0000 Subject: [PATCH 30/36] replace with type aliases Signed-off-by: tomocy --- .../extensions/access_loggers/grpc/grpc_access_log_impl.h | 3 +++ source/extensions/clusters/redis/redis_cluster.h | 2 ++ source/extensions/common/tap/admin.h | 4 ++++ source/extensions/common/tap/tap_matcher.h | 6 +++++- .../filters/common/ext_authz/ext_authz_grpc_impl.h | 3 +++ source/extensions/health_checkers/redis/redis.h | 3 +++ .../quic_listeners/quiche/envoy_quic_client_connection.h | 4 ++++ .../quic_listeners/quiche/envoy_quic_client_stream.h | 4 ++++ .../quic_listeners/quiche/envoy_quic_connection.h | 2 ++ .../quic_listeners/quiche/envoy_quic_server_stream.h | 4 ++++ .../quic_listeners/quiche/quic_io_handle_wrapper.h | 3 +++ .../resource_monitors/fixed_heap/fixed_heap_monitor.h | 2 ++ .../injected_resource/injected_resource_monitor.h | 4 ++++ source/extensions/stat_sinks/common/statsd/statsd.h | 2 ++ source/extensions/tracers/datadog/datadog_tracer_impl.h | 4 ++++ .../tracers/dynamic_ot/dynamic_opentracing_driver_impl.h | 4 ++++ source/extensions/tracers/lightstep/lightstep_tracer_impl.h | 3 +++ source/extensions/tracers/zipkin/zipkin_tracer_impl.h | 4 ++++ source/extensions/transport_sockets/alts/tsi_socket.h | 4 ++++ source/extensions/transport_sockets/tap/tap_config_impl.h | 4 ++++ .../extensions/transport_sockets/tls/context_manager_impl.h | 3 +++ source/extensions/upstreams/http/tcp/upstream_request.h | 4 ++++ .../quic_listeners/quiche/active_quic_listener_test.cc | 1 + .../quic_listeners/quiche/crypto_test_utils_for_envoy.cc | 5 +++++ .../quic_listeners/quiche/envoy_quic_server_stream_test.cc | 2 +- 25 files changed, 82 insertions(+), 2 deletions(-) diff --git a/source/extensions/access_loggers/grpc/grpc_access_log_impl.h b/source/extensions/access_loggers/grpc/grpc_access_log_impl.h index b79a7ad1b8d56..1007bc30ddf2f 100644 --- a/source/extensions/access_loggers/grpc/grpc_access_log_impl.h +++ b/source/extensions/access_loggers/grpc/grpc_access_log_impl.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -129,6 +130,8 @@ class GrpcAccessLoggerImpl : public GrpcAccessLogger { const envoy::config::core::v3::ApiVersion transport_api_version_; }; +using GrpcAccessLoggerImplPtr = std::unique_ptr; + class GrpcAccessLoggerCacheImpl : public Singleton::Instance, public GrpcAccessLoggerCache { public: GrpcAccessLoggerCacheImpl(Grpc::AsyncClientManager& async_client_manager, Stats::Scope& scope, diff --git a/source/extensions/clusters/redis/redis_cluster.h b/source/extensions/clusters/redis/redis_cluster.h index a3e4574c70324..5f549869e0ed8 100644 --- a/source/extensions/clusters/redis/redis_cluster.h +++ b/source/extensions/clusters/redis/redis_cluster.h @@ -284,6 +284,8 @@ class RedisCluster : public Upstream::BaseDynamicClusterImpl { const Common::Redis::ClusterRefreshManager::HandlePtr registration_handle_; }; +using RedisClusterSharedPtr = std::shared_ptr; + class RedisClusterFactory : public Upstream::ConfigurableClusterFactoryBase< envoy::config::cluster::redis::RedisClusterConfig> { public: diff --git a/source/extensions/common/tap/admin.h b/source/extensions/common/tap/admin.h index c876e9f7fd765..3d302b8ac0b10 100644 --- a/source/extensions/common/tap/admin.h +++ b/source/extensions/common/tap/admin.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/tap/v3/common.pb.h" #include "envoy/server/admin.h" #include "envoy/singleton/manager.h" @@ -84,6 +86,8 @@ class AdminHandler : public Singleton::Instance, absl::optional attached_request_; }; +using AdminHandlerPtr = std::unique_ptr; + } // namespace Tap } // namespace Common } // namespace Extensions diff --git a/source/extensions/common/tap/tap_matcher.h b/source/extensions/common/tap/tap_matcher.h index 79705e3fe9241..07dd391db226e 100644 --- a/source/extensions/common/tap/tap_matcher.h +++ b/source/extensions/common/tap/tap_matcher.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/tap/v3/common.pb.h" #include "common/buffer/buffer_impl.h" @@ -26,6 +28,8 @@ class MatcherCtx { virtual ~MatcherCtx() = default; }; +using MatcherCtxPtr = std::unique_ptr; + /** * Base class for all tap matchers. * @@ -54,7 +58,7 @@ class Matcher { bool matches_{false}; // Does the matcher currently match? bool might_change_status_{true}; // Is it possible for matches_ to change in subsequent updates? - std::unique_ptr ctx_{}; // Context used by matchers to save interim context. + MatcherCtxPtr ctx_{}; // Context used by matchers to save interim context. }; using MatchStatusVector = std::vector; diff --git a/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.h b/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.h index ad9799940e9fb..da1ed1d2ebf1e 100644 --- a/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.h +++ b/source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.h @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -73,6 +74,8 @@ class GrpcClientImpl : public Client, const envoy::config::core::v3::ApiVersion transport_api_version_; }; +using GrpcClientImplPtr = std::unique_ptr; + } // namespace ExtAuthz } // namespace Common } // namespace Filters diff --git a/source/extensions/health_checkers/redis/redis.h b/source/extensions/health_checkers/redis/redis.h index 4bc6b44e7db51..bcbed179e345f 100644 --- a/source/extensions/health_checkers/redis/redis.h +++ b/source/extensions/health_checkers/redis/redis.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/api/api.h" #include "envoy/config/core/v3/health_check.pb.h" @@ -128,6 +129,8 @@ class RedisHealthChecker : public Upstream::HealthCheckerImplBase { const std::string auth_password_; }; +using RedisHealthCheckerSharedPtr = std::shared_ptr; + } // namespace RedisHealthChecker } // namespace HealthCheckers } // namespace Extensions diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_client_connection.h b/source/extensions/quic_listeners/quiche/envoy_quic_client_connection.h index 48406debe5684..bd22bf757e0a6 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_client_connection.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_client_connection.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/event/dispatcher.h" #include "common/network/utility.h" @@ -58,5 +60,7 @@ class EnvoyQuicClientConnection : public EnvoyQuicConnection, public Network::Ud Event::FileEventPtr file_event_; }; +using EnvoyQuicClientConnectionPtr = std::unique_ptr; + } // namespace Quic } // namespace Envoy diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_client_stream.h b/source/extensions/quic_listeners/quiche/envoy_quic_client_stream.h index 761201c16f7cf..26c1c1b75b6a6 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_client_stream.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_client_stream.h @@ -1,5 +1,7 @@ #pragma once +#include + #pragma GCC diagnostic push // QUICHE allows unused parameters. #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -67,5 +69,7 @@ class EnvoyQuicClientStream : public quic::QuicSpdyClientStream, Http::ResponseDecoder* response_decoder_{nullptr}; }; +using EnvoyQuicClientStreamPtr = std::unique_ptr; + } // namespace Quic } // namespace Envoy diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_connection.h b/source/extensions/quic_listeners/quiche/envoy_quic_connection.h index ce189d89f34f6..e58caf4c57769 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_connection.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_connection.h @@ -68,5 +68,7 @@ class EnvoyQuicConnection : public quic::QuicConnection, Network::Connection* envoy_connection_{nullptr}; }; +using EnvoyQuicConnectionPtr = std::unique_ptr; + } // namespace Quic } // namespace Envoy diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_server_stream.h b/source/extensions/quic_listeners/quiche/envoy_quic_server_stream.h index a9393a1761ff2..7a33709b00e5b 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_server_stream.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_server_stream.h @@ -1,5 +1,7 @@ #pragma once +#include + #pragma GCC diagnostic push // QUICHE allows unused parameters. #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -68,5 +70,7 @@ class EnvoyQuicServerStream : public quic::QuicSpdyServerStreamBase, Http::RequestDecoder* request_decoder_{nullptr}; }; +using EnvoyQuicServerStreamPtr = std::unique_ptr; + } // namespace Quic } // namespace Envoy diff --git a/source/extensions/quic_listeners/quiche/quic_io_handle_wrapper.h b/source/extensions/quic_listeners/quiche/quic_io_handle_wrapper.h index f80d73afa92f6..34d5e75ab2b1d 100644 --- a/source/extensions/quic_listeners/quiche/quic_io_handle_wrapper.h +++ b/source/extensions/quic_listeners/quiche/quic_io_handle_wrapper.h @@ -1,4 +1,5 @@ #include +#include #include "envoy/network/io_handle.h" @@ -94,5 +95,7 @@ class QuicIoHandleWrapper : public Network::IoHandle { bool closed_{false}; }; +using QuicIoHandleWrapperPtr = std::unique_ptr; + } // namespace Quic } // namespace Envoy diff --git a/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h b/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h index b741edb5b913b..df85fa56b245f 100644 --- a/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h +++ b/source/extensions/resource_monitors/fixed_heap/fixed_heap_monitor.h @@ -42,6 +42,8 @@ class FixedHeapMonitor : public Server::ResourceMonitor { MemoryStatsReaderPtr stats_; }; +using FixedHeapMonitorPtr = std::unique_ptr; + } // namespace FixedHeapMonitor } // namespace ResourceMonitors } // namespace Extensions diff --git a/source/extensions/resource_monitors/injected_resource/injected_resource_monitor.h b/source/extensions/resource_monitors/injected_resource/injected_resource_monitor.h index d2609f3f383a2..a3a08ce84ae60 100644 --- a/source/extensions/resource_monitors/injected_resource/injected_resource_monitor.h +++ b/source/extensions/resource_monitors/injected_resource/injected_resource_monitor.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/api/api.h" #include "envoy/config/resource_monitor/injected_resource/v2alpha/injected_resource.pb.h" #include "envoy/filesystem/filesystem.h" @@ -39,6 +41,8 @@ class InjectedResourceMonitor : public Server::ResourceMonitor { Api::Api& api_; }; +using InjectedResourceMonitorPtr = std::unique_ptr; + } // namespace InjectedResourceMonitor } // namespace ResourceMonitors } // namespace Extensions diff --git a/source/extensions/stat_sinks/common/statsd/statsd.h b/source/extensions/stat_sinks/common/statsd/statsd.h index 65de7a935d1ca..84954c0681939 100644 --- a/source/extensions/stat_sinks/common/statsd/statsd.h +++ b/source/extensions/stat_sinks/common/statsd/statsd.h @@ -145,6 +145,8 @@ class TcpStatsdSink : public Stats::Sink { Stats::Counter& cx_overflow_stat_; }; +using TcpStatsdSinkPtr = std::unique_ptr; + } // namespace Statsd } // namespace Common } // namespace StatSinks diff --git a/source/extensions/tracers/datadog/datadog_tracer_impl.h b/source/extensions/tracers/datadog/datadog_tracer_impl.h index b3dc01d6a7cfc..2b3a372fcd498 100644 --- a/source/extensions/tracers/datadog/datadog_tracer_impl.h +++ b/source/extensions/tracers/datadog/datadog_tracer_impl.h @@ -2,6 +2,8 @@ #include +#include + #include "envoy/config/trace/v3/datadog.pb.h" #include "envoy/local_info/local_info.h" #include "envoy/runtime/runtime.h" @@ -80,6 +82,8 @@ class Driver : public Common::Ot::OpenTracingDriver { ThreadLocal::SlotPtr tls_; }; +using DriverPtr = std::unique_ptr; + /** * This class wraps the encoder provided with the tracer at initialization * and uses Http::AsyncClient to send completed traces to the Datadog Agent. diff --git a/source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h b/source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h index a872088b8e111..cead983b7ddbd 100644 --- a/source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h +++ b/source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/runtime/runtime.h" #include "envoy/thread_local/thread_local.h" #include "envoy/tracing/http_tracer.h" @@ -39,6 +41,8 @@ class DynamicOpenTracingDriver : public Common::Ot::OpenTracingDriver { std::shared_ptr tracer_; }; +using DynamicOpenTracingDriverPtr = std::unique_ptr; + } // namespace DynamicOt } // namespace Tracers } // namespace Extensions diff --git a/source/extensions/tracers/lightstep/lightstep_tracer_impl.h b/source/extensions/tracers/lightstep/lightstep_tracer_impl.h index e99d92b5346e9..26a1738d481d8 100644 --- a/source/extensions/tracers/lightstep/lightstep_tracer_impl.h +++ b/source/extensions/tracers/lightstep/lightstep_tracer_impl.h @@ -146,6 +146,9 @@ class LightStepDriver : public Common::Ot::OpenTracingDriver { Stats::StatNamePool pool_; const Grpc::Context::RequestStatNames request_stat_names_; }; + +using LightStepDriverPtr = std::unique_ptr; + } // namespace Lightstep } // namespace Tracers } // namespace Extensions diff --git a/source/extensions/tracers/zipkin/zipkin_tracer_impl.h b/source/extensions/tracers/zipkin/zipkin_tracer_impl.h index 1624ddf59cc5e..a035ad4332477 100644 --- a/source/extensions/tracers/zipkin/zipkin_tracer_impl.h +++ b/source/extensions/tracers/zipkin/zipkin_tracer_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/common/random_generator.h" #include "envoy/config/trace/v3/zipkin.pb.h" #include "envoy/local_info/local_info.h" @@ -143,6 +145,8 @@ class Driver : public Tracing::Driver { TimeSource& time_source_; }; +using DriverPtr = std::unique_ptr; + /** * Information about the Zipkin collector. */ diff --git a/source/extensions/transport_sockets/alts/tsi_socket.h b/source/extensions/transport_sockets/alts/tsi_socket.h index 0acba405022dc..3f0ee854ca8e4 100644 --- a/source/extensions/transport_sockets/alts/tsi_socket.h +++ b/source/extensions/transport_sockets/alts/tsi_socket.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/network/transport_socket.h" #include "common/buffer/buffer_impl.h" @@ -90,6 +92,8 @@ class TsiSocket : public Network::TransportSocket, bool read_error_{}; }; +using TsiSocketPtr = std::unique_ptr; + /** * An implementation of Network::TransportSocketFactory for TsiSocket */ diff --git a/source/extensions/transport_sockets/tap/tap_config_impl.h b/source/extensions/transport_sockets/tap/tap_config_impl.h index 5b4542eee17f7..91af715da1066 100644 --- a/source/extensions/transport_sockets/tap/tap_config_impl.h +++ b/source/extensions/transport_sockets/tap/tap_config_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/tap/v3/common.pb.h" #include "envoy/data/tap/v3/transport.pb.h" #include "envoy/event/timer.h" @@ -46,6 +48,8 @@ class PerSocketTapperImpl : public PerSocketTapper { uint32_t tx_bytes_buffered_{}; }; +using PerSocketTapperImplPtr = std::unique_ptr; + class SocketTapConfigImpl : public Extensions::Common::Tap::TapConfigBaseImpl, public SocketTapConfig, public std::enable_shared_from_this { diff --git a/source/extensions/transport_sockets/tls/context_manager_impl.h b/source/extensions/transport_sockets/tls/context_manager_impl.h index d08e12e974105..1011c77391850 100644 --- a/source/extensions/transport_sockets/tls/context_manager_impl.h +++ b/source/extensions/transport_sockets/tls/context_manager_impl.h @@ -2,6 +2,7 @@ #include #include +#include #include "envoy/common/time.h" #include "envoy/ssl/context_manager.h" @@ -47,6 +48,8 @@ class ContextManagerImpl final : public Envoy::Ssl::ContextManager { PrivateKeyMethodManagerImpl private_key_method_manager_{}; }; +using ContextManagerImplPtr = std::unique_ptr; + } // namespace Tls } // namespace TransportSockets } // namespace Extensions diff --git a/source/extensions/upstreams/http/tcp/upstream_request.h b/source/extensions/upstreams/http/tcp/upstream_request.h index 1c2e7a44d0338..c0f3d17eb8567 100644 --- a/source/extensions/upstreams/http/tcp/upstream_request.h +++ b/source/extensions/upstreams/http/tcp/upstream_request.h @@ -61,6 +61,8 @@ class TcpConnPool : public Router::GenericConnPool, public Envoy::Tcp::Connectio Router::GenericConnectionPoolCallbacks* callbacks_{}; }; +using TcpConnPoolPtr = std::unique_ptr; + class TcpUpstream : public Router::GenericUpstream, public Envoy::Tcp::ConnectionPool::UpstreamCallbacks { public: @@ -86,6 +88,8 @@ class TcpUpstream : public Router::GenericUpstream, Envoy::Tcp::ConnectionPool::ConnectionDataPtr upstream_conn_data_; }; +using TcpUpstreamPtr = std::unique_ptr; + } // namespace Tcp } // namespace Http } // namespace Upstreams diff --git a/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc b/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc index 60f85c2f7655e..a42867389a18d 100644 --- a/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc +++ b/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc @@ -74,6 +74,7 @@ class ActiveQuicListenerTest : public QuicMultiVersionTest { protected: using Socket = Network::NetworkListenSocket>; + using SocketPtr = std::unique_ptr; ActiveQuicListenerTest() : version_(GetParam().first), api_(Api::createApiForTest(simulated_time_system_)), diff --git a/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc b/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc index a742a89981dae..0c28b9fe8b80d 100644 --- a/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc +++ b/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc @@ -25,6 +25,11 @@ namespace quic { namespace test { namespace crypto_test_utils { + +using ProofSourcePtr = std::unique_ptr; +using ProofVerifierPtr = std::unique_ptr; +using ProofVerifyContextPtr = std::unique_ptr; + // NOLINTNEXTLINE(readability-identifier-naming) ProofSourcePtr ProofSourceForTesting() { return std::make_unique(); } diff --git a/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc b/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc index 9cfecf56bbe50..eb58648e4b3fe 100644 --- a/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc +++ b/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc @@ -61,7 +61,7 @@ class EnvoyQuicServerStreamTest : public testing::TestWithParam { quic_stream_->setRequestDecoder(stream_decoder_); quic_stream_->addCallbacks(stream_callbacks_); quic::test::QuicConnectionPeer::SetAddressValidated(&quic_connection_); - quic_session_.ActivateStream(std::unique_ptr(quic_stream_)); + quic_session_.ActivateStream(EnvoyQuicServerStreamPtr(quic_stream_)); EXPECT_CALL(quic_session_, ShouldYield(_)).WillRepeatedly(testing::Return(false)); EXPECT_CALL(quic_session_, WritevData(_, _, _, _, _, _)) .WillRepeatedly(Invoke([](quic::QuicStreamId, size_t write_length, quic::QuicStreamOffset, From 02a46bd524a6aadb2b7dedf2234bfe3a2e850f77 Mon Sep 17 00:00:00 2001 From: tomocy Date: Sun, 12 Jul 2020 11:55:53 +0000 Subject: [PATCH 31/36] fix Signed-off-by: tomocy --- source/exe/main_common.cc | 2 +- source/exe/main_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index ff31d7eb78f3d..29d936007d050 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -46,7 +46,7 @@ Runtime::LoaderPtr ProdComponentFactory::createRuntime(Server::Instance& server, MainCommonBase::MainCommonBase(const OptionsImpl& options, Event::TimeSystem& time_system, ListenerHooks& listener_hooks, Server::ComponentFactory& component_factory, - Runtime::RandomGeneratorPtr&& random_generator, + Random::RandomGeneratorPtr&& random_generator, Thread::ThreadFactory& thread_factory, Filesystem::Instance& file_system, ProcessContextPtr process_context) : options_(options), component_factory_(component_factory), thread_factory_(thread_factory), diff --git a/source/exe/main_common.h b/source/exe/main_common.h index acbddf2df6430..292aa53a8e378 100644 --- a/source/exe/main_common.h +++ b/source/exe/main_common.h @@ -40,7 +40,7 @@ class MainCommonBase { // destructed. MainCommonBase(const OptionsImpl& options, Event::TimeSystem& time_system, ListenerHooks& listener_hooks, Server::ComponentFactory& component_factory, - Runtime::RandomGeneratorPtr&& random_generator, + Random::RandomGeneratorPtr&& random_generator, Thread::ThreadFactory& thread_factory, Filesystem::Instance& file_system, ProcessContextPtr process_context); From 3c94bf2eec9163d40d005ee5669c404d21cb7373 Mon Sep 17 00:00:00 2001 From: tomocy Date: Sun, 12 Jul 2020 20:06:02 +0000 Subject: [PATCH 32/36] replace with type aliases Signed-off-by: tomocy --- .../access_loggers/grpc/grpc_access_log_impl.h | 2 ++ .../grpc/http_grpc_access_log_impl.h | 3 +++ source/extensions/clusters/aggregate/cluster.h | 4 ++++ .../clusters/redis/redis_cluster_lb.h | 5 +++++ .../common/ext_authz/ext_authz_http_impl.h | 4 ++++ source/extensions/filters/common/lua/lua.h | 2 ++ .../original_src/original_src_socket_option.h | 4 ++++ .../adaptive_concurrency_filter.h | 2 ++ .../http/admission_control/admission_control.h | 2 ++ .../filters/http/common/compressor/compressor.h | 2 ++ .../http/dynamic_forward_proxy/proxy_filter.h | 4 ++++ .../filters/http/dynamo/dynamo_filter.h | 3 +++ .../filters/http/ext_authz/ext_authz.h | 2 ++ .../filters/http/fault/fault_filter.h | 2 ++ .../http/grpc_http1_reverse_bridge/filter.h | 3 +++ .../extensions/filters/http/gzip/gzip_filter.h | 4 ++++ .../filters/http/health_check/health_check.h | 2 ++ .../filters/http/ip_tagging/ip_tagging_filter.h | 2 ++ .../extensions/filters/http/jwt_authn/filter.h | 4 ++++ source/extensions/filters/http/lua/lua_filter.h | 7 ++++++- .../filters/http/on_demand/on_demand_update.h | 4 ++++ .../filters/http/original_src/original_src.h | 4 ++++ .../filters/http/ratelimit/ratelimit.h | 2 ++ .../filters/http/squash/squash_filter.h | 3 +++ .../filters/http/tap/tap_config_impl.h | 4 ++++ source/extensions/filters/http/tap/tap_filter.h | 4 ++++ .../listener/http_inspector/http_inspector.h | 4 ++++ .../listener/tls_inspector/tls_inspector.h | 4 ++++ .../network/client_ssl_auth/client_ssl_auth.h | 2 ++ .../filters/network/common/redis/client.h | 2 ++ .../filters/network/dubbo_proxy/conn_manager.h | 2 ++ .../filters/network/dubbo_proxy/message_impl.h | 4 ++++ .../network/dubbo_proxy/router/router_impl.h | 2 ++ .../filters/network/ext_authz/ext_authz.h | 3 +++ .../filters/network/mysql_proxy/mysql_filter.h | 4 ++++ .../network/postgres_proxy/postgres_decoder.h | 3 +++ .../network/postgres_proxy/postgres_filter.h | 4 ++++ .../filters/network/ratelimit/ratelimit.h | 3 +++ .../filters/network/rbac/rbac_filter.h | 4 ++++ .../network/redis_proxy/conn_pool_impl.h | 3 +++ .../filters/network/redis_proxy/proxy_filter.h | 2 ++ .../network/rocketmq_proxy/conn_manager.h | 4 ++++ .../filters/network/rocketmq_proxy/protocol.h | 17 +++++++++++++++++ .../sni_dynamic_forward_proxy/proxy_filter.h | 4 ++++ .../filters/network/thrift_proxy/config.h | 3 +++ .../thrift_proxy/filters/ratelimit/ratelimit.h | 2 ++ .../network/thrift_proxy/router/router_impl.h | 2 ++ .../thrift_proxy/router/router_ratelimit_impl.h | 2 ++ .../filters/network/zookeeper_proxy/filter.h | 2 ++ .../filters/udp/dns_filter/dns_filter.h | 4 ++++ .../filters/udp/dns_filter/dns_parser.h | 4 ++++ .../ext_authz/ext_authz_http_impl_test.cc | 1 - .../json_transcoder_filter_test.cc | 2 ++ 53 files changed, 175 insertions(+), 2 deletions(-) diff --git a/source/extensions/access_loggers/grpc/grpc_access_log_impl.h b/source/extensions/access_loggers/grpc/grpc_access_log_impl.h index 1007bc30ddf2f..5cf04837c49b0 100644 --- a/source/extensions/access_loggers/grpc/grpc_access_log_impl.h +++ b/source/extensions/access_loggers/grpc/grpc_access_log_impl.h @@ -161,6 +161,8 @@ class GrpcAccessLoggerCacheImpl : public Singleton::Instance, public GrpcAccessL const LocalInfo::LocalInfo& local_info_; }; +using GrpcAccessLoggerCacheImplPtr = std::unique_ptr; + } // namespace GrpcCommon } // namespace AccessLoggers } // namespace Extensions diff --git a/source/extensions/access_loggers/grpc/http_grpc_access_log_impl.h b/source/extensions/access_loggers/grpc/http_grpc_access_log_impl.h index 0c1a80180fa93..0d6ec73ac0fde 100644 --- a/source/extensions/access_loggers/grpc/http_grpc_access_log_impl.h +++ b/source/extensions/access_loggers/grpc/http_grpc_access_log_impl.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -59,6 +60,8 @@ class HttpGrpcAccessLog : public Common::ImplBase { std::vector filter_states_to_log_; }; +using HttpGrpcAccessLogPtr = std::unique_ptr; + } // namespace HttpGrpc } // namespace AccessLoggers } // namespace Extensions diff --git a/source/extensions/clusters/aggregate/cluster.h b/source/extensions/clusters/aggregate/cluster.h index 417a8e8de156b..55657ca9b746d 100644 --- a/source/extensions/clusters/aggregate/cluster.h +++ b/source/extensions/clusters/aggregate/cluster.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/cluster/v3/cluster.pb.h" #include "envoy/extensions/clusters/aggregate/v3/cluster.pb.h" #include "envoy/extensions/clusters/aggregate/v3/cluster.pb.validate.h" @@ -66,6 +68,8 @@ class Cluster : public Upstream::ClusterImplBase, Upstream::ClusterUpdateCallbac linearizePrioritySet(const std::function& skip_predicate); }; +using ClusterSharedPtr = std::shared_ptr; + // Load balancer used by each worker thread. It will be refreshed when clusters, hosts or priorities // are updated. class AggregateClusterLoadBalancer : public Upstream::LoadBalancer { diff --git a/source/extensions/clusters/redis/redis_cluster_lb.h b/source/extensions/clusters/redis/redis_cluster_lb.h index 0c5142a8290a3..1ada23cfc7134 100644 --- a/source/extensions/clusters/redis/redis_cluster_lb.h +++ b/source/extensions/clusters/redis/redis_cluster_lb.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -203,6 +204,8 @@ class RedisClusterLoadBalancerFactory : public ClusterSlotUpdateCallBack, Random::RandomGenerator& random_; }; +using RedisClusterLoadBalancerFactorySharedPtr = std::shared_ptr; + class RedisClusterThreadAwareLoadBalancer : public Upstream::ThreadAwareLoadBalancer { public: RedisClusterThreadAwareLoadBalancer(Upstream::LoadBalancerFactorySharedPtr factory) @@ -216,6 +219,8 @@ class RedisClusterThreadAwareLoadBalancer : public Upstream::ThreadAwareLoadBala Upstream::LoadBalancerFactorySharedPtr factory_; }; +using RedisClusterThreadAwareLoadBalancerPtr = std::unique_ptr; + } // namespace Redis } // namespace Clusters } // namespace Extensions diff --git a/source/extensions/filters/common/ext_authz/ext_authz_http_impl.h b/source/extensions/filters/common/ext_authz/ext_authz_http_impl.h index 8f5abd684379f..b4c4321395c9d 100644 --- a/source/extensions/filters/common/ext_authz/ext_authz_http_impl.h +++ b/source/extensions/filters/common/ext_authz/ext_authz_http_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/core/v3/base.pb.h" #include "envoy/extensions/filters/http/ext_authz/v3/ext_authz.pb.h" #include "envoy/service/auth/v3/external_auth.pb.h" @@ -178,6 +180,8 @@ class RawHttpClientImpl : public Client, RequestCallbacks* callbacks_{}; }; +using RawHttpClientImplPtr = std::unique_ptr; + } // namespace ExtAuthz } // namespace Common } // namespace Filters diff --git a/source/extensions/filters/common/lua/lua.h b/source/extensions/filters/common/lua/lua.h index b9bb7caa157ea..5ada4e620d57a 100644 --- a/source/extensions/filters/common/lua/lua.h +++ b/source/extensions/filters/common/lua/lua.h @@ -417,6 +417,8 @@ class ThreadLocalState : Logger::Loggable { uint64_t current_global_slot_{}; }; +using ThreadLocalStatePtr = std::unique_ptr; + /** * An exception specific to Lua errors. */ diff --git a/source/extensions/filters/common/original_src/original_src_socket_option.h b/source/extensions/filters/common/original_src/original_src_socket_option.h index 8e86dc87d7198..b1b0b6c79c17e 100644 --- a/source/extensions/filters/common/original_src/original_src_socket_option.h +++ b/source/extensions/filters/common/original_src/original_src_socket_option.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/core/v3/base.pb.h" #include "envoy/network/address.h" #include "envoy/network/listen_socket.h" @@ -41,6 +43,8 @@ class OriginalSrcSocketOption : public Network::Socket::Option { Network::Address::InstanceConstSharedPtr src_address_; }; +using OriginalSrcSocketOptionPtr = std::unique_ptr; + } // namespace OriginalSrc } // namespace Common } // namespace Filters diff --git a/source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h b/source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h index 19223b598d688..0261fbbe2bd6c 100644 --- a/source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h +++ b/source/extensions/filters/http/adaptive_concurrency/adaptive_concurrency_filter.h @@ -69,6 +69,8 @@ class AdaptiveConcurrencyFilter : public Http::PassThroughFilter, CleanupPtr deferred_sample_task_; }; +using AdaptiveConcurrencyFilterPtr = std::unique_ptr; + } // namespace AdaptiveConcurrency } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/admission_control/admission_control.h b/source/extensions/filters/http/admission_control/admission_control.h index aad9579e707fe..d89a8e93981c5 100644 --- a/source/extensions/filters/http/admission_control/admission_control.h +++ b/source/extensions/filters/http/admission_control/admission_control.h @@ -112,6 +112,8 @@ class AdmissionControlFilter : public Http::PassThroughFilter, bool record_request_; }; +using AdmissionControlFilterSharedPtr = std::shared_ptr; + } // namespace AdmissionControl } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/common/compressor/compressor.h b/source/extensions/filters/http/common/compressor/compressor.h index 62fb93d6883f6..285fc941a1dac 100644 --- a/source/extensions/filters/http/common/compressor/compressor.h +++ b/source/extensions/filters/http/common/compressor/compressor.h @@ -158,6 +158,8 @@ class CompressorFilter : public Http::PassThroughFilter { std::unique_ptr accept_encoding_; }; +using CompressorFilterPtr = std::unique_ptr; + } // namespace Compressors } // namespace Common } // namespace HttpFilters diff --git a/source/extensions/filters/http/dynamic_forward_proxy/proxy_filter.h b/source/extensions/filters/http/dynamic_forward_proxy/proxy_filter.h index 8a786d14d75c5..4c66fa2cec9b1 100644 --- a/source/extensions/filters/http/dynamic_forward_proxy/proxy_filter.h +++ b/source/extensions/filters/http/dynamic_forward_proxy/proxy_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/extensions/filters/http/dynamic_forward_proxy/v3/dynamic_forward_proxy.pb.h" #include "envoy/upstream/cluster_manager.h" @@ -64,6 +66,8 @@ class ProxyFilter Extensions::Common::DynamicForwardProxy::DnsCache::LoadDnsCacheEntryHandlePtr cache_load_handle_; }; +using ProxyFilterPtr = std::unique_ptr; + } // namespace DynamicForwardProxy } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/dynamo/dynamo_filter.h b/source/extensions/filters/http/dynamo/dynamo_filter.h index d341c801cad61..4c1a987b96e3e 100644 --- a/source/extensions/filters/http/dynamo/dynamo_filter.h +++ b/source/extensions/filters/http/dynamo/dynamo_filter.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "envoy/http/filter.h" @@ -81,6 +82,8 @@ class DynamoFilter : public Http::StreamFilter { TimeSource& time_source_; }; +using DynamoFilterPtr = std::unique_ptr; + } // namespace Dynamo } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/ext_authz/ext_authz.h b/source/extensions/filters/http/ext_authz/ext_authz.h index 14b52ffd776ad..45674aa6ab469 100644 --- a/source/extensions/filters/http/ext_authz/ext_authz.h +++ b/source/extensions/filters/http/ext_authz/ext_authz.h @@ -257,6 +257,8 @@ class Filter : public Logger::Loggable, envoy::service::auth::v3::CheckRequest check_request_{}; }; +using FilterPtr = std::unique_ptr; + } // namespace ExtAuthz } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/fault/fault_filter.h b/source/extensions/filters/http/fault/fault_filter.h index 2f1c844b85f66..e51dd2cf31553 100644 --- a/source/extensions/filters/http/fault/fault_filter.h +++ b/source/extensions/filters/http/fault/fault_filter.h @@ -284,6 +284,8 @@ class FaultFilter : public Http::StreamFilter, Logger::Loggable; + } // namespace Fault } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/grpc_http1_reverse_bridge/filter.h b/source/extensions/filters/http/grpc_http1_reverse_bridge/filter.h index 8a518783bf5d6..12707aac9f6c4 100644 --- a/source/extensions/filters/http/grpc_http1_reverse_bridge/filter.h +++ b/source/extensions/filters/http/grpc_http1_reverse_bridge/filter.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/extensions/filters/http/grpc_http1_reverse_bridge/v3/config.pb.h" @@ -48,6 +49,8 @@ class Filter : public Envoy::Http::PassThroughFilter { Buffer::OwnedImpl buffer_{}; }; +using FilterPtr = std::unique_ptr; + class FilterConfigPerRoute : public Router::RouteSpecificFilterConfig { public: FilterConfigPerRoute( diff --git a/source/extensions/filters/http/gzip/gzip_filter.h b/source/extensions/filters/http/gzip/gzip_filter.h index be30f081a043c..610c78f58b3ec 100644 --- a/source/extensions/filters/http/gzip/gzip_filter.h +++ b/source/extensions/filters/http/gzip/gzip_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/extensions/filters/http/gzip/v3/gzip.pb.h" #include "extensions/compression/gzip/compressor/zlib_compressor_impl.h" @@ -55,6 +57,8 @@ class GzipFilterConfig : public Common::Compressors::CompressorFilterConfig { const uint32_t chunk_size_; }; +using GzipFilterConfigSharedPtr = std::shared_ptr; + } // namespace Gzip } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/health_check/health_check.h b/source/extensions/filters/http/health_check/health_check.h index d11f0d3a80a93..12dfc711fe494 100644 --- a/source/extensions/filters/http/health_check/health_check.h +++ b/source/extensions/filters/http/health_check/health_check.h @@ -110,6 +110,8 @@ class HealthCheckFilter : public Http::StreamFilter { ClusterMinHealthyPercentagesConstSharedPtr cluster_min_healthy_percentages_; }; +using HealthCheckFilterPtr = std::unique_ptr; + } // namespace HealthCheck } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h b/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h index d1bbcd5de995f..8f05f5fbf53f9 100644 --- a/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h +++ b/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h @@ -99,6 +99,8 @@ class IpTaggingFilter : public Http::StreamDecoderFilter { Http::StreamDecoderFilterCallbacks* callbacks_{}; }; +using IpTaggingFilterPtr = std::unique_ptr; + } // namespace IpTagging } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/jwt_authn/filter.h b/source/extensions/filters/http/jwt_authn/filter.h index 732eb1ca913dd..5175751706bab 100644 --- a/source/extensions/filters/http/jwt_authn/filter.h +++ b/source/extensions/filters/http/jwt_authn/filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/http/filter.h" #include "common/common/lock_guard.h" @@ -52,6 +54,8 @@ class Filter : public Http::StreamDecoderFilter, ContextSharedPtr context_; }; +using FilterPtr = std::unique_ptr; + } // namespace JwtAuthn } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/lua/lua_filter.h b/source/extensions/filters/http/lua/lua_filter.h index 24909a95d6499..c66065e38a3ac 100644 --- a/source/extensions/filters/http/lua/lua_filter.h +++ b/source/extensions/filters/http/lua/lua_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/extensions/filters/http/lua/v3/lua.pb.h" #include "envoy/http/filter.h" #include "envoy/upstream/cluster_manager.h" @@ -344,7 +346,8 @@ class FilterConfig : Logger::Loggable { absl::flat_hash_map per_lua_code_setups_map_; }; -using FilterConfigConstSharedPtr = std::shared_ptr; +using FilterConfigSharedPtr = std::shared_ptr; +using FilterConfigConstSharedPtr = std::shared_ptr; /** * Route configuration for the filter. @@ -362,6 +365,8 @@ class FilterConfigPerRoute : public Router::RouteSpecificFilterConfig { const std::string name_; }; +using FilterConfigPerRouteSharedPtr = std::shared_ptr; + namespace { PerLuaCodeSetup* getPerLuaCodeSetup(const FilterConfig* filter_config, diff --git a/source/extensions/filters/http/on_demand/on_demand_update.h b/source/extensions/filters/http/on_demand/on_demand_update.h index 455ef4160aa5a..5ff8f036f0d89 100644 --- a/source/extensions/filters/http/on_demand/on_demand_update.h +++ b/source/extensions/filters/http/on_demand/on_demand_update.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/http/filter.h" namespace Envoy { @@ -35,6 +37,8 @@ class OnDemandRouteUpdate : public Http::StreamDecoderFilter { Envoy::Http::FilterHeadersStatus filter_iteration_state_{Http::FilterHeadersStatus::Continue}; }; +using OnDemandRouteUpdatePtr = std::unique_ptr; + } // namespace OnDemand } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/original_src/original_src.h b/source/extensions/filters/http/original_src/original_src.h index 032f93ee63048..fe41540a88114 100644 --- a/source/extensions/filters/http/original_src/original_src.h +++ b/source/extensions/filters/http/original_src/original_src.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/http/filter.h" #include "envoy/network/address.h" @@ -37,6 +39,8 @@ class OriginalSrcFilter : public Http::StreamDecoderFilter, Logger::Loggable; + } // namespace OriginalSrc } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/ratelimit/ratelimit.h b/source/extensions/filters/http/ratelimit/ratelimit.h index c47e93cfde4f1..e4e4d8015f380 100644 --- a/source/extensions/filters/http/ratelimit/ratelimit.h +++ b/source/extensions/filters/http/ratelimit/ratelimit.h @@ -143,6 +143,8 @@ class Filter : public Http::StreamFilter, public Filters::Common::RateLimit::Req Http::RequestHeaderMap* request_headers_{}; }; +using FilterPtr = std::unique_ptr; + } // namespace RateLimitFilter } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/squash/squash_filter.h b/source/extensions/filters/http/squash/squash_filter.h index d654e7f220886..6288fc11b0677 100644 --- a/source/extensions/filters/http/squash/squash_filter.h +++ b/source/extensions/filters/http/squash/squash_filter.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "envoy/extensions/filters/http/squash/v3/squash.pb.h" @@ -142,6 +143,8 @@ class SquashFilter : public Http::StreamDecoderFilter, const static std::string ERROR_STATE; }; +using SquashFilterSharedPtr = std::shared_ptr; + } // namespace Squash } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/tap/tap_config_impl.h b/source/extensions/filters/http/tap/tap_config_impl.h index f61f275774c56..f2b4b0b2ff422 100644 --- a/source/extensions/filters/http/tap/tap_config_impl.h +++ b/source/extensions/filters/http/tap/tap_config_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/config/tap/v3/common.pb.h" #include "envoy/data/tap/v3/common.pb.h" #include "envoy/data/tap/v3/http.pb.h" @@ -88,6 +90,8 @@ class HttpPerRequestTapperImpl : public HttpPerRequestTapper, Logger::Loggable; + } // namespace TapFilter } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/http/tap/tap_filter.h b/source/extensions/filters/http/tap/tap_filter.h index 585d1af8b81f7..3bec37fb3fd8d 100644 --- a/source/extensions/filters/http/tap/tap_filter.h +++ b/source/extensions/filters/http/tap/tap_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/access_log/access_log.h" #include "envoy/extensions/filters/http/tap/v3/tap.pb.h" #include "envoy/http/filter.h" @@ -116,6 +118,8 @@ class Filter : public Http::StreamFilter, public AccessLog::Instance { HttpPerRequestTapperPtr tapper_; }; +using FilterPtr = std::unique_ptr; + } // namespace TapFilter } // namespace HttpFilters } // namespace Extensions diff --git a/source/extensions/filters/listener/http_inspector/http_inspector.h b/source/extensions/filters/listener/http_inspector/http_inspector.h index a73beeea11a97..e9047fd46a6a5 100644 --- a/source/extensions/filters/listener/http_inspector/http_inspector.h +++ b/source/extensions/filters/listener/http_inspector/http_inspector.h @@ -2,6 +2,8 @@ #include +#include + #include "envoy/event/file_event.h" #include "envoy/event/timer.h" #include "envoy/network/filter.h" @@ -91,6 +93,8 @@ class Filter : public Network::ListenerFilter, Logger::Loggable; + } // namespace HttpInspector } // namespace ListenerFilters } // namespace Extensions diff --git a/source/extensions/filters/listener/tls_inspector/tls_inspector.h b/source/extensions/filters/listener/tls_inspector/tls_inspector.h index be232ce7928ea..f8dd1013d4c04 100644 --- a/source/extensions/filters/listener/tls_inspector/tls_inspector.h +++ b/source/extensions/filters/listener/tls_inspector/tls_inspector.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/event/file_event.h" #include "envoy/event/timer.h" #include "envoy/network/filter.h" @@ -99,6 +101,8 @@ class Filter : public Network::ListenerFilter, Logger::Loggable; + } // namespace TlsInspector } // namespace ListenerFilters } // namespace Extensions diff --git a/source/extensions/filters/network/client_ssl_auth/client_ssl_auth.h b/source/extensions/filters/network/client_ssl_auth/client_ssl_auth.h index e5d1bf7937066..40d5506ffa5cf 100644 --- a/source/extensions/filters/network/client_ssl_auth/client_ssl_auth.h +++ b/source/extensions/filters/network/client_ssl_auth/client_ssl_auth.h @@ -127,6 +127,8 @@ class ClientSslAuthFilter : public Network::ReadFilter, public Network::Connecti Network::ReadFilterCallbacks* read_callbacks_{}; }; +using ClientSslAuthFilterPtr = std::unique_ptr; + } // namespace ClientSslAuth } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/common/redis/client.h b/source/extensions/filters/network/common/redis/client.h index f0c573f92f824..59a6afa81b067 100644 --- a/source/extensions/filters/network/common/redis/client.h +++ b/source/extensions/filters/network/common/redis/client.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/upstream/cluster_manager.h" @@ -186,6 +187,7 @@ class Config { virtual ReadPolicy readPolicy() const PURE; }; +using ConfigPtr = std::unique_ptr; using ConfigSharedPtr = std::shared_ptr; /** diff --git a/source/extensions/filters/network/dubbo_proxy/conn_manager.h b/source/extensions/filters/network/dubbo_proxy/conn_manager.h index e2689ea82e3ae..c76156331f0fc 100644 --- a/source/extensions/filters/network/dubbo_proxy/conn_manager.h +++ b/source/extensions/filters/network/dubbo_proxy/conn_manager.h @@ -106,6 +106,8 @@ class ConnectionManager : public Network::ReadFilter, Network::ReadFilterCallbacks* read_callbacks_{}; }; +using ConnectionManagerPtr = std::unique_ptr; + } // namespace DubboProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/dubbo_proxy/message_impl.h b/source/extensions/filters/network/dubbo_proxy/message_impl.h index 1fc20c5f7a11f..aeda05ca2f4b9 100644 --- a/source/extensions/filters/network/dubbo_proxy/message_impl.h +++ b/source/extensions/filters/network/dubbo_proxy/message_impl.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "extensions/filters/network/dubbo_proxy/message.h" namespace Envoy { @@ -36,6 +38,8 @@ class ContextImpl : public ContextBase { bool is_heartbeat_{false}; }; +using ContextImplSharedPtr = std::shared_ptr; + class RpcInvocationBase : public RpcInvocation { public: ~RpcInvocationBase() override = default; diff --git a/source/extensions/filters/network/dubbo_proxy/router/router_impl.h b/source/extensions/filters/network/dubbo_proxy/router/router_impl.h index bb860cb82b9a5..55a6f2abfe02d 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/router_impl.h +++ b/source/extensions/filters/network/dubbo_proxy/router/router_impl.h @@ -98,6 +98,8 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, bool filter_complete_{false}; }; +using RouterPtr = std::unique_ptr; + } // namespace Router } // namespace DubboProxy } // namespace NetworkFilters diff --git a/source/extensions/filters/network/ext_authz/ext_authz.h b/source/extensions/filters/network/ext_authz/ext_authz.h index 9fa49f0f3bb7a..64f2230ec8e37 100644 --- a/source/extensions/filters/network/ext_authz/ext_authz.h +++ b/source/extensions/filters/network/ext_authz/ext_authz.h @@ -116,6 +116,9 @@ class Filter : public Network::ReadFilter, bool calling_check_{}; envoy::service::auth::v3::CheckRequest check_request_{}; }; + +using FilterPtr = std::unique_ptr; + } // namespace ExtAuthz } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/mysql_proxy/mysql_filter.h b/source/extensions/filters/network/mysql_proxy/mysql_filter.h index f3f0502922fdf..25cab864a5442 100644 --- a/source/extensions/filters/network/mysql_proxy/mysql_filter.h +++ b/source/extensions/filters/network/mysql_proxy/mysql_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/access_log/access_log.h" #include "envoy/network/connection.h" #include "envoy/network/filter.h" @@ -105,6 +107,8 @@ class MySQLFilter : public Network::Filter, DecoderCallbacks, Logger::Loggable; + } // namespace MySQLProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/postgres_proxy/postgres_decoder.h b/source/extensions/filters/network/postgres_proxy/postgres_decoder.h index bd779a2c24ac4..936539a125204 100644 --- a/source/extensions/filters/network/postgres_proxy/postgres_decoder.h +++ b/source/extensions/filters/network/postgres_proxy/postgres_decoder.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include "envoy/common/platform.h" @@ -146,6 +147,8 @@ class DecoderImpl : public Decoder, Logger::Loggable { MsgParserDict BE_notices_; }; +using DecoderImplPtr = std::unique_ptr; + } // namespace PostgresProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/postgres_proxy/postgres_filter.h b/source/extensions/filters/network/postgres_proxy/postgres_filter.h index 6ebe4a645e934..3a63b2b9993c6 100644 --- a/source/extensions/filters/network/postgres_proxy/postgres_filter.h +++ b/source/extensions/filters/network/postgres_proxy/postgres_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/network/filter.h" #include "envoy/stats/scope.h" #include "envoy/stats/stats.h" @@ -120,6 +122,8 @@ class PostgresFilter : public Network::Filter, DecoderPtr decoder_; }; +using PostgresFilterPtr = std::unique_ptr; + } // namespace PostgresProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/ratelimit/ratelimit.h b/source/extensions/filters/network/ratelimit/ratelimit.h index 2babfd85dcd25..e29daff945036 100644 --- a/source/extensions/filters/network/ratelimit/ratelimit.h +++ b/source/extensions/filters/network/ratelimit/ratelimit.h @@ -104,6 +104,9 @@ class Filter : public Network::ReadFilter, Status status_{Status::NotStarted}; bool calling_limit_{}; }; + +using FilterPtr = std::unique_ptr; + } // namespace RateLimitFilter } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/rbac/rbac_filter.h b/source/extensions/filters/network/rbac/rbac_filter.h index 7ed2dbdc57561..1dd57ca879471 100644 --- a/source/extensions/filters/network/rbac/rbac_filter.h +++ b/source/extensions/filters/network/rbac/rbac_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/extensions/filters/network/rbac/v3/rbac.pb.h" #include "envoy/network/connection.h" #include "envoy/network/filter.h" @@ -77,6 +79,8 @@ class RoleBasedAccessControlFilter : public Network::ReadFilter, EngineResult checkEngine(Filters::Common::RBAC::EnforcementMode mode); }; +using RoleBasedAccessControlFilterPtr = std::unique_ptr; + } // namespace RBACFilter } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/redis_proxy/conn_pool_impl.h b/source/extensions/filters/network/redis_proxy/conn_pool_impl.h index ca31b413d53ef..ac3de20ebfa6f 100644 --- a/source/extensions/filters/network/redis_proxy/conn_pool_impl.h +++ b/source/extensions/filters/network/redis_proxy/conn_pool_impl.h @@ -193,6 +193,9 @@ class InstanceImpl : public Instance, public std::enable_shared_from_this; +using InstanceImplSharedPtr = std::shared_ptr; + } // namespace ConnPool } // namespace RedisProxy } // namespace NetworkFilters diff --git a/source/extensions/filters/network/redis_proxy/proxy_filter.h b/source/extensions/filters/network/redis_proxy/proxy_filter.h index 1694a2a0640e9..27211615675c4 100644 --- a/source/extensions/filters/network/redis_proxy/proxy_filter.h +++ b/source/extensions/filters/network/redis_proxy/proxy_filter.h @@ -127,6 +127,8 @@ class ProxyFilter : public Network::ReadFilter, bool connection_allowed_; }; +using ProxyFilterPtr = std::unique_ptr; + } // namespace RedisProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/rocketmq_proxy/conn_manager.h b/source/extensions/filters/network/rocketmq_proxy/conn_manager.h index e69237b6cae72..9ce075a65f6dc 100644 --- a/source/extensions/filters/network/rocketmq_proxy/conn_manager.h +++ b/source/extensions/filters/network/rocketmq_proxy/conn_manager.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/common/time.h" #include "envoy/extensions/filters/network/rocketmq_proxy/v3/rocketmq_proxy.pb.h" @@ -209,6 +210,9 @@ class ConnectionManager : public Network::ReadFilter, Logger::Loggable ack_directive_table_; }; + +using ConnectionManagerPtr = std::unique_ptr; + } // namespace RocketmqProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/rocketmq_proxy/protocol.h b/source/extensions/filters/network/rocketmq_proxy/protocol.h index fee961767e0e7..31ac8e789187e 100644 --- a/source/extensions/filters/network/rocketmq_proxy/protocol.h +++ b/source/extensions/filters/network/rocketmq_proxy/protocol.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "envoy/common/pure.h" @@ -325,6 +326,8 @@ class SendMessageRequestHeader : public RoutingCommandCustomHeader, friend class Decoder; }; +using SendMessageRequestHeaderPtr = std::unique_ptr; + /** * Custom command header to respond to a send-message-request. */ @@ -369,6 +372,8 @@ class SendMessageResponseHeader : public CommandCustomHeader { std::string transaction_id_; }; +using SendMessageResponseHeaderPtr = std::unique_ptr; + /** * Classic RocketMQ needs to known addresses of each broker to work with. To resolve the addresses, * client SDK uses this command header to query name servers. @@ -382,6 +387,8 @@ class GetRouteInfoRequestHeader : public RoutingCommandCustomHeader { void decode(const ProtobufWkt::Value& ext_fields) override; }; +using GetRouteInfoRequestHeaderPtr = std::unique_ptr; + /** * When a client wishes to consume messages stored in brokers, it sends a pop command to brokers. * Brokers would send a batch of messages to the client. At the same time, the broker keeps the @@ -456,6 +463,8 @@ class PopMessageRequestHeader : public RoutingCommandCustomHeader { bool order_{false}; }; +using PopMessageRequestHeaderPtr = std::unique_ptr; + /** * The pop response command header. See pop request header for how-things-work explanation. */ @@ -510,6 +519,8 @@ class PopMessageResponseHeader : public CommandCustomHeader { std::string order_count_info_; }; +using PopMessageResponseHeaderPtr = std::unique_ptr; + /** * This command is used by the client to acknowledge message(s) that has been successfully consumed. * Once the broker received this request, the associated message will formally marked as consumed. @@ -555,6 +566,8 @@ class AckMessageRequestHeader : public RoutingCommandCustomHeader { std::string key_; }; +using AckMessageRequestHeaderPtr = std::unique_ptr; + /** * When a client shuts down gracefully, it notifies broker(now envoy) this event. */ @@ -588,6 +601,8 @@ class UnregisterClientRequestHeader : public CommandCustomHeader { std::string consumer_group_; }; +using UnregisterClientRequestHeaderPtr = std::unique_ptr; + /** * Classic SDK clients use client-side load balancing. This header is kept for compatibility. */ @@ -607,6 +622,8 @@ class GetConsumerListByGroupRequestHeader : public CommandCustomHeader { std::string consumer_group_; }; +using GetConsumerListByGroupRequestHeaderPtr = std::unique_ptr; + /** * The response body. */ diff --git a/source/extensions/filters/network/sni_dynamic_forward_proxy/proxy_filter.h b/source/extensions/filters/network/sni_dynamic_forward_proxy/proxy_filter.h index 65cd7235b71e7..535c96446aacf 100644 --- a/source/extensions/filters/network/sni_dynamic_forward_proxy/proxy_filter.h +++ b/source/extensions/filters/network/sni_dynamic_forward_proxy/proxy_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/extensions/filters/network/sni_dynamic_forward_proxy/v3alpha/sni_dynamic_forward_proxy.pb.h" #include "envoy/network/filter.h" #include "envoy/upstream/cluster_manager.h" @@ -60,6 +62,8 @@ class ProxyFilter Network::ReadFilterCallbacks* read_callbacks_{}; }; +using ProxyFilterPtr = std::unique_ptr; + } // namespace SniDynamicForwardProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/thrift_proxy/config.h b/source/extensions/filters/network/thrift_proxy/config.h index 01be67c6a7693..76ebe934a4abb 100644 --- a/source/extensions/filters/network/thrift_proxy/config.h +++ b/source/extensions/filters/network/thrift_proxy/config.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "envoy/extensions/filters/network/thrift_proxy/v3/thrift_proxy.pb.h" @@ -95,6 +96,8 @@ class ConfigImpl : public Config, std::list filter_factories_; }; +using ConfigImplPtr = std::unique_ptr; + } // namespace ThriftProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit.h b/source/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit.h index 90a244ca78e09..f270f016dfbd5 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit.h +++ b/source/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit.h @@ -96,6 +96,8 @@ class Filter : public ThriftProxy::ThriftFilters::PassThroughDecoderFilter, bool initiating_call_{false}; }; +using FilterPtr = std::unique_ptr; + } // namespace RateLimitFilter } // namespace ThriftFilters } // namespace Extensions diff --git a/source/extensions/filters/network/thrift_proxy/router/router_impl.h b/source/extensions/filters/network/thrift_proxy/router/router_impl.h index d5c77e45f66e0..aa35fce3ce2ee 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_impl.h +++ b/source/extensions/filters/network/thrift_proxy/router/router_impl.h @@ -273,6 +273,8 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, Buffer::OwnedImpl upstream_request_buffer_; }; +using RouterPtr = std::unique_ptr; + } // namespace Router } // namespace ThriftProxy } // namespace NetworkFilters diff --git a/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.h b/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.h index 8b84668c643b0..ed034253a1d6a 100644 --- a/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.h +++ b/source/extensions/filters/network/thrift_proxy/router/router_ratelimit_impl.h @@ -130,6 +130,8 @@ class RateLimitPolicyEntryImpl : public RateLimitPolicyEntry { std::vector actions_; }; +using RateLimitPolicyEntryImplPtr = std::unique_ptr; + /** * Implementation of RateLimitPolicy that reads from the JSON route config. */ diff --git a/source/extensions/filters/network/zookeeper_proxy/filter.h b/source/extensions/filters/network/zookeeper_proxy/filter.h index 1e14336739d5a..cd98d80018c83 100644 --- a/source/extensions/filters/network/zookeeper_proxy/filter.h +++ b/source/extensions/filters/network/zookeeper_proxy/filter.h @@ -191,6 +191,8 @@ class ZooKeeperFilter : public Network::Filter, DecoderPtr decoder_; }; +using ZooKeeperFilterPtr = std::unique_ptr; + } // namespace ZooKeeperProxy } // namespace NetworkFilters } // namespace Extensions diff --git a/source/extensions/filters/udp/dns_filter/dns_filter.h b/source/extensions/filters/udp/dns_filter/dns_filter.h index 780f63a32c2a9..ab0e36f023b74 100644 --- a/source/extensions/filters/udp/dns_filter/dns_filter.h +++ b/source/extensions/filters/udp/dns_filter/dns_filter.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/event/file_event.h" #include "envoy/extensions/filters/udp/dns_filter/v3alpha/dns_filter.pb.h" #include "envoy/network/dns.h" @@ -315,6 +317,8 @@ class DnsFilter : public Network::UdpListenerReadFilter, Logger::Loggable; + } // namespace DnsFilter } // namespace UdpFilters } // namespace Extensions diff --git a/source/extensions/filters/udp/dns_filter/dns_parser.h b/source/extensions/filters/udp/dns_filter/dns_parser.h index c4f57cf5bd710..95011bc566a60 100644 --- a/source/extensions/filters/udp/dns_filter/dns_parser.h +++ b/source/extensions/filters/udp/dns_filter/dns_parser.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "envoy/buffer/buffer.h" #include "envoy/common/platform.h" #include "envoy/common/random_generator.h" @@ -273,6 +275,8 @@ class DnsMessageParser : public Logger::Loggable { Random::RandomGenerator& rng_; }; +using DnsMessageParserPtr = std::unique_ptr; + } // namespace DnsFilter } // namespace UdpFilters } // namespace Extensions diff --git a/test/extensions/filters/common/ext_authz/ext_authz_http_impl_test.cc b/test/extensions/filters/common/ext_authz/ext_authz_http_impl_test.cc index f81608f80e4e7..a63db85a4f564 100644 --- a/test/extensions/filters/common/ext_authz/ext_authz_http_impl_test.cc +++ b/test/extensions/filters/common/ext_authz/ext_authz_http_impl_test.cc @@ -132,7 +132,6 @@ class ExtAuthzHttpClientTest : public testing::Test { NiceMock async_client_; NiceMock async_request_; ClientConfigSharedPtr config_; - TimeSource& time_source_; RawHttpClientImplPtr client_; MockRequestCallbacks request_callbacks_; Tracing::MockSpan parent_span_; diff --git a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc index 5067ec96722ef..a5da562162a27 100644 --- a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc +++ b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc @@ -1,5 +1,6 @@ #include #include +#include #include "envoy/extensions/filters/http/grpc_json_transcoder/v3/transcoder.pb.h" @@ -31,6 +32,7 @@ using Envoy::Protobuf::util::MessageDifferencer; using Envoy::ProtobufUtil::error::Code; using google::api::HttpRule; using google::grpc::transcoding::Transcoder; +using TranscoderPtr = std::unique_ptr; namespace Envoy { namespace Extensions { From 4eb323d380ce15c0757007fe6c102e2ed1edf907 Mon Sep 17 00:00:00 2001 From: tomocy Date: Mon, 13 Jul 2020 09:20:50 +0000 Subject: [PATCH 33/36] fix Signed-off-by: tomocy --- source/common/filesystem/win32/watcher_impl.h | 3 ++- source/common/formatter/substitution_formatter.h | 5 +++++ test/exe/main_common_test.cc | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/common/filesystem/win32/watcher_impl.h b/source/common/filesystem/win32/watcher_impl.h index bcb283af21352..9589457717ae9 100644 --- a/source/common/filesystem/win32/watcher_impl.h +++ b/source/common/filesystem/win32/watcher_impl.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -53,7 +54,7 @@ class WatcherImpl : public Watcher, Logger::Loggable { WatcherImpl* watcher_; }; - typedef DirectoryWatchPtr DirectoryWatchPtr; + typedef std::unique_ptr DirectoryWatchPtr; Api::Api& api_; std::unordered_map callback_map_; diff --git a/source/common/formatter/substitution_formatter.h b/source/common/formatter/substitution_formatter.h index 00b4be31ac0db..192e17924f1d6 100644 --- a/source/common/formatter/substitution_formatter.h +++ b/source/common/formatter/substitution_formatter.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -101,6 +102,8 @@ class FormatterImpl : public Formatter { std::vector providers_; }; +using FormatterImplPtr = std::unique_ptr; + class JsonFormatterImpl : public Formatter { public: JsonFormatterImpl(const absl::flat_hash_map& format_mapping, @@ -124,6 +127,8 @@ class JsonFormatterImpl : public Formatter { absl::string_view local_reply_body) const; }; +using JsonFormatterImplPtr = std::unique_ptr; + /** * FormatterProvider for string literals. It ignores headers and stream info and returns string by * which it was initialized. diff --git a/test/exe/main_common_test.cc b/test/exe/main_common_test.cc index 15ea66851ca94..376e856138b22 100644 --- a/test/exe/main_common_test.cc +++ b/test/exe/main_common_test.cc @@ -130,7 +130,7 @@ TEST_P(MainCommonTest, RetryDynamicBaseIdFails) { EXPECT_THROW_WITH_MESSAGE( MainCommonBase(second_options, real_time_system, default_listener_hooks, - prod_component_factory, Runtime::RandomGeneratorPtr{mock_rng}, + prod_component_factory, Random::RandomGeneratorPtr{mock_rng}, platform.threadFactory(), platform.fileSystem(), nullptr), EnvoyException, "unable to select a dynamic base id"); #endif From a66968ab21603e969b93b4f8dec37a4692a1195e Mon Sep 17 00:00:00 2001 From: tomocy Date: Mon, 13 Jul 2020 09:27:32 +0000 Subject: [PATCH 34/36] fix not to fix typedef Signed-off-by: tomocy --- tools/code_format/check_format.py | 2 +- tools/testdata/check_format/using_type_alias.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index aa3baef938f4c..4d8df4bf9a02a 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -185,7 +185,7 @@ r"^.*\[\]$", } -USING_TYPE_ALIAS_REGEX = re.compile("using .* = .*;") +USING_TYPE_ALIAS_REGEX = re.compile("(using .* = .*;|typedef .* .*;)") SMART_PTR_REGEX = re.compile("std::(unique_ptr|shared_ptr)<(.*?)>(?!;)") OPTIONAL_REF_REGEX = re.compile("absl::optional>(?!;)") NON_TYPE_ALIAS_ALLOWED_TYPE_REGEX = re.compile(f"({'|'.join(NON_TYPE_ALIAS_ALLOWED_TYPES)})") diff --git a/tools/testdata/check_format/using_type_alias.cc b/tools/testdata/check_format/using_type_alias.cc index 34f737222e9cf..50b4a3ab4a522 100644 --- a/tools/testdata/check_format/using_type_alias.cc +++ b/tools/testdata/check_format/using_type_alias.cc @@ -5,6 +5,7 @@ namespace Network { class Connection; using ConnectionPtr = std::unique_ptr; +typedef std::unique_ptr ConnectionPtr; template using EdfSchedulerPtr = std::unique_ptr>; From 47630b3e6817767ae5e1ff504afdb97d65aa571b Mon Sep 17 00:00:00 2001 From: tomocy Date: Mon, 13 Jul 2020 14:36:24 +0000 Subject: [PATCH 35/36] fix Signed-off-by: tomocy --- .../filters/network/redis_proxy/conn_pool_impl.h | 7 ++++--- .../filters/network/redis_proxy/conn_pool_impl_test.cc | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source/extensions/filters/network/redis_proxy/conn_pool_impl.h b/source/extensions/filters/network/redis_proxy/conn_pool_impl.h index ac3de20ebfa6f..2e92ca77af8c8 100644 --- a/source/extensions/filters/network/redis_proxy/conn_pool_impl.h +++ b/source/extensions/filters/network/redis_proxy/conn_pool_impl.h @@ -53,6 +53,10 @@ class DoNothingPoolCallbacks : public PoolCallbacks { void onFailure() override{}; }; +class InstanceImpl; + +using InstanceImplSharedPtr = std::shared_ptr; + class InstanceImpl : public Instance, public std::enable_shared_from_this { public: InstanceImpl( @@ -101,8 +105,6 @@ class InstanceImpl : public Instance, public std::enable_shared_from_this; - using ThreadLocalActiveClientPtr = std::unique_ptr; struct PendingRequest : public Common::Redis::Client::ClientCallbacks, @@ -194,7 +196,6 @@ class InstanceImpl : public Instance, public std::enable_shared_from_this; -using InstanceImplSharedPtr = std::shared_ptr; } // namespace ConnPool } // namespace RedisProxy diff --git a/test/extensions/filters/network/redis_proxy/conn_pool_impl_test.cc b/test/extensions/filters/network/redis_proxy/conn_pool_impl_test.cc index b7553bd3b45e2..fb9b173fc979e 100644 --- a/test/extensions/filters/network/redis_proxy/conn_pool_impl_test.cc +++ b/test/extensions/filters/network/redis_proxy/conn_pool_impl_test.cc @@ -78,7 +78,7 @@ class RedisConnPoolImplTest : public testing::Test, public Common::Redis::Client std::make_shared>(); auto redis_command_stats = Common::Redis::RedisCommandStats::createRedisCommandStats(store->symbolTable()); - InstanceImplPtr conn_pool_impl = std::make_unique( + InstanceImplSharedPtr conn_pool_impl = std::make_shared( cluster_name_, cm_, *this, tls_, Common::Redis::Client::createConnPoolSettings(20, hashtagging, true, max_unknown_conns, read_policy_), From 5c20a6f23e08f5484932e3a7320397d028019706 Mon Sep 17 00:00:00 2001 From: tomocy Date: Tue, 14 Jul 2020 09:42:52 +0000 Subject: [PATCH 36/36] fix Signed-off-by: tomocy --- .../quiche/envoy_quic_crypto_server_stream.h | 2 +- .../quiche/envoy_quic_fake_proof_source.h | 2 ++ test/common/network/lc_trie_speed_test.cc | 6 +++--- test/common/stats/utility_fuzz_test.cc | 3 +-- .../quiche/envoy_quic_server_session_test.cc | 10 +++++----- .../fixed_heap/fixed_heap_monitor_test.cc | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_crypto_server_stream.h b/source/extensions/quic_listeners/quiche/envoy_quic_crypto_server_stream.h index faaa6254bdf89..afdf87e9ab914 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_crypto_server_stream.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_crypto_server_stream.h @@ -68,7 +68,7 @@ class EnvoyQuicCryptoServerStream : public quic::QuicCryptoServerStream, private: EnvoyProcessClientHelloResultCallback* done_cb_wrapper_{nullptr}; - std::unique_ptr details_; + EnvoyQuicProofSourceDetailsPtr details_; }; // A dedicated stream to do TLS1.3 handshake. diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h b/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h index 64d6b21bbfbf6..6352c03787d3a 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h @@ -39,6 +39,8 @@ class EnvoyQuicProofSourceDetails : public quic::ProofSource::Details { const Network::FilterChain& filter_chain_; }; +using EnvoyQuicProofSourceDetailsPtr = std::unique_ptr; + // A fake implementation of quic::ProofSource which uses RSA cipher suite to sign in GetProof(). // TODO(danzh) Rename it to EnvoyQuicProofSource once it's fully implemented. class EnvoyQuicFakeProofSource : public quic::ProofSource { diff --git a/test/common/network/lc_trie_speed_test.cc b/test/common/network/lc_trie_speed_test.cc index 836fb67fd55f0..763c44412a7cb 100644 --- a/test/common/network/lc_trie_speed_test.cc +++ b/test/common/network/lc_trie_speed_test.cc @@ -94,7 +94,7 @@ BENCHMARK(lcTrieConstructMinimal); static void lcTrieLookup(benchmark::State& state) { CidrInputs cidr_inputs; AddressInputs address_inputs; - std::unique_ptr> lc_trie = + Envoy::Network::LcTrie::LcTriePtr lc_trie = std::make_unique>(cidr_inputs.tag_data_); static size_t i = 0; @@ -112,7 +112,7 @@ BENCHMARK(lcTrieLookup); static void lcTrieLookupWithNestedPrefixes(benchmark::State& state) { CidrInputs cidr_inputs; AddressInputs address_inputs; - std::unique_ptr> lc_trie_nested_prefixes = + Envoy::Network::LcTrie::LcTriePtr lc_trie_nested_prefixes = std::make_unique>( cidr_inputs.tag_data_nested_prefixes_); @@ -131,7 +131,7 @@ BENCHMARK(lcTrieLookupWithNestedPrefixes); static void lcTrieLookupMinimal(benchmark::State& state) { CidrInputs cidr_inputs; AddressInputs address_inputs; - std::unique_ptr> lc_trie_minimal = + Envoy::Network::LcTrie::LcTriePtr lc_trie_minimal = std::make_unique>(cidr_inputs.tag_data_minimal_); static size_t i = 0; diff --git a/test/common/stats/utility_fuzz_test.cc b/test/common/stats/utility_fuzz_test.cc index 7d34966a7adaa..416e517e0ac90 100644 --- a/test/common/stats/utility_fuzz_test.cc +++ b/test/common/stats/utility_fuzz_test.cc @@ -39,8 +39,7 @@ DEFINE_FUZZER(const uint8_t* buf, size_t len) { } else { symbol_table = std::make_unique(); } - std::unique_ptr store = - std::make_unique(*symbol_table); + Stats::IsolatedStoreImplPtr store = std::make_unique(*symbol_table); Stats::StatNamePool pool(*symbol_table); Stats::ScopePtr scope = store->createScope(provider.ConsumeRandomLengthString(max_len)); Stats::ElementVec ele_vec; diff --git a/test/extensions/quic_listeners/quiche/envoy_quic_server_session_test.cc b/test/extensions/quic_listeners/quiche/envoy_quic_server_session_test.cc index 6ddae3c806242..2d3b71ebd8f6a 100644 --- a/test/extensions/quic_listeners/quiche/envoy_quic_server_session_test.cc +++ b/test/extensions/quic_listeners/quiche/envoy_quic_server_session_test.cc @@ -87,7 +87,7 @@ class ProofSourceDetailsSetter { public: virtual ~ProofSourceDetailsSetter() = default; - virtual void setProofSourceDetails(std::unique_ptr details) = 0; + virtual void setProofSourceDetails(EnvoyQuicProofSourceDetailsPtr details) = 0; }; class TestQuicCryptoServerStream : public EnvoyQuicCryptoServerStream, @@ -105,12 +105,12 @@ class TestQuicCryptoServerStream : public EnvoyQuicCryptoServerStream, const EnvoyQuicProofSourceDetails* proofSourceDetails() const override { return details_.get(); } - void setProofSourceDetails(std::unique_ptr details) override { + void setProofSourceDetails(EnvoyQuicProofSourceDetailsPtr details) override { details_ = std::move(details); } private: - std::unique_ptr details_; + EnvoyQuicProofSourceDetailsPtr details_; }; class TestEnvoyQuicTlsServerHandshaker : public EnvoyQuicTlsServerHandshaker, @@ -127,7 +127,7 @@ class TestEnvoyQuicTlsServerHandshaker : public EnvoyQuicTlsServerHandshaker, bool encryption_established() const override { return true; } const EnvoyQuicProofSourceDetails* proofSourceDetails() const override { return details_.get(); } - void setProofSourceDetails(std::unique_ptr details) override { + void setProofSourceDetails(EnvoyQuicProofSourceDetailsPtr details) override { details_ = std::move(details); } const quic::QuicCryptoNegotiatedParameters& crypto_negotiated_params() const override { @@ -135,7 +135,7 @@ class TestEnvoyQuicTlsServerHandshaker : public EnvoyQuicTlsServerHandshaker, } private: - std::unique_ptr details_; + EnvoyQuicProofSourceDetailsPtr details_; quic::QuicReferenceCountedPointer params_; }; diff --git a/test/extensions/resource_monitors/fixed_heap/fixed_heap_monitor_test.cc b/test/extensions/resource_monitors/fixed_heap/fixed_heap_monitor_test.cc index a33d12dae7898..f229c943eed47 100644 --- a/test/extensions/resource_monitors/fixed_heap/fixed_heap_monitor_test.cc +++ b/test/extensions/resource_monitors/fixed_heap/fixed_heap_monitor_test.cc @@ -61,7 +61,7 @@ TEST(FixedHeapMonitorTest, ComputeUsageWithRealMemoryStats) { const double expected_usage = (stats_reader->reservedHeapBytes() - stats_reader->unmappedHeapBytes()) / static_cast(max_heap); - std::unique_ptr monitor(new FixedHeapMonitor(config, std::move(stats_reader))); + FixedHeapMonitorPtr monitor(new FixedHeapMonitor(config, std::move(stats_reader))); ResourcePressure resource; monitor->updateResourceUsage(resource);