-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpersistent_store.h
More file actions
53 lines (43 loc) · 1.82 KB
/
persistent_store.h
File metadata and controls
53 lines (43 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <cstddef>
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
#include "communicator_protocol.h"
class PersistentStore {
public:
PersistentStore();
bool init(const std::string &rootDir, std::string &error);
bool persistOutbound(const CommEnvelopeHeader &header,
const std::vector<uint8_t> &payload,
bool relayable,
std::string &error,
const EnvelopeAuthConfig *auth = nullptr);
bool persistInbound(const CommEnvelopeHeader &header,
const std::vector<uint8_t> &payload,
bool relayable,
std::string &error,
const EnvelopeAuthConfig *auth = nullptr);
bool exportRelayBundle(const std::string &outputPath,
std::size_t maxRecords,
std::size_t *exportedCount,
std::string &error);
bool importRelayBundle(const std::string &inputPath,
std::vector<std::vector<uint8_t>> &envelopes,
std::string &error);
bool pruneIfDiskLow(std::string &error);
[[nodiscard]] const std::string &rootDir() const;
private:
std::string rootDir_;
std::string journalPath_;
std::string blobsDir_;
bool appendJournalLine(const std::string &line, std::string &error);
bool persistInternal(const CommEnvelopeHeader &header,
const std::vector<uint8_t> &payload,
bool relayable,
bool outbound,
std::string &error,
const EnvelopeAuthConfig *auth);
std::string makeBlobPath(uint64_t msgId, uint64_t tsMs, bool outbound) const;
};