Documentation ¶
Overview ¶
Package config 负责配置信息
Index ¶
- Constants
- Variables
- func CheckError(err error, errType string) error
- func ControlCors() gin.HandlerFunc
- func GetProjectName() string
- func Init()
- func InitCos()
- func InitEmail()
- func InitGrpc()
- func InitLogger()
- func InitMysql()
- func InitRedis()
- func InitSms()
- func InitSts()
- func InitWeb(funs []gin.HandlerFunc) *gin.Engine
- func LogRecovery() gin.HandlerFunc
- func NewGrpcServer() *grpc.Server
- func NewPool(endpoints map[string]GrpcEndpoint) map[string]Pool
- func ProjectPath() (path string)
- func PutGrpcConn(name string, conn *IdleConn)
- func RPCConnectMonitor() grpc.UnaryClientInterceptor
- func RegisterGRPCServiceConsul(address string, port int, tags []string) error
- func RunServer(s *grpc.Server, addr string)
- func RunWeb(r *gin.Engine, addr string)
- func SetLogger() gin.HandlerFunc
- func SetProjectName(name string)
- func TimeoutUnaryClientInterceptor(timeout time.Duration) grpc.UnaryClientInterceptor
- func Usage()
- type ChannelPool
- func (c *ChannelPool) Close(conn *grpc.ClientConn) error
- func (c *ChannelPool) Get() (*IdleConn, error)
- func (c *ChannelPool) Len() int
- func (c *ChannelPool) Put(ic *IdleConn) error
- func (c *ChannelPool) Release()
- func (c *ChannelPool) RetrieveConcurrentStream(ic *IdleConn)
- func (c *ChannelPool) RetrieveStream(ic *IdleConn)
- type Config
- type CosClient
- type GrpcEndpoint
- type IdleConn
- type MysqlInstance
- type Pool
- type PoolConfig
- type RedisClient
- type StsClient
- type TencentSms
Constants ¶
View Source
const ( OnlineServiceHostPort = ":50051" HttpTimeoutHandler = 10 * time.Second //TimeoutHandler默认的http超时时间,http响应时间超过后直接返回client端503(不同项目可根据接口最大超时时间调整) EnvLocal = "local" EnvTest = "test" EnvBVT = "bvt" EnvProduct = "product" EnvBenchmark = "benchmark" )
Variables ¶
View Source
var ( CoreCtx coreCtx DevEnv string TestConfig string ProjectName string )
View Source
var ( ErrClosed = errors.New("pool had closed") ErrLimit = errors.New("pool is reached max") MaxConcurrentStreams = 100 MaxGetConnTimes = 200 )
View Source
var CosClientList = make(map[string]CosClient)
View Source
var EmailConfig = &emailConfig{}
View Source
var StsClientList = make(map[string]StsClient)
View Source
var TencentSmsClient = &TencentSms{}
Functions ¶
func CheckError ¶
func GetProjectName ¶
func GetProjectName() string
func InitLogger ¶
func InitLogger()
func LogRecovery ¶
func LogRecovery() gin.HandlerFunc
func NewGrpcServer ¶
func ProjectPath ¶
func ProjectPath() (path string)
func PutGrpcConn ¶
func RPCConnectMonitor ¶
func RPCConnectMonitor() grpc.UnaryClientInterceptor
RPCConnectMonitor gRPC.Server 重启, gRPC.Pool连接的时健康检测
func RegisterGRPCServiceConsul ¶
RegisterGRPCServiceConsul 注册服务到consul
func SetProjectName ¶
func SetProjectName(name string)
func TimeoutUnaryClientInterceptor ¶
func TimeoutUnaryClientInterceptor(timeout time.Duration) grpc.UnaryClientInterceptor
TimeoutUnaryClientInterceptor returns a new unary client interceptor that sets a timeout on the request context.
Types ¶
type ChannelPool ¶
type ChannelPool struct {
// contains filtered or unexported fields
}
func (*ChannelPool) RetrieveConcurrentStream ¶
func (c *ChannelPool) RetrieveConcurrentStream(ic *IdleConn)
RetrieveConcurrentStream 回收steam
func (*ChannelPool) RetrieveStream ¶
func (c *ChannelPool) RetrieveStream(ic *IdleConn)
RetrieveStream 回收steam
type GrpcEndpoint ¶
type IdleConn ¶
type IdleConn struct { Conn *grpc.ClientConn // contains filtered or unexported fields }
type MysqlInstance ¶
func GetMysqlInstance ¶
func GetMysqlInstance(dbName string) (MysqlInstance, error)
type Pool ¶
type Pool interface { Get() (*IdleConn, error) Put(*IdleConn) error RetrieveConcurrentStream(*IdleConn) RetrieveStream(*IdleConn) Close(*grpc.ClientConn) error Release() Len() int }
Pool 定义pool接口
func NewChannelPool ¶
func NewChannelPool(poolConfig *PoolConfig) (Pool, error)
NewChannelPool 初始化连接池
type PoolConfig ¶
type RedisClient ¶
type TencentSms ¶
type TencentSms struct { Client *sms.Client Request *sms.SendSmsRequest MobileCode string }
Click to show internal directories.
Click to hide internal directories.