leakybucket

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Reference uber ratelimit, the different is support no wait take func

Package leakybucket is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLimiter

func NewLimiter(client *redis.Client) *leakyBucketLimiter

Types

type LeakyBucket

type LeakyBucket interface {
	Allow(ctx context.Context, key string, requestCount int) (bool, error)
	SetLimit(rate int)
	SetBurst(burst int)
}

func NewLeakyBucket

func NewLeakyBucket(rate, volume int, client *redis.Client, opts ...Option) LeakyBucket

type MockLeakyBucket

type MockLeakyBucket struct {
	// contains filtered or unexported fields
}

MockLeakyBucket is a mock of LeakyBucket interface.

func NewMockLeakyBucket

func NewMockLeakyBucket(ctrl *gomock.Controller) *MockLeakyBucket

NewMockLeakyBucket creates a new mock instance.

func (*MockLeakyBucket) Allow

func (m *MockLeakyBucket) Allow(ctx context.Context, key string, requestCount int) (bool, error)

Allow mocks base method.

func (*MockLeakyBucket) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockLeakyBucket) SetBurst

func (m *MockLeakyBucket) SetBurst(burst int)

SetBurst mocks base method.

func (*MockLeakyBucket) SetLimit

func (m *MockLeakyBucket) SetLimit(rate int)

SetLimit mocks base method.

type MockLeakyBucketMockRecorder

type MockLeakyBucketMockRecorder struct {
	// contains filtered or unexported fields
}

MockLeakyBucketMockRecorder is the mock recorder for MockLeakyBucket.

func (*MockLeakyBucketMockRecorder) Allow

func (mr *MockLeakyBucketMockRecorder) Allow(ctx, key, requestCount interface{}) *gomock.Call

Allow indicates an expected call of Allow.

func (*MockLeakyBucketMockRecorder) SetBurst

func (mr *MockLeakyBucketMockRecorder) SetBurst(burst interface{}) *gomock.Call

SetBurst indicates an expected call of SetBurst.

func (*MockLeakyBucketMockRecorder) SetLimit

func (mr *MockLeakyBucketMockRecorder) SetLimit(rate interface{}) *gomock.Call

SetLimit indicates an expected call of SetLimit.

type Option

type Option func(o *option)

func WithClock

func WithClock(clock clock.Clock) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL