frame

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClickHouse added in v1.1.7

func ClickHouse(name string) driver.Conn

指定名称的ClickHouse实例访问方法

func ClickHouseDB added in v1.1.9

func ClickHouseDB(name string) *gorm.DB

ClickHouseDB 获取指定名称的ClickHouse GORM DB

func DB

func DB(name string) *gorm.DB

保留原有的命名实例访问方法

func DefaultClickHouse added in v1.1.7

func DefaultClickHouse() driver.Conn

默认实例的全局访问方法

func DefaultClickHouseDB added in v1.1.9

func DefaultClickHouseDB() *gorm.DB

DefaultClickHouseDB 获取默认ClickHouse GORM DB

func DefaultDB

func DefaultDB() *gorm.DB

默认实例的全局访问方法

func DefaultSlaveDB

func DefaultSlaveDB() *gorm.DB

默认实例的从库访问方法

func GetRedis

func GetRedis() *redis.Client

GetRedis 获取全局Redis单机实例

func GetRedisCluster

func GetRedisCluster() *redis.ClusterClient

GetRedisCluster 获取全局Redis集群实例

func SlaveDB

func SlaveDB(name string) *gorm.DB

ReplicaDB 获取从库连接

Types

type Component

type Component interface {
	// Start 启动组件
	Start(ctx context.Context) error
	// Stop 停止组件
	Stop(ctx context.Context) error
}

Component 定义组件接口

type Frame

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

Frame 框架核心结构

func New

func New(opts ...Option) *Frame

New 创建新的框架实例

func (*Frame) AfterStart added in v1.0.6

func (f *Frame) AfterStart(hook Hook) *Frame

AfterStart 注册启动后的钩子函数

func (*Frame) BeforeStop added in v1.0.6

func (f *Frame) BeforeStop(hook Hook) *Frame

BeforeStop 注册停止前的钩子函数

func (*Frame) RegisterComponent

func (f *Frame) RegisterComponent(component Component)

RegisterComponent 注册组件

func (*Frame) Run

func (f *Frame) Run() error

Run 运行框架并处理信号

func (*Frame) SetLogger

func (f *Frame) SetLogger(logger *zap.Logger)

SetLogger 设置日志记录器

func (*Frame) Start

func (f *Frame) Start(ctx context.Context) error

Start 启动框架

func (*Frame) Stop

func (f *Frame) Stop(ctx context.Context) error

Stop 停止框架

type FrameConfig

type FrameConfig struct {
	ShutdownTimeout time.Duration
}

FrameConfig 框架配置

type Hook added in v1.0.6

type Hook func(ctx context.Context) error

Hook 定义钩子函数类型

type Option

type Option func(*Frame)

Option 定义框架选项函数类型

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) Option

WithShutdownTimeout 设置关闭超时时间

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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