app

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitPathInfo

func InitPathInfo(configPath *string)

func IsNil

func IsNil(i interface{}) bool

IsNil 判断interface是否为空

Types

type App

type App struct {
	Application
	// contains filtered or unexported fields
}

func (*App) Start

func (app *App) Start() error

func (*App) Stop

func (app *App) Stop()

type Application

type Application interface {
	Start() error
	Stop()
}

func NewApp

func NewApp(opts ...Option) (Application, error)

type Config

type Config struct {
	//ServerName string `json:"server_name" yaml:"server_name"`
	//Type       ipType `json:"type" yaml:"type"`
	IP             string          `json:"ip" yaml:"ip"`
	Servers        map[string]Port `json:"servers" yaml:"servers"`   // 所有服务Port信息
	ConfigInitType string          `json:"config_init_type"`         // file:读本地配置  center:读取配置中心
	RpcType        string          `json:"rpc_type" yaml:"rpc_type"` // 支持local,kubernetes,register
	Env            string          `json:"env"  yaml:"env"`
	// contains filtered or unexported fields
}

func NewAppConfig

func NewAppConfig(rootPath string, yaml ...string) (conf *Config, err error)

NewAppConfig 获取app配置

type Option

type Option func(app *App) error

func Register

func Register(register register.Register) Option

func Servers

func Servers(servers ...server.Server) Option

func Tracing

func Tracing(exporter opentelemetry.SpanExporter, serviceName string) Option

type Port

type Port struct {
	HttpPort int `json:"http_port" yaml:"http_port"`
	GrpcPort int `json:"grpc_port" yaml:"grpc_port"`
}

type Util

type Util struct {
	Info *Config
	Sf   *singleflight.Group
	// contains filtered or unexported fields
}

func NewInitUtil

func NewInitUtil(config *Config) (*Util, error)

NewInitUtil 根据配置获取Util工具箱

func NewUtil

func NewUtil(yaml ...string) *Util

func (*Util) Auth

func (u *Util) Auth() (authorization.Auth, error)

func (*Util) Cache

func (u *Util) Cache() (cache.Cache, error)

func (*Util) CacheDb

func (u *Util) CacheDb(db int) (cache.Cache, error)

func (*Util) CheckPort

func (u *Util) CheckPort(svcName string) bool

func (*Util) Close

func (u *Util) Close()

func (*Util) Db

func (u *Util) Db(ctx context.Context) (*orm.Gorm, error)

Db 读写库

func (*Util) DbReadOnly

func (u *Util) DbReadOnly(ctx context.Context) (*orm.Gorm, error)

DbReadOnly 只读库

func (*Util) Es

func (u *Util) Es() (*es.ES, error)

func (*Util) Exporter

func (u *Util) Exporter() (opentelemetry.SpanExporter, error)

func (*Util) Locker

func (u *Util) Locker(key, identification string, RefreshTime time.Duration) (locker.Locker, error)

func (*Util) Mq

func (u *Util) Mq() (mq.Producer, error)

func (*Util) Port

func (u *Util) Port(svcName string) Port

func (*Util) Register

func (u *Util) Register() (register.Register, error)

func (*Util) Rpc

func (u *Util) Rpc(ctx context.Context, serverName string) (conn *rpc.Conn, err error)

Jump to

Keyboard shortcuts

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