Documentation ¶
Index ¶
- Constants
- Variables
- type ApUpdateCallback
- type ApiPkg
- type ApolloConfPkg
- type ApolloPkg
- func (c *ApolloPkg) Alias(alias string) *ApolloPkg
- func (c *ApolloPkg) GetBool(key string) bool
- func (c *ApolloPkg) GetDuration(key string) time.Duration
- func (c *ApolloPkg) GetFloat64(key string) float64
- func (c *ApolloPkg) GetInt(key string) int
- func (c *ApolloPkg) GetInt32(key string) int32
- func (c *ApolloPkg) GetInt64(key string) int64
- func (c *ApolloPkg) GetIntSlice(key string) []int
- func (c *ApolloPkg) GetSizeInBytes(key string) uint
- func (c *ApolloPkg) GetString(key string) string
- func (c *ApolloPkg) GetStringMap(key string) map[string]any
- func (c *ApolloPkg) GetStringMapString(key string) map[string]string
- func (c *ApolloPkg) GetStringMapStringSlice(key string) map[string][]string
- func (c *ApolloPkg) GetStringMapStruct(key string, outputStruct interface{}) error
- func (c *ApolloPkg) GetStringSlice(key string) []string
- func (c *ApolloPkg) GetTime(key string) time.Time
- func (c *ApolloPkg) GetUint(key string) uint
- func (c *ApolloPkg) GetUint16(key string) uint16
- func (c *ApolloPkg) GetUint32(key string) uint32
- func (c *ApolloPkg) GetUint64(key string) uint64
- func (c *ApolloPkg) Start(apConf *ApolloConfPkg, callback ApUpdateCallback) error
- func (c *ApolloPkg) Struct(alias string, outputStruct interface{}) error
- func (c *ApolloPkg) Update(updates map[string]interface{}) error
- type AppConfigPkg
- type Callback
- type ConfigPkg
- type CustomLogFormatter
- type CustomLogHook
- type DatabasePkg
- type DbPoolConfig
- type EntrySpanOptions
- type ExitSpanOptions
- type GormLogger
- func (p *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
- func (p *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
- func (p *GormLogger) LogMode(level logger.LogLevel) logger.Interface
- func (p *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (p *GormLogger) Warn(ctx context.Context, msg string, data ...interface{})
- type GoroutineContextManager
- type HttpPkg
- func (p *HttpPkg) Get(c context.Context, link string, timeout int, header map[string]string) (string, error)
- func (p *HttpPkg) GetResBody() string
- func (p *HttpPkg) GetResCode() int
- func (p *HttpPkg) GetResMsg() string
- func (p *HttpPkg) GetStatusCode() int
- func (p *HttpPkg) Post(c context.Context, link string, requestBody io.Reader, timeout int, ...) (string, error)
- func (p *HttpPkg) Request(c context.Context, link string, params map[string]interface{}, method string) *HttpPkg
- func (p *HttpPkg) Res(res any) *HttpPkg
- func (p *HttpPkg) Set(param string, value string) *HttpPkg
- func (p *HttpPkg) WithContentType(contentType string) *HttpPkg
- func (p *HttpPkg) WithHeader(header map[string]string) *HttpPkg
- func (p *HttpPkg) WithTimeout(timeout int) *HttpPkg
- func (p *HttpPkg) WithTrans() *HttpPkg
- type LocalSpanOptions
- type LoggerPkg
- type Redis
- func (p *Redis) Del(c context.Context, key string) error
- func (p *Redis) Get(c context.Context, key string) *redis.StringCmd
- func (p *Redis) Init(host string, port int, auth string, poolSize int, defaultDb int, prefix string)
- func (p *Redis) Set(c context.Context, key string, value interface{}, expiration time.Duration) error
- func (p *Redis) SetNX(c context.Context, key string, value interface{}, expiration time.Duration) error
- type ResponseContent
- type Routes
- type Rule
- type TracerPkg
- func (p *TracerPkg) CheckEnable() bool
- func (p *TracerPkg) CreateEntrySpan(c context.Context, opts EntrySpanOptions) (go2sky.Span, context.Context, error)
- func (p *TracerPkg) CreateExitSpan(c context.Context, opts ExitSpanOptions) (go2sky.Span, error)
- func (p *TracerPkg) CreateExitSpanWithContext(c context.Context, opts ExitSpanOptions) (go2sky.Span, context.Context, error)
- func (p *TracerPkg) CreateLocalSpan(c context.Context, opts LocalSpanOptions) (go2sky.Span, context.Context, error)
- func (p *TracerPkg) DisableTracer()
- func (p *TracerPkg) EnableTracer()
- func (p *TracerPkg) Init(serviceAddr string, serviceName string, enable bool)
- func (p *TracerPkg) SpanErr(span go2sky.Span, content ...string)
- func (p *TracerPkg) SpanTag(span go2sky.Span, tag go2sky.Tag, content string)
- type Validators
Constants ¶
View Source
const ( ComponentRedisServer = 7 ComponentIDGINHttpServer = 5006 )
Variables ¶
View Source
var Api = &ApiPkg{}
View Source
var Apollo = &ApolloPkg{Viper: viper.New()}
View Source
var Config = &ConfigPkg{}
View Source
var Database = &DatabasePkg{}
View Source
var GCM = &GoroutineContextManager{
GlobalGinContextKey: "ppw_gin_context",
}
View Source
var Http = &HttpPkg{}
View Source
var RedisCli = &Redis{}
View Source
var Tracer = &TracerPkg{}
Functions ¶
This section is empty.
Types ¶
type ApUpdateCallback ¶ added in v0.6.2
ApUpdateCallback 外部指定的apollo配置变更后的回调,用于外部跟进处理配置变更后的后续逻辑
type ApiPkg ¶
type ApiPkg struct {
// contains filtered or unexported fields
}
func (*ApiPkg) GetResponse ¶ added in v0.8.7
func (*ApiPkg) RegisterValidates ¶
func (p *ApiPkg) RegisterValidates(validates []*Validators)
type ApolloConfPkg ¶ added in v0.6.6
type ApolloConfPkg struct { Service string `mapstructure:"service"` CacheDir string `mapstructure:"cache_dir"` App map[string]AppConfigPkg `mapstructure:"app"` }
type ApolloPkg ¶
func (*ApolloPkg) GetDuration ¶ added in v0.6.9
func (*ApolloPkg) GetFloat64 ¶ added in v0.6.9
func (*ApolloPkg) GetIntSlice ¶ added in v0.6.9
func (*ApolloPkg) GetSizeInBytes ¶ added in v0.6.9
func (*ApolloPkg) GetStringMap ¶ added in v0.6.9
func (*ApolloPkg) GetStringMapString ¶ added in v0.6.9
func (*ApolloPkg) GetStringMapStringSlice ¶ added in v0.6.9
func (*ApolloPkg) GetStringMapStruct ¶ added in v0.7.7
func (*ApolloPkg) GetStringSlice ¶ added in v0.6.9
func (*ApolloPkg) Start ¶ added in v0.6.9
func (c *ApolloPkg) Start(apConf *ApolloConfPkg, callback ApUpdateCallback) error
Start 启动apollo配置中心,配置读写依赖viper
type AppConfigPkg ¶ added in v0.6.9
type ConfigPkg ¶
type ConfigPkg struct { *viper.Viper ConfigPath string // 本地配置文件路径 ConfigType string // 本地配置文件类型 LocalStructMap map[string]interface{} }
func (*ConfigPkg) GetStringMapStruct ¶ added in v0.7.7
type CustomLogFormatter ¶
type CustomLogFormatter struct{}
type CustomLogHook ¶
type CustomLogHook struct {
LogDir string
}
func (*CustomLogHook) Levels ¶
func (hook *CustomLogHook) Levels() []logrus.Level
type DatabasePkg ¶
type DatabasePkg struct {
// contains filtered or unexported fields
}
func (*DatabasePkg) GetDb ¶
func (c *DatabasePkg) GetDb(config *DbPoolConfig) *gorm.DB
func (*DatabasePkg) Init ¶
func (c *DatabasePkg) Init(dbKey string, dbc *DbPoolConfig, callback Callback)
type DbPoolConfig ¶
type DbPoolConfig struct { Type string `mapstructure:"type"` Host string `mapstructure:"host"` Port int `mapstructure:"port"` User string `mapstructure:"user"` Password string `mapstructure:"password"` Database string `mapstructure:"db"` Charset string `mapstructure:"charset"` TablePrefix string `mapstructure:"table_prefix"` MaxOpenConns int `mapstructure:"max_open_conns" summary:"最大连接数"` MaxIdleConns int `mapstructure:"max_idle_conns" summary:"最大空闲连接数"` ConnMaxLifetime int `mapstructure:"conn_max_lifetime" summary:"连接的最大存活时间"` ConnMaxIdleTime int `mapstructure:"conn_max_idle_time" summary:"连接空闲超时"` }
type EntrySpanOptions ¶
type ExitSpanOptions ¶
type GormLogger ¶
type GormLogger struct { }
func (*GormLogger) Error ¶
func (p *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
func (*GormLogger) Info ¶
func (p *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
type GoroutineContextManager ¶
type GoroutineContextManager struct {
GlobalGinContextKey string
}
func (*GoroutineContextManager) GetContext ¶
func (*GoroutineContextManager) SetContext ¶
func (gcm *GoroutineContextManager) SetContext(ctx *gin.Context)
type HttpPkg ¶
type HttpPkg struct {
// contains filtered or unexported fields
}
func (*HttpPkg) GetResBody ¶ added in v0.8.9
func (*HttpPkg) GetResCode ¶ added in v0.8.9
func (*HttpPkg) GetStatusCode ¶ added in v0.8.9
func (*HttpPkg) WithContentType ¶ added in v0.8.5
func (*HttpPkg) WithHeader ¶ added in v0.8.5
func (*HttpPkg) WithTimeout ¶ added in v0.8.5
type LocalSpanOptions ¶
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
func NewRedisClient ¶ added in v0.7.9
type ResponseContent ¶
type TracerPkg ¶
type TracerPkg struct {
// contains filtered or unexported fields
}
func (*TracerPkg) CheckEnable ¶ added in v0.6.2
func (*TracerPkg) CreateEntrySpan ¶
func (p *TracerPkg) CreateEntrySpan(c context.Context, opts EntrySpanOptions) (go2sky.Span, context.Context, error)
CreateEntrySpan 创建入口起始span,最终出口调用sky.GetGcm().DeleteContext()
func (*TracerPkg) CreateExitSpan ¶
CreateExitSpan 创建对外请求span,返回的content为当前请求的主线context
func (*TracerPkg) CreateExitSpanWithContext ¶
func (*TracerPkg) CreateLocalSpan ¶
func (p *TracerPkg) CreateLocalSpan(c context.Context, opts LocalSpanOptions) (go2sky.Span, context.Context, error)
CreateLocalSpan 创建内部自定span
func (*TracerPkg) DisableTracer ¶ added in v0.8.4
func (p *TracerPkg) DisableTracer()
func (*TracerPkg) EnableTracer ¶ added in v0.8.4
func (p *TracerPkg) EnableTracer()
Click to show internal directories.
Click to hide internal directories.