Documentation
¶
Overview ¶
Package ncrated is [rated] package for nctask and ncaction.
Example ¶
t := func() error { return nil }
timed := nctask.Task(t).Timed(time.Second)
rl := Task(rate.NewLimiter(rate.Every(time.Second), 1), t)
begin := time.Now()
timed.Run() // run t, wait a second
timed.Run() // run t, wait a second
timed.Run() // run t, wait a second
fmt.Printf("timed task: elapsed %d seconds\n", time.Since(begin)/time.Second)
begin = time.Now()
rl.Run() // run t
rl.Run() // wait a second, run t
rl.Run() // wait a second, run t
fmt.Printf("ratelimited task: elapsed %d seconds\n", time.Since(begin)/time.Second)
Output: timed task: elapsed 3 seconds ratelimited task: elapsed 2 seconds
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Data ¶
Data creates an ncaction.Data that respects the rate limit, quite like Task.
There's no rate limited ncaction.Action or ncaction.Converter. For actions, rate limit should be applied on resulted task. For converters, it should be applied on resulted data.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.