Versions in this module Expand all Collapse all v1 v1.0.0 Mar 29, 2026 Changes in this version + const DebugLevel + const ErrorLevel + const FatalLevel + const InfoLevel + const WarnLevel + func CustomizeDefaultHttpClient(maxIdleConns, maxIdleConnsPerHost, maxConnsPerHost int) + func DummyList[T any]() []T + func GenRandomToken() (string, error) + func GetLogger() *zap.SugaredLogger + func GetRawLogger() *zap.Logger + func HandleRestfulResponse(resp *http.Response, obj any) (code int, err error) + func HttpChangeLogLevel(w http.ResponseWriter, r *http.Request) + func HttpGetJsonArgs(r *http.Request, obj any) error + func HttpGetJsonArgsWithLog(logger *ContextLogger, r *http.Request, obj any) error + func HttpGetPbArgs(r *http.Request, m proto.Message) (bin bool, err error) + func HttpReplyJson(w http.ResponseWriter, code int, obj any) error + func HttpReplyJsonWithLog(logger *ContextLogger, w http.ResponseWriter, code int, obj any) error + func HttpReplyPb(w http.ResponseWriter, code int, m proto.Message, bin bool) (err error) + func IncrWithTTL(ctx context.Context, db *redis.Client, key string, ttlSeconds int64) (int64, error) + func InitLog(path string, maxBackups, maxDays int) + func IsMysqlDuplicateError(err error) bool + func ListIntoSet[T comparable](list []T, set map[T]bool) + func ListToSet[T comparable](list []T) map[T]bool + func LoadJsonFile(filepath string, obj any) error + func LoadYamlFile(filepath string, obj any) error + func LogLevelEnabled(lv LogLevel) bool + func MaybeMetrisName(name string) bool + func NewCounter(name string) prometheus.Counter + func NewCounterVec(name string, labelNames ...string) *prometheus.CounterVec + func NewGauge(name string) prometheus.Gauge + func NewGaugeVec(name string, labelNames ...string) *prometheus.GaugeVec + func NewRedisClient(cfg *RedisConfig) *redis.Client + func NewRedisClientWithCheck(cfg *RedisConfig) (*redis.Client, error) + func NewRestfulRequest(ctx context.Context, method, url string, headers, params map[string]string, ...) (*http.Request, error) + func NewSummary(name string) prometheus.Summary + func NewSummaryVec(name string, labelNames ...string) *prometheus.SummaryVec + func OverwriteMysqlParams(config string, patch map[string]string) string + func RecordLatencyUs(s prometheus.Observer, begin time.Time) + func ReplaceNilByDummy[T any](list []T) []T + func RestfulDelete(ctx context.Context, url string, headers, params map[string]string) (code int, err error) + func RestfulDo(ctx context.Context, method, url string, headers, params map[string]string, ...) (code int, err error) + func RestfulGet(ctx context.Context, url string, headers, params map[string]string, out any) (code int, err error) + func RestfulPatch(ctx context.Context, url string, headers, params map[string]string, obj any) (code int, err error) + func RestfulPost(ctx context.Context, url string, headers, params map[string]string, ...) (code int, err error) + func RestfulPut(ctx context.Context, url string, headers, params map[string]string, obj any) (code int, err error) + func RunHttpServer(router http.Handler, address string) error + func SetLogLevel(lv LogLevel) + func SqlCreate(ctx context.Context, stmt *sql.Stmt, args ...any) (int64, error) + func SqlModify(ctx context.Context, stmt *sql.Stmt, args ...any) (int64, error) + func SyncLog() + func TryRegisterMetris(r *prometheus.Registry, m prometheus.Collector) + func TryToConvertMetrisName(name string) (string, error) + func UnsafeBytesToString(b []byte) string + func UnsafeStringToBytes(s string) []byte + type ActionMetrics struct + Count prometheus.Counter + Failure prometheus.Counter + Latency prometheus.Summary + func (m *ActionMetrics) Init(prefix string) + func (m *ActionMetrics) MustRegister(registry *prometheus.Registry) + func (m *ActionMetrics) Register(registry *prometheus.Registry) + type ContextLogger struct + func NewContextLogger(ctx string) *ContextLogger + func (l *ContextLogger) Debug(msg string) + func (l *ContextLogger) Debugf(tpl string, args ...any) + func (l *ContextLogger) Error(msg string) + func (l *ContextLogger) Errorf(tpl string, args ...any) + func (l *ContextLogger) Info(msg string) + func (l *ContextLogger) Infof(tpl string, args ...any) + func (l *ContextLogger) Warn(msg string) + func (l *ContextLogger) Warnf(tpl string, args ...any) + type LogLevel = zapcore.Level + type RedisConfig struct + Address string + IdleSize int + Password string + PoolSize int + type Xorshift struct + func (xs *Xorshift) Init(seed uint32) + func (xs *Xorshift) Next() uint32