Documentation ¶
Overview ¶
读取配置文件
Index ¶
- func ArrayFindString(search []string, flag string) bool
- func FbindParams(ctx *gin.Context, input interface{}) error
- func GenToken(authData map[string]string) (string, error)
- func GetGrpcClientConn(serviceName, tag string) (*grpc.ClientConn, error)
- func GetGrpcCtx(ctx *gin.Context) context.Context
- func ParsearseToken(tokenStr string) (*customClaims, error)
- func ReturnJson(ctx *gin.Context, code int, data any, err error)
- type Auth
- type Config
- type Consul
- type Cors
- type Fgin
- func (f *Fgin) GetConfig() Config
- func (f *Fgin) GetFgrpcClientConn(serviceName string) (*FgrpcClientConn, error)
- func (f *Fgin) GetGormDb(name string) *gorm.DB
- func (f *Fgin) GetGrpcServer(path string) *grpc.Server
- func (f *Fgin) GetHttpServer(path string) *gin.Engine
- func (f *Fgin) GetLogger() *zap.SugaredLogger
- func (f *Fgin) GetRabbitmqConn(queueName string) (*amqp.Connection, error)
- func (f *Fgin) GetRedisClient() redis.UniversalClient
- func (f *Fgin) Run(router *gin.Engine)
- func (f *Fgin) RunGrpc(s *grpc.Server)
- type FginRabbitmq
- type FgrpcClientConn
- type GormLog
- type GrpcClient
- type HealthService
- type Jaeger
- type Log
- type Mysql
- type Rabbitmq
- type Redis
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FbindParams ¶
绑定参数,利用的gin的bind逻辑,可返回自定义错误
func GetGrpcClientConn ¶
func GetGrpcClientConn(serviceName, tag string) (*grpc.ClientConn, error)
该方法用于需要关闭conn的时候使用
func ParsearseToken ¶
Types ¶
type Auth ¶
type Auth struct { AuthLs []string `json:"auth_ls" mapstructure:"auth_ls"` Timeout int `json:"time_out" mapstructure:"time_out"` SecreKey string `json:"secre_key" mapstructure:"secre_key"` SigningMethod int `json:"signing_method" mapstructure:"signing_method"` HeaderKey string `json:"header_key" mapstructure:"header_key"` DisableLs []string `json:"disable_ls" mapstructure:"disable_ls"` }
type Config ¶
type Config struct { ServiceName string `yaml:"service_name" mapstructure:"service_name"` Tag string `yaml:"tag" mapstructure:"tag"` NetType string `yaml:"net_type" mapstructure:"net_type"` Ip string `yaml:"ip" mapstructure:"ip"` Port int `yaml:"port" mapstructure:"port"` Env string `yaml:"env" mapstructure:"env"` Log Log `yaml:"log" mapstructure:"log"` Auth Auth `yaml:"auth" mapstructure:"auth"` Mysql []Mysql `yaml:"mysql" mapstructure:"mysql"` GormLog GormLog `yaml:"gorm_log" mapstructure:"gorm_log"` Redis Redis `yaml:"redis" mapstructure:"redis"` Consul Consul `yaml:"consul" mapstructure:"consul"` Jaeger Jaeger `yaml:"jaeger" mapstructure:"jaeger"` Rabbitmq []Rabbitmq `yaml:"rabbitmq" mapstructure:"rabbitmq"` GrpcClient []GrpcClient `yaml:"grpc_client" mapstructure:"grpc_client"` Cors Cors `yaml:"cors" mapstructure:"cors"` }
type Cors ¶
type Cors struct { UseDefault bool `yaml:"use_default" mapstructure:"use_default"` AllowOrigins string `yaml:"allow_origins" mapstructure:"allow_origins"` AllowMethods string `yaml:"allow_methods" mapstructure:"allow_methods"` AllowHeaders string `yaml:"allow_headers" mapstructure:"allow_headers"` ExposeHeaders string `yaml:"expose_headers" mapstructure:"expose_headers"` AllowCredentials bool `yaml:"allow_credentials" mapstructure:"allow_credentials"` MaxAge int `yaml:"max_age" mapstructure:"max_age"` }
解决跨域配置
type Fgin ¶
type Fgin struct{}
func (*Fgin) GetFgrpcClientConn ¶
func (f *Fgin) GetFgrpcClientConn(serviceName string) (*FgrpcClientConn, error)
获取grpc已经dail的conn
func (*Fgin) GetRabbitmqConn ¶
func (f *Fgin) GetRabbitmqConn(queueName string) (*amqp.Connection, error)
获取rabbitmq dail的conn
type FginRabbitmq ¶
type FginRabbitmq struct { QueueName string MaxRetry int32 MaxConsume int RabbitmqConn *amqp.Connection RabbitmqCh []*amqp.Channel RabbitmqQueue *amqp.Queue }
框架的默认队列对象
func (*FginRabbitmq) DefaultConsumer ¶
func (fr *FginRabbitmq) DefaultConsumer(hander func(msg amqp.Delivery) error) error
默认消费者
func (*FginRabbitmq) DefaultProducter ¶
func (fr *FginRabbitmq) DefaultProducter(contentType string, body []byte) error
默认生产者
type FgrpcClientConn ¶
type FgrpcClientConn struct {
*grpc.ClientConn
}
func (*FgrpcClientConn) Close ¶
func (f *FgrpcClientConn) Close()
type GormLog ¶
type GormLog struct { SlowThreshold int `yaml:"slow_threshold" mapstructure:"slow_threshold"` // 慢查询阈值,单位 ms Colorful bool `yaml:"colorful" mapstructure:"colorful"` // 日志是否着色 IgnoreRecordNotFoundError bool `yaml:"ignore_record_not_found_error" mapstructure:"ignore_record_not_found_error"` // 是否忽略记录不存在的错误 ParameterizedQueries bool `yaml:"parameterized_queries" mapstructure:"parameterized_queries"` // 不包含参数在sql log内 LogLevel int `yaml:"log_level" mapstructure:"log_level"` // 1: Silent, 2: Error, 3: Warn, 4: Info }
type GrpcClient ¶
type HealthService ¶
type HealthService struct{}
手动实现健康检查部分
func (*HealthService) Check ¶
func (s *HealthService) Check(ctx context.Context, req *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error)
func (*HealthService) Watch ¶
func (s *HealthService) Watch(req *healthpb.HealthCheckRequest, srv healthpb.Health_WatchServer) error
type Redis ¶
type Redis struct { Addrs []string `yaml:"addrs" mapstructure:"addrs"` // 多个地址,使用集群模式 UserName string `yaml:"user_name" mapstructure:"user_name"` PassWord string `yaml:"pass_word" mapstructure:"pass_word"` Db int `yaml:"db" mapstructure:"db"` MasterName string `yaml:"master_name" mapstructure:"master_name"` // 配置name,使用哨兵模式 }
Click to show internal directories.
Click to hide internal directories.