Documentation ¶
Overview ¶
bootstrap 用于管理项目所有的依赖, 并通过依赖注入的方式保证全局只初始化一次依赖实例. 在主进程结束前调用 bootstrap.Teardown 以合理的关闭资源.
Index ¶
- type Bootstrap
- func (b *Bootstrap) AddTeardown(teardown func())
- func (b *Bootstrap) GetConfig(path string) *Config
- func (b *Bootstrap) GetLogger() logger.Logger
- func (b *Bootstrap) GetRecordController() *controller.RecordController
- func (b *Bootstrap) GetRecordDB() *gorm.DB
- func (b *Bootstrap) GetRecordDao() dao.RecordDao
- func (b *Bootstrap) GetRecordGrpcController() *controller.RecordGrpcController
- func (b *Bootstrap) GetRecordService() service.RecordService
- func (b *Bootstrap) Teardown()
- type Config
- type GrpcConfig
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bootstrap ¶
type Bootstrap struct {
// contains filtered or unexported fields
}
func NewBootstrap ¶
func NewBootstrap() *Bootstrap
func (*Bootstrap) AddTeardown ¶
func (b *Bootstrap) AddTeardown(teardown func())
func (*Bootstrap) GetRecordController ¶
func (b *Bootstrap) GetRecordController() *controller.RecordController
func (*Bootstrap) GetRecordDB ¶
func (*Bootstrap) GetRecordDao ¶
func (*Bootstrap) GetRecordGrpcController ¶
func (b *Bootstrap) GetRecordGrpcController() *controller.RecordGrpcController
func (*Bootstrap) GetRecordService ¶
func (b *Bootstrap) GetRecordService() service.RecordService
type Config ¶
type Config struct { // Logging log.Options `mapstructure:"logger"` // DB database.Options `mapstructure:"db" yaml:"db"` Grpc GrpcConfig `mapstructure:"grpc" yaml:"grpc"` Server ServerConfig `mapstructure:"server" yaml:"server"` }
type GrpcConfig ¶
type GrpcConfig struct {
Port int `mapstructure:"port" yaml:"port"`
}
Click to show internal directories.
Click to hide internal directories.