Documentation ¶
Index ¶
- Constants
- Variables
- func ComLogNotice(c *gin.Context, dltag string, m map[string]interface{})
- func ComLogWarning(c *gin.Context, dltag string, m map[string]interface{})
- func ContextError(c context.Context, dltag string, m map[string]interface{})
- func ContextNotice(c context.Context, dltag string, m map[string]interface{})
- func ContextWarning(c context.Context, dltag string, m map[string]interface{})
- func DefaultGetValidParams(c *gin.Context, params interface{}) error
- func GenSaltPassword(salt, password string) string
- func GetGinTraceContext(c *gin.Context) *lib.TraceContext
- func GetTraceContext(c context.Context) *lib.TraceContext
- func GetTranslation(c *gin.Context) (ut.Translator, error)
- func GetValidator(c *gin.Context) (*validator.Validate, error)
- func InStringSlice(slice []string, str string) bool
- func JwtDecode(tokenString string) (*jwt.StandardClaims, error)
- func JwtEncode(claims jwt.StandardClaims) (string, error)
- func MD5(s string) string
- func Obj2Json(s interface{}) string
- func RedisConfDo(commandName string, args ...interface{}) (interface{}, error)
- func RedisConfPipline(pip ...func(c redis.Conn)) error
- type FlowCounter
- type FlowLimiter
- type FlowLimiterItem
- type RedisFlowCountService
- func (o *RedisFlowCountService) GetDayData(t time.Time) (int64, error)
- func (o *RedisFlowCountService) GetDayKey(t time.Time) string
- func (o *RedisFlowCountService) GetHourData(t time.Time) (int64, error)
- func (o *RedisFlowCountService) GetHourKey(t time.Time) string
- func (o *RedisFlowCountService) Increase()
Constants ¶
View Source
const ( ValidatorKey = "ValidatorKey" TranslatorKey = "TranslatorKey" AdminSessionInfoKey = "AdminSessionInfoKey" LoadTypeHTTP = 0 LoadTypeTCP = 1 LoadTypeGRPC = 2 RuleTypePrefixURL = 0 RuleTypeDomin = 1 RedisFlowDayKey = "flow_day_count" RedisFlowHourKey = "flow_hour_count" FlowTotal = "flow_total" FlowCountServicePrefix = "flow_service_" FlowCountAppPrefix = "flow_app_" FlowServicePrefix = "flow_service_" FlowAppPrefix = "flow_app_" JwtSignKey = "my_sign_key" JwtExpires = 60 * 60 )
Variables ¶
View Source
var ( LoadTypeMap = map[int]string{ LoadTypeHTTP: "HTTP", LoadTypeTCP: "TCP", LoadTypeGRPC: "GRPC", } )
Functions ¶
func ComLogWarning ¶
错误日志
func ContextError ¶
错误日志
func ContextNotice ¶
普通日志
func ContextWarning ¶
错误日志
func DefaultGetValidParams ¶
func GenSaltPassword ¶
func GetGinTraceContext ¶
func GetGinTraceContext(c *gin.Context) *lib.TraceContext
从gin的Context中获取数据
func GetTranslation ¶
func GetValidator ¶
func InStringSlice ¶
func RedisConfDo ¶
func RedisConfPipline ¶
Types ¶
type FlowCounter ¶
type FlowCounter struct { RedisFlowCountMap map[string]*RedisFlowCountService RedisFlowCountSlice []*RedisFlowCountService Locker sync.RWMutex }
var FlowCounterHandler *FlowCounter
func NewFlowCounter ¶
func NewFlowCounter() *FlowCounter
func (*FlowCounter) GetCounter ¶
func (counter *FlowCounter) GetCounter(serviceName string) (*RedisFlowCountService, error)
type FlowLimiter ¶
type FlowLimiter struct { FlowLimiertMap map[string]*FlowLimiterItem FlowLimiterSlice []*FlowLimiterItem Locker sync.RWMutex }
var FlowLimiterHandler *FlowLimiter
func NewFlowLimiter ¶
func NewFlowLimiter() *FlowLimiter
func (*FlowLimiter) GetLimiter ¶
type FlowLimiterItem ¶
type RedisFlowCountService ¶
type RedisFlowCountService struct { AppID string Interval time.Duration QPS int64 Unix int64 TickerCount int64 TotalCount int64 }
func NewRedisFlowCountService ¶
func NewRedisFlowCountService(appID string, interval time.Duration) *RedisFlowCountService
func (*RedisFlowCountService) GetDayData ¶
func (o *RedisFlowCountService) GetDayData(t time.Time) (int64, error)
func (*RedisFlowCountService) GetDayKey ¶
func (o *RedisFlowCountService) GetDayKey(t time.Time) string
func (*RedisFlowCountService) GetHourData ¶
func (o *RedisFlowCountService) GetHourData(t time.Time) (int64, error)
func (*RedisFlowCountService) GetHourKey ¶
func (o *RedisFlowCountService) GetHourKey(t time.Time) string
Click to show internal directories.
Click to hide internal directories.