BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Martin · Fit a retry into an RPC deadline

Decide whether another RPC attempt fits the remaining end-to-end deadline.

Fit a retry into an RPC deadline

Resetting a timeout at each hop lets a retry outlive its caller. Subtract already-spent time and the coming backoff. Fifty ticks have elapsed and ten are reserved for backoff. An idempotent retry has forty ticks available.

Run the framework with your own input

Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-martin.git
cd blyx-martin
blyxc native-run project.blyx -- 100 "20,30" 10 35 14 1 1 3

API and return values

Returns [retry now or after wait, attempt budget after wait, attempts left]. The minimum is the shortest useful child duration. Invalid input returns an empty vector.

ArgumentAccepted input
budgetnonnegative finite number
stagesVector of: nonnegative finite number
waitnonnegative finite number
minimumpositive finite number
statusnonnegative exact integer
idempotentnonnegative exact integer
attemptsnonnegative exact integer
limitpositive exact integer

Use the libraries independently

The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.

Try the program

Output Ready
Expected output
1
40
2
Open in the full playground →

Practice

Change budget = 60.0, stages = [50], wait = 8.0, minimum = 5.0. Predict the result, then run the program.

Hint

Returns [retry now or after wait, attempt budget after wait, attempts left]. The minimum is the shortest useful child duration.

Worked solution

The result vector is [0, 2, 2]. Compare its fields with the return layout in the API section.

Find

    let budget = 100.0;

Replace with

    let budget = 60.0;

Find

    let stages = [20, 30];

Replace with

    let stages = [50];

Find

    let wait = 10.0;

Replace with

    let wait = 8.0;

Find

    let minimum = 35.0;

Replace with

    let minimum = 5.0;

Output after the change

0
2
2