Registry / Framework

framework · v0.1.2
Replica Promote
Fence a replica promotion against its required log offset before announcing a new primary.
Use Replica Promote
use vendor::replica_promote::replica_promote;
Run the example
nest demo replica_promote@0.1.2
blyxc native-run replica_promote-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::replica_promote::replica_promote;
fn main() {
let arguments = cli_args();
if args_len(arguments) > 0 {
if args_len(arguments) % 2 != 0 {
stderr_line("Expected event and value pairs");
process_exit(2);
}
let mut live = replica_promote_start();
let mut i = 0;
while i < args_len(arguments) {
let input = args_at(arguments, i + 1);
if !text_is_number(input) {
stderr_line("Expected a whole numeric event value");
process_exit(2);
}
live = replica_promote_step(live, args_at(arguments, i), text_number(input));
let command = replica_promote_command(live);
println!(command);
if command == "reject" { process_exit(1); }
i += 2;
}
return;
}
let mut state = replica_promote_start();
state = replica_promote_step(state, "target", 100.0);
println!(replica_promote_command(state));
state = replica_promote_step(state, "lag", 80.0);
println!(replica_promote_command(state));
state = replica_promote_step(state, "replayed", 101.0);
println!(replica_promote_command(state));
state = replica_promote_step(state, "confirmed", 100.0);
println!(replica_promote_command(state));
state = replica_promote_step(state, "confirmed", 101.0);
println!(replica_promote_command(state));
state = replica_promote_step(state, "advertise", 101.0);
println!(replica_promote_command(state));
}
Expected output
poll_replica
wait_for_log
fence_old_primary
reject
enable_writes
update_routes
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | 1304493496 | 9dc520df131c67cda2dc7b3b7e841089beebcc6837b78a8802263d1b3626beaf |
| 0.1.1 | Download ZIP · Browse files | bdfff7d2c4 | 4ba898a274a60844f42aa9eb35b7840bfb98312e5687ff4008b397be91319121 |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | ae6c2d0d812fb7fcddda53a2c06b92da0beccb4d2fb097b30f074b276baa69c7 |