bootstrap

package
v0.0.0-...-93144e6 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

bootstrap 用于管理项目所有的依赖, 并通过依赖注入的方式保证全局只初始化一次依赖实例. 在主进程结束前调用 bootstrap.Teardown 以合理的关闭资源.

Index

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) GetConfig

func (b *Bootstrap) GetConfig(path string) *Config

GetConfig 根据传入的路径解析

func (*Bootstrap) GetLogger

func (b *Bootstrap) GetLogger() logger.Logger

func (*Bootstrap) GetRecordController

func (b *Bootstrap) GetRecordController() *controller.RecordController

func (*Bootstrap) GetRecordDB

func (b *Bootstrap) GetRecordDB() *gorm.DB

func (*Bootstrap) GetRecordDao

func (b *Bootstrap) GetRecordDao() dao.RecordDao

func (*Bootstrap) GetRecordGrpcController

func (b *Bootstrap) GetRecordGrpcController() *controller.RecordGrpcController

func (*Bootstrap) GetRecordService

func (b *Bootstrap) GetRecordService() service.RecordService

func (*Bootstrap) Teardown

func (b *Bootstrap) Teardown()

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"`
}

type ServerConfig

type ServerConfig struct {
	Host            string   `mapstructure:"host" yaml:"host"`
	Port            uint     `mapstructure:"port" yaml:"port"`
	CorsAllowOrigin []string `mapstructure:"cors_allow_origin"`
	DefaultExpired  int64    `mapstructure:"default_expired"`
}

Jump to

Keyboard shortcuts

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