tps

package
v1.3.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package filter is a generated GoMock package.

  • Licensed to the Apache Software Foundation (ASF) under one or more
  • contributor license agreements. See the NOTICE file distributed with
  • this work for additional information regarding copyright ownership.
  • The ASF licenses this file to You 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.

Package filter is a generated GoMock package.

Index

Constants

View Source
const (
	FixedWindowKey = "fixedWindow"
)

Variables

This section is empty.

Functions

func GetMethodServiceTpsLimiter

func GetMethodServiceTpsLimiter() filter.TpsLimiter

Types

type FixedWindowTpsLimitStrategyImpl

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

*

  • It's the same as default implementation in Java
  • It's not a thread-safe implementation.
  • It you want to use the thread-safe implementation, please use ThreadSafeFixedWindowTpsLimitStrategyImpl
  • This is the default implementation. *
  • "UserProvider":
  • registry: "hangzhouzk"
  • protocol : "dubbo"
  • interface : "com.ikurento.user.UserProvider"
  • ... # other configuration
  • tps.limiter: "method-service" # the name of limiter
  • tps.limit.strategy: "default" or "fixedWindow" # service-level
  • methods:
  • - name: "GetUser"
  • tps.interval: 3000
  • tps.limit.strategy: "default" or "fixedWindow" # method-level

func (*FixedWindowTpsLimitStrategyImpl) IsAllowable

func (impl *FixedWindowTpsLimitStrategyImpl) IsAllowable() bool

type MethodServiceTpsLimiterImpl

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

*

  • This implementation allows developer to config both method-level and service-level tps limiter.
  • for example:
  • "UserProvider":
  • registry: "hangzhouzk"
  • protocol : "dubbo"
  • interface : "com.ikurento.user.UserProvider"
  • ... # other configuration
  • tps.limiter: "method-service" or "default" # the name of MethodServiceTpsLimiterImpl. It's the default limiter too.
  • tps.limit.interval: 5000 # interval, the time unit is ms
  • tps.limit.rate: 300 # the max value in the interval. <0 means that the service will not be limited.
  • methods:
  • - name: "GetUser"
  • tps.interval: 3000
  • tps.limit.rate: 20, # in this case, this configuration in service-level will be ignored.
  • - name: "UpdateUser"
  • tps.limit.rate: -1, # If the rate<0, the method will be ignored * *
  • More examples:
  • case1:
  • "UserProvider":
  • registry: "hangzhouzk"
  • protocol : "dubbo"
  • interface : "com.ikurento.user.UserProvider"
  • ... # other configuration
  • tps.limiter: "method-service" or "default" # the name of MethodServiceTpsLimiterImpl. It's the default limiter too.
  • tps.limit.interval: 5000 # interval, the time unit is ms
  • tps.limit.rate: 300 # the max value in the interval. <0 means that the service will not be limited.
  • methods:
  • - name: "GetUser"
  • - name: "UpdateUser"
  • tps.limit.rate: -1,
  • in this case, the method UpdateUser will be ignored,
  • which means that only GetUser will be limited by service-level configuration. *
  • case2:
  • "UserProvider":
  • registry: "hangzhouzk"
  • protocol : "dubbo"
  • interface : "com.ikurento.user.UserProvider"
  • ... # other configuration
  • tps.limiter: "method-service" or "default" # the name of MethodServiceTpsLimiterImpl. It's the default limiter too.
  • tps.limit.interval: 5000 # interval, the time unit is ms
  • tps.limit.rate: 300 # the max value in the interval. <0 means that the service will not be limited.
  • methods:
  • - name: "GetUser"
  • - name: "UpdateUser"
  • tps.limit.rate: 30,
  • In this case, the GetUser will be limited by service-level configuration(300 times in 5000ms),
  • but UpdateUser will be limited by its configuration (30 times in 60000ms) *
  • case3:
  • "UserProvider":
  • registry: "hangzhouzk"
  • protocol : "dubbo"
  • interface : "com.ikurento.user.UserProvider"
  • ... # other configuration
  • tps.limiter: "method-service" or "default" # the name of MethodServiceTpsLimiterImpl. It's the default limiter too.
  • methods:
  • - name: "GetUser"
  • - name: "UpdateUser"
  • tps.limit.rate: 70,
  • tps.limit.interval: 40000
  • In this case, only UpdateUser will be limited by its configuration (70 times in 40000ms)

