Blyx Nest Blyx language
Registry / Framework
framework · v0.1.2

Snapshot Fence

Buffer changes during snapshot export and release the change feed only at a matching snapshot fence.

Source repository · Package JSON

Use Snapshot Fence

use vendor::snapshot_fence::snapshot_fence;

Run the example

nest demo snapshot_fence@0.1.2
blyxc native-run snapshot_fence-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::snapshot_fence::snapshot_fence;

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 = snapshot_fence_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 = snapshot_fence_step(live, args_at(arguments, i), text_number(input));
            let command = snapshot_fence_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = snapshot_fence_start();
    state = snapshot_fence_step(state, "capture", 20.0);
    println!(snapshot_fence_command(state));
    state = snapshot_fence_step(state, "change", 19.0);
    println!(snapshot_fence_command(state));
    state = snapshot_fence_step(state, "change", 21.0);
    println!(snapshot_fence_command(state));
    state = snapshot_fence_step(state, "sealed", 20.0);
    println!(snapshot_fence_command(state));
    state = snapshot_fence_step(state, "applied", 21.0);
    println!(snapshot_fence_command(state));
}

Expected output

record_fence
covered_by_snapshot
buffer_change
drain_buffer
resume_tail

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse filesf6092d7b209883d9693b431d8609a96147f4a7869b1f4db583750284f273ed3344f81b705d
0.1.1Download ZIP · Browse files421441eb1fe6e6b38edd23f293b24a9a7e478424b38f51549ec4c2b36ecc0e5ba7a50f5d6b
0.1.0Download ZIP · Browse files6349f237849868279321a8876b6e06d765801a58721d3a0103ee3c36e4191edcdd9950f2f8