core

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(a any, b any)

func Set

func Set(newCore *Core)

Types

type Core

type Core struct {
	Db     *gorm.DB
	Config *config.Config
	Info   *Info

	Mongo *mongo.Client
	Etcd  *clientv3.Client
	// contains filtered or unexported fields
}

func Copy

func Copy() *Core

func New

func New() *Core

func (*Core) Bind

func (*Core) Bind(a any, b any)

func (*Core) ConfigRegister

func (*Core) ConfigRegister() *config.Config

ConfigRegister 注册 配置

func (*Core) GetDb

func (*Core) GetDb() *gorm.DB

GetDb 获取当前数据库实例

func (*Core) GetEnv

func (*Core) GetEnv() string

GetEnv 获取当前环境

func (*Core) GetName

func (*Core) GetName() string

GetName 获取当前服务名称

func (*Core) GetPort

func (*Core) GetPort() int

GetDb 获取当前数据库实例

func (*Core) GetVersion

func (*Core) GetVersion() string

GetVersion 获取当前版本号

func (*Core) Init

func (*Core) Init()

Init 启动其他服务

func (*Core) MongoRegister

func (*Core) MongoRegister(Uri ...string) *mongo.Client

MongoRegister 注册Mongo

func (*Core) SetConfigFile

func (*Core) SetConfigFile(file string) *config.Config

ConfigRegister 注册 配置

func (*Core) SetInfo

func (*Core) SetInfo(info *Info)

type ICore

type ICore interface {
	Init()
	GetEnv() string
	GetName() string
	GetVersion() string
	GetDb() *gorm.DB
	GetPort() int
	ConfigRegister() *config.Config
	SetConfigFile(file string) *config.Config
	MongoRegister(Uri ...string) *mongo.Client
	Bind(a any, b any)
}

ICore 服务核心接口

func Make

func Make(opts ...Option) ICore

Make 构建新核心

type Info

type Info struct {
	Port int
	Env  string
	Name string
	// contains filtered or unexported fields
}

type Option

type Option func(*Core)

Option 返回匿名函数 供初始化执行时

func ConfigRegister

func ConfigRegister() Option

func Env

func Env(env string) Option

Env 设置环境变量

func Name

func Name(name string) Option

Name 设置项目名称

func Port

func Port(port int) Option

Port 设置端口号

func Version

func Version(version string) Option

Version 设置项目版本

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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