Registry / Framework

framework · v0.1.2
Savepoint Batch
Control a nested transaction using a savepoint depth and reject outer commit before nested scopes close.
Use Savepoint Batch
use vendor::savepoint_batch::savepoint_batch;
Run the example
nest demo savepoint_batch@0.1.2
blyxc native-run savepoint_batch-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::savepoint_batch::savepoint_batch;
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 = savepoint_batch_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 = savepoint_batch_step(live, args_at(arguments, i), text_number(input));
let command = savepoint_batch_command(live);
println!(command);
if command == "reject" { process_exit(1); }
i += 2;
}
return;
}
let mut state = savepoint_batch_start();
state = savepoint_batch_step(state, "begin", 0.0);
println!(savepoint_batch_command(state));
state = savepoint_batch_step(state, "save", 0.0);
println!(savepoint_batch_command(state));
state = savepoint_batch_step(state, "commit", 0.0);
println!(savepoint_batch_command(state));
state = savepoint_batch_step(state, "rewind", 0.0);
println!(savepoint_batch_command(state));
state = savepoint_batch_step(state, "commit", 0.0);
println!(savepoint_batch_command(state));
}
Expected output
open_transaction
create_savepoint
reject
rollback_savepoint
commit_transaction
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | 6bacabeb67 | 72f7d81935de2ad4159234fe03ee6e3da34dbbd7e49c0bc268d4fbcb1bf6b606 |
| 0.1.1 | Download ZIP · Browse files | 8e05ba28f9 | 7b8ba07820b3cd988616a0debfaea0fcee3231a1b45fb1f13a4abbdb4b996912 |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | baa53c33f7425c3bb7358a255fb7ed45bcb1bb73e6b1e8571990612dad95543f |