Documentation ¶
Overview ¶
Example ¶
const firstGroup = "firstGroup" const secondGroup = "secondGroup" rl := New(1000, WithoutSlack()). AddGroup(firstGroup, 100, WithoutSlack()). AddGroup(secondGroup, 200, WithoutSlack()) ch1 := make(chan string, 10) ch2 := make(chan string, 10) var wg sync.WaitGroup wg.Add(2) ctx := context.Background() go func() { defer wg.Done() prev := time.Now() for i := 0; i < 5; i++ { now := rl.Take(ctx, firstGroup) if i != 0 { ch1 <- now.Sub(prev).String() } prev = now } }() go func() { defer wg.Done() prev := time.Now() for i := 0; i < 5; i++ { now := rl.Take(ctx, secondGroup) if i != 0 { ch2 <- now.Sub(prev).String() } prev = now } }() wg.Wait() close(ch1) close(ch2) for v := range ch1 { fmt.Println(v) } for v := range ch2 { fmt.Println(v) }
Output: 10ms 10ms 10ms 10ms 5ms 5ms 5ms 5ms
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.