base

package
v0.0.0-...-2d053d8 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SuccessBase = model.BaseResp{Code: errno.SuccessCode, Msg: errno.SuccessMsg}

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 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() 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