tigerbeetle 0.0.40 → 0.17.8
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.
- checksums.yaml +4 -4
- data/LICENSE +0 -25
- data/README.md +670 -80
- data/docs/migration.md +201 -0
- data/sig/tigerbeetle.rbs +271 -0
- data/src/ext/tigerbeetle/extconf.rb +47 -0
- data/src/ext/tigerbeetle/lib/aarch64-linux-gnu.2.27/libtb_client.so +0 -0
- data/src/ext/tigerbeetle/lib/aarch64-linux-musl/libtb_client.so +0 -0
- data/src/ext/tigerbeetle/lib/aarch64-macos/libtb_client.dylib +0 -0
- data/src/ext/tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so +0 -0
- data/src/ext/tigerbeetle/lib/x86_64-linux-musl/libtb_client.so +0 -0
- data/src/ext/tigerbeetle/lib/x86_64-macos/libtb_client.dylib +0 -0
- data/src/ext/tigerbeetle/lib/x86_64-windows/tb_client.dll +0 -0
- data/src/ext/tigerbeetle/rb_tb_gen.h +458 -0
- data/{ext/tb_client/tigerbeetle/src/clients/rust/assets → src/ext/tigerbeetle}/tb_client.h +18 -16
- data/src/ext/tigerbeetle/tigerbeetle.c +310 -0
- data/src/tigerbeetle/bindings.rb +347 -0
- data/src/tigerbeetle/client.rb +129 -0
- data/src/tigerbeetle/completion_dispatcher.rb +108 -0
- data/src/tigerbeetle/id.rb +40 -0
- data/src/tigerbeetle/tb.rb +3 -0
- data/src/tigerbeetle/version.rb +3 -0
- data/src/tigerbeetle.rb +39 -0
- metadata +33 -350
- data/CHANGELOG.md +0 -162
- data/ext/tb_client/extconf.rb +0 -41
- data/ext/tb_client/tigerbeetle/LICENSE +0 -177
- data/ext/tb_client/tigerbeetle/build.zig +0 -2296
- data/ext/tb_client/tigerbeetle/src/aof.zig +0 -1000
- data/ext/tb_client/tigerbeetle/src/build/fetch.zig +0 -112
- data/ext/tb_client/tigerbeetle/src/build_multiversion.zig +0 -808
- data/ext/tb_client/tigerbeetle/src/cdc/amqp/protocol.zig +0 -1283
- data/ext/tb_client/tigerbeetle/src/cdc/amqp/spec.zig +0 -1704
- data/ext/tb_client/tigerbeetle/src/cdc/amqp/types.zig +0 -341
- data/ext/tb_client/tigerbeetle/src/cdc/amqp.zig +0 -1450
- data/ext/tb_client/tigerbeetle/src/cdc/runner.zig +0 -1659
- data/ext/tb_client/tigerbeetle/src/clients/c/samples/main.c +0 -406
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/context.zig +0 -1092
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/echo_client.zig +0 -286
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/packet.zig +0 -158
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/signal.zig +0 -229
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/signal_fuzz.zig +0 -110
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client.h +0 -386
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client.zig +0 -34
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client_exports.zig +0 -281
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client_header.zig +0 -312
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client_header_test.zig +0 -138
- data/ext/tb_client/tigerbeetle/src/clients/c/test.zig +0 -466
- data/ext/tb_client/tigerbeetle/src/clients/docs_samples.zig +0 -157
- data/ext/tb_client/tigerbeetle/src/clients/docs_types.zig +0 -90
- data/ext/tb_client/tigerbeetle/src/clients/dotnet/ci.zig +0 -203
- data/ext/tb_client/tigerbeetle/src/clients/dotnet/docs.zig +0 -79
- data/ext/tb_client/tigerbeetle/src/clients/dotnet/dotnet_bindings.zig +0 -542
- data/ext/tb_client/tigerbeetle/src/clients/go/ci.zig +0 -109
- data/ext/tb_client/tigerbeetle/src/clients/go/docs.zig +0 -86
- data/ext/tb_client/tigerbeetle/src/clients/go/go_bindings.zig +0 -370
- data/ext/tb_client/tigerbeetle/src/clients/go/pkg/native/tb_client.h +0 -386
- data/ext/tb_client/tigerbeetle/src/clients/java/ci.zig +0 -167
- data/ext/tb_client/tigerbeetle/src/clients/java/docs.zig +0 -126
- data/ext/tb_client/tigerbeetle/src/clients/java/java_bindings.zig +0 -996
- data/ext/tb_client/tigerbeetle/src/clients/java/src/client.zig +0 -748
- data/ext/tb_client/tigerbeetle/src/clients/java/src/jni.zig +0 -3238
- data/ext/tb_client/tigerbeetle/src/clients/java/src/jni_tests.zig +0 -1718
- data/ext/tb_client/tigerbeetle/src/clients/java/src/jni_thread_cleaner.zig +0 -190
- data/ext/tb_client/tigerbeetle/src/clients/node/ci.zig +0 -104
- data/ext/tb_client/tigerbeetle/src/clients/node/docs.zig +0 -75
- data/ext/tb_client/tigerbeetle/src/clients/node/node.zig +0 -522
- data/ext/tb_client/tigerbeetle/src/clients/node/node_bindings.zig +0 -267
- data/ext/tb_client/tigerbeetle/src/clients/node/src/c.zig +0 -3
- data/ext/tb_client/tigerbeetle/src/clients/node/src/translate.zig +0 -379
- data/ext/tb_client/tigerbeetle/src/clients/python/ci.zig +0 -131
- data/ext/tb_client/tigerbeetle/src/clients/python/docs.zig +0 -63
- data/ext/tb_client/tigerbeetle/src/clients/python/python_bindings.zig +0 -588
- data/ext/tb_client/tigerbeetle/src/clients/rust/ci.zig +0 -73
- data/ext/tb_client/tigerbeetle/src/clients/rust/docs.zig +0 -106
- data/ext/tb_client/tigerbeetle/src/clients/rust/rust_bindings.zig +0 -305
- data/ext/tb_client/tigerbeetle/src/config.zig +0 -296
- data/ext/tb_client/tigerbeetle/src/constants.zig +0 -790
- data/ext/tb_client/tigerbeetle/src/copyhound.zig +0 -202
- data/ext/tb_client/tigerbeetle/src/counting_allocator.zig +0 -72
- data/ext/tb_client/tigerbeetle/src/direction.zig +0 -120
- data/ext/tb_client/tigerbeetle/src/docs_website/build.zig +0 -158
- data/ext/tb_client/tigerbeetle/src/docs_website/src/content.zig +0 -156
- data/ext/tb_client/tigerbeetle/src/docs_website/src/docs.zig +0 -252
- data/ext/tb_client/tigerbeetle/src/docs_website/src/file_checker.zig +0 -313
- data/ext/tb_client/tigerbeetle/src/docs_website/src/html.zig +0 -87
- data/ext/tb_client/tigerbeetle/src/docs_website/src/page_writer.zig +0 -63
- data/ext/tb_client/tigerbeetle/src/docs_website/src/redirects.zig +0 -47
- data/ext/tb_client/tigerbeetle/src/docs_website/src/search_index_writer.zig +0 -28
- data/ext/tb_client/tigerbeetle/src/docs_website/src/service_worker_writer.zig +0 -61
- data/ext/tb_client/tigerbeetle/src/docs_website/src/single_page_writer.zig +0 -169
- data/ext/tb_client/tigerbeetle/src/docs_website/src/website.zig +0 -46
- data/ext/tb_client/tigerbeetle/src/ewah.zig +0 -445
- data/ext/tb_client/tigerbeetle/src/ewah_benchmark.zig +0 -128
- data/ext/tb_client/tigerbeetle/src/ewah_fuzz.zig +0 -171
- data/ext/tb_client/tigerbeetle/src/fuzz_tests.zig +0 -179
- data/ext/tb_client/tigerbeetle/src/integration_tests.zig +0 -662
- data/ext/tb_client/tigerbeetle/src/io/common.zig +0 -155
- data/ext/tb_client/tigerbeetle/src/io/darwin.zig +0 -1093
- data/ext/tb_client/tigerbeetle/src/io/linux.zig +0 -1880
- data/ext/tb_client/tigerbeetle/src/io/test.zig +0 -1005
- data/ext/tb_client/tigerbeetle/src/io/windows.zig +0 -1598
- data/ext/tb_client/tigerbeetle/src/io.zig +0 -34
- data/ext/tb_client/tigerbeetle/src/iops.zig +0 -134
- data/ext/tb_client/tigerbeetle/src/list.zig +0 -236
- data/ext/tb_client/tigerbeetle/src/lsm/binary_search.zig +0 -848
- data/ext/tb_client/tigerbeetle/src/lsm/binary_search_benchmark.zig +0 -179
- data/ext/tb_client/tigerbeetle/src/lsm/cache_map.zig +0 -424
- data/ext/tb_client/tigerbeetle/src/lsm/cache_map_fuzz.zig +0 -420
- data/ext/tb_client/tigerbeetle/src/lsm/compaction.zig +0 -2114
- data/ext/tb_client/tigerbeetle/src/lsm/composite_key.zig +0 -185
- data/ext/tb_client/tigerbeetle/src/lsm/forest.zig +0 -1146
- data/ext/tb_client/tigerbeetle/src/lsm/forest_fuzz.zig +0 -1102
- data/ext/tb_client/tigerbeetle/src/lsm/forest_table_iterator.zig +0 -200
- data/ext/tb_client/tigerbeetle/src/lsm/groove.zig +0 -1495
- data/ext/tb_client/tigerbeetle/src/lsm/k_way_merge.zig +0 -739
- data/ext/tb_client/tigerbeetle/src/lsm/k_way_merge_benchmark.zig +0 -166
- data/ext/tb_client/tigerbeetle/src/lsm/manifest.zig +0 -754
- data/ext/tb_client/tigerbeetle/src/lsm/manifest_level.zig +0 -1294
- data/ext/tb_client/tigerbeetle/src/lsm/manifest_level_fuzz.zig +0 -510
- data/ext/tb_client/tigerbeetle/src/lsm/manifest_log.zig +0 -1241
- data/ext/tb_client/tigerbeetle/src/lsm/manifest_log_fuzz.zig +0 -628
- data/ext/tb_client/tigerbeetle/src/lsm/node_pool.zig +0 -247
- data/ext/tb_client/tigerbeetle/src/lsm/scan_buffer.zig +0 -116
- data/ext/tb_client/tigerbeetle/src/lsm/scan_builder.zig +0 -543
- data/ext/tb_client/tigerbeetle/src/lsm/scan_fuzz.zig +0 -938
- data/ext/tb_client/tigerbeetle/src/lsm/scan_lookup.zig +0 -293
- data/ext/tb_client/tigerbeetle/src/lsm/scan_merge.zig +0 -359
- data/ext/tb_client/tigerbeetle/src/lsm/scan_range.zig +0 -99
- data/ext/tb_client/tigerbeetle/src/lsm/scan_state.zig +0 -17
- data/ext/tb_client/tigerbeetle/src/lsm/scan_tree.zig +0 -962
- data/ext/tb_client/tigerbeetle/src/lsm/schema.zig +0 -617
- data/ext/tb_client/tigerbeetle/src/lsm/scratch_memory.zig +0 -84
- data/ext/tb_client/tigerbeetle/src/lsm/segmented_array.zig +0 -1500
- data/ext/tb_client/tigerbeetle/src/lsm/segmented_array_benchmark.zig +0 -149
- data/ext/tb_client/tigerbeetle/src/lsm/segmented_array_fuzz.zig +0 -7
- data/ext/tb_client/tigerbeetle/src/lsm/set_associative_cache.zig +0 -865
- data/ext/tb_client/tigerbeetle/src/lsm/table.zig +0 -607
- data/ext/tb_client/tigerbeetle/src/lsm/table_memory.zig +0 -843
- data/ext/tb_client/tigerbeetle/src/lsm/table_value_iterator.zig +0 -90
- data/ext/tb_client/tigerbeetle/src/lsm/timestamp_range.zig +0 -40
- data/ext/tb_client/tigerbeetle/src/lsm/tree.zig +0 -629
- data/ext/tb_client/tigerbeetle/src/lsm/tree_fuzz.zig +0 -933
- data/ext/tb_client/tigerbeetle/src/lsm/zig_zag_merge.zig +0 -534
- data/ext/tb_client/tigerbeetle/src/message_buffer.zig +0 -469
- data/ext/tb_client/tigerbeetle/src/message_bus.zig +0 -1219
- data/ext/tb_client/tigerbeetle/src/message_bus_fuzz.zig +0 -936
- data/ext/tb_client/tigerbeetle/src/message_pool.zig +0 -343
- data/ext/tb_client/tigerbeetle/src/multiversion.zig +0 -2195
- data/ext/tb_client/tigerbeetle/src/queue.zig +0 -390
- data/ext/tb_client/tigerbeetle/src/repl/completion.zig +0 -201
- data/ext/tb_client/tigerbeetle/src/repl/parser.zig +0 -1356
- data/ext/tb_client/tigerbeetle/src/repl/terminal.zig +0 -496
- data/ext/tb_client/tigerbeetle/src/repl.zig +0 -1034
- data/ext/tb_client/tigerbeetle/src/scripts/amqp.zig +0 -973
- data/ext/tb_client/tigerbeetle/src/scripts/cfo.zig +0 -1866
- data/ext/tb_client/tigerbeetle/src/scripts/changelog.zig +0 -304
- data/ext/tb_client/tigerbeetle/src/scripts/ci.zig +0 -227
- data/ext/tb_client/tigerbeetle/src/scripts/client_readmes.zig +0 -658
- data/ext/tb_client/tigerbeetle/src/scripts/devhub.zig +0 -466
- data/ext/tb_client/tigerbeetle/src/scripts/release.zig +0 -1058
- data/ext/tb_client/tigerbeetle/src/scripts.zig +0 -105
- data/ext/tb_client/tigerbeetle/src/shell.zig +0 -1195
- data/ext/tb_client/tigerbeetle/src/stack.zig +0 -260
- data/ext/tb_client/tigerbeetle/src/state_machine/auditor.zig +0 -911
- data/ext/tb_client/tigerbeetle/src/state_machine/workload.zig +0 -2079
- data/ext/tb_client/tigerbeetle/src/state_machine.zig +0 -4872
- data/ext/tb_client/tigerbeetle/src/state_machine_fuzz.zig +0 -288
- data/ext/tb_client/tigerbeetle/src/state_machine_tests.zig +0 -3128
- data/ext/tb_client/tigerbeetle/src/static_allocator.zig +0 -82
- data/ext/tb_client/tigerbeetle/src/stdx/bit_set.zig +0 -157
- data/ext/tb_client/tigerbeetle/src/stdx/bounded_array.zig +0 -292
- data/ext/tb_client/tigerbeetle/src/stdx/debug.zig +0 -65
- data/ext/tb_client/tigerbeetle/src/stdx/flags.zig +0 -1414
- data/ext/tb_client/tigerbeetle/src/stdx/huge_page_allocator.zig +0 -115
- data/ext/tb_client/tigerbeetle/src/stdx/mlock.zig +0 -92
- data/ext/tb_client/tigerbeetle/src/stdx/prng.zig +0 -677
- data/ext/tb_client/tigerbeetle/src/stdx/radix.zig +0 -336
- data/ext/tb_client/tigerbeetle/src/stdx/ring_buffer.zig +0 -511
- data/ext/tb_client/tigerbeetle/src/stdx/sort_test.zig +0 -112
- data/ext/tb_client/tigerbeetle/src/stdx/stdx.zig +0 -1163
- data/ext/tb_client/tigerbeetle/src/stdx/testing/low_level_hash_vectors.zig +0 -142
- data/ext/tb_client/tigerbeetle/src/stdx/testing/snaptest.zig +0 -361
- data/ext/tb_client/tigerbeetle/src/stdx/time_units.zig +0 -275
- data/ext/tb_client/tigerbeetle/src/stdx/unshare.zig +0 -295
- data/ext/tb_client/tigerbeetle/src/stdx/vendored/aegis.zig +0 -436
- data/ext/tb_client/tigerbeetle/src/stdx/windows.zig +0 -48
- data/ext/tb_client/tigerbeetle/src/stdx/zipfian.zig +0 -402
- data/ext/tb_client/tigerbeetle/src/storage.zig +0 -489
- data/ext/tb_client/tigerbeetle/src/storage_fuzz.zig +0 -180
- data/ext/tb_client/tigerbeetle/src/testing/bench.zig +0 -146
- data/ext/tb_client/tigerbeetle/src/testing/cluster/grid_checker.zig +0 -53
- data/ext/tb_client/tigerbeetle/src/testing/cluster/journal_checker.zig +0 -61
- data/ext/tb_client/tigerbeetle/src/testing/cluster/manifest_checker.zig +0 -76
- data/ext/tb_client/tigerbeetle/src/testing/cluster/message_bus.zig +0 -110
- data/ext/tb_client/tigerbeetle/src/testing/cluster/network.zig +0 -412
- data/ext/tb_client/tigerbeetle/src/testing/cluster/state_checker.zig +0 -331
- data/ext/tb_client/tigerbeetle/src/testing/cluster/storage_checker.zig +0 -458
- data/ext/tb_client/tigerbeetle/src/testing/cluster.zig +0 -1198
- data/ext/tb_client/tigerbeetle/src/testing/exhaustigen.zig +0 -128
- data/ext/tb_client/tigerbeetle/src/testing/fixtures.zig +0 -181
- data/ext/tb_client/tigerbeetle/src/testing/fuzz.zig +0 -144
- data/ext/tb_client/tigerbeetle/src/testing/id.zig +0 -97
- data/ext/tb_client/tigerbeetle/src/testing/io.zig +0 -317
- data/ext/tb_client/tigerbeetle/src/testing/marks.zig +0 -126
- data/ext/tb_client/tigerbeetle/src/testing/packet_simulator.zig +0 -533
- data/ext/tb_client/tigerbeetle/src/testing/reply_sequence.zig +0 -154
- data/ext/tb_client/tigerbeetle/src/testing/state_machine.zig +0 -389
- data/ext/tb_client/tigerbeetle/src/testing/storage.zig +0 -1247
- data/ext/tb_client/tigerbeetle/src/testing/table.zig +0 -249
- data/ext/tb_client/tigerbeetle/src/testing/time.zig +0 -98
- data/ext/tb_client/tigerbeetle/src/testing/tmp_tigerbeetle.zig +0 -212
- data/ext/tb_client/tigerbeetle/src/testing/vortex/constants.zig +0 -26
- data/ext/tb_client/tigerbeetle/src/testing/vortex/faulty_network.zig +0 -579
- data/ext/tb_client/tigerbeetle/src/testing/vortex/java_driver/ci.zig +0 -39
- data/ext/tb_client/tigerbeetle/src/testing/vortex/logged_process.zig +0 -214
- data/ext/tb_client/tigerbeetle/src/testing/vortex/rust_driver/ci.zig +0 -34
- data/ext/tb_client/tigerbeetle/src/testing/vortex/supervisor.zig +0 -785
- data/ext/tb_client/tigerbeetle/src/testing/vortex/workload.zig +0 -543
- data/ext/tb_client/tigerbeetle/src/testing/vortex/zig_driver.zig +0 -181
- data/ext/tb_client/tigerbeetle/src/tidy.zig +0 -1449
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/benchmark_driver.zig +0 -227
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/benchmark_load.zig +0 -1069
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/cli.zig +0 -1422
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/inspect.zig +0 -1658
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/inspect_integrity.zig +0 -518
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/libtb_client.zig +0 -36
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/main.zig +0 -646
- data/ext/tb_client/tigerbeetle/src/tigerbeetle.zig +0 -958
- data/ext/tb_client/tigerbeetle/src/time.zig +0 -236
- data/ext/tb_client/tigerbeetle/src/trace/event.zig +0 -745
- data/ext/tb_client/tigerbeetle/src/trace/statsd.zig +0 -462
- data/ext/tb_client/tigerbeetle/src/trace.zig +0 -556
- data/ext/tb_client/tigerbeetle/src/unit_tests.zig +0 -321
- data/ext/tb_client/tigerbeetle/src/vopr.zig +0 -1785
- data/ext/tb_client/tigerbeetle/src/vortex.zig +0 -101
- data/ext/tb_client/tigerbeetle/src/vsr/checkpoint_trailer.zig +0 -473
- data/ext/tb_client/tigerbeetle/src/vsr/checksum.zig +0 -208
- data/ext/tb_client/tigerbeetle/src/vsr/checksum_benchmark.zig +0 -43
- data/ext/tb_client/tigerbeetle/src/vsr/client.zig +0 -768
- data/ext/tb_client/tigerbeetle/src/vsr/client_replies.zig +0 -532
- data/ext/tb_client/tigerbeetle/src/vsr/client_sessions.zig +0 -338
- data/ext/tb_client/tigerbeetle/src/vsr/clock.zig +0 -1019
- data/ext/tb_client/tigerbeetle/src/vsr/fault_detector.zig +0 -279
- data/ext/tb_client/tigerbeetle/src/vsr/free_set.zig +0 -1381
- data/ext/tb_client/tigerbeetle/src/vsr/free_set_fuzz.zig +0 -315
- data/ext/tb_client/tigerbeetle/src/vsr/grid.zig +0 -1460
- data/ext/tb_client/tigerbeetle/src/vsr/grid_blocks_missing.zig +0 -757
- data/ext/tb_client/tigerbeetle/src/vsr/grid_scrubber.zig +0 -797
- data/ext/tb_client/tigerbeetle/src/vsr/journal.zig +0 -2586
- data/ext/tb_client/tigerbeetle/src/vsr/marzullo.zig +0 -308
- data/ext/tb_client/tigerbeetle/src/vsr/message_header.zig +0 -1777
- data/ext/tb_client/tigerbeetle/src/vsr/multi_batch.zig +0 -715
- data/ext/tb_client/tigerbeetle/src/vsr/multi_batch_fuzz.zig +0 -185
- data/ext/tb_client/tigerbeetle/src/vsr/repair_budget.zig +0 -333
- data/ext/tb_client/tigerbeetle/src/vsr/replica.zig +0 -12356
- data/ext/tb_client/tigerbeetle/src/vsr/replica_format.zig +0 -416
- data/ext/tb_client/tigerbeetle/src/vsr/replica_reformat.zig +0 -165
- data/ext/tb_client/tigerbeetle/src/vsr/replica_test.zig +0 -2928
- data/ext/tb_client/tigerbeetle/src/vsr/routing.zig +0 -1075
- data/ext/tb_client/tigerbeetle/src/vsr/superblock.zig +0 -1603
- data/ext/tb_client/tigerbeetle/src/vsr/superblock_fuzz.zig +0 -484
- data/ext/tb_client/tigerbeetle/src/vsr/superblock_quorums.zig +0 -405
- data/ext/tb_client/tigerbeetle/src/vsr/superblock_quorums_fuzz.zig +0 -355
- data/ext/tb_client/tigerbeetle/src/vsr/sync.zig +0 -29
- data/ext/tb_client/tigerbeetle/src/vsr.zig +0 -1727
- data/lib/tb_client/shared_lib.rb +0 -66
- data/lib/tb_client.rb +0 -282
- data/lib/tigerbeetle/account.rb +0 -38
- data/lib/tigerbeetle/account_balance.rb +0 -23
- data/lib/tigerbeetle/account_filter.rb +0 -31
- data/lib/tigerbeetle/atomic_counter.rb +0 -14
- data/lib/tigerbeetle/client.rb +0 -214
- data/lib/tigerbeetle/converters/account.rb +0 -63
- data/lib/tigerbeetle/converters/account_balance.rb +0 -31
- data/lib/tigerbeetle/converters/account_filter.rb +0 -32
- data/lib/tigerbeetle/converters/base.rb +0 -35
- data/lib/tigerbeetle/converters/create_accounts_result.rb +0 -21
- data/lib/tigerbeetle/converters/create_transfers_result.rb +0 -21
- data/lib/tigerbeetle/converters/query_filter.rb +0 -33
- data/lib/tigerbeetle/converters/time.rb +0 -23
- data/lib/tigerbeetle/converters/transfer.rb +0 -64
- data/lib/tigerbeetle/converters/uint_128.rb +0 -24
- data/lib/tigerbeetle/converters.rb +0 -12
- data/lib/tigerbeetle/error.rb +0 -4
- data/lib/tigerbeetle/id.rb +0 -30
- data/lib/tigerbeetle/platforms.rb +0 -9
- data/lib/tigerbeetle/query_filter.rb +0 -31
- data/lib/tigerbeetle/request.rb +0 -7
- data/lib/tigerbeetle/transfer.rb +0 -40
- data/lib/tigerbeetle/version.rb +0 -4
- data/lib/tigerbeetle.rb +0 -13
- data/tigerbeetle.gemspec +0 -60
|
@@ -1,579 +0,0 @@
|
|
|
1
|
-
//! The `Network` is a set of proxies used to inject network faults in a Vortex test cluster. We
|
|
2
|
-
//! create one `Proxy` per replica in the test cluster. Each proxy has a set of available
|
|
3
|
-
//! `Connection`s, which model the communication through the proxy (replica-to-replica or
|
|
4
|
-
//! client-to-replica). Each `Connection` has two pipes, connecting the peers' inputs and outputs
|
|
5
|
-
//! (recv and send).
|
|
6
|
-
//!
|
|
7
|
-
//! The _mappings_ are pairs of addresses:
|
|
8
|
-
//!
|
|
9
|
-
//! * _origin_: the address on which the proxy listens for connections from _origin_ peers
|
|
10
|
-
//! * _remote_: the address the proxy connects to, to communicate with the _remote_ peers
|
|
11
|
-
//!
|
|
12
|
-
//! A pipe runs, alternating recv and send, until it sees that the connection is no longer proxying
|
|
13
|
-
//! or if there's an error or EOF, in which case it also closes the parent connection.
|
|
14
|
-
//!
|
|
15
|
-
//! When the `Faults` struct is populated with non-null configurations, the pipes inject
|
|
16
|
-
//! corresponding faults according to the probabilities.
|
|
17
|
-
//!
|
|
18
|
-
//! NOTE: The pipe is not yet message-aware (and perhaps shouldn't be?), which means that we deal
|
|
19
|
-
//! with whatever chunks of bytes we receive immediately, instead of collecting a buffer with a
|
|
20
|
-
//! full message before piping it through.
|
|
21
|
-
const std = @import("std");
|
|
22
|
-
const stdx = @import("stdx");
|
|
23
|
-
const IO = @import("../../io.zig").IO;
|
|
24
|
-
const constants = @import("constants.zig");
|
|
25
|
-
|
|
26
|
-
const assert = std.debug.assert;
|
|
27
|
-
const log = std.log.scoped(.faulty_network);
|
|
28
|
-
const Ratio = stdx.PRNG.Ratio;
|
|
29
|
-
|
|
30
|
-
const Faults = struct {
|
|
31
|
-
const Delay = struct {
|
|
32
|
-
time_ms: u32,
|
|
33
|
-
jitter_ms: u32,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
delay: ?Delay = null,
|
|
37
|
-
corrupt: ?Ratio = null,
|
|
38
|
-
|
|
39
|
-
// Others not implemented: duplication, reordering, rate
|
|
40
|
-
|
|
41
|
-
pub fn heal(faults: *Faults) void {
|
|
42
|
-
faults.delay = null;
|
|
43
|
-
faults.corrupt = null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
pub fn is_healed(faults: *const Faults) bool {
|
|
47
|
-
return faults.delay == null and faults.corrupt == null;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const Pipe = struct {
|
|
52
|
-
io: *IO,
|
|
53
|
-
connection: *Connection,
|
|
54
|
-
input: ?std.posix.socket_t = null,
|
|
55
|
-
output: ?std.posix.socket_t = null,
|
|
56
|
-
buffer: [constants.vsr.message_size_max]u8 = undefined,
|
|
57
|
-
status: enum { idle, recv, send, send_timeout } = .idle,
|
|
58
|
-
recv_size: u32 = 0,
|
|
59
|
-
send_size: u32 = 0,
|
|
60
|
-
|
|
61
|
-
recv_completion: IO.Completion = undefined,
|
|
62
|
-
send_completion: IO.Completion = undefined,
|
|
63
|
-
|
|
64
|
-
fn open(
|
|
65
|
-
pipe: *Pipe,
|
|
66
|
-
input: std.posix.socket_t,
|
|
67
|
-
output: std.posix.socket_t,
|
|
68
|
-
) void {
|
|
69
|
-
assert(pipe.connection.state == .proxying);
|
|
70
|
-
assert(pipe.status == .idle);
|
|
71
|
-
assert(pipe.input == null);
|
|
72
|
-
assert(pipe.output == null);
|
|
73
|
-
assert(pipe.recv_size == 0);
|
|
74
|
-
assert(pipe.send_size == 0);
|
|
75
|
-
|
|
76
|
-
pipe.input = input;
|
|
77
|
-
pipe.output = output;
|
|
78
|
-
|
|
79
|
-
// Kick off the recv/send loop.
|
|
80
|
-
pipe.recv();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
fn recv(pipe: *Pipe) void {
|
|
84
|
-
assert(pipe.send_size <= pipe.recv_size);
|
|
85
|
-
assert(pipe.connection.state == .proxying);
|
|
86
|
-
|
|
87
|
-
assert(pipe.status == .idle);
|
|
88
|
-
pipe.status = .recv;
|
|
89
|
-
|
|
90
|
-
pipe.recv_size = 0;
|
|
91
|
-
pipe.send_size = 0;
|
|
92
|
-
|
|
93
|
-
// We don't need to recv a certain count of bytes, because whatever we recv, we send along.
|
|
94
|
-
pipe.connection.io.recv(
|
|
95
|
-
*Pipe,
|
|
96
|
-
pipe,
|
|
97
|
-
recv_callback,
|
|
98
|
-
&pipe.recv_completion,
|
|
99
|
-
pipe.input.?,
|
|
100
|
-
pipe.buffer[0..],
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
fn recv_callback(pipe: *Pipe, _: *IO.Completion, result: IO.RecvError!usize) void {
|
|
105
|
-
assert(pipe.recv_size == 0);
|
|
106
|
-
assert(pipe.send_size == 0);
|
|
107
|
-
assert(pipe.connection.state != .free);
|
|
108
|
-
assert(pipe.connection.state != .accepting);
|
|
109
|
-
assert(pipe.connection.state != .connecting);
|
|
110
|
-
|
|
111
|
-
assert(pipe.status == .recv);
|
|
112
|
-
pipe.status = .idle;
|
|
113
|
-
|
|
114
|
-
if (pipe.connection.state != .proxying) return;
|
|
115
|
-
|
|
116
|
-
const recv_size = result catch |err| {
|
|
117
|
-
log.warn("recv error ({d},{d}): {any}", .{
|
|
118
|
-
pipe.connection.replica_index,
|
|
119
|
-
pipe.connection.connection_index,
|
|
120
|
-
err,
|
|
121
|
-
});
|
|
122
|
-
return pipe.connection.try_close();
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
pipe.recv_size = @intCast(recv_size);
|
|
126
|
-
if (pipe.recv_size == 0) {
|
|
127
|
-
// Zero bytes means EOF.
|
|
128
|
-
return pipe.connection.try_close();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (pipe.connection.network.faults.corrupt) |corrupt| {
|
|
132
|
-
if (pipe.connection.network.prng.chance(corrupt)) {
|
|
133
|
-
switch (pipe.connection.network.prng.enum_uniform(enum { shuffle, zero })) {
|
|
134
|
-
.shuffle => {
|
|
135
|
-
log.debug("shuffling {d} bytes ({d},{d})", .{
|
|
136
|
-
pipe.recv_size,
|
|
137
|
-
pipe.connection.replica_index,
|
|
138
|
-
pipe.connection.connection_index,
|
|
139
|
-
});
|
|
140
|
-
pipe.connection.network.prng.shuffle(u8, pipe.buffer[0..pipe.recv_size]);
|
|
141
|
-
},
|
|
142
|
-
.zero => {
|
|
143
|
-
log.debug("zeroing {d} bytes ({d},{d})", .{
|
|
144
|
-
pipe.recv_size,
|
|
145
|
-
pipe.connection.replica_index,
|
|
146
|
-
pipe.connection.connection_index,
|
|
147
|
-
});
|
|
148
|
-
@memset(pipe.buffer[0..pipe.recv_size], 0);
|
|
149
|
-
},
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (pipe.connection.network.faults.delay) |delay| {
|
|
155
|
-
assert(delay.jitter_ms <= delay.time_ms);
|
|
156
|
-
const jitter_size = pipe.connection.network.prng.int_inclusive(
|
|
157
|
-
u32,
|
|
158
|
-
delay.jitter_ms,
|
|
159
|
-
);
|
|
160
|
-
const jitter_diff_ms: i32 = @as(i32, @intCast(jitter_size)) *
|
|
161
|
-
(if (pipe.connection.network.prng.boolean()) @as(i32, 1) else -1);
|
|
162
|
-
const timeout_duration_ns = @as(
|
|
163
|
-
u63,
|
|
164
|
-
@intCast(@as(i32, @intCast(delay.time_ms)) + jitter_diff_ms),
|
|
165
|
-
) * std.time.ns_per_ms;
|
|
166
|
-
log.debug("delaying {} ({d},{d})", .{
|
|
167
|
-
std.fmt.fmtDuration(timeout_duration_ns),
|
|
168
|
-
pipe.connection.replica_index,
|
|
169
|
-
pipe.connection.connection_index,
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
assert(pipe.status == .idle);
|
|
173
|
-
pipe.status = .send_timeout;
|
|
174
|
-
pipe.io.timeout(
|
|
175
|
-
*Pipe,
|
|
176
|
-
pipe,
|
|
177
|
-
timeout_callback,
|
|
178
|
-
&pipe.send_completion,
|
|
179
|
-
timeout_duration_ns,
|
|
180
|
-
);
|
|
181
|
-
} else {
|
|
182
|
-
pipe.send();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
fn timeout_callback(pipe: *Pipe, _: *IO.Completion, result: IO.TimeoutError!void) void {
|
|
187
|
-
assert(pipe.status == .send_timeout);
|
|
188
|
-
assert(pipe.connection.state != .free);
|
|
189
|
-
assert(pipe.connection.state != .accepting);
|
|
190
|
-
assert(pipe.connection.state != .connecting);
|
|
191
|
-
pipe.status = .idle;
|
|
192
|
-
|
|
193
|
-
if (pipe.connection.state != .proxying) return;
|
|
194
|
-
|
|
195
|
-
result catch @panic("timeout error");
|
|
196
|
-
pipe.send();
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
fn send(pipe: *Pipe) void {
|
|
200
|
-
assert(pipe.connection.state == .proxying);
|
|
201
|
-
assert(pipe.send_size < pipe.recv_size);
|
|
202
|
-
|
|
203
|
-
assert(pipe.status == .idle);
|
|
204
|
-
pipe.status = .send;
|
|
205
|
-
|
|
206
|
-
pipe.io.send(
|
|
207
|
-
*Pipe,
|
|
208
|
-
pipe,
|
|
209
|
-
send_callback,
|
|
210
|
-
&pipe.send_completion,
|
|
211
|
-
pipe.output.?,
|
|
212
|
-
pipe.buffer[pipe.send_size..pipe.recv_size],
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
fn send_callback(pipe: *Pipe, _: *IO.Completion, result: IO.SendError!usize) void {
|
|
217
|
-
assert(pipe.send_size < pipe.recv_size);
|
|
218
|
-
assert(pipe.connection.state != .free);
|
|
219
|
-
assert(pipe.connection.state != .accepting);
|
|
220
|
-
assert(pipe.connection.state != .connecting);
|
|
221
|
-
|
|
222
|
-
assert(pipe.status == .send);
|
|
223
|
-
pipe.status = .idle;
|
|
224
|
-
|
|
225
|
-
if (pipe.connection.state != .proxying) return;
|
|
226
|
-
|
|
227
|
-
const send_size = result catch |err| {
|
|
228
|
-
log.warn("send error ({d},{d}): {any}", .{
|
|
229
|
-
pipe.connection.replica_index,
|
|
230
|
-
pipe.connection.connection_index,
|
|
231
|
-
err,
|
|
232
|
-
});
|
|
233
|
-
return pipe.connection.try_close();
|
|
234
|
-
};
|
|
235
|
-
pipe.send_size += @intCast(send_size);
|
|
236
|
-
|
|
237
|
-
if (pipe.send_size < pipe.recv_size) {
|
|
238
|
-
pipe.send();
|
|
239
|
-
} else {
|
|
240
|
-
assert(pipe.send_size == pipe.recv_size);
|
|
241
|
-
pipe.recv();
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const Connection = struct {
|
|
247
|
-
io: *IO,
|
|
248
|
-
network: *Network,
|
|
249
|
-
state: enum {
|
|
250
|
-
free,
|
|
251
|
-
accepting,
|
|
252
|
-
connecting,
|
|
253
|
-
proxying,
|
|
254
|
-
closing,
|
|
255
|
-
closing_origin,
|
|
256
|
-
closing_remote,
|
|
257
|
-
} = .free,
|
|
258
|
-
|
|
259
|
-
replica_index: usize,
|
|
260
|
-
connection_index: usize,
|
|
261
|
-
|
|
262
|
-
origin_fd: ?std.posix.socket_t = null,
|
|
263
|
-
remote_fd: ?std.posix.socket_t = null,
|
|
264
|
-
|
|
265
|
-
origin_to_remote_pipe: Pipe,
|
|
266
|
-
remote_to_origin_pipe: Pipe,
|
|
267
|
-
|
|
268
|
-
remote_address: ?std.net.Address = null,
|
|
269
|
-
|
|
270
|
-
accept_completion: IO.Completion = undefined,
|
|
271
|
-
connect_completion: IO.Completion = undefined,
|
|
272
|
-
close_completion: IO.Completion = undefined,
|
|
273
|
-
|
|
274
|
-
fn accept_callback(
|
|
275
|
-
connection: *Connection,
|
|
276
|
-
_: *IO.Completion,
|
|
277
|
-
result: IO.AcceptError!std.posix.socket_t,
|
|
278
|
-
) void {
|
|
279
|
-
assert(connection.state == .accepting);
|
|
280
|
-
assert(connection.origin_fd == null);
|
|
281
|
-
assert(connection.remote_fd == null);
|
|
282
|
-
assert(connection.remote_address != null);
|
|
283
|
-
|
|
284
|
-
const fd = result catch |err| {
|
|
285
|
-
log.warn("accept failed ({d},{d}): {}", .{
|
|
286
|
-
connection.replica_index,
|
|
287
|
-
connection.connection_index,
|
|
288
|
-
err,
|
|
289
|
-
});
|
|
290
|
-
return connection.try_close();
|
|
291
|
-
};
|
|
292
|
-
connection.origin_fd = fd;
|
|
293
|
-
|
|
294
|
-
const remote_fd = connection.io.open_socket_tcp(
|
|
295
|
-
connection.remote_address.?.any.family,
|
|
296
|
-
tcp_options,
|
|
297
|
-
) catch |err| {
|
|
298
|
-
log.warn("couldn't open socket for remote ({d},{d}): {}", .{
|
|
299
|
-
connection.replica_index,
|
|
300
|
-
connection.connection_index,
|
|
301
|
-
err,
|
|
302
|
-
});
|
|
303
|
-
return connection.try_close();
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
connection.remote_fd = remote_fd;
|
|
307
|
-
connection.state = .connecting;
|
|
308
|
-
|
|
309
|
-
connection.io.connect(
|
|
310
|
-
*Connection,
|
|
311
|
-
connection,
|
|
312
|
-
Connection.connect_callback,
|
|
313
|
-
&connection.connect_completion,
|
|
314
|
-
connection.remote_fd.?,
|
|
315
|
-
connection.remote_address.?,
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
fn connect_callback(
|
|
320
|
-
connection: *Connection,
|
|
321
|
-
_: *IO.Completion,
|
|
322
|
-
result: IO.ConnectError!void,
|
|
323
|
-
) void {
|
|
324
|
-
assert(connection.state == .connecting);
|
|
325
|
-
assert(connection.origin_fd != null);
|
|
326
|
-
assert(connection.remote_fd != null);
|
|
327
|
-
|
|
328
|
-
result catch |err| {
|
|
329
|
-
log.warn("connect failed ({d},{d}): {}", .{
|
|
330
|
-
connection.replica_index,
|
|
331
|
-
connection.connection_index,
|
|
332
|
-
err,
|
|
333
|
-
});
|
|
334
|
-
return connection.try_close();
|
|
335
|
-
};
|
|
336
|
-
connection.state = .proxying;
|
|
337
|
-
connection.origin_to_remote_pipe.open(connection.origin_fd.?, connection.remote_fd.?);
|
|
338
|
-
connection.remote_to_origin_pipe.open(connection.remote_fd.?, connection.origin_fd.?);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
fn try_close(connection: *Connection) void {
|
|
342
|
-
assert(connection.state != .free);
|
|
343
|
-
|
|
344
|
-
if (connection.state == .closing_origin or
|
|
345
|
-
connection.state == .closing_remote) return;
|
|
346
|
-
|
|
347
|
-
const has_inflight_operations =
|
|
348
|
-
connection.origin_to_remote_pipe.status != .idle or
|
|
349
|
-
connection.remote_to_origin_pipe.status != .idle;
|
|
350
|
-
|
|
351
|
-
if (connection.state != .closing and has_inflight_operations) {
|
|
352
|
-
log.debug("try_close ({d},{d}): marking connection as closing", .{
|
|
353
|
-
connection.replica_index,
|
|
354
|
-
connection.connection_index,
|
|
355
|
-
});
|
|
356
|
-
connection.state = .closing;
|
|
357
|
-
std.posix.shutdown(connection.origin_fd.?, .both) catch |err| switch (err) {
|
|
358
|
-
error.SocketNotConnected => {},
|
|
359
|
-
else => log.warn("shutdown origin_fd ({d},{d}) failed: {}", .{
|
|
360
|
-
connection.replica_index, connection.connection_index, err,
|
|
361
|
-
}),
|
|
362
|
-
};
|
|
363
|
-
std.posix.shutdown(connection.remote_fd.?, .both) catch |err| switch (err) {
|
|
364
|
-
error.SocketNotConnected => {},
|
|
365
|
-
else => log.warn("shutdown remote_fd ({d},{d}) failed: {}", .{
|
|
366
|
-
connection.replica_index, connection.connection_index, err,
|
|
367
|
-
}),
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (has_inflight_operations) {
|
|
372
|
-
// Network.tick() will keep calling try_close().
|
|
373
|
-
assert(connection.state == .closing);
|
|
374
|
-
} else {
|
|
375
|
-
// Kick off the close sequence.
|
|
376
|
-
connection.state = .closing_origin;
|
|
377
|
-
connection.io.close(
|
|
378
|
-
*Connection,
|
|
379
|
-
connection,
|
|
380
|
-
close_origin_callback,
|
|
381
|
-
&connection.close_completion,
|
|
382
|
-
connection.origin_fd.?,
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
fn close_origin_callback(
|
|
388
|
-
connection: *Connection,
|
|
389
|
-
_: *IO.Completion,
|
|
390
|
-
result: IO.CloseError!void,
|
|
391
|
-
) void {
|
|
392
|
-
assert(connection.state == .closing_origin);
|
|
393
|
-
defer assert(connection.state == .closing_remote);
|
|
394
|
-
|
|
395
|
-
assert(connection.origin_fd != null);
|
|
396
|
-
defer assert(connection.origin_fd == null);
|
|
397
|
-
|
|
398
|
-
result catch |err| {
|
|
399
|
-
log.warn("close_origin_callback ({d},{d}) error: {any}", .{
|
|
400
|
-
connection.replica_index,
|
|
401
|
-
connection.connection_index,
|
|
402
|
-
err,
|
|
403
|
-
});
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
connection.state = .closing_remote;
|
|
407
|
-
connection.origin_fd = null;
|
|
408
|
-
connection.io.close(
|
|
409
|
-
*Connection,
|
|
410
|
-
connection,
|
|
411
|
-
close_remote_callback,
|
|
412
|
-
&connection.close_completion,
|
|
413
|
-
connection.remote_fd.?,
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
fn close_remote_callback(
|
|
418
|
-
connection: *Connection,
|
|
419
|
-
_: *IO.Completion,
|
|
420
|
-
result: IO.CloseError!void,
|
|
421
|
-
) void {
|
|
422
|
-
assert(connection.state == .closing_remote);
|
|
423
|
-
defer assert(connection.state == .free);
|
|
424
|
-
|
|
425
|
-
assert(connection.remote_fd != null);
|
|
426
|
-
defer assert(connection.remote_fd == null);
|
|
427
|
-
|
|
428
|
-
result catch |err| {
|
|
429
|
-
log.warn("close_remote_callback ({d},{d}) error: {any}", .{
|
|
430
|
-
connection.replica_index,
|
|
431
|
-
connection.connection_index,
|
|
432
|
-
err,
|
|
433
|
-
});
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
log.debug("close_remote_callback ({d},{d}): marking connection as free", .{
|
|
437
|
-
connection.replica_index,
|
|
438
|
-
connection.connection_index,
|
|
439
|
-
});
|
|
440
|
-
connection.state = .free;
|
|
441
|
-
connection.remote_fd = null;
|
|
442
|
-
connection.remote_address = null;
|
|
443
|
-
connection.origin_to_remote_pipe = .{ .io = connection.io, .connection = connection };
|
|
444
|
-
connection.remote_to_origin_pipe = .{ .io = connection.io, .connection = connection };
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
const Proxy = struct {
|
|
449
|
-
io: *IO,
|
|
450
|
-
accept_fd: std.posix.socket_t,
|
|
451
|
-
origin_address: std.net.Address, // The proxy's address.
|
|
452
|
-
remote_address: std.net.Address, // The replica's address.
|
|
453
|
-
connections: [constants.vortex.connections_count_max]Connection,
|
|
454
|
-
|
|
455
|
-
fn deinit(proxy: *Proxy) void {
|
|
456
|
-
proxy.io.close_socket(proxy.accept_fd);
|
|
457
|
-
proxy.* = undefined;
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
const tcp_options: IO.TCPOptions = .{
|
|
462
|
-
.rcvbuf = 0,
|
|
463
|
-
.sndbuf = 0,
|
|
464
|
-
.keepalive = null,
|
|
465
|
-
.user_timeout_ms = 0,
|
|
466
|
-
.nodelay = false,
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
pub const Network = struct {
|
|
470
|
-
io: *IO,
|
|
471
|
-
prng: *stdx.PRNG,
|
|
472
|
-
proxies: []Proxy,
|
|
473
|
-
faults: Faults,
|
|
474
|
-
|
|
475
|
-
pub fn listen(
|
|
476
|
-
allocator: std.mem.Allocator,
|
|
477
|
-
prng: *stdx.PRNG,
|
|
478
|
-
io: *IO,
|
|
479
|
-
replica_ports: []const u16,
|
|
480
|
-
) !*Network {
|
|
481
|
-
const network = try allocator.create(Network);
|
|
482
|
-
errdefer allocator.destroy(network);
|
|
483
|
-
|
|
484
|
-
const proxies = try allocator.alloc(Proxy, replica_ports.len);
|
|
485
|
-
errdefer allocator.free(proxies);
|
|
486
|
-
|
|
487
|
-
network.* = .{
|
|
488
|
-
.io = io,
|
|
489
|
-
.prng = prng,
|
|
490
|
-
.proxies = proxies,
|
|
491
|
-
.faults = std.mem.zeroes(Faults),
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
var proxies_initialized: usize = 0;
|
|
495
|
-
errdefer for (proxies[0..proxies_initialized]) |*proxy| proxy.deinit();
|
|
496
|
-
|
|
497
|
-
// Proxies get an unused port from the ephemeral port range (usually 32768-60999; see
|
|
498
|
-
// /proc/sys/net/ipv4/ip_local_port_range) by listening on port=0.
|
|
499
|
-
// We assume that replicas' ports are from outside of that range and cannot conflict.
|
|
500
|
-
for (proxies, replica_ports, 0..) |*proxy, replica_port, replica_index| {
|
|
501
|
-
const Address = std.net.Address;
|
|
502
|
-
const replica_address = Address.parseIp("127.0.0.1", replica_port) catch unreachable;
|
|
503
|
-
const listen_address = Address.parseIp("127.0.0.1", 0) catch unreachable;
|
|
504
|
-
const listen_fd = try io.open_socket_tcp(std.posix.AF.INET, tcp_options);
|
|
505
|
-
errdefer io.close_socket(listen_fd);
|
|
506
|
-
|
|
507
|
-
const origin_address = try io.listen(listen_fd, listen_address, .{ .backlog = 64 });
|
|
508
|
-
proxy.* = .{
|
|
509
|
-
.io = io,
|
|
510
|
-
.accept_fd = listen_fd,
|
|
511
|
-
.origin_address = origin_address,
|
|
512
|
-
.remote_address = replica_address,
|
|
513
|
-
.connections = undefined,
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
for (&proxy.connections, 0..) |*connection, connection_index| {
|
|
517
|
-
connection.* = .{
|
|
518
|
-
.io = io,
|
|
519
|
-
.network = network,
|
|
520
|
-
.state = .free,
|
|
521
|
-
.replica_index = replica_index,
|
|
522
|
-
.connection_index = connection_index,
|
|
523
|
-
.origin_to_remote_pipe = .{ .io = io, .connection = connection },
|
|
524
|
-
.remote_to_origin_pipe = .{ .io = io, .connection = connection },
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
proxies_initialized += 1;
|
|
528
|
-
|
|
529
|
-
log.debug("proxying {any} -> {any}", .{ origin_address, replica_address });
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
return network;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
pub fn destroy(network: *Network, allocator: std.mem.Allocator) void {
|
|
536
|
-
for (network.proxies) |*proxy| proxy.deinit();
|
|
537
|
-
allocator.free(network.proxies);
|
|
538
|
-
allocator.destroy(network);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
pub fn tick(network: *Network) void {
|
|
542
|
-
for (network.proxies, 0..) |*proxy, replica_index| {
|
|
543
|
-
for (&proxy.connections) |*connection| {
|
|
544
|
-
assert(connection.replica_index == replica_index);
|
|
545
|
-
|
|
546
|
-
if (connection.state == .closing) {
|
|
547
|
-
connection.try_close();
|
|
548
|
-
continue;
|
|
549
|
-
}
|
|
550
|
-
// This proxy tries to accept with connections that are free. The pipes must also
|
|
551
|
-
// have no outstanding IO submissions racing with reusing the pipes for new
|
|
552
|
-
// connections.
|
|
553
|
-
if (connection.state == .free) {
|
|
554
|
-
assert(connection.origin_to_remote_pipe.status == .idle);
|
|
555
|
-
assert(connection.remote_to_origin_pipe.status == .idle);
|
|
556
|
-
assert(connection.origin_fd == null);
|
|
557
|
-
assert(connection.remote_fd == null);
|
|
558
|
-
assert(connection.remote_address == null);
|
|
559
|
-
|
|
560
|
-
log.debug("accepting ({d},{d})", .{
|
|
561
|
-
connection.replica_index,
|
|
562
|
-
connection.connection_index,
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
connection.state = .accepting;
|
|
566
|
-
connection.remote_address = proxy.remote_address;
|
|
567
|
-
|
|
568
|
-
network.io.accept(
|
|
569
|
-
*Connection,
|
|
570
|
-
connection,
|
|
571
|
-
Connection.accept_callback,
|
|
572
|
-
&connection.accept_completion,
|
|
573
|
-
proxy.accept_fd,
|
|
574
|
-
);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const builtin = @import("builtin");
|
|
2
|
-
const std = @import("std");
|
|
3
|
-
const log = std.log;
|
|
4
|
-
const assert = std.debug.assert;
|
|
5
|
-
|
|
6
|
-
const Shell = @import("../../../shell.zig");
|
|
7
|
-
|
|
8
|
-
pub fn tests(shell: *Shell, gpa: std.mem.Allocator) !void {
|
|
9
|
-
_ = gpa;
|
|
10
|
-
|
|
11
|
-
assert(shell.file_exists("pom.xml"));
|
|
12
|
-
|
|
13
|
-
// NB: This expects the TB java driver to have been installed with `mvn install`.
|
|
14
|
-
try shell.exec("mvn --batch-mode --file pom.xml --quiet package", .{});
|
|
15
|
-
|
|
16
|
-
// NB: This expects the vortex bin to be available.
|
|
17
|
-
if (builtin.target.os.tag == .linux) {
|
|
18
|
-
const base_path = "../../../../";
|
|
19
|
-
const vortex_bin = base_path ++ "zig-out/bin/vortex";
|
|
20
|
-
const class_path_driver = base_path ++
|
|
21
|
-
"src/clients/java/target/tigerbeetle-java-0.0.1-SNAPSHOT.jar";
|
|
22
|
-
const class_path = class_path_driver ++ ":" ++ base_path ++
|
|
23
|
-
"src/testing/vortex/java_driver/target/vortex-driver-java-0.0.1-SNAPSHOT.jar";
|
|
24
|
-
const driver_command = "java -cp " ++ class_path ++ " Main";
|
|
25
|
-
try shell.exec(
|
|
26
|
-
"{vortex_bin} " ++
|
|
27
|
-
"supervisor --driver-command={driver_command} " ++
|
|
28
|
-
"--replica-count=1 " ++
|
|
29
|
-
"--disable-faults " ++
|
|
30
|
-
"--test-duration=1s",
|
|
31
|
-
.{
|
|
32
|
-
.vortex_bin = vortex_bin,
|
|
33
|
-
.driver_command = driver_command,
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
} else {
|
|
37
|
-
log.warn("Not testing vortex java on OS {}", .{builtin.target.os.tag});
|
|
38
|
-
}
|
|
39
|
-
}
|