userver: userver/dump/operations_encrypted.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
operations_encrypted.hpp
1#pragma once
2
3#include <boost/filesystem/operations.hpp>
4
5#include <userver/dump/factory.hpp>
6#include <userver/dump/operations.hpp>
7#include <userver/utils/fast_pimpl.hpp>
8#include <userver/utils/strong_typedef.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace dump {
13
14using SecretKey = utils::NonLoggable<class SecretKeyTag, std::string>;
15
16class EncryptedWriter final : public Writer {
17 public:
18 /// @brief Creates a new dump file and opens it
19 /// @throws `Error` on a filesystem error
20 EncryptedWriter(std::string filename, const SecretKey& secret_key,
21 boost::filesystem::perms, tracing::ScopeTime& scope);
22
23 ~EncryptedWriter() override;
24
25 void Finish() override;
26
27 private:
28 void WriteRaw(std::string_view data) override;
29
30 struct Impl;
31 utils::FastPimpl<Impl, 632, 8> impl_;
32};
33
34class EncryptedReader final : public Reader {
35 public:
36 /// @brief Opens an existing dump file
37 /// @throws `Error` on a filesystem error
38 EncryptedReader(std::string filename, const SecretKey& key);
39
40 ~EncryptedReader() override;
41
42 void Finish() override;
43
44 private:
45 std::string_view ReadRaw(std::size_t max_size) override;
46
47 struct Impl;
48 utils::FastPimpl<Impl, 600, 8> impl_;
49};
50
51class EncryptedOperationsFactory final : public OperationsFactory {
52 public:
53 EncryptedOperationsFactory(SecretKey&& secret_key,
54 boost::filesystem::perms perms);
55
56 std::unique_ptr<Reader> CreateReader(std::string full_path) override;
57
58 std::unique_ptr<Writer> CreateWriter(std::string full_path,
59 tracing::ScopeTime& scope) override;
60
61 private:
62 const SecretKey secret_key_;
63 const boost::filesystem::perms perms_;
64};
65
66} // namespace dump
67
68USERVER_NAMESPACE_END