PHPackages                             nadylib/leaky-bucket - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nadylib/leaky-bucket

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nadylib/leaky-bucket
====================

An fiber-based implementation of the LeakyBucket algorithm

0.1.0(2y ago)034.6k1AGPL-3.0-or-laterPHPPHP &gt;=8.1.17

Since Apr 28Pushed 2y agoCompare

[ Source](https://github.com/Nadybot/leaky-bucket)[ Packagist](https://packagist.org/packages/nadylib/leaky-bucket)[ RSS](/packages/nadylib-leaky-bucket/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependencies (8)Versions (2)Used By (1)

leaky-bucket
============

[](#leaky-bucket)

[![PHP Tests passing or not](https://github.com/nadybot/leaky-bucket/actions/workflows/php.yml/badge.svg)](https://github.com/Nadybot/leaky-bucket/actions/workflows/php.yml)

An async Leaky Bucket implementation using the Revolt EventLoop

Usage
-----

[](#usage)

```
use Nadylib\LeakyBucket\LeakyBucket;

$bucket = new Nadylib\LeakyBucket\LeakyBucket(
	size: 5,
	refillDelay: 1.0,
	refillAmount: 1
);
```

There is only 1 function of interest: `LeakyBucket::take()`:

```
use Nadylib\LeakyBucket\LeakyBucket;

$bucket = new Nadylib\LeakyBucket\LeakyBucket(
	size: 5,
	refillDelay: 1.0,
	refillAmount: 1
);
for ($i = 1; $i take(1);
	$time = (new DateTimeImmutable())->format("H:i:s.v");
	echo("[{$time}] Taken.\n");
}
```

The first 5 takes will take immediately, while 6 and 7 take 1s each. There is no sleep involved, just async fibers, so this is absolutely safe to use.

```
use Nadylib\LeakyBucket\LeakyBucket;
use Revolt\EventLoop;

$bucket = new Nadylib\LeakyBucket\LeakyBucket(
	size: 5,
	refillDelay: 1.0,
	refillAmount: 1
);
for ($i = 1; $i take(callback: function() {
		$time = (new DateTimeImmutable())->format("H:i:s.v");
		echo("[{$time}] Taken.\n");
	});
}
EventLoop::run();
```

This will behave exactly the same, but the call to `$bucket->take()` will always return immediately.

When using the callback version, make sure to call `EventLoop::run()` at the end, because the main fiber/thread is never suspended, but always returns immediately, so you have to make sure the event loop finishes its work. In a real world environment, this will not be necessary, because your code will run in a global event loop anyway.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

798d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/43058421?v=4)[Nadyita](/maintainers/Nadyita)[@Nadyita](https://github.com/Nadyita)

---

Top Contributors

[![Nadyita](https://avatars.githubusercontent.com/u/43058421?v=4)](https://github.com/Nadyita "Nadyita (19 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nadylib-leaky-bucket/health.svg)

```
[![Health](https://phpackages.com/badges/nadylib-leaky-bucket/health.svg)](https://phpackages.com/packages/nadylib-leaky-bucket)
```

###  Alternatives

[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

514139.2M693](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k53](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
