base

package
v0.0.0-...-fede4b9 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBaseResp

func BuildBaseResp(err error) *model.BaseResp

func BuildRespAndLog

func BuildRespAndLog(err error) *model.BaseResp

func BuildSuccessResp

func BuildSuccessResp() *model.BaseResp

func BuildTypeList

func BuildTypeList[T any, U any](items []U, buildFunc func(U) T) []T

func HandleJwchError

func HandleJwchError(err error) error

HandleJwchError 对于jwch库返回的错误类型,需要使用 HandleJwchError 来保留 cookie 异常

func LogError

func LogError(err error)

Types

type ClientSet

type ClientSet struct {
	CacheClient *cache.Cache     // Redis
	ESClient    *elastic.Client  // ElasticSearch
	DBClient    *db.Database     // Database
	SFClient    *utils.Snowflake // Snowflake(DB initialize together)

	HzClient *client.Client // Hertz client
	// contains filtered or unexported fields
}

ClientSet storage various client objects Notice: some or all of them maybe nil, we should check obj when use

func NewClientSet

func NewClientSet(opt ...Option) *ClientSet

NewClientSet will be protected by sync.Once for ensure only 1 instance could be created in 1 lifecycle

func (*ClientSet) Close

func (cs *ClientSet) Close()

Close iterates over all cleanup functions and calls them.

type Option

type Option func(clientSet *ClientSet)

func WithDBClient

func WithDBClient(tableName string) Option

WithDBClient will create database object

func WithElasticSearch

func WithElasticSearch() Option

func WithHzClient

func WithHzClient() Option

func WithRedisClient

func WithRedisClient(dbName int) Option

WithRedisClient will create redis object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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