Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseWrapper ¶
BaseWrapper implements Wrapper by saving the acceptor as an attribute. Conns from acceptor.GetConnChan are processed by wrapConn and forwarded to its own connChan. Any new wrapper can inherit from BaseWrapper and just implement wrapConn.
func NewBaseWrapper ¶
func NewBaseWrapper(wrapConn func(acceptor.PlayerConn) acceptor.PlayerConn) BaseWrapper
NewBaseWrapper returns an instance of BaseWrapper.
func (*BaseWrapper) GetConnChan ¶
func (b *BaseWrapper) GetConnChan() chan acceptor.PlayerConn
GetConnChan returns the wrapper conn chan
func (*BaseWrapper) ListenAndServe ¶
func (b *BaseWrapper) ListenAndServe()
ListenAndServe starts a goroutine that wraps acceptor's conn and calls acceptor's listenAndServe
type RateLimiter ¶
type RateLimiter struct { acceptor.PlayerConn // contains filtered or unexported fields }
RateLimiter wraps net.Conn by applying rate limiting and return empty if exceeded. It uses the leaky bucket algorithm (https://en.wikipedia.org/wiki/Leaky_bucket). Here, "limit" is the number of requests it accepts during an "interval" duration. After making a request, a slot is occupied and only freed after "interval" duration. If a new request comes when no slots are available, the buffer from Read is droped and ignored by pitaya. On the client side, this will yield a timeout error and the client must be prepared to handle it.
func NewRateLimiter ¶
func NewRateLimiter( reporters []metrics.Reporter, conn acceptor.PlayerConn, limit int, interval time.Duration, forceDisable bool, ) *RateLimiter
NewRateLimiter returns an initialized *RateLimiting
func (*RateLimiter) GetNextMessage ¶
func (r *RateLimiter) GetNextMessage() (msg []byte, err error)
GetNextMessage gets the next message in the connection
type RateLimitingWrapper ¶
type RateLimitingWrapper struct {
BaseWrapper
}
RateLimitingWrapper rate limits for each connection received
func NewRateLimitingWrapper ¶
func NewRateLimitingWrapper(reporters []metrics.Reporter, c config.RateLimitingConfig) *RateLimitingWrapper
NewRateLimitingWrapper returns an instance of *RateLimitingWrapper