Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-ng committed Nov 23, 2020
1 parent fd674fc commit 7a58f71
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ chance to access the resource in the FIFO order.
### Limiter with Timeout

```go
nl := limiter.New(3).WithTimeout(10)
nl := limiter.New(3,
WithTimeout(10),
)
nl.Wait()
Execute......
nl.Finish()
Expand All @@ -48,7 +50,9 @@ given the maximum preference because it is of high priority. In the case of tie
### Priority Limiter with Dynamic priority

```go
nl := priority.NewLimiter(3).WithDynamicPriority(5)
nl := priority.NewLimiter(3,
WithDynamicPriority(5),
)
nl.Wait(priority.Low)
Execute......
nl.Finish()
Expand All @@ -58,7 +62,9 @@ In Dynamic Priority Limiter , the goroutines with lower priority will get their
### Priority Limiter with Timeout

```go
nl := priority.NewLimiter(3).WithTimeout(30)
nl := priority.NewLimiter(3,
WithTimeout(30),
)
nl.Wait(constants.High)
Execute......
nl.Finish()
Expand Down
6 changes: 4 additions & 2 deletions priority/priorityRateLimiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func TestPriorityLimiter(t *testing.T) {

func TestDynamicPriority(t *testing.T) {
nl := NewLimiter(3,
WithDynamicPriority(10))
WithDynamicPriority(10),
)
var wg sync.WaitGroup
wg.Add(5)
for i := 0; i < 5; i++ {
Expand All @@ -61,7 +62,8 @@ func TestDynamicPriority(t *testing.T) {

func TestPriorityLimiter_Timeout(t *testing.T) {
nl := NewLimiter(3,
WithTimeout(100))
WithTimeout(100),
)
var wg sync.WaitGroup
wg.Add(5)
for i := 0; i < 5; i++ {
Expand Down
3 changes: 2 additions & 1 deletion rateLimiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ func TestConcurrentRateLimiterBlocking(t *testing.T) {

func TestConcurrentRateLimiterTimeout(t *testing.T) {
l := New(2,
WithTimeout(300))
WithTimeout(300),
)

var wg sync.WaitGroup
wg.Add(5)
Expand Down

0 comments on commit 7a58f71

Please sign in to comment.