From 1975e0a4b3bd471178ce0bcdecef9109fe4909ca Mon Sep 17 00:00:00 2001 From: Taruna Agrawal Date: Mon, 24 Jun 2024 11:16:27 -0700 Subject: [PATCH] Katran: Replace folly::optional with std::optional (set1) Summary: Since folly::optional is deprecated, replaced folly::optional with std::optional. Reviewed By: lima1756 Differential Revision: D58732977 fbshipit-source-id: 11fe38c3163d7104891fb9e06f664d8991579459 --- katran/lib/KatranLb.cpp | 4 ++-- katran/lib/KatranLb.h | 6 +++--- katran/lib/KatranMonitor.cpp | 2 +- katran/lib/KatranMonitor.h | 4 +--- katran/lib/MonitoringServiceCore.h | 6 +++--- katran/lib/testing/BpfTester.h | 2 +- katran/lib/testing/PacketAttributes.h | 2 +- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/katran/lib/KatranLb.cpp b/katran/lib/KatranLb.cpp index 82cfd835c..9db3cc3bc 100644 --- a/katran/lib/KatranLb.cpp +++ b/katran/lib/KatranLb.cpp @@ -825,7 +825,7 @@ void KatranLb::loadBpfProgs() { bool KatranLb::reloadBalancerProg( const std::string& path, - folly::Optional config) { + std::optional config) { int res; res = bpfAdapter_->reloadBpfProg(path); if (res) { @@ -1509,7 +1509,7 @@ std::unique_ptr KatranLb::getKatranMonitorEventBuffer( bool KatranLb::restartKatranMonitor( uint32_t limit, - folly::Optional storage) { + std::optional storage) { if (!monitor_) { return false; } diff --git a/katran/lib/KatranLb.h b/katran/lib/KatranLb.h index c19f0130e..3903ee693 100644 --- a/katran/lib/KatranLb.h +++ b/katran/lib/KatranLb.h @@ -151,7 +151,7 @@ class KatranLb { */ bool reloadBalancerProg( const std::string& path, - folly::Optional config = folly::none); + std::optional config = std::nullopt); /** * helper function to attach bpf program (e.g. to rootlet array, @@ -677,7 +677,7 @@ class KatranLb { */ bool restartKatranMonitor( uint32_t limit, - folly::Optional storage = folly::none); + std::optional storage = std::nullopt); /** * @param monitoring::EventId event monitoring event id. see @@ -1097,7 +1097,7 @@ class KatranLb { std::unordered_map vips_; - folly::Optional lruMissStatsVip_; + std::optional lruMissStatsVip_; /** * Maps an HcKey to its id diff --git a/katran/lib/KatranMonitor.cpp b/katran/lib/KatranMonitor.cpp index 7674188df..3b85c3651 100644 --- a/katran/lib/KatranMonitor.cpp +++ b/katran/lib/KatranMonitor.cpp @@ -74,7 +74,7 @@ void KatranMonitor::stopMonitor() { void KatranMonitor::restartMonitor( uint32_t limit, - folly::Optional storage) { + std::optional storage) { if (storage.has_value() && config_.storage != *storage) { stopMonitor(); config_.storage = *storage; diff --git a/katran/lib/KatranMonitor.h b/katran/lib/KatranMonitor.h index 78c7d2780..894ae0fb8 100644 --- a/katran/lib/KatranMonitor.h +++ b/katran/lib/KatranMonitor.h @@ -48,9 +48,7 @@ class KatranMonitor { void stopMonitor(); - void restartMonitor( - uint32_t limit, - folly::Optional storage); + void restartMonitor(uint32_t limit, std::optional storage); PcapWriterStats getWriterStats(); diff --git a/katran/lib/MonitoringServiceCore.h b/katran/lib/MonitoringServiceCore.h index 339d88e11..97b56b45a 100644 --- a/katran/lib/MonitoringServiceCore.h +++ b/katran/lib/MonitoringServiceCore.h @@ -78,9 +78,9 @@ class MonitoringServiceCore */ typedef struct SubscriptionResult { ResponseStatus status; - folly::Optional cid; - folly::Optional subscribed_events; - folly::Optional> sub_cb; + std::optional cid; + std::optional subscribed_events; + std::optional> sub_cb; /** * Constructor used for error and empty results diff --git a/katran/lib/testing/BpfTester.h b/katran/lib/testing/BpfTester.h index 1cadc4fba..f424ea9f0 100644 --- a/katran/lib/testing/BpfTester.h +++ b/katran/lib/testing/BpfTester.h @@ -52,7 +52,7 @@ struct TesterConfig { */ int bpfProgFd{-1}; - folly::Optional singleTestRunPacketNumber_{folly::none}; + std::optional singleTestRunPacketNumber_{std::nullopt}; }; /** diff --git a/katran/lib/testing/PacketAttributes.h b/katran/lib/testing/PacketAttributes.h index abac5842f..9466e3ec2 100644 --- a/katran/lib/testing/PacketAttributes.h +++ b/katran/lib/testing/PacketAttributes.h @@ -37,7 +37,7 @@ struct PacketAttributes { // We set this if we want to verify whether or not the packet was // routed through global lru - folly::Optional routedThroughGlobalLru{folly::none}; + std::optional routedThroughGlobalLru{std::nullopt}; }; } // namespace katran