func (MethodServiceTpsLimiterImpl) IsAllowable

func (limiter MethodServiceTpsLimiterImpl) IsAllowable(url common.URL, invocation protocol.Invocation) bool

type MockTpsLimitStrategy

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

MockTpsLimitStrategy is a mock of TpsLimitStrategy interface

func NewMockTpsLimitStrategy

func NewMockTpsLimitStrategy(ctrl *gomock.Controller) *MockTpsLimitStrategy

NewMockTpsLimitStrategy creates a new mock instance

func (*MockTpsLimitStrategy) EXPECT

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

func (*MockTpsLimitStrategy) IsAllowable

func (m *MockTpsLimitStrategy) IsAllowable() bool

IsAllowable mocks base method

type MockTpsLimitStrategyMockRecorder

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

MockTpsLimitStrategyMockRecorder is the mock recorder for MockTpsLimitStrategy

func (*MockTpsLimitStrategyMockRecorder) IsAllowable

func (mr *MockTpsLimitStrategyMockRecorder) IsAllowable() *gomock.Call

IsAllowable indicates an expected call of IsAllowable

type MockTpsLimiter

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

MockTpsLimiter is a mock of TpsLimiter interface

func NewMockTpsLimiter

func NewMockTpsLimiter(ctrl *gomock.Controller) *MockTpsLimiter

NewMockTpsLimiter creates a new mock instance

func (*MockTpsLimiter) EXPECT

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

func (*MockTpsLimiter) IsAllowable

func (m *MockTpsLimiter) IsAllowable(arg0 common.URL, arg1 protocol.Invocation) bool

IsAllowable mocks base method

type MockTpsLimiterMockRecorder

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

MockTpsLimiterMockRecorder is the mock recorder for MockTpsLimiter

func (*MockTpsLimiterMockRecorder) IsAllowable

func (mr *MockTpsLimiterMockRecorder) IsAllowable(arg0, arg1 interface{}) *gomock.Call

IsAllowable indicates an expected call of IsAllowable

type SlidingWindowTpsLimitStrategyImpl

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

*

  • it's thread-safe.
  • "UserProvider":
  • registry: "hangzhouzk"
  • protocol : "dubbo"
  • interface : "com.ikurento.user.UserProvider"
  • ... # other configuration
  • tps.limiter: "method-service" # the name of limiter
  • tps.limit.strategy: "slidingWindow" # service-level
  • methods:
  • - name: "GetUser"
  • tps.interval: 3000
  • tps.limit.strategy: "slidingWindow" # method-level

func (*SlidingWindowTpsLimitStrategyImpl) IsAllowable

func (impl *SlidingWindowTpsLimitStrategyImpl) IsAllowable() bool

type ThreadSafeFixedWindowTpsLimitStrategyImpl

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

*

  • it's the thread-safe implementation.
  • Also, it's a thread-safe decorator of FixedWindowTpsLimitStrategyImpl
  • "UserProvider":
  • registry: "hangzhouzk"
  • protocol : "dubbo"
  • interface : "com.ikurento.user.UserProvider"
  • ... # other configuration
  • tps.limiter: "method-service" # the name of limiter
  • tps.limit.strategy: "threadSafeFixedWindow" # service-level
  • methods:
  • - name: "GetUser"
  • tps.interval: 3000
  • tps.limit.strategy: "threadSafeFixedWindow" # method-level

func (*ThreadSafeFixedWindowTpsLimitStrategyImpl) IsAllowable

func (impl *ThreadSafeFixedWindowTpsLimitStrategyImpl) IsAllowable() bool

Jump to

Keyboard shortcuts

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