application

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	GoDandelionConnChange = "go_dandelion_conn_change"
)
View Source
const (
	GoDandelionMongoConnChange = "go_dandelion_mongo_conn_change"
)

Variables

This section is empty.

Functions

func AppDBChange

func AppDBChange(appKey string, changeType dgorm.ChangeType) error

AppDBChange 用于上报应用数据库发生变更。 如中心服务器修改应用数据库,则需要上报,运 营服务订阅到消息后,自动刷新应用数据库连接 依赖于redis

func AppMongoDBChange added in v1.5.0

func AppMongoDBChange(appKey string, changeType dmongo.ChangeType) error

AppMongoDBChange 用于上报应用MongoDB发生变更。 如中心服务器修改应用MongoDB,则需要上报,运 营服务订阅到消息后,自动刷新应用MongoDB连接 依赖于redis

func HttpServer

func HttpServer() *http.HttpServer

func Init

func Init()

func InitAppDB

func InitAppDB(configFunc dgorm.AppConfigFunc, changeFunc dgorm.AppChangeFunc)

InitAppDB 初始化应用数据库 configFunc 定义获取相关应用数据库连接方法。用于在应 用数据库连接发生变更行为时,各服务自动获取最新的数据 库连接,不用额外进行重连刷新操作

changeFunc 定义相关数据库变更时,业务需要执行的方法 发生变更时,进行回调处理。如,增加新的应用,服务需要 创建表单等操作

func InitAppMongoDB added in v1.5.0

func InitAppMongoDB(configFunc dmongo.AppConfigFunc, changeFunc dmongo.AppChangeFunc)

InitAppMongoDB 初始化应用MongoDB configFunc 定义获取相关应用MongoDB连接方法。用于在应 用MongoDB连接发生变更行为时,各服务自动获取最新的MongoDB 连接,不用额外进行重连刷新操作

changeFunc 定义相关MongoDB变更时,业务需要执行的方法 发生变更时,进行回调处理。如,增加新的应用,服务需要 创建集合等操作

func Plugs

func Plugs(plugins ...Plugin) error

func RegisterHeaderFunc

func RegisterHeaderFunc(f func(ctx *routing.Context, header map[string]string) map[string]string)

func RegisterRpcPlugin

func RegisterRpcPlugin(plugins ...server.Plugin)

func RpcServer

func RpcServer(handler interface{}, auth ...rpcx.AuthFunc)

Types

type DB

type DB struct {
}

func (*DB) GetDB

func (*DB) GetDB(appKeys ...string) *gorm.DB

GetDB 获取数据库连接

type MongoDB added in v1.5.0

type MongoDB struct {
}

func (*MongoDB) Close added in v1.5.0

func (*MongoDB) Close()

Close 关闭MongoDB连接

func (*MongoDB) GetClient added in v1.5.0

func (*MongoDB) GetClient(appKeys ...string) *mongo.Client

GetClient 获取MongoDB客户端连接

func (*MongoDB) GetCollection added in v1.5.0

func (*MongoDB) GetCollection(dbName, collectionName string, appKeys ...string) *mongo.Collection

GetCollection 获取MongoDB集合实例

func (*MongoDB) GetDatabase added in v1.5.0

func (*MongoDB) GetDatabase(dbName string, appKeys ...string) *mongo.Database

GetDatabase 获取MongoDB数据库实例

type Plugin

type Plugin interface {
	// Config 返回需要初始化的配置,建议使用第二层级
	Config() interface{}
	InitPlugin() error
}

type Redis

type Redis struct {
}

func (*Redis) GetRedis

func (r *Redis) GetRedis() *redigo.Client

type RpcClient

type RpcClient struct {
	ClientName string
	ClientPool *rpcx.ClientPool
	HeaderFunc func(ctx *routing.Context, header map[string]string) map[string]string
}

func GetRpcClient added in v1.5.0

func GetRpcClient() *RpcClient

Jump to

Keyboard shortcuts

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