Documentation
¶
Index ¶
- Constants
- Variables
- func B2S(b []byte) string
- func JSONUnmarshal(data []byte, v interface{}) error
- func JoinErrors(errs []error) error
- func NewCancelShieldContext(ctx context.Context) context.Context
- func Recover()
- func RecoverWithFunc(f func(r any))
- type AtomicBool
- type AtomicString
- type CancelShieldContext
- type LogLevel
- type Logger
- type Rate
- type RateLimiter
- type ResponseError
- type SyncMap
- func (m *SyncMap[V]) Delete(key string)
- func (m *SyncMap[V]) Load(key string) (value V, ok bool)
- func (m *SyncMap[V]) LoadAndDelete(key string) (value V, loaded bool)
- func (m *SyncMap[V]) LoadOrStore(key string, value V) (actual V, loaded bool)
- func (m *SyncMap[V]) Range(f func(key string, value V) bool)
- func (m *SyncMap[V]) Store(key string, value V)
- type TokenBucketLimiter
Constants ¶
View Source
const ( LogLevelDebug = LogLevel(0) LogLevelInfo = LogLevel(1) LogLevelWarn = LogLevel(2) LogLevelError = LogLevel(3) )
Variables ¶
View Source
var ( ErrClientNotSupport = errors.New("this feature client not support") ErrServerNotSupport = errors.New("this feature server not support") ErrRequestInvalid = errors.New("request invalid") ErrLackResponseChan = errors.New("lack response chan") ErrDuplicateResponseReceived = errors.New("duplicate response received") ErrMethodNotSupport = errors.New("method not support") ErrJSONUnmarshal = errors.New("json unmarshal error") ErrSessionHasNotInitialized = errors.New("the session has not been initialized") ErrLackSession = errors.New("lack session") ErrSessionClosed = errors.New("session closed") ErrSendEOF = errors.New("send EOF") ErrRateLimitExceeded = errors.New("rate limit exceeded") )
Functions ¶
func JSONUnmarshal ¶ added in v0.1.7
func JoinErrors ¶
func NewCancelShieldContext ¶ added in v0.2.0
func RecoverWithFunc ¶
func RecoverWithFunc(f func(r any))
Types ¶
type AtomicBool ¶ added in v0.1.10
type AtomicBool struct {
// contains filtered or unexported fields
}
func NewAtomicBool ¶ added in v0.1.10
func NewAtomicBool() *AtomicBool
func (*AtomicBool) Load ¶ added in v0.1.10
func (b *AtomicBool) Load() bool
func (*AtomicBool) Store ¶ added in v0.1.10
func (b *AtomicBool) Store(value bool)
type AtomicString ¶ added in v0.2.0
type AtomicString struct {
// contains filtered or unexported fields
}
func NewAtomicString ¶ added in v0.2.0
func NewAtomicString() *AtomicString
func (*AtomicString) Load ¶ added in v0.2.0
func (b *AtomicString) Load() string
func (*AtomicString) Store ¶ added in v0.2.0
func (b *AtomicString) Store(value string)
type CancelShieldContext ¶ added in v0.2.0
func (CancelShieldContext) Deadline ¶ added in v0.2.0
func (v CancelShieldContext) Deadline() (deadline time.Time, ok bool)
func (CancelShieldContext) Done ¶ added in v0.2.0
func (v CancelShieldContext) Done() <-chan struct{}
func (CancelShieldContext) Err ¶ added in v0.2.0
func (v CancelShieldContext) Err() error
type Logger ¶
type Logger interface {
Debugf(format string, a ...any)
Infof(format string, a ...any)
Warnf(format string, a ...any)
Errorf(format string, a ...any)
}
type RateLimiter ¶ added in v0.2.7
RateLimiter 定义速率限制接口
type ResponseError ¶
func NewResponseError ¶
func NewResponseError(code int, message string, data interface{}) *ResponseError
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
type SyncMap ¶
type SyncMap[V any] struct { // contains filtered or unexported fields }
func (*SyncMap[V]) LoadAndDelete ¶
func (*SyncMap[V]) LoadOrStore ¶
type TokenBucketLimiter ¶ added in v0.2.7
type TokenBucketLimiter struct {
// contains filtered or unexported fields
}
TokenBucketLimiter 令牌桶限速器实现
func NewTokenBucketLimiter ¶ added in v0.2.7
func NewTokenBucketLimiter(defaultRate Rate) *TokenBucketLimiter
NewTokenBucketLimiter 创建新的令牌桶限速器
func (*TokenBucketLimiter) Allow ¶ added in v0.2.7
func (l *TokenBucketLimiter) Allow(toolName string) bool
Allow 检查请求是否被允许
func (*TokenBucketLimiter) SetToolLimit ¶ added in v0.2.7
func (l *TokenBucketLimiter) SetToolLimit(toolName string, rate Rate)
SetToolLimit 为特定工具设置限制
Click to show internal directories.
Click to hide internal directories.