tigerbeetle-node 0.11.12 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/README.md +212 -196
  2. package/dist/bin/aarch64-linux-gnu/client.node +0 -0
  3. package/dist/bin/aarch64-linux-musl/client.node +0 -0
  4. package/dist/bin/aarch64-macos/client.node +0 -0
  5. package/dist/bin/x86_64-linux-gnu/client.node +0 -0
  6. package/dist/bin/x86_64-linux-musl/client.node +0 -0
  7. package/dist/bin/x86_64-macos/client.node +0 -0
  8. package/dist/index.js +33 -1
  9. package/dist/index.js.map +1 -1
  10. package/package-lock.json +66 -0
  11. package/package.json +8 -17
  12. package/src/index.ts +56 -1
  13. package/src/node.zig +10 -9
  14. package/dist/.client.node.sha256 +0 -1
  15. package/scripts/build_lib.sh +0 -61
  16. package/scripts/download_node_headers.sh +0 -32
  17. package/src/tigerbeetle/scripts/benchmark.bat +0 -48
  18. package/src/tigerbeetle/scripts/benchmark.sh +0 -66
  19. package/src/tigerbeetle/scripts/confirm_image.sh +0 -44
  20. package/src/tigerbeetle/scripts/fuzz_loop.sh +0 -15
  21. package/src/tigerbeetle/scripts/fuzz_unique_errors.sh +0 -7
  22. package/src/tigerbeetle/scripts/install.bat +0 -7
  23. package/src/tigerbeetle/scripts/install.sh +0 -21
  24. package/src/tigerbeetle/scripts/install_zig.bat +0 -113
  25. package/src/tigerbeetle/scripts/install_zig.sh +0 -90
  26. package/src/tigerbeetle/scripts/lint.zig +0 -199
  27. package/src/tigerbeetle/scripts/pre-commit.sh +0 -9
  28. package/src/tigerbeetle/scripts/scripts/benchmark.bat +0 -48
  29. package/src/tigerbeetle/scripts/scripts/benchmark.sh +0 -66
  30. package/src/tigerbeetle/scripts/scripts/confirm_image.sh +0 -44
  31. package/src/tigerbeetle/scripts/scripts/fuzz_loop.sh +0 -15
  32. package/src/tigerbeetle/scripts/scripts/fuzz_unique_errors.sh +0 -7
  33. package/src/tigerbeetle/scripts/scripts/install.bat +0 -7
  34. package/src/tigerbeetle/scripts/scripts/install.sh +0 -21
  35. package/src/tigerbeetle/scripts/scripts/install_zig.bat +0 -113
  36. package/src/tigerbeetle/scripts/scripts/install_zig.sh +0 -90
  37. package/src/tigerbeetle/scripts/scripts/lint.zig +0 -199
  38. package/src/tigerbeetle/scripts/scripts/pre-commit.sh +0 -9
  39. package/src/tigerbeetle/scripts/scripts/shellcheck.sh +0 -5
  40. package/src/tigerbeetle/scripts/scripts/tests_on_alpine.sh +0 -10
  41. package/src/tigerbeetle/scripts/scripts/tests_on_ubuntu.sh +0 -14
  42. package/src/tigerbeetle/scripts/scripts/upgrade_ubuntu_kernel.sh +0 -48
  43. package/src/tigerbeetle/scripts/scripts/validate_docs.sh +0 -23
  44. package/src/tigerbeetle/scripts/scripts/vr_state_enumerate +0 -46
  45. package/src/tigerbeetle/scripts/shellcheck.sh +0 -5
  46. package/src/tigerbeetle/scripts/tests_on_alpine.sh +0 -10
  47. package/src/tigerbeetle/scripts/tests_on_ubuntu.sh +0 -14
  48. package/src/tigerbeetle/scripts/upgrade_ubuntu_kernel.sh +0 -48
  49. package/src/tigerbeetle/scripts/validate_docs.sh +0 -23
  50. package/src/tigerbeetle/scripts/vr_state_enumerate +0 -46
  51. package/src/tigerbeetle/src/benchmark.zig +0 -314
  52. package/src/tigerbeetle/src/config.zig +0 -234
  53. package/src/tigerbeetle/src/constants.zig +0 -436
  54. package/src/tigerbeetle/src/ewah.zig +0 -286
  55. package/src/tigerbeetle/src/ewah_benchmark.zig +0 -120
  56. package/src/tigerbeetle/src/ewah_fuzz.zig +0 -130
  57. package/src/tigerbeetle/src/fifo.zig +0 -120
  58. package/src/tigerbeetle/src/io/benchmark.zig +0 -213
  59. package/src/tigerbeetle/src/io/darwin.zig +0 -814
  60. package/src/tigerbeetle/src/io/linux.zig +0 -1062
  61. package/src/tigerbeetle/src/io/test.zig +0 -643
  62. package/src/tigerbeetle/src/io/windows.zig +0 -1183
  63. package/src/tigerbeetle/src/io.zig +0 -34
  64. package/src/tigerbeetle/src/iops.zig +0 -107
  65. package/src/tigerbeetle/src/lsm/README.md +0 -308
  66. package/src/tigerbeetle/src/lsm/binary_search.zig +0 -341
  67. package/src/tigerbeetle/src/lsm/bloom_filter.zig +0 -125
  68. package/src/tigerbeetle/src/lsm/compaction.zig +0 -603
  69. package/src/tigerbeetle/src/lsm/composite_key.zig +0 -77
  70. package/src/tigerbeetle/src/lsm/direction.zig +0 -11
  71. package/src/tigerbeetle/src/lsm/eytzinger.zig +0 -587
  72. package/src/tigerbeetle/src/lsm/eytzinger_benchmark.zig +0 -330
  73. package/src/tigerbeetle/src/lsm/forest.zig +0 -204
  74. package/src/tigerbeetle/src/lsm/forest_fuzz.zig +0 -401
  75. package/src/tigerbeetle/src/lsm/grid.zig +0 -573
  76. package/src/tigerbeetle/src/lsm/groove.zig +0 -972
  77. package/src/tigerbeetle/src/lsm/k_way_merge.zig +0 -474
  78. package/src/tigerbeetle/src/lsm/level_iterator.zig +0 -332
  79. package/src/tigerbeetle/src/lsm/manifest.zig +0 -617
  80. package/src/tigerbeetle/src/lsm/manifest_level.zig +0 -877
  81. package/src/tigerbeetle/src/lsm/manifest_log.zig +0 -789
  82. package/src/tigerbeetle/src/lsm/manifest_log_fuzz.zig +0 -691
  83. package/src/tigerbeetle/src/lsm/merge_iterator.zig +0 -106
  84. package/src/tigerbeetle/src/lsm/node_pool.zig +0 -235
  85. package/src/tigerbeetle/src/lsm/posted_groove.zig +0 -378
  86. package/src/tigerbeetle/src/lsm/segmented_array.zig +0 -1328
  87. package/src/tigerbeetle/src/lsm/segmented_array_benchmark.zig +0 -148
  88. package/src/tigerbeetle/src/lsm/segmented_array_fuzz.zig +0 -9
  89. package/src/tigerbeetle/src/lsm/set_associative_cache.zig +0 -850
  90. package/src/tigerbeetle/src/lsm/table.zig +0 -1031
  91. package/src/tigerbeetle/src/lsm/table_immutable.zig +0 -203
  92. package/src/tigerbeetle/src/lsm/table_iterator.zig +0 -340
  93. package/src/tigerbeetle/src/lsm/table_mutable.zig +0 -220
  94. package/src/tigerbeetle/src/lsm/test.zig +0 -438
  95. package/src/tigerbeetle/src/lsm/tree.zig +0 -1193
  96. package/src/tigerbeetle/src/lsm/tree_fuzz.zig +0 -474
  97. package/src/tigerbeetle/src/message_bus.zig +0 -1012
  98. package/src/tigerbeetle/src/message_pool.zig +0 -156
  99. package/src/tigerbeetle/src/ring_buffer.zig +0 -399
  100. package/src/tigerbeetle/src/simulator.zig +0 -569
  101. package/src/tigerbeetle/src/state_machine/auditor.zig +0 -577
  102. package/src/tigerbeetle/src/state_machine/workload.zig +0 -883
  103. package/src/tigerbeetle/src/state_machine.zig +0 -1881
  104. package/src/tigerbeetle/src/static_allocator.zig +0 -65
  105. package/src/tigerbeetle/src/stdx.zig +0 -162
  106. package/src/tigerbeetle/src/storage.zig +0 -393
  107. package/src/tigerbeetle/src/testing/cluster/message_bus.zig +0 -82
  108. package/src/tigerbeetle/src/testing/cluster/network.zig +0 -237
  109. package/src/tigerbeetle/src/testing/cluster/state_checker.zig +0 -169
  110. package/src/tigerbeetle/src/testing/cluster/storage_checker.zig +0 -202
  111. package/src/tigerbeetle/src/testing/cluster.zig +0 -443
  112. package/src/tigerbeetle/src/testing/fuzz.zig +0 -140
  113. package/src/tigerbeetle/src/testing/hash_log.zig +0 -66
  114. package/src/tigerbeetle/src/testing/id.zig +0 -99
  115. package/src/tigerbeetle/src/testing/packet_simulator.zig +0 -364
  116. package/src/tigerbeetle/src/testing/priority_queue.zig +0 -645
  117. package/src/tigerbeetle/src/testing/reply_sequence.zig +0 -139
  118. package/src/tigerbeetle/src/testing/state_machine.zig +0 -249
  119. package/src/tigerbeetle/src/testing/storage.zig +0 -757
  120. package/src/tigerbeetle/src/testing/table.zig +0 -247
  121. package/src/tigerbeetle/src/testing/time.zig +0 -84
  122. package/src/tigerbeetle/src/tigerbeetle.zig +0 -227
  123. package/src/tigerbeetle/src/time.zig +0 -112
  124. package/src/tigerbeetle/src/tracer.zig +0 -529
  125. package/src/tigerbeetle/src/unit_tests.zig +0 -42
  126. package/src/tigerbeetle/src/vopr.zig +0 -495
  127. package/src/tigerbeetle/src/vsr/README.md +0 -209
  128. package/src/tigerbeetle/src/vsr/client.zig +0 -544
  129. package/src/tigerbeetle/src/vsr/clock.zig +0 -853
  130. package/src/tigerbeetle/src/vsr/journal.zig +0 -2413
  131. package/src/tigerbeetle/src/vsr/journal_format_fuzz.zig +0 -111
  132. package/src/tigerbeetle/src/vsr/marzullo.zig +0 -309
  133. package/src/tigerbeetle/src/vsr/replica.zig +0 -6381
  134. package/src/tigerbeetle/src/vsr/replica_format.zig +0 -219
  135. package/src/tigerbeetle/src/vsr/superblock.zig +0 -1631
  136. package/src/tigerbeetle/src/vsr/superblock_client_table.zig +0 -256
  137. package/src/tigerbeetle/src/vsr/superblock_free_set.zig +0 -929
  138. package/src/tigerbeetle/src/vsr/superblock_free_set_fuzz.zig +0 -334
  139. package/src/tigerbeetle/src/vsr/superblock_fuzz.zig +0 -390
  140. package/src/tigerbeetle/src/vsr/superblock_manifest.zig +0 -615
  141. package/src/tigerbeetle/src/vsr/superblock_quorums.zig +0 -394
  142. package/src/tigerbeetle/src/vsr/superblock_quorums_fuzz.zig +0 -314
  143. package/src/tigerbeetle/src/vsr.zig +0 -1352
