Spend a permit budget against a fixed capacity and turn the granted and denied counts into a spend, drain, or throttle remediation action.

Semaphore Budget Remediation Report

SemaphoreBudgetRemediationReport.cs
using System;

class Program
{
    static void Main()
    {
        int requests = ;
        int capacity = 2;
        int granted = 0;
        int denied = 0;

        for (int i = 0; i < requests; i++)
        {
            if (granted < capacity)
            {
                granted++;
            }
            else
            {
                denied++;
            }
        }
        int spare = capacity - granted;

        string action;
        if (denied > 0)
        {
            action = "throttle";
        }
        else if (spare == 0)
        {
            action = "drain";
        }
        else
        {
            action = "spend";
        }

        Console.WriteLine("requests=" + requests + " granted=" + granted + " denied=" + denied + " " + action);
    }
}
using System;

class Program
{
    static void Main()
    {
        int requests = ;
        int capacity = 2;
        int granted = 0;
        int denied = 0;

        for (int i = 0; i < requests; i++)
        {
            if (granted < capacity)
            {
                granted++;
            }
            else
            {
                denied++;
            }
        }
        int spare = capacity - granted;

        string action;
        if (denied > 0)
        {
            action = "throttle";
        }
        else if (spare == 0)
        {
            action = "drain";
        }
        else
        {
            action = "spend";
        }

        Console.WriteLine("requests=" + requests + " granted=" + granted + " denied=" + denied + " " + action);
    }
}
using System;

class Program
{
    static void Main()
    {
        int requests = ;
        int capacity = 2;
        int granted = 0;
        int denied = 0;

        for (int i = 0; i < requests; i++)
        {
            if (granted < capacity)
            {
                granted++;
            }
            else
            {
                denied++;
            }
        }
        int spare = capacity - granted;

        string action;
        if (denied > 0)
        {
            action = "throttle";
        }
        else if (spare == 0)
        {
            action = "drain";
        }
        else
        {
            action = "spend";
        }

        Console.WriteLine("requests=" + requests + " granted=" + granted + " denied=" + denied + " " + action);
    }
}
budget capacity The permit capacity and budget are scalars, so the granted and denied counts that drive the remediation action stay deterministic and free of semaphore identity.