Files
lo/docs/data/core-newthrottlebywithcount.md
T
2025-10-06 19:59:26 +02:00

879 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
NewThrottleByWithCount newthrottlebywithcount retry.go#L377 core concurrency https://go.dev/play/p/vQk3ECH7_EW
core#concurrency#newthrottlebywithcount
core#concurrency#newthrottle
core#concurrency#newthrottleby
core#concurrency#newthrottlewithcount
core#concurrency#newdebounce
core#concurrency#newdebounceby
100
func NewThrottleByWithCount[T comparable](interval time.Duration, count int, f ...func(key T)) (throttle func(key T), reset func())

Creates a throttled function per key with a per-interval invocation limit.

throttle, reset := lo.NewThrottleByWithCount[string](
    100*time.Millisecond,
    3,
    func(key string) {
        println(key)
    },
)

for i := 0; i < 10; i++ {
    throttle("foo")
}

reset()