A retry helper maps observed failures into a bounded plan.

Retry Plan

retry_plan.cpp
#include <iostream>

struct RetryPlan {
    int attempts;
    int delay;
};

RetryPlan planRetries(int failures) {
    if (failures == 0) {
        return {1, 0};
    }
    if (failures < 3) {
        return {3, 5};
    }
    return {5, 10};
}

int main() {
    int failures = ;

    RetryPlan plan = planRetries(failures);
    int totalDelay = plan.attempts * plan.delay;

    std::cout << "failures=" << failures << std::endl;
    std::cout << "attempts=" << plan.attempts << std::endl;
    std::cout << "totalDelay=" << totalDelay << std::endl;
    return 0;
}
#include <iostream>

struct RetryPlan {
    int attempts;
    int delay;
};

RetryPlan planRetries(int failures) {
    if (failures == 0) {
        return {1, 0};
    }
    if (failures < 3) {
        return {3, 5};
    }
    return {5, 10};
}

int main() {
    int failures = ;

    RetryPlan plan = planRetries(failures);
    int totalDelay = plan.attempts * plan.delay;

    std::cout << "failures=" << failures << std::endl;
    std::cout << "attempts=" << plan.attempts << std::endl;
    std::cout << "totalDelay=" << totalDelay << std::endl;
    return 0;
}
#include <iostream>

struct RetryPlan {
    int attempts;
    int delay;
};

RetryPlan planRetries(int failures) {
    if (failures == 0) {
        return {1, 0};
    }
    if (failures < 3) {
        return {3, 5};
    }
    return {5, 10};
}

int main() {
    int failures = ;

    RetryPlan plan = planRetries(failures);
    int totalDelay = plan.attempts * plan.delay;

    std::cout << "failures=" << failures << std::endl;
    std::cout << "attempts=" << plan.attempts << std::endl;
    std::cout << "totalDelay=" << totalDelay << std::endl;
    return 0;
}
plan A small result struct can carry related decisions back to the caller.
bounds Bounded retry plans keep a workflow predictable and easy to trace.