ratelimit

package
v5.1.15+incompatible Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimitReader

type RateLimitReader struct {
	Reader  io.Reader
	Limiter *RateLimiter
}

func NewRateLimitReader

func NewRateLimitReader(reader io.Reader, capacity, rate int64) *RateLimitReader

func NewRateLimitReaderWithLimiter

func NewRateLimitReaderWithLimiter(reader io.Reader, limiter *RateLimiter) *RateLimitReader

func (*RateLimitReader) Read

func (rlr *RateLimitReader) Read(p []byte) (n int, err error)

type RateLimitReaderV2

type RateLimitReaderV2 struct {
	Reader  io.Reader
	Limiter *RateLimiter
}

func NewRateLimitReaderV2

func NewRateLimitReaderV2(reader io.Reader, capacity, rate int64) *RateLimitReaderV2

func NewRateLimitReaderWithLimiterV2

func NewRateLimitReaderWithLimiterV2(reader io.Reader, limiter *RateLimiter) *RateLimitReaderV2

func (*RateLimitReaderV2) Read

func (rlr *RateLimitReaderV2) Read(p []byte) (n int, err error)

func (*RateLimitReaderV2) Reset

func (rlr *RateLimitReaderV2) Reset() error

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(capacity, rate int64) *RateLimiter

func (*RateLimiter) Acquire

func (rl *RateLimiter) Acquire(permits int64) int64

func (*RateLimiter) SetCapacity

func (rl *RateLimiter) SetCapacity(newCapacity int64)

func (*RateLimiter) SetCapacityAndRate

func (rl *RateLimiter) SetCapacityAndRate(newCapacity, newRate int64)

func (*RateLimiter) SetRate

func (rl *RateLimiter) SetRate(newRate int64)

Jump to

Keyboard shortcuts

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