@@ -1,113 +0,0 @@
1
- @echo off
2
-
3
- set ZIG_RELEASE_DEFAULT=0.9.1
4
-
5
- :: Determine the Zig build:
6
- if "%~1"=="" (
7
- set ZIG_RELEASE=%ZIG_RELEASE_DEFAULT%
8
- ) else if "%~1"=="latest" (
9
- set ZIG_RELEASE=builds
10
- ) else (
11
- set ZIG_RELEASE=%~1
12
- )
13
-
14
- :: Checks format of release version.
15
- echo.%ZIG_RELEASE% | findstr /b /r /c:"builds" /c:"^[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*">nul || (echo.Unexpected release format. && exit 1)
16
-
17
- set ZIG_OS=windows
18
- set ZIG_ARCH=x86_64
19
-
20
- set ZIG_TARGET=zig-%ZIG_OS%-%ZIG_ARCH%
21
-
22
- :: Determine the build, split the JSON line on whitespace and extract the 2nd field:
23
- for /f "tokens=2" %%a in ('curl --silent https://ziglang.org/download/index.json ^| findstr %ZIG_TARGET% ^| findstr %ZIG_RELEASE%' ) do (
24
- set ZIG_URL=%%a
25
- )
26
-
27
- :: Then remove quotes and commas:
28
- for /f %%b in ("%ZIG_URL:,=%") do (
29
- set ZIG_URL=%%~b
30
- )
31
-
32
- :: Checks the ZIG_URL variable follows the expected format.
33
- echo.%ZIG_URL% | findstr /b /r /c:"https://ziglang.org/builds/" /c:"https://ziglang.org/download/%ZIG_RELEASE%">nul || (echo.Unexpected release URL format. && exit 1)
34
-
35
- if "%ZIG_RELEASE%"=="builds" (
36
- echo Installing Zig latest build...
37
- ) else (
38
- echo Installing Zig %ZIG_RELEASE% release build...
39
- )
40
-
41
- :: Using variable modifiers to determine the directory and filename from the URL:
42
- :: %%~ni Expands %%i to a file name only and %%~xi Expands %%i to a file name extension only.
43
- for /f %%i in ("%ZIG_URL%") do (
44
- set ZIG_DIRECTORY=%%~ni
45
- set ZIG_TARBALL=%%~nxi
46
- )
47
-
48
- :: Checks the ZIG_DIRECTORY variable follows the expected format.
49
- echo.%ZIG_DIRECTORY% | findstr /b /r /c:"zig-win64-" /c:"zig-windows-x86_64-">nul || (echo.Unexpected zip directory name format. && exit 1)
50
-
51
- :: Making sure we download to the same output document, without wget adding "-1" etc. if the file was previously partially downloaded:
52
- if exist %ZIG_TARBALL% (
53
- del /q %ZIG_TARBALL%
54
- if exist %ZIG_TARBALL% (
55
- echo Failed to delete %ZIG_TARBALL%.
56
- exit 1
57
- )
58
- )
59
-
60
- echo Downloading %ZIG_URL%...
61
- curl --silent --progress-bar --output %ZIG_TARBALL% %ZIG_URL%
62
- if not exist %ZIG_TARBALL% (
63
- echo Failed to download Zig zip file.
64
- exit 1
65
- )
66
-
67
- :: Replace any existing Zig installation so that we can install or upgrade:
68
- echo Removing any existing 'zig' and %ZIG_DIRECTORY% folders before extracting.
69
- if exist zig\ (
70
- rd /s /q zig\
71
- :: Ensure the directory has been deleted.
72
- if exist zig\ (
73
- echo The ‘zig’ directory could not be deleted.
74
- exit 1
75
- )
76
- )
77
-
78
- if exist %ZIG_DIRECTORY%\ (
79
- rd /s /q %ZIG_DIRECTORY%
80
- :: Ensure the directory has been deleted.
81
- if exist %ZIG_DIRECTORY% (
82
- echo The %ZIG_DIRECTORY% directory could not be deleted.
83
- exit 1
84
- )
85
- )
86
-
87
- :: Extract and then remove the downloaded tarball:
88
- echo Extracting %ZIG_TARBALL%...
89
-
90
- :: Hiding Powershell's progress bar during the extraction
91
- SET PS_DISABLE_PROGRESS="$ProgressPreference=[System.Management.Automation.ActionPreference]::SilentlyContinue"
92
- powershell -Command "%PS_DISABLE_PROGRESS%;Expand-Archive %ZIG_TARBALL% -DestinationPath ."
93
-
94
- if not exist %ZIG_TARBALL% (
95
- echo Failed to extract zip file.
96
- exit 1
97
- )
98
-
99
- echo Installing %ZIG_DIRECTORY% to 'zig' in current working directory...
100
- ren %ZIG_DIRECTORY% zig
101
- if exist %ZIG_DIRECTORY% (
102
- echo Failed to rename %ZIG_DIRECTORY% to zig.
103
- exit 1
104
- )
105
-
106
- :: Removes the zip file
107
- del /q %ZIG_TARBALL%
108
- if exist %ZIG_TARBALL% (
109
- echo Failed to delete %ZIG_TARBALL% file.
110
- exit 1
111
- )
112
-
113
- echo "Congratulations, you have successfully installed Zig version %ZIG_RELEASE%. Enjoy!"
@@ -1,90 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -eu
3
-
4
- ZIG_RELEASE_DEFAULT="0.9.1"
5
- # Default to the release build, or allow the latest dev build, or an explicit release version:
6
- ZIG_RELEASE=${1:-$ZIG_RELEASE_DEFAULT}
7
- if [ "$ZIG_RELEASE" = "latest" ]; then
8
- ZIG_RELEASE="builds"
9
- fi
10
-
11
- # Validate the release version explicitly:
12
- if echo "$ZIG_RELEASE" | grep -q '^builds$'; then
13
- echo "Installing Zig latest build..."
14
- elif echo "$ZIG_RELEASE" | grep -q '^[0-9]\+.[0-9]\+.[0-9]\+$'; then
15
- echo "Installing Zig $ZIG_RELEASE release build..."
16
- else
17
- echo "Release version invalid"
18
- exit 1
19
- fi
20
-
21
- # Determine the architecture:
22
- if [ "$(uname -m)" = 'arm64' ] || [ "$(uname -m)" = 'aarch64' ]; then
23
- ZIG_ARCH="aarch64"
24
- else
25
- ZIG_ARCH="x86_64"
26
- fi
27
-
28
- # Determine the operating system:
29
- if [ "$(uname)" = "Linux" ]; then
30
- ZIG_OS="linux"
31
- else
32
- ZIG_OS="macos"
33
- fi
34
-
35
- ZIG_TARGET="zig-$ZIG_OS-$ZIG_ARCH"
36
-
37
- # Determine the build, split the JSON line on whitespace and extract the 2nd field, then remove quotes and commas:
38
- if command -v wget; then
39
- # -4 forces `wget` to connect to ipv4 addresses, as ipv6 fails to resolve on certain distros.
40
- # Only A records (for ipv4) are used in DNS:
41
- ipv4="-4"
42
- # But Alpine doesn't support this argument
43
- if [ -f /etc/alpine-release ]; then
44
- ipv4=""
45
- fi
46
- ZIG_URL=$(wget $ipv4 --quiet -O - https://ziglang.org/download/index.json | grep -F "$ZIG_TARGET" | grep -F "$ZIG_RELEASE" | awk '{print $2}' | sed 's/[",]//g')
47
- else
48
- ZIG_URL=$(curl --silent https://ziglang.org/download/index.json | grep -F "$ZIG_TARGET" | grep -F "$ZIG_RELEASE" | awk '{print $2}' | sed 's/[",]//g')
49
- fi
50
-
51
- # Ensure that the release is actually hosted on the ziglang.org website:
52
- if [ -z "$ZIG_URL" ]; then
53
- echo "Release not found on ziglang.org"
54
- exit 1
55
- fi
56
-
57
- # Work out the filename from the URL, as well as the directory without the ".tar.xz" file extension:
58
- ZIG_TARBALL=$(basename "$ZIG_URL")
59
- ZIG_DIRECTORY=$(basename "$ZIG_TARBALL" .tar.xz)
60
-
61
- # Download, making sure we download to the same output document, without wget adding "-1" etc. if the file was previously partially downloaded:
62
- echo "Downloading $ZIG_URL..."
63
- if command -v wget; then
64
- # -4 forces `wget` to connect to ipv4 addresses, as ipv6 fails to resolve on certain distros.
65
- # Only A records (for ipv4) are used in DNS:
66
- ipv4="-4"
67
- # But Alpine doesn't support this argument
68
- if [ -f /etc/alpine-release ]; then
69
- ipv4=""
70
- fi
71
- wget $ipv4 --quiet --output-document="$ZIG_TARBALL" "$ZIG_URL"
72
- else
73
- curl --silent --output "$ZIG_TARBALL" "$ZIG_URL"
74
- fi
75
-
76
- # Extract and then remove the downloaded tarball:
77
- echo "Extracting $ZIG_TARBALL..."
78
- tar -xf "$ZIG_TARBALL"
79
- rm "$ZIG_TARBALL"
80
-
81
- # Replace any existing Zig installation so that we can install or upgrade:
82
- echo "Installing $ZIG_DIRECTORY to 'zig' in current working directory..."
83
- rm -rf zig
84
- mv "$ZIG_DIRECTORY" zig
85
-
86
- # It's up to the user to add this to their path if they want to:
87
- ZIG_BIN="$(pwd)/zig/zig"
88
-
89
- ZIG_VERSION=$($ZIG_BIN version)
90
- echo "Congratulations, you have successfully installed Zig $ZIG_VERSION to $ZIG_BIN. Enjoy!"
@@ -1,199 +0,0 @@
1
- const std = @import("std");
2
- const fs = std.fs;
3
- const math = std.math;
4
- const mem = std.mem;
5
-
6
- const whitelist = std.ComptimeStringMap([]const u32, .{
7
- .{ "src/cli.zig", &.{ 35, 39 } },
8
- });
9
-
10
- fn whitelisted(path: []const u8, line: u32) bool {
11
- const lines = whitelist.get(path) orelse return false;
12
- return mem.indexOfScalar(u32, lines, line) != null;
13
- }
14
-
15
- const Stats = struct {
16
- path: []const u8,
17
- assert_count: u32,
18
- function_count: u32,
19
- ratio: f64,
20
- };
21
-
22
- var file_stats = std.ArrayListUnmanaged(Stats){};
23
- var seen = std.AutoArrayHashMapUnmanaged(fs.File.INode, void){};
24
-
25
- var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
26
- const gpa = general_purpose_allocator.allocator();
27
-
28
- pub fn main() !void {
29
- const argv = std.os.argv;
30
- for (argv[1..]) |raw_path| {
31
- const path = mem.span(raw_path);
32
- lint_file(path, fs.cwd(), path) catch |err| switch (err) {
33
- error.IsDir, error.AccessDenied => try lint_dir(path, fs.cwd(), path),
34
- else => return err,
35
- };
36
- }
37
-
38
- var max_path_len: usize = "total:".len;
39
- var total_assert_count: usize = 0;
40
- var total_function_count: usize = 0;
41
- for (file_stats.items) |stats| {
42
- max_path_len = math.max(max_path_len, stats.path.len);
43
- total_assert_count += stats.assert_count;
44
- total_function_count += stats.function_count;
45
- }
46
-
47
- std.sort.sort(Stats, file_stats.items, {}, struct {
48
- fn less_than(_: void, a: Stats, b: Stats) bool {
49
- return a.ratio > b.ratio;
50
- }
51
- }.less_than);
52
-
53
- var buffered_writer = std.io.bufferedWriter(std.io.getStdOut().writer());
54
- const stdout = buffered_writer.writer();
55
-
56
- try stdout.writeAll("\npath");
57
- try stdout.writeByteNTimes(' ', max_path_len - "path".len);
58
- try stdout.writeAll(" asserts functions ratio\n");
59
-
60
- for (file_stats.items) |stats| {
61
- try stdout.writeAll(stats.path);
62
- try stdout.writeByteNTimes(' ', max_path_len - stats.path.len);
63
- try stdout.print(" {d: >7} {d: >9} {d: >5.2}\n", .{
64
- stats.assert_count,
65
- stats.function_count,
66
- stats.ratio,
67
- });
68
- }
69
-
70
- try stdout.writeByteNTimes(' ', max_path_len - "total:".len);
71
- try stdout.print("total: {d: >7} {d: >9} {d: >5.2}\n", .{
72
- total_assert_count,
73
- total_function_count,
74
- @intToFloat(f64, total_assert_count) / @intToFloat(f64, total_function_count),
75
- });
76
- try buffered_writer.flush();
77
- }
78
-
79
- const LintError = error{
80
- OutOfMemory,
81
- ParseError,
82
- NotUtf8,
83
- } || fs.File.OpenError || fs.File.ReadError || fs.File.WriteError;
84
-
85
- fn lint_dir(file_path: []const u8, parent_dir: fs.Dir, parent_sub_path: []const u8) LintError!void {
86
- var dir = try parent_dir.openDir(parent_sub_path, .{ .iterate = true });
87
- defer dir.close();
88
-
89
- const stat = try dir.stat();
90
- if (try seen.fetchPut(gpa, stat.inode, {})) |_| return;
91
-
92
- var dir_it = dir.iterate();
93
- while (try dir_it.next()) |entry| {
94
- const is_dir = entry.kind == .Directory;
95
-
96
- if (is_dir and std.mem.eql(u8, entry.name, "zig-cache")) continue;
97
-
98
- if (is_dir or mem.endsWith(u8, entry.name, ".zig")) {
99
- const full_path = try fs.path.join(gpa, &[_][]const u8{ file_path, entry.name });
100
- defer gpa.free(full_path);
101
-
102
- if (is_dir) {
103
- try lint_dir(full_path, dir, entry.name);
104
- } else {
105
- try lint_file(full_path, dir, entry.name);
106
- }
107
- }
108
- }
109
- }
110
-
111
- fn lint_file(file_path: []const u8, dir: fs.Dir, sub_path: []const u8) LintError!void {
112
- const source_file = try dir.openFile(sub_path, .{});
113
- defer source_file.close();
114
-
115
- const stat = try source_file.stat();
116
-
117
- if (stat.kind == .Directory) return error.IsDir;
118
-
119
- // Add to set after no longer possible to get error.IsDir.
120
- if (try seen.fetchPut(gpa, stat.inode, {})) |_| return;
121
-
122
- const source = try source_file.readToEndAllocOptions(
123
- gpa,
124
- math.maxInt(usize),
125
- null,
126
- @alignOf(u8),
127
- 0,
128
- );
129
- try check_line_length(source, file_path);
130
-
131
- var tree = try std.zig.parse(gpa, source);
132
- defer tree.deinit(gpa);
133
-
134
- if (tree.errors.len != 0) return error.ParseError;
135
-
136
- const node_tags = tree.nodes.items(.tag);
137
- const main_tokens = tree.nodes.items(.main_token);
138
- const node_datas = tree.nodes.items(.data);
139
-
140
- var function_count: u32 = 0;
141
- var assert_count: u32 = 0;
142
- for (node_tags) |tag, node| {
143
- switch (tag) {
144
- .fn_decl => {
145
- function_count += 1;
146
- const body = node_datas[node].rhs;
147
- const body_start = tree.tokenLocation(0, tree.firstToken(body));
148
- const body_end = tree.tokenLocation(0, tree.lastToken(body));
149
- // Add 1 as the count returned by tokenLocation() is
150
- // 0-indexed while most editors start at 1.
151
- const line = @intCast(u32, body_start.line + 1);
152
- const body_lines = body_end.line - body_start.line;
153
- if (body_lines > 70 and !whitelisted(file_path, line)) {
154
- const stderr = std.io.getStdErr().writer();
155
- try stderr.print("{s}:{d} function body exceeds 70 lines ({d} lines)\n", .{
156
- file_path,
157
- line,
158
- body_lines,
159
- });
160
- }
161
- },
162
-
163
- .call_one, .call_one_comma => {
164
- const lhs = node_datas[node].lhs;
165
- if (node_tags[lhs] == .identifier and
166
- mem.eql(u8, "assert", tree.tokenSlice(main_tokens[lhs])))
167
- {
168
- assert_count += 1;
169
- }
170
- },
171
-
172
- .unreachable_literal => assert_count += 1,
173
-
174
- else => {},
175
- }
176
- }
177
-
178
- try file_stats.append(gpa, .{
179
- .path = try gpa.dupe(u8, file_path),
180
- .assert_count = assert_count,
181
- .function_count = function_count,
182
- .ratio = @intToFloat(f64, assert_count) / @intToFloat(f64, function_count),
183
- });
184
- }
185
-
186
- fn check_line_length(source: []const u8, path: []const u8) !void {
187
- var i: usize = 0;
188
- var line: u32 = 1;
189
- while (mem.indexOfScalar(u8, source[i..], '\n')) |newline| : (line += 1) {
190
- const line_length = std.unicode.utf8CountCodepoints(
191
- source[i..][0..newline],
192
- ) catch return error.NotUtf8;
193
- if (line_length > 100 and !whitelisted(path, line)) {
194
- const stderr = std.io.getStdErr().writer();
195
- try stderr.print("{s}:{d} line exceeds 100 columns\n", .{ path, line });
196
- }
197
- i += newline + 1;
198
- }
199
- }
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Usage:
4
- # ln -s ../../scripts/pre-commit.sh .git/hooks/pre-commit
5
-
6
- set -euo pipefail
7
- cd "$(git rev-parse --show-toplevel)"
8
-
9
- zig fmt --check .
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- docker run -v "$(pwd)":/wrk -w /wrk koalaman/shellcheck scripts/*.sh
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- docker run --entrypoint sh -v "$(pwd)":/wrk -w /wrk alpine -c "
6
- set -e
7
- ./scripts/install_zig.sh
8
- zig/zig build test
9
- ./scripts/install.sh
10
- "
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- docker run --entrypoint sh -v "$(pwd)":/wrk -w /wrk ubuntu -c "
6
- set -e
7
-
8
- apt-get update -y
9
- apt-get install -y curl xz-utils
10
-
11
- ./scripts/install_zig.sh
12
- zig/zig build test
13
- ./scripts/install.sh
14
- "
@@ -1,48 +0,0 @@
1
- #!/bin/bash
2
- set -eEuo pipefail
3
-
4
- # Assert that we are only upgrading the kernel for Ubuntu, and not another distribution:
5
- DISTRIBUTION=$(lsb_release -i | awk '{print $3}')
6
- if [ "$DISTRIBUTION" != "Ubuntu" ]; then
7
- echo "This script must be run on Ubuntu."
8
- exit 1
9
- fi
10
-
11
- # No need to downgrade the kernel if we are on a newer version.
12
- CURRENT_KERNEL_VERSION=$(uname -r | grep -o "[0-9\.]*" | head -1)
13
- if [ "$(printf '%s\n' "5.7.15" "$CURRENT_KERNEL_VERSION" | sort -V | head -n1)" = "5.7.15" ]; then
14
- echo "Current kernel ${CURRENT_KERNEL_VERSION} supports io_uring. No need to upgrade."
15
- exit 0
16
- else
17
- echo "Upgrading kernel from ${CURRENT_KERNEL_VERSION} to 5.7.15."
18
- fi
19
-
20
- # Use a temporary download directory that we can cleanup afterwards:
21
- DIRECTORY_PREFIX="upgrade_ubuntu_kernel"
22
- rm -rf $DIRECTORY_PREFIX
23
- mkdir $DIRECTORY_PREFIX
24
-
25
- # Download the 5.7.15 amd64 generic kernel files (note the "_all.deb" or "generic" keywords):
26
- echo "Downloading the 5.7.15 amd64 generic kernel files..."
27
- wget --quiet --show-progress --directory-prefix=$DIRECTORY_PREFIX https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.7.15/amd64/linux-headers-5.7.15-050715_5.7.15-050715.202008111432_all.deb
28
- wget --quiet --show-progress --directory-prefix=$DIRECTORY_PREFIX https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.7.15/amd64/linux-headers-5.7.15-050715-generic_5.7.15-050715.202008111432_amd64.deb
29
- wget --quiet --show-progress --directory-prefix=$DIRECTORY_PREFIX https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.7.15/amd64/linux-image-unsigned-5.7.15-050715-generic_5.7.15-050715.202008111432_amd64.deb
30
- wget --quiet --show-progress --directory-prefix=$DIRECTORY_PREFIX https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.7.15/amd64/linux-modules-5.7.15-050715-generic_5.7.15-050715.202008111432_amd64.deb
31
-
32
- # Install and then remove the downloaded files:
33
- echo "Installing (requires root)..."
34
- sudo dpkg -i $DIRECTORY_PREFIX/*.deb
35
- rm -rf $DIRECTORY_PREFIX
36
- echo "Installed the 5.7.15 amd64 generic kernel files."
37
-
38
- # Reboot the system if the user wants to:
39
- read -p "Press Y to reboot your system (or any other key to reboot later)... " -n 1 -r
40
- echo
41
- if [[ $REPLY =~ ^[Yy]$ ]]
42
- then
43
- echo "Rebooting in 3 seconds..."
44
- sleep 3
45
- sudo reboot
46
- else
47
- echo "You must reboot your system for these changes to take effect."
48
- fi
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- # This script builds the docs website for the currently checked out
6
- # branch.
7
-
8
- git clone https://github.com/tigerbeetledb/docs docs_website
9
- # Try to grab branch from Github Actions CI.
10
- # See also: https://docs.github.com/en/actions/learn-github-actions/environment-variables.
11
- BRANCH="$GITHUB_HEAD_REF"
12
- if [[ -z "$BRANCH" ]]; then
13
- # Otherwise fall back to git rev-parse
14
- BRANCH=$(git rev-parse --abbrev-ref HEAD)
15
- fi
16
-
17
- REPO="https://github.com/tigerbeetledb/tigerbeetle"
18
- if [[ -n "$SOURCE_REPO" ]]; then
19
- REPO="${SOURCE_REPO}"
20
- fi
21
-
22
- ( cd docs_website && npm install && ./scripts/build.sh "$BRANCH" "$REPO" )
23
- rm -rf docs_website
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const messages = [
4
- 'prepare',
5
- 'prepare_ok',
6
- 'commit',
7
- 'request_state_transfer',
8
- 'state_transfer',
9
- 'start_view_change',
10
- 'do_view_change',
11
- 'start_view'
12
- ];
13
-
14
- const views = [
15
- 'old_view',
16
- 'same_view',
17
- 'new_view'
18
- ];
19
-
20
- const statuses = [
21
- 'normal',
22
- 'view_change',
23
- 'recovering'
24
- ];
25
-
26
- const tuples = {};
27
-
28
- statuses.forEach(
29
- function(status) {
30
- views.forEach(
31
- function(view) {
32
- messages.forEach(
33
- function(message) {
34
- tuples[`${message}, ${view}, ${status}`] = true;
35
- }
36
- );
37
- }
38
- );
39
- }
40
- );
41
-
42
- Object.keys(tuples).sort().forEach(
43
- function(key) {
44
- console.log(key);
45
- }
46
- );
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- docker run -v "$(pwd)":/wrk -w /wrk koalaman/shellcheck scripts/*.sh
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- docker run --entrypoint sh -v "$(pwd)":/wrk -w /wrk alpine -c "
6
- set -e
7
- ./scripts/install_zig.sh
8
- zig/zig build test
9
- ./scripts/install.sh
10
- "
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- docker run --entrypoint sh -v "$(pwd)":/wrk -w /wrk ubuntu -c "
6
- set -e
7
-
8
- apt-get update -y
9
- apt-get install -y curl xz-utils
10
-
11
- ./scripts/install_zig.sh
12
- zig/zig build test
13
- ./scripts/install.sh
14
- "
@@ -1,48 +0,0 @@
1
- #!/bin/bash
2
- set -eEuo pipefail
3
-
4
- # Assert that we are only upgrading the kernel for Ubuntu, and not another distribution:
5
- DISTRIBUTION=$(lsb_release -i | awk '{print $3}')
6
- if [ "$DISTRIBUTION" != "Ubuntu" ]; then
7
- echo "This script must be run on Ubuntu."
8
- exit 1
9
- fi
10
-
11
- # No need to downgrade the kernel if we are on a newer version.
12
- CURRENT_KERNEL_VERSION=$(uname -r | grep -o "[0-9\.]*" | head -1)
13
- if [ "$(printf '%s\n' "5.7.15" "$CURRENT_KERNEL_VERSION" | sort -V | head -n1)" = "5.7.15" ]; then
14
- echo "Current kernel ${CURRENT_KERNEL_VERSION} supports io_uring. No need to upgrade."
15
- exit 0
16
- else
17
- echo "Upgrading kernel from ${CURRENT_KERNEL_VERSION} to 5.7.15."
18
- fi
19
-
20
- # Use a temporary download directory that we can cleanup afterwards:
21
- DIRECTORY_PREFIX="upgrade_ubuntu_kernel"
22
- rm -rf $DIRECTORY_PREFIX
23
- mkdir $DIRECTORY_PREFIX
24
-
25
- # Download the 5.7.15 amd64 generic kernel files (note the "_all.deb" or "generic" keywords):
26
- echo "Downloading the 5.7.15 amd64 generic kernel files..."
27
- wget --quiet --show-progress --directory-prefix=$DIRECTORY_PREFIX https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.7.15/amd64/linux-headers-5.7.15-050715_5.7.15-050715.202008111432_all.deb
28
- wget --quiet --show-progress --directory-prefix=$DIRECTORY_PREFIX https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.7.15/amd64/linux-headers-5.7.15-050715-generic_5.7.15-050715.202008111432_amd64.deb
29
- wget --quiet --show-progress --directory-prefix=$DIRECTORY_PREFIX https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.7.15/amd64/linux-image-unsigned-5.7.15-050715-generic_5.7.15-050715.202008111432_amd64.deb
30
- wget --quiet --show-progress --directory-prefix=$DIRECTORY_PREFIX https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.7.15/amd64/linux-modules-5.7.15-050715-generic_5.7.15-050715.202008111432_amd64.deb
31
-
32
- # Install and then remove the downloaded files:
33
- echo "Installing (requires root)..."
34
- sudo dpkg -i $DIRECTORY_PREFIX/*.deb
35
- rm -rf $DIRECTORY_PREFIX
36
- echo "Installed the 5.7.15 amd64 generic kernel files."
37
-
38
- # Reboot the system if the user wants to:
39
- read -p "Press Y to reboot your system (or any other key to reboot later)... " -n 1 -r
40
- echo
41
- if [[ $REPLY =~ ^[Yy]$ ]]
42
- then
43
- echo "Rebooting in 3 seconds..."
44
- sleep 3
45
- sudo reboot
46
- else
47
- echo "You must reboot your system for these changes to take effect."
48
- fi
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- # This script builds the docs website for the currently checked out
6
- # branch.
7
-
8
- git clone https://github.com/tigerbeetledb/docs docs_website
9
- # Try to grab branch from Github Actions CI.
10
- # See also: https://docs.github.com/en/actions/learn-github-actions/environment-variables.
11
- BRANCH="$GITHUB_HEAD_REF"
12
- if [[ -z "$BRANCH" ]]; then
13
- # Otherwise fall back to git rev-parse
14
- BRANCH=$(git rev-parse --abbrev-ref HEAD)
15
- fi
16
-
17
- REPO="https://github.com/tigerbeetledb/tigerbeetle"
18
- if [[ -n "$SOURCE_REPO" ]]; then
19
- REPO="${SOURCE_REPO}"
20
- fi
21
-
22
- ( cd docs_website && npm install && ./scripts/build.sh "$BRANCH" "$REPO" )
23
- rm -rf docs_website