strategy

package
v1.0.0-rc303rc1reinit2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package filter is a generated GoMock package.

Index

Constants

View Source
const (
	// FixedWindowKey defines limiter limit algorithm
	FixedWindowKey = "fixedWindow"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FixedWindowTpsLimitStrategy

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

FixedWindowTpsLimitStrategy implements the TPS limit strategy base on requests count during the interval *

  • 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 ThreadSafeFixedWindowTpsLimitStrategy
  • 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 (*FixedWindowTpsLimitStrategy) IsAllowable

func (impl *FixedWindowTpsLimitStrategy) IsAllowable() bool

IsAllowable determines if the requests over the TPS limit within the interval. It is not thread-safe.

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 SlidingWindowTpsLimitStrategy

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

SlidingWindowTpsLimitStrategy implements a thread-safe TPS limit strategy base on requests count. *

  • 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 (*SlidingWindowTpsLimitStrategy) IsAllowable

func (impl *SlidingWindowTpsLimitStrategy) IsAllowable() bool

IsAllowable determines whether the number of requests within the time window overs the threshold It is thread-safe.

type ThreadSafeFixedWindowTpsLimitStrategy

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

ThreadSafeFixedWindowTpsLimitStrategy is the thread-safe implementation. It's also a thread-safe decorator of FixedWindowTpsLimitStrategy *

  • "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 (*ThreadSafeFixedWindowTpsLimitStrategy) IsAllowable

func (impl *ThreadSafeFixedWindowTpsLimitStrategy) IsAllowable() bool

IsAllowable implements thread-safe then run the FixedWindowTpsLimitStrategy

Jump to

Keyboard shortcuts

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