Skip to content

cha0ran/bucket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

package main

import (
	"fmt"
	"github.com/cha0ran/bucket"
	"sync"
	"time"
)

func main() {
	var wg sync.WaitGroup
	b := bucket.NewBucket(time.Minute, 60, 1, false)
	defer b.Close()

	for i := 0; i < 100; i++ {
		wg.Add(1)
		go func(taskId int) {
			defer wg.Done()
			b.Take()
			fmt.Printf("Task number: %d", taskId)
		}(i)
	}

	wg.Wait()
}

About

A simple token bucket.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages