-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced PersistenceManager. Adapted FileWorker for PersistenceManager. Issue link:#1184 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
- Loading branch information
1 parent
3378cac
commit 46937c4
Showing
26 changed files
with
492 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,5 @@ wal_flush = "only_write" | |
|
||
[resource] | ||
resource_dir = "/var/infinity/resource" | ||
|
||
[persistence] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,5 @@ wal_dir = "/var/infinity/wal" | |
|
||
[resource] | ||
resource_dir = "/var/infinity/resource" | ||
|
||
[persistence] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Refers to | ||
// https://datatracker.ietf.org/doc/rfc9562/, chapter 5.7, UUID Version 7 | ||
|
||
module; | ||
|
||
export module uuid; | ||
|
||
import stl; | ||
|
||
export namespace infinity { | ||
|
||
struct UUID { | ||
union { | ||
u8 data[16]; | ||
u64 data64[2]; | ||
}; | ||
|
||
UUID() { | ||
auto now = std::chrono::system_clock::now().time_since_epoch(); | ||
u64 ms = std::chrono::duration_cast<std::chrono::milliseconds>(now).count(); | ||
u64 ns = std::chrono::duration_cast<std::chrono::nanoseconds>(now).count(); | ||
data64[0] = (ms << 16) | (ns & 0xffff); | ||
if constexpr (std::endian::native == std::endian::little) { | ||
data64[0] = __builtin_bswap64(data64[0]); | ||
} | ||
std::mt19937 rng(std::random_device{}()); | ||
std::uniform_int_distribution<u64> dist; | ||
data64[1] = dist(rng); | ||
data[6] = (data[6] & 0x0f) | 0x70; // ver, 4-bit, 0b0111 | ||
data[8] = (data[8] & 0x3f) | 0x80; // var, 2-bit, 0b10 | ||
} | ||
|
||
String to_string() const { | ||
char buf[37]; | ||
std::sprintf(buf, | ||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", | ||
data[0], | ||
data[1], | ||
data[2], | ||
data[3], | ||
data[4], | ||
data[5], | ||
data[6], | ||
data[7], | ||
data[8], | ||
data[9], | ||
data[10], | ||
data[11], | ||
data[12], | ||
data[13], | ||
data[14], | ||
data[15]); | ||
return buf; | ||
} | ||
}; | ||
|
||
} // namespace infinity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.