utils

package
v0.0.0-...-3bbbf02 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FanIn  = 1 << 0
	FanOut = 1 << 1
)

Variables

This section is empty.

Functions

func Abort

func Abort(ctx *gin.Context, code int, msg string)

func Extract

func Extract(bind string) (string, error)

func InBlacklist

func InBlacklist(uid string) bool

func Listen

func Listen(network string, addr string) (net.Listener, error)

func ResponseJSON

func ResponseJSON(ctx *gin.Context, code int, msg string, data interface{})

func UpdateProc

func UpdateProc(service string)

func WatchBlacklist

func WatchBlacklist()

Types

type CBOption

type CBOption func(cb *CircuitBreaker)

func WithDuration

func WithDuration(duration int64) CBOption

func WithFailsLimit

func WithFailsLimit(failsRateLimit int64) CBOption

func WithLatencyLimit

func WithLatencyLimit(latencyLimit int64) CBOption

func WithTotalLimit

func WithTotalLimit(totalLimit int64) CBOption

type CircuitBreaker

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

func NewCircuitBreaker

func NewCircuitBreaker(opts ...CBOption) *CircuitBreaker

func (*CircuitBreaker) Allow

func (cb *CircuitBreaker) Allow(f func() bool) bool

type Counter

type Counter int64

func (*Counter) Add

func (c *Counter) Add() int64

func (*Counter) Load

func (c *Counter) Load() int64

func (*Counter) Reset

func (c *Counter) Reset()

type RateLimiter

type RateLimiter interface {
	Push(t pool.Task) bool
	Pop() (pool.Task, bool)
	Close() error
}

func NewRateLimiter

func NewRateLimiter(size int, rate int64, mode int) (RateLimiter, error)

type Response

type Response struct {
	Code int         `json:"code"` // 业务错误码
	Data interface{} `json:"data"` // 数据
	Msg  string      `json:"msg"`  // 提示信息
}

Jump to

Keyboard shortcuts

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