internal

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var K = koanf.New(".")

Functions

func GetSiteMode added in v1.1.0

func GetSiteMode() string

func LoadEnv

func LoadEnv(siteMode string)

Types

type Error

type Error struct {
	Code    int
	Message string
}

func NewError

func NewError(code int, message string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) GetCode

func (e *Error) GetCode() int

func (*Error) String

func (e *Error) String() string

time="2021-09-24T20:52:10+08:00" level=info msg="初始化Etcd配置成功" init=etcd

type Mysql

type Mysql struct {
	Host            string
	Port            int
	Username        string
	Password        string
	Database        string
	Prefix          string
	Debug           bool
	Logger          *logrus.Logger
	Db              *gorm.DB
	MaxIdleConns    int //最大空闲连接数
	MaxOpenConns    int //最大连接数
	ConnMaxLifetime int //分钟
	SectionLog      string
}

func NewMysql

func NewMysql(
	host string,
	port int,
	username string,
	password string,
	database string,
	prefix string,
	debug bool,
	log *logrus.Logger,
	sectionLog string,
) *Mysql

func (*Mysql) Close

func (m *Mysql) Close() error

Close 关闭数据库

func (*Mysql) GetDb

func (m *Mysql) GetDb() (db *gorm.DB, err error)

GetDb 获取数据库

func (*Mysql) GetDns

func (m *Mysql) GetDns() string

func (*Mysql) GetLevel

func (m *Mysql) GetLevel() logger.LogLevel

func (*Mysql) NewConnection

func (m *Mysql) NewConnection() (*gorm.DB, error)

func (*Mysql) SetLogger added in v1.1.0

func (m *Mysql) SetLogger(logger *logrus.Logger)

type Pub

type Pub struct {
	Port    int
	Publish bool
}

type Redis

type Redis struct {
	Host string
	Port int
	Auth string
	Db   int
}

func NewRedis

func NewRedis(host string, port int, auth string, db int) *Redis

func (*Redis) Client added in v1.1.6

func (r *Redis) Client() *redis.Client

type Server

type Server struct {
	Cluster string
	Ip      string
	Name    string
	Loger   map[string]ZLog
	Etcd    zetcd.Etcd
	Retry   bool
	Listen  map[string]Pub
	Mysql   map[string]Mysql
	Redis   map[string]Redis
	EtcdDis *zetcd.EtcdDis
	Service map[string]string //service.key, service.value
	sync.RWMutex
}

func NewServer added in v1.1.0

func NewServer() (*Server, error)

func (*Server) FillIp added in v1.1.0

func (s *Server) FillIp()

func (*Server) GetClusterRedis added in v1.1.6

func (s *Server) GetClusterRedis(addrs []string) *redis.ClusterClient

GetClusterRedis 获取redis集群

func (*Server) GetDb added in v1.1.0

func (s *Server) GetDb() (*gorm.DB, error)

GetDb 指定DB

func (*Server) GetDbBySec added in v1.1.0

func (s *Server) GetDbBySec(sectionDb string) (*gorm.DB, error)

GetDbBySec 指定DB

func (*Server) GetLog added in v1.1.0

func (s *Server) GetLog(section string) *logrus.Logger

func (*Server) GetRandomEndPoint added in v1.1.4

func (s *Server) GetRandomEndPoint(serviceName string) (endpoint string, err error)

GetRandomEndPoint 获取随机的端点

func (*Server) GetRedis added in v1.1.6

func (s *Server) GetRedis(sectionDb string) (*redis.Client, error)

GetRedis 指定redis

func (*Server) GrpcRequestRemote added in v1.1.0

func (s *Server) GrpcRequestRemote(ctx context.Context, serverName string, req interface{}, reqFactory sd.Factory) (response interface{}, err error)

GrpcRequestRemote 外部服务

func (*Server) Log added in v1.1.0

func (s *Server) Log() *logrus.Logger

func (*Server) Register added in v1.1.0

func (s *Server) Register()

func (*Server) SetSiteMode added in v1.1.0

func (s *Server) SetSiteMode(siteMode string)

func (*Server) UnRegister added in v1.1.0

func (s *Server) UnRegister()

type ZLog added in v1.1.0

type ZLog struct {
	Path       string
	File       string
	Age        int64
	Rotation   int64
	Log        *logrus.Logger
	Initialize bool
}

func NewLog

func NewLog(path, file string, age, rotation int64) *ZLog

func (*ZLog) CheckOrCreateDIr added in v1.1.0

func (l *ZLog) CheckOrCreateDIr(baseLogPaht string, where string) bool

func (*ZLog) GetFilePath added in v1.1.0

func (l *ZLog) GetFilePath() string

func (*ZLog) GetRotation added in v1.1.0

func (l *ZLog) GetRotation() int64

Directories

Path Synopsis
proto

Jump to

Keyboard shortcuts

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