Documentation
¶
Index ¶
- Constants
- Variables
- func CryptoRandInt(n int) *big.Int
- func FileAbsPath(path string) string
- func FindPidSliceByProcessName(name string) []string
- func InjectPopulate(values ...interface{})
- func KillProcess(name string) (err error)
- func MathRandInt(n int) int
- func NewValue(bean interface{}) (val interface{})
- func ProcessIsRunning(name string) bool
- func RandUseragent() string
- func RetryDo(fn func() error, intervalSecond int64) error
- func RetryDoTimes(times, intervalSecond int64, fn func() error) error
- func SetTimeZone() error
- func TextTemplateMustParse(text string, data interface{}) (result string)
- func Ticker(d time.Duration, fn func())
- func TimeExcWrap(fn func()) time.Duration
- func TimeNow() time.Time
- func TodayDate() string
- func ValueIndirect(val reflect.Value) reflect.Value
- type ABFileOption
- type AbFile
- type Config
- type G2cache
- func (g *G2cache) BigCache() *bigcache.BigCache
- func (g *G2cache) Constructor()
- func (g *G2cache) Delete(key string) (err error)
- func (g *G2cache) Get(key string) (data []byte, err error)
- func (g *G2cache) GoCache() *cache.Cache
- func (g *G2cache) New() *G2cache
- func (g *G2cache) Reset() (err error)
- func (g *G2cache) Set(key string, data []byte) (err error)
- type G2cron
- type GoPool
- type Graceful
- type IWriter
- type ItfCache
- type ItfExec
- type ItfGracefulProcess
- type JSONTime
- func (p *JSONTime) Add(d time.Duration) *JSONTime
- func (p JSONTime) Addr() *JSONTime
- func (p *JSONTime) Convert2Time() time.Time
- func (p *JSONTime) Date() *JSONTime
- func (p *JSONTime) FromDB(data []byte) error
- func (p *JSONTime) GobDecode(data []byte) error
- func (p *JSONTime) GobEncode() ([]byte, error)
- func (p *JSONTime) MarshalJSON() ([]byte, error)
- func (p *JSONTime) Scan(v interface{}) error
- func (p *JSONTime) SetByTime(timeVal time.Time)
- func (p *JSONTime) String() string
- func (p *JSONTime) StringFormat(layout string) string
- func (p *JSONTime) Time() time.Time
- func (p *JSONTime) ToDB() (b []byte, err error)
- func (p *JSONTime) UnmarshalJSON(data []byte) error
- func (p *JSONTime) Value() (driver.Value, error)
- type Level
- type LevelLogger
- type Map
- func (m Map) GetBool(key string) bool
- func (m Map) GetInt(key string) int
- func (m Map) GetInt64(key string) int64
- func (m Map) GetString(key string) string
- func (m Map) MarshalBinary() (data []byte, err error)
- func (m Map) MergeTo(mp Map)
- func (m Map) ToBean(bean interface{}) (err error)
- func (m *Map) UnmarshalBinary(data []byte) error
- type RestyAgent
Constants ¶
const ( //TimeZone ... TimeZone = "Asia/Shanghai" //Custom ... Custom = "2006-01-02 15:04:05" //DateLayout ... DateLayout = "2006-01-02" )
const (
MB int
)
常量,大小定义
Variables ¶
var ErrNotFound = errors.New("item not found")
ErrNotFound ...
var TimeNowFunc = time.Now
TimeNowFunc ...
Functions ¶
func FindPidSliceByProcessName ¶ added in v2.0.3
FindPidSliceByProcessName get pid list
func KillProcess ¶ added in v2.0.3
KillProcess ...kill process
func ProcessIsRunning ¶ added in v2.0.3
ProcessIsRunning is running
func RetryDoTimes ¶ added in v2.0.3
RetryDoTimes ...
func TextTemplateMustParse ¶ added in v2.0.2
TextTemplateMustParse ...
Types ¶
type ABFileOption ¶ added in v2.0.3
type ABFileOption struct {
//文件最大值,超过该值自动备份,备份文件大小略大于该值
FileMaxSize int
//保存目录天数
SaveDays int
//writer buffer size,内存缓冲区大小
BufferSize int
//自动刷新数据到磁盘的周期,默认值为2秒
AutoFlushPeriod time.Duration
//检查删除过期文件目录间隔
AutoDelPeriod time.Duration
}
ABFileOption 参数配置
type AbFile ¶ added in v2.0.3
type AbFile struct {
Config *Config `inject:""`
Graceful *Graceful `inject:""`
// contains filtered or unexported fields
}
AbFile ...
type Config ¶ added in v2.0.3
type Config struct {
// contains filtered or unexported fields
}
Config ...
func (*Config) SetFilename ¶ added in v2.0.3
SetFilename ...
func (*Config) SetRootPath ¶ added in v2.0.3
SetRootPath ...
type G2cache ¶ added in v2.0.3
type G2cache struct {
// contains filtered or unexported fields
}
G2cache ...
type G2cron ¶ added in v2.0.3
type G2cron struct {
Logger LevelLogger `inject:""`
// contains filtered or unexported fields
}
G2cron ...
func (*G2cron) OnProcessStart ¶ added in v2.0.3
func (c *G2cron) OnProcessStart()
OnProcessStart ...启动定时任务
type GoPool ¶ added in v2.0.3
type GoPool struct {
LevelLogger LevelLogger `inject:""`
Grace *Graceful `inject:""`
// contains filtered or unexported fields
}
GoPool ...goroutine pool
type Graceful ¶ added in v2.0.3
type Graceful struct {
Logger LevelLogger `inject:""`
// contains filtered or unexported fields
}
Graceful ...
func (*Graceful) RegHTTPServer ¶ added in v2.0.3
RegHTTPServer ...注册一个http服务
func (*Graceful) RegProcessor ¶ added in v2.0.3
func (g *Graceful) RegProcessor(p ItfGracefulProcess)
RegProcessor ...注册一个对象,用于关闭程序后的行为
func (*Graceful) WaitForSignal ¶ added in v2.0.3
func (g *Graceful) WaitForSignal()
WaitForSignal ...
type IWriter ¶ added in v2.0.3
type IWriter interface {
AfterShutdown()
Closed() bool
Close()
Flush() (err error)
Write(p []byte) (n int, err error)
File() *os.File
}
IWriter ...
type ItfCache ¶ added in v2.0.3
type ItfCache interface {
Set(key string, data []byte) (err error)
Get(key string) (data []byte, err error)
Delete(key string) (err error)
Reset() (err error)
}
ItfCache ...
type ItfExec ¶ added in v2.0.3
type ItfExec interface {
Start() error
Run() error
Output() ([]byte, error)
CombinedOutput() ([]byte, error)
}
ItfExec ...
func NewExecInner ¶ added in v2.0.3
NewExecInner ...
type ItfGracefulProcess ¶ added in v2.0.3
type ItfGracefulProcess interface{ AfterShutdown() }
ItfGracefulProcess 接口,提供给关闭后行为
type JSONTime ¶ added in v2.0.3
JSONTime ...
func Must2JSONTimeAddr ¶ added in v2.0.3
Must2JSONTimeAddr maybe panic
func NewJSONTimeOfTime ¶ added in v2.0.3
NewJSONTimeOfTime 时间转换为JSONTime
func (*JSONTime) Convert2Time ¶ added in v2.0.3
Convert2Time ...
func (*JSONTime) MarshalJSON ¶ added in v2.0.3
MarshalJSON ...
func (*JSONTime) StringFormat ¶ added in v2.0.3
StringFormat 转换为固定格式字符串
func (*JSONTime) UnmarshalJSON ¶ added in v2.0.3
UnmarshalJSON ...
type Level ¶ added in v2.0.3
type Level uint32
Level type
level
func ParseLevel ¶ added in v2.0.3
ParseLevel takes a string level and returns the log level constant.
func (Level) MarshalText ¶ added in v2.0.3
MarshalText ...
func (Level) String ¶ added in v2.0.3
Convert the Level to a string. E.g. PanicLevel becomes "panic".
func (*Level) UnmarshalText ¶ added in v2.0.3
UnmarshalText implements encoding.TextUnmarshaler.
type LevelLogger ¶ added in v2.0.3
type LevelLogger interface {
SetOutput(io.Writer)
Writer() io.Writer
Print(...interface{})
Printf(string, ...interface{})
Println(...interface{})
Fatal(...interface{})
Fatalf(string, ...interface{})
Fatalln(...interface{})
Panic(...interface{})
Panicf(string, ...interface{})
Panicln(...interface{})
Debugf(string, ...interface{})
Infof(string, ...interface{})
Warnf(string, ...interface{})
Errorf(string, ...interface{})
SetLevel(lvl Level)
}
LevelLogger ...
func NewLevelLogger ¶ added in v2.0.3
func NewLevelLogger(prefix string, out ...io.Writer) LevelLogger
NewLevelLogger ...
type Map ¶ added in v2.0.2
type Map map[string]interface{}
Map ...
func (Map) MarshalBinary ¶ added in v2.0.2
MarshalBinary ...
func (*Map) UnmarshalBinary ¶ added in v2.0.2
UnmarshalBinary ...
type RestyAgent ¶ added in v2.0.3
type RestyAgent struct {
Logger LevelLogger `inject:""`
// contains filtered or unexported fields
}
RestyAgent ...
func (*RestyAgent) SetDialTimeout ¶ added in v2.0.3
func (a *RestyAgent) SetDialTimeout(d time.Duration) *RestyAgent
SetDialTimeout ... 非线程安全
func (*RestyAgent) SetProxy ¶ added in v2.0.3
func (a *RestyAgent) SetProxy(proxyURL string, user *url.Userinfo) *RestyAgent
SetProxy ... 非线程安全