Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ThrottleCallback ¶
type ThrottleItem ¶
type ThrottleItem[T any] struct { // contains filtered or unexported fields }
func (*ThrottleItem[T]) Submit ¶
func (i *ThrottleItem[T]) Submit(ctx context.Context, item T)
type Throttler ¶
func New ¶
func New[T any](callback ThrottleCallback[T], releaseInterval time.Duration) *Throttler[T]
func (*Throttler[T]) Submit ¶
Submit will perform the callback immediately if no items of the given key have been processed in recent time. Otherwise, it will throttle the item and only execute it after releaseInterval has passed since the previous item. If new items come in with that key before releaseInterval, then the time at which they will all be released will be postponed accordingly.
Click to show internal directories.
Click to hide internal directories.