private refillTotalBucket()

in src/eventBucketThrottle.ts [52:69]


    private refillTotalBucket() {
        const now = Math.floor(Date.now() / 1000);

        this.totalLastFilled = typeof this.totalLastFilled === "undefined" ? now : this.totalLastFilled;

        // We've already divided by 1000, so this timeDelta will represent
        // the number of seconds elapsed since the last time the method was called
        const timeDelta = now - this.totalLastFilled;

        // If we somehow calculate incorrectly the bucket size as something
        // over what the potential capacity could be we default to the maxiumum
        // bucket size
        this.totalBucketSize = Math.min(
            this.totalCapacity,
            this.totalBucketSize + Math.floor(timeDelta * this.fillPerSecond)
        );
        this.totalLastFilled = now;
    }