Documentation
¶
Index ¶
- Constants
- Variables
- type APIPkg
- type ApUpdateCallback
- 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 DBPoolConfig
- type DatabasePkg
- type Entry
- type EntrySpanOptions
- type ExitSpanOptions
- type GormLogger
- func (p *GormLogger) Error(_ context.Context, _ string, _ ...interface{})
- func (p *GormLogger) Info(_ context.Context, _ string, _ ...interface{})
- func (p *GormLogger) LogMode(_ logger.LogLevel) logger.Interface
- func (p *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), _ error)
- func (p *GormLogger) Warn(_ context.Context, _ string, _ ...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, body 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 PreLogFunc
- type Redis
- func (p *Redis) Client() *redis.Client
- 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 Routes
- type Rule
- type Session
- type SessionWithRedis
- 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 APIPkg ¶ added in v0.9.6
type APIPkg struct {
// contains filtered or unexported fields
}
func (*APIPkg) GetResponse ¶ added in v0.9.6
func (*APIPkg) RegisterRoutes ¶ added in v0.9.6
func (*APIPkg) RegisterValidates ¶ added in v0.9.6
func (p *APIPkg) RegisterValidates(validates []Validators)
type ApUpdateCallback ¶ added in v0.6.2
ApUpdateCallback 外部指定的apollo配置变更后的回调,用于外部跟进处理配置变更后的后续逻辑
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
Log2Tracer bool
// contains filtered or unexported fields
}
func (*CustomLogHook) Levels ¶
func (hook *CustomLogHook) Levels() []logrus.Level
type DBPoolConfig ¶ added in v0.9.6
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"` // 最大连接数
MaxIdleConns int `mapstructure:"max_idle_conns"` // 最大空闲连接数
ConnMaxLifetime int `mapstructure:"conn_max_lifetime"` // 连接的最大存活时间
ConnMaxIdleTime int `mapstructure:"conn_max_idle_time"` // 连接空闲超时
}
type DatabasePkg ¶
type DatabasePkg struct {
}
func (*DatabasePkg) GetDB ¶ added in v0.9.6
func (c *DatabasePkg) GetDB(config *DBPoolConfig) *gorm.DB
func (*DatabasePkg) Init ¶
func (c *DatabasePkg) Init(dbc *DBPoolConfig, callback Callback)
type EntrySpanOptions ¶
type ExitSpanOptions ¶
type GormLogger ¶
type GormLogger struct {
}
func (*GormLogger) Error ¶
func (p *GormLogger) Error(_ context.Context, _ string, _ ...interface{})
type GoroutineContextManager ¶
type GoroutineContextManager struct {
GlobalGinContextKey contextKey
}
func (*GoroutineContextManager) GetContext ¶
func (*GoroutineContextManager) SetContext ¶
func (gcm *GoroutineContextManager) SetContext(ctx *gin.Context)
type HTTPPkg ¶ added in v0.9.6
type HTTPPkg struct {
// contains filtered or unexported fields
}
func (*HTTPPkg) GetResBody ¶ added in v0.9.6
func (*HTTPPkg) GetResCode ¶ added in v0.9.6
func (*HTTPPkg) GetStatusCode ¶ added in v0.9.6
func (*HTTPPkg) WithContentType ¶ added in v0.9.6
func (*HTTPPkg) WithHeader ¶ added in v0.9.6
func (*HTTPPkg) WithTimeout ¶ added in v0.9.6
type LocalSpanOptions ¶
type PreLogFunc ¶ added in v0.9.7
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
func NewRedisClient ¶ added in v0.7.9
type SessionWithRedis ¶ added in v0.8.21
type SessionWithRedis struct {
// contains filtered or unexported fields
}
func NewSession ¶ added in v0.8.21
func (*SessionWithRedis) Create ¶ added in v0.8.21
func (s *SessionWithRedis) Create(c *gin.Context, sessionName string, data string, ttl time.Duration) error
Create 创建 session sessionName 用于区分不同 session,比如用户 session 与管理员 session data 存储在 session 中的数据 ttl session 有效期
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()
type Validators ¶
Click to show internal directories.
Click to hide internal directories.