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

Embargo Clock

Release an embargoed story only after its scheduled timestamp and support postponement.

Source repository · Package JSON

Use Embargo Clock

use vendor::embargo_clock::embargo_clock;

Run the example

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

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 = embargo_clock_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 = embargo_clock_step(live, args_at(arguments, i), text_number(input));
            let command = embargo_clock_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = embargo_clock_start();
    state = embargo_clock_step(state, "schedule", 60.0);
    println!(embargo_clock_command(state));
    state = embargo_clock_step(state, "tick", 55.0);
    println!(embargo_clock_command(state));
    state = embargo_clock_step(state, "postpone", 80.0);
    println!(embargo_clock_command(state));
    state = embargo_clock_step(state, "tick", 80.0);
    println!(embargo_clock_command(state));
}

Expected output

store_deadline
wait
replace_deadline
release

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse filesd72fac755816e3110106bd0bb3b4ac5e4803d83b45f68b7eeee0642380415d59b720e7038a
0.1.1Download ZIP · Browse files797c3e47e087f15a18f2de7b627bd7ca6f84050e6ede89f79a52d2245929f90951b2252eba
0.1.0Download ZIP · Browse files6349f23784c183c996736470cc2fcd61034db1d2ca720a8b0131c3422407ec14e00f5fa4aa