database

package
v1.1.39 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache 数据库配置缓存

func NewCache

func NewCache(prov *provider.Provider) *Cache

NewCache 创建数据库配置缓存

func (*Cache) GetAllServices added in v1.1.32

func (c *Cache) GetAllServices(ctx context.Context, tenantID int) (map[string]*TenantDatabaseConfig, error)

GetAllServices 获取租户所有服务的数据库配置

func (*Cache) GetByService added in v1.1.32

func (c *Cache) GetByService(ctx context.Context, tenantID int, serviceCode string) (*TenantDatabaseConfig, error)

GetByService 获取指定服务的数据库配置

type TenantDatabaseConfig

type TenantDatabaseConfig struct {
	// 租户信息
	TenantID int    `json:"tenant_id"`
	Code     string `json:"code"`
	Name     string `json:"name"`

	// 服务信息
	ServiceCode string `json:"service_code"`

	// 数据库连接参数
	Driver   string `json:"driver"`
	Host     string `json:"host"`
	Port     int    `json:"port"`
	DbName   string `json:"db_name"`
	Username string `json:"username"`
	Password string `json:"password"`
	SSLMode  string `json:"ssl_mode"`

	// 连接池设置
	MaxOpenConns int `json:"max_open_conns"`
	MaxIdleConns int `json:"max_idle_conns"`
}

TenantDatabaseConfig 租户数据库配置

Jump to

Keyboard shortcuts

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