BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Sandpiper · Schedule redelivery after a lease expires

Schedule a deterministic redelivery after both lease expiry and retry backoff.

Schedule redelivery after a lease expires

Redelivery before a worker's lease expires can duplicate work. Make retry time depend on both the lease and the attempt count. The eight-tick lease ends at tick 18. A four-tick backoff makes tick 22 the earliest eligible retry.

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-sandpiper.git
cd blyx-sandpiper
blyxc native-run project.blyx -- 10 8 19 2 16 1

API and return values

Returns [ready, ticks to eligibility, retry delay]. Delay begins when the lease expires. The queue host owns acknowledgement and delivery. Invalid input returns an empty vector.

ArgumentAccepted input
issuednonnegative exact integer
ttlpositive exact integer
nownonnegative exact integer
basepositive exact integer
ceilingpositive exact integer
attemptnonnegative 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
0
3
4
Open in the full playground →

Practice

Change now = 22.0. Predict the result, then run the program.

Hint

Returns [ready, ticks to eligibility, retry delay]. Delay begins when the lease expires. The queue host owns acknowledgement and delivery.

Worked solution

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

Find

    let now = 19.0;

Replace with

    let now = 22.0;

Output after the change

1
0
4