Skip to content

Commit 7ca0130

Browse files
authored
Make token bucket diagram a bit more clear (#25)
1 parent 33060bb commit 7ca0130

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,21 @@ limiter, err := rate.NewTokenBucketLimiter(
154154
The token bucket algorithm uses a simple metaphor of a bucket that holds tokens:
155155

156156
```
157-
┌─────────────────────────┐
158-
│ │
159-
│ ┌───┐ ┌───┐ ┌───┐ │
160-
│ │ T │ │ T │ │ T │ │ ← Tokens in bucket (current: 3)
161-
│ └───┘ └───┘ └───┘ │
162-
│ │ ← Empty space (burst capacity: 10)
163-
│ │
164-
└─────────────────────────┘
157+
┌─────────────────────────────────────┐
158+
│ │
159+
│ ┌───┐ ┌───┐ ┌───┐ ┌ ┐ ┌ ┐ │
160+
│ │ T │ │ T │ │ T │ │ │ │ │ │
161+
│ └───┘ └───┘ └───┘ └ ┘ └ ┘ │
162+
│ ↑ ↑ ↑ │
163+
│ avail avail avail │
164+
│ │
165+
│ Available: 3 tokens │ Capacity: 5 │
166+
└─────────────────────────────────────┘
165167
166168
│ Refill rate: 100 tokens/second
167169
168170
┌───┐ ┌───┐
169-
│ T │ │ T │ ... ← New tokens added at constant rate
171+
│ T │ │ T │ ... ← New tokens added at constant rate
170172
└───┘ └───┘
171173
```
172174

0 commit comments

Comments
 (0)