Documentation ¶
Index ¶
- Constants
- func Context(ictx iris.Context) context.Context
- func ContextWithTraceID(ctx context.Context, traceId string) context.Context
- func TraceID(ctx context.Context) string
- type Aa
- func (app *Aa) IrisMiddleware(ictx iris.Context)
- func (app *Aa) LoadIni(path string) error
- func (app *Aa) MysqlConfig(section string) (MysqlConfig, error)
- func (app *Aa) ParseTimeout(t string, defaultTimeouts ...time.Duration) (conn time.Duration, read time.Duration, write time.Duration)
- func (app *Aa) ParseToConfiguration()
- func (app *Aa) RedisConfig(section string) (RedisConfig, error)
- func (app *Aa) Run(jobs ...Job)
- type Config
- type Configuration
- type Ini
- func (c *Ini) AddOtherConfigs(otherConfigs map[string]string)
- func (c *Ini) AddRsaConfigs(rsaConfigs map[string][]byte)
- func (c *Ini) Get(key string, defaultValue ...interface{}) *dtype.Dtype
- func (c *Ini) GetString(key string, defaultValue ...string) string
- func (c *Ini) LoadAIni(cfgs map[string]json.RawMessage) error
- func (c *Ini) MustGet(key string) (*dtype.Dtype, error)
- func (c *Ini) MustGetString(key string) (string, error)
- func (c *Ini) Reload(app *Aa) error
- type Job
- type Log
- type MysqlConfig
- type MysqlPoolConfig
- type RedisConfig
- type RedisPoolConfig
Constants ¶
View Source
const ( CkRsaRoot = "rsa_root" CkEnv = "env" CkTimezoneID = "timezone_id" CkTimeFormat = "time_format" CkMock = "mock" )
View Source
const TraceIdKey = "aa_trace_id"
Variables ¶
This section is empty.
Functions ¶
func ContextWithTraceID ¶
Types ¶
type Aa ¶
type Aa struct { //once sync.Once // self imported configurations, e.g. parsed from ini Config Config // system configuration Configuration Configuration Log Log }
func (*Aa) IrisMiddleware ¶
func (app *Aa) IrisMiddleware(ictx iris.Context)
tracePrefix should be captialized
func (*Aa) MysqlConfig ¶
func (app *Aa) MysqlConfig(section string) (MysqlConfig, error)
func (*Aa) ParseTimeout ¶
func (app *Aa) ParseTimeout(t string, defaultTimeouts ...time.Duration) (conn time.Duration, read time.Duration, write time.Duration)
ParseTimeout connection timeout, r timeout, w timeout, heartbeat interval 10s, 1000ms
func (*Aa) ParseToConfiguration ¶
func (app *Aa) ParseToConfiguration()
func (*Aa) RedisConfig ¶
func (app *Aa) RedisConfig(section string) (RedisConfig, error)
type Config ¶
type Config interface { Reload(app *Aa) error LoadAIni(cfgs map[string]json.RawMessage) error // 加载 a ini 一维json配置 AddOtherConfigs(otherConfigs map[string]string) // 这里有锁,所以要批量设置 //getOtherConfig(key string) string // 不要获取太细分,否则容易导致错误不容易被排查 AddRsaConfigs(rsaConfigs map[string][]byte) //GetRsa(name string) ([]byte, bool) // 不要获取太细分,否则容易导致错误不容易被排查 MustGetString(key string) (string, error) GetString(key string, defaultValue ...string) string MustGet(key string) (*dtype.Dtype, error) Get(key string, defaultValue ...interface{}) *dtype.Dtype }
type Configuration ¶
type Configuration struct { Env string // dev test preprod product TimezoneID string // e.g. "Asia/Shanghai" TimeLocation *time.Location TimeFormat string // e.g. "2006-02-01 15:04:05" Mock bool // using mock }
func (Configuration) Log ¶
func (c Configuration) Log()
type Ini ¶
type Ini struct {
// contains filtered or unexported fields
}
func (*Ini) AddOtherConfigs ¶
这里有锁,所以要批量设置
func (*Ini) AddRsaConfigs ¶
type Log ¶
type Log interface { AError(ctx context.Context, e *ae.Error) // AuthDebug 包含详细的开发情报的信息,通常只在调试一个程序时使用 Debug(ctx context.Context, msg string, args ...interface{}) // Info 情报信息,正常的系统消息,比如骚扰报告,带宽数据等,不需要处理。 Info(ctx context.Context, msg string, args ...interface{}) // Notice 不是错误情况,也不需要立即处理。 Notice(ctx context.Context, msg string, args ...interface{}) // Warn 警告信息,不是错误,比如系统磁盘使用了85%等。 Warn(ctx context.Context, msg string, args ...interface{}) // Error 错误,不是非常紧急,在一定时间内修复即可。 Error(ctx context.Context, msg string, args ...interface{}) // Crit 重要情况,如硬盘错误,备用连接丢失 Crit(ctx context.Context, msg string, args ...interface{}) // Alert 应该被立即改正的问题,如系统数据库被破坏,ISP连接丢失。 Alert(ctx context.Context, msg string, args ...interface{}) // Emerg 紧急情况,需要立即通知技术人员。 Emerg(ctx context.Context, msg string, args ...interface{}) Printf(ctx context.Context, msg string, args ...interface{}) Println(ctx context.Context, msg ...interface{}) // Trace 跟踪请求链路,用于性能监控 Trace(ctx context.Context) }
func NewDefaultLog ¶
func NewDefaultLog() Log
type MysqlConfig ¶
type MysqlConfig struct { Schema string // dbname User string Password string // Scheme string // tcp|unix,只支持tcp,unix仅本地可用 TLS string // 默认 false,Valid Values: true, false, skip-verify, preferred, <name> Host string // mysql客户端在尝试与mysql服务器建立连接时,mysql服务器返回错误握手协议前等待客户端数据包的最大时限。默认10秒。 ConnTimeout time.Duration // 使用时,需要设置单位,s, ms等。Timeout for establishing connections, aka dial timeout ReadTimeout time.Duration // 使用时,需要设置单位,s, ms等。I/O read timeout. WriteTimeout time.Duration // 使用时,需要设置单位,s, ms等。I/O write timeout. Pool MysqlPoolConfig }
type MysqlPoolConfig ¶
type RedisConfig ¶
type RedisPoolConfig ¶
type RedisPoolConfig struct { // Maximum number of idle connections in the pool. MaxIdle int // Maximum number of connections allocated by the pool at a given time. // When zero, there is no limit on the number of connections in the pool. MaxActive int // Close connections after remaining idle for this duration. If the value // is zero, then idle connections are not closed. Applications should set // the timeout to a value less than the server's timeout. IdleTimeout time.Duration // If Wait is true and the pool is at the MaxActive limit, then Get() waits // for a connection to be returned to the pool before returning. Wait bool // Close connections older than this duration. If the value is zero, then // the pool does not close connections based on age. MaxConnLifetime time.Duration }
Click to show internal directories.
Click to hide internal directories.