Documentation
¶
Index ¶
- func GetContextClaims(ctx *gin.Context) (*jwt.TokenClaims, error)
- func GetOutboundIP() string
- func GetOutboundIPByInterface() string
- func GetOutboundIPByUDP() string
- func IsDir(path string) (bool, error)
- func IsFile(path string) (bool, error)
- func IsTestNetwork(ip string) bool
- func Md5(s string) string
- func PathExists(path string) (bool, error)
- func Sha1(s string) string
- func Sha256(s string) string
- func Sha512(s string) string
- type Discovery
- type Instance
- type LoadBalanceStrategy
- type LoadBalancer
- type LocksmithLogger
- type LocksmithMutex
- type Mutex
- type RedisLock
- type RedisLocksmith
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetContextClaims ¶
func GetContextClaims(ctx *gin.Context) (*jwt.TokenClaims, error)
GetContextClaims 从上下文中获取当前请求接口的Claims
func GetOutboundIP ¶
func GetOutboundIP() string
func GetOutboundIPByInterface ¶
func GetOutboundIPByInterface() string
func GetOutboundIPByUDP ¶
func GetOutboundIPByUDP() string
func IsTestNetwork ¶
Types ¶
type LoadBalanceStrategy ¶
type LoadBalanceStrategy int
LoadBalanceStrategy 负载均衡策略
const ( RoundRobin LoadBalanceStrategy = iota // 轮询 Random // 随机 LeastConnections // 最少连接 )
type LoadBalancer ¶
type LoadBalancer[T Instance] struct { // contains filtered or unexported fields }
LoadBalancer 负载均衡器
func NewLoadBalancer ¶
func NewLoadBalancer[T Instance](discovery Discovery[T], strategy LoadBalanceStrategy) *LoadBalancer[T]
NewLoadBalancer 创建负载均衡器
func (*LoadBalancer[T]) GetInstanceStats ¶
func (lb *LoadBalancer[T]) GetInstanceStats(serviceName string) (map[string]int, error)
GetInstanceStats 获取统计信息
func (*LoadBalancer[T]) GetServiceInstance ¶
func (lb *LoadBalancer[T]) GetServiceInstance(serviceName string) (T, error)
GetServiceInstance 获取服务实例
func (*LoadBalancer[T]) ReleaseConnection ¶
func (lb *LoadBalancer[T]) ReleaseConnection(instanceID string)
ReleaseConnection 释放连接
type LocksmithLogger ¶
type LocksmithLogger interface {
logger.LogCtxInterface
}
type LocksmithMutex ¶
type RedisLock ¶
type RedisLock struct {
Mutex
// contains filtered or unexported fields
}
type RedisLocksmith ¶
type RedisLocksmith struct {
// contains filtered or unexported fields
}
func NewRedisLocksmith ¶
func NewRedisLocksmith(logger LocksmithLogger, redisClient *redis.CommonRedisClient) *RedisLocksmith
Click to show internal directories.
Click to hide internal directories.