summaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/client/misc/getter.h
diff options
context:
space:
mode:
authorcerevra <[email protected]>2022-02-10 16:45:58 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:45:58 +0300
commitbf41dd01f6c920583e9faae7cd55ed25e547e052 (patch)
treeec7c8c285ffa648a5c5efeff453787a15ab811ac /library/cpp/tvmauth/client/misc/getter.h
parente2c3e3004f7cd68441cefcfa4aaccd3d8051c846 (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/tvmauth/client/misc/getter.h')
-rw-r--r--library/cpp/tvmauth/client/misc/getter.h118
1 files changed, 59 insertions, 59 deletions
diff --git a/library/cpp/tvmauth/client/misc/getter.h b/library/cpp/tvmauth/client/misc/getter.h
index b0327d69e99..a2bde9de7cf 100644
--- a/library/cpp/tvmauth/client/misc/getter.h
+++ b/library/cpp/tvmauth/client/misc/getter.h
@@ -1,66 +1,66 @@
-#pragma once
-
-#include "checker.h"
-
-namespace NTvmAuth {
- class TServiceTicketGetter {
- public:
- TServiceTicketGetter(TAsyncUpdaterPtr updater)
- : Updater_(std::move(updater))
- {
- Y_ENSURE(Updater_);
- GetCache();
- }
-
- /*!
- * Fetching must enabled in TClientSettings
- * Can throw exception if cache is invalid or wrong config
- * @param dst
- */
- TString GetTicket(const TClientSettings::TAlias& dst) const {
- TServiceTicketsPtr c = GetCache();
- return GetTicketImpl(dst, c->TicketsByAlias, c->ErrorsByAlias, c->UnfetchedAliases);
- }
-
- TString GetTicket(const TTvmId dst) const {
- TServiceTicketsPtr c = GetCache();
- return GetTicketImpl(dst, c->TicketsById, c->ErrorsById, c->UnfetchedIds);
- }
-
- private:
+#pragma once
+
+#include "checker.h"
+
+namespace NTvmAuth {
+ class TServiceTicketGetter {
+ public:
+ TServiceTicketGetter(TAsyncUpdaterPtr updater)
+ : Updater_(std::move(updater))
+ {
+ Y_ENSURE(Updater_);
+ GetCache();
+ }
+
+ /*!
+ * Fetching must enabled in TClientSettings
+ * Can throw exception if cache is invalid or wrong config
+ * @param dst
+ */
+ TString GetTicket(const TClientSettings::TAlias& dst) const {
+ TServiceTicketsPtr c = GetCache();
+ return GetTicketImpl(dst, c->TicketsByAlias, c->ErrorsByAlias, c->UnfetchedAliases);
+ }
+
+ TString GetTicket(const TTvmId dst) const {
+ TServiceTicketsPtr c = GetCache();
+ return GetTicketImpl(dst, c->TicketsById, c->ErrorsById, c->UnfetchedIds);
+ }
+
+ private:
template <class Key, class Cont, class UnfetchedCont>
TString GetTicketImpl(const Key& dst, const Cont& tickets, const Cont& errors, const UnfetchedCont& unfetched) const {
- auto it = tickets.find(dst);
- if (it != tickets.end()) {
- return it->second;
- }
-
- it = errors.find(dst);
- if (it != errors.end()) {
- ythrow TMissingServiceTicket()
- << "Failed to get ticket for '" << dst << "': "
- << it->second;
- }
-
+ auto it = tickets.find(dst);
+ if (it != tickets.end()) {
+ return it->second;
+ }
+
+ it = errors.find(dst);
+ if (it != errors.end()) {
+ ythrow TMissingServiceTicket()
+ << "Failed to get ticket for '" << dst << "': "
+ << it->second;
+ }
+
if (unfetched.contains(dst)) {
ythrow TMissingServiceTicket()
<< "Failed to get ticket for '" << dst << "': this dst was not fetched yet.";
}
- ythrow TBrokenTvmClientSettings()
- << "Destination '" << dst << "' was not specified in settings. "
- << "Check your settings (if you use Qloud/YP/tvmtool - check it's settings)";
- }
-
- private:
- TServiceTicketsPtr GetCache() const {
- TServiceTicketsPtr c = Updater_->GetCachedServiceTickets();
- Y_ENSURE_EX(c, TBrokenTvmClientSettings()
- << "Need to use TClientSettings::EnableServiceTicketsFetchOptions()");
- return c;
- }
-
- private:
- TAsyncUpdaterPtr Updater_;
- };
-}
+ ythrow TBrokenTvmClientSettings()
+ << "Destination '" << dst << "' was not specified in settings. "
+ << "Check your settings (if you use Qloud/YP/tvmtool - check it's settings)";
+ }
+
+ private:
+ TServiceTicketsPtr GetCache() const {
+ TServiceTicketsPtr c = Updater_->GetCachedServiceTickets();
+ Y_ENSURE_EX(c, TBrokenTvmClientSettings()
+ << "Need to use TClientSettings::EnableServiceTicketsFetchOptions()");
+ return c;
+ }
+
+ private:
+ TAsyncUpdaterPtr Updater_;
+ };
+}