/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
cloud/filestore/apps/client/lib/create_session.cpp
68 строк
2 KB
Andrei Strelkovskii
filestore service: logging client-id to profile log; added support for --client-id in most of the filestore-client commands (#4926)
01 янв 2026, 23:31
Не верифицирован
01 янв 2026, 23:31
a0ec4f4
Код
Авторство
О чём код?
#include "command.h" #include <cloud/filestore/public/api/protos/session.pb.h> namespace NCloud::NFileStore::NClient { namespace { //////////////////////////////////////////////////////////////////////////////// void Print(const NProto::TCreateSessionResponse& response, bool jsonOutput) { if (jsonOutput) { Cout << response.AsJSON() << Endl; } else { Cout << response.DebugString() << Endl; } } //////////////////////////////////////////////////////////////////////////////// class TCreateSessionCommand final : public TFileStoreCommand { private: TString SessionId; ui64 SeqNo = 0; public: TCreateSessionCommand() : TFileStoreCommand(true /* isClientIdRequired */) { Opts.AddLongOption("session-id") .RequiredArgument("SESSION_ID") .StoreResult(&SessionId); Opts.AddLongOption("seq-no") .RequiredArgument("SEQ_NO") .StoreResult(&SeqNo); } bool Execute() override { auto request = std::make_shared<NProto::TCreateSessionRequest>(); request->SetFileSystemId(FileSystemId); request->MutableHeaders()->SetSessionId(SessionId); request->MutableHeaders()->SetClientId(ClientId); request->MutableHeaders()->SetSessionSeqNo(SeqNo); TCallContextPtr ctx = MakeIntrusive<TCallContext>(FileSystemId); auto response = WaitFor(Client->CreateSession(ctx, std::move(request))); CheckResponse(response); Print(response, JsonOutput); return true; } }; } // namespace //////////////////////////////////////////////////////////////////////////////// TCommandPtr NewCreateSessionCommand() { return std::make_shared<TCreateSessionCommand>(); } } // namespace NCloud::NFileStore::NClient