Documentation ¶
Index ¶
- Constants
- func SetLog(w io.Writer)
- func Timer() func() (start, end time.Time, duration time.Duration)
- type Counter
- type DynamicPoolMonitor
- func (m *DynamicPoolMonitor) Construct() GoroutineUID
- func (m *DynamicPoolMonitor) Destroy(gid GoroutineUID)
- func (m *DynamicPoolMonitor) GetCurrentActiveCount() int
- func (m *DynamicPoolMonitor) GetGoroutineCount() int
- func (m *DynamicPoolMonitor) GetGoroutinePeak() int
- func (m *DynamicPoolMonitor) GetStatusSettle() map[GoroutineStatus]time.Duration
- func (m *DynamicPoolMonitor) SwitchGoRoutineStatus(gid GoroutineUID)
- func (m *DynamicPoolMonitor) TryConstruct(want bool) (GoroutineUID, bool)
- func (m *DynamicPoolMonitor) TryDestroy(gid GoroutineUID) bool
- type Generator
- type GoroutinePool
- func (g *GoroutinePool) GetCurrentActiveCount() int
- func (g *GoroutinePool) GetGoroutineCount() int
- func (g *GoroutinePool) GetGoroutinePeak() int
- func (g *GoroutinePool) GetStatusSettle() map[GoroutineStatus]time.Duration
- func (g *GoroutinePool) GetWorkCount() int
- func (g *GoroutinePool) Put(obj TaskObj)
- func (g *GoroutinePool) Stop()
- type GoroutineSettle
- func (g *GoroutineSettle) AutoSwitchGoRoutineStatus() GoroutineStatus
- func (g *GoroutineSettle) GetRecentActiveRatio() float64
- func (g *GoroutineSettle) GetRecentStatusSettle() map[GoroutineStatus]time.Duration
- func (g *GoroutineSettle) GetStatus() GoroutineStatus
- func (g *GoroutineSettle) GetStatusSettle() map[GoroutineStatus]time.Duration
- func (g *GoroutineSettle) GetSurvivalDuration() time.Duration
- type GoroutineSettleMap
- func (m *GoroutineSettleMap) AutoSwitchGoRoutineStatus(gid GoroutineUID) GoroutineStatus
- func (m *GoroutineSettleMap) DeleteGoroutineSettle(gid GoroutineUID)
- func (m *GoroutineSettleMap) GetActiveGoroutineCount() int
- func (m *GoroutineSettleMap) GetAllGoroutineStatusDuration() map[GoroutineStatus]time.Duration
- func (m *GoroutineSettleMap) GetAllGoroutineUID() []GoroutineUID
- func (m *GoroutineSettleMap) GetCurrentStatus(gid GoroutineUID) GoroutineStatus
- func (m *GoroutineSettleMap) GetRecentActiveRatio(gid GoroutineUID) float64
- func (m *GoroutineSettleMap) GetRecentStatusSettle(gid GoroutineUID) map[GoroutineStatus]time.Duration
- func (m *GoroutineSettleMap) GetStatusSettle(gid GoroutineUID) map[GoroutineStatus]time.Duration
- func (m *GoroutineSettleMap) GetSurvivalDuration(gid GoroutineUID) time.Duration
- func (m *GoroutineSettleMap) NewGoroutineSettle(gid GoroutineUID, gs *GoroutineSettle) GoroutineUID
- type GoroutineStatus
- type GoroutineUID
- type IGenerator
- type Latency
- type LatencyMap
- func (g *LatencyMap) Clone() *LatencyMap
- func (g *LatencyMap) GetAll() map[GoroutineStatus]time.Duration
- func (g *LatencyMap) IsStart(status GoroutineStatus) bool
- func (g *LatencyMap) Set(status GoroutineStatus, l *Latency)
- func (g *LatencyMap) Start(status GoroutineStatus)
- func (g *LatencyMap) Stop(status GoroutineStatus)
- type Options
- type RecentRecord
- type StatusSettle
- type StatusSettleMap
- func (m *StatusSettleMap) AddMultiStatusDuration(multiStatusDuration map[GoroutineStatus]time.Duration)
- func (m *StatusSettleMap) AddStatusDuration(status GoroutineStatus, duration time.Duration)
- func (m *StatusSettleMap) GetAllStatusDuration() map[GoroutineStatus]time.Duration
- func (m *StatusSettleMap) GetOrCreate(status GoroutineStatus, duration time.Duration) *StatusSettle
- type StatusSwitch
- type TaskObj
Constants ¶
View Source
const (
CaseRecentDuration = time.Second * 60
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
计数器(线程安全)
func NewCounter ¶
func NewCounter() *Counter
type DynamicPoolMonitor ¶
type DynamicPoolMonitor struct {
// contains filtered or unexported fields
}
func NewDynamicPoolMonitor ¶
func NewDynamicPoolMonitor(o *Options) *DynamicPoolMonitor
func (*DynamicPoolMonitor) Construct ¶
func (m *DynamicPoolMonitor) Construct() GoroutineUID
强制构建一个新线程
func (*DynamicPoolMonitor) Destroy ¶
func (m *DynamicPoolMonitor) Destroy(gid GoroutineUID)
强制销毁一个线程
func (*DynamicPoolMonitor) GetCurrentActiveCount ¶
func (m *DynamicPoolMonitor) GetCurrentActiveCount() int
获取当前活跃线程数
func (*DynamicPoolMonitor) GetGoroutineCount ¶
func (m *DynamicPoolMonitor) GetGoroutineCount() int
获取当前存活线程数
func (*DynamicPoolMonitor) GetGoroutinePeak ¶
func (m *DynamicPoolMonitor) GetGoroutinePeak() int
获取存活线程数最高峰值
func (*DynamicPoolMonitor) GetStatusSettle ¶
func (m *DynamicPoolMonitor) GetStatusSettle() map[GoroutineStatus]time.Duration
获取状态总结
func (*DynamicPoolMonitor) SwitchGoRoutineStatus ¶
func (m *DynamicPoolMonitor) SwitchGoRoutineStatus(gid GoroutineUID)
切换一个线程的状态
func (*DynamicPoolMonitor) TryConstruct ¶
func (m *DynamicPoolMonitor) TryConstruct(want bool) (GoroutineUID, bool)
尝试创建一个线程
func (*DynamicPoolMonitor) TryDestroy ¶
func (m *DynamicPoolMonitor) TryDestroy(gid GoroutineUID) bool
尝试关闭一个线程 如果线程最近活跃时长较短 则关闭线程
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func NewGenerator() *Generator
func (*Generator) Collect ¶
func (i *Generator) Collect(gid GoroutineUID)
func (*Generator) Generate ¶
func (i *Generator) Generate() GoroutineUID
type GoroutinePool ¶
type GoroutinePool struct {
// contains filtered or unexported fields
}
func NewGoroutinePool ¶
func NewGoroutinePool(options *Options) *GoroutinePool
func (*GoroutinePool) GetCurrentActiveCount ¶
func (g *GoroutinePool) GetCurrentActiveCount() int
获取当前活跃线程数
func (*GoroutinePool) GetStatusSettle ¶
func (g *GoroutinePool) GetStatusSettle() map[GoroutineStatus]time.Duration
获取状态总结
type GoroutineSettle ¶
type GoroutineSettle struct {
// contains filtered or unexported fields
}
单个线程信息总结(线程安全)
func NewGoroutineSettle ¶
func NewGoroutineSettle(d time.Duration) *GoroutineSettle
func (*GoroutineSettle) AutoSwitchGoRoutineStatus ¶
func (g *GoroutineSettle) AutoSwitchGoRoutineStatus() GoroutineStatus
切换线程状态
func (*GoroutineSettle) GetRecentActiveRatio ¶
func (g *GoroutineSettle) GetRecentActiveRatio() float64
获取最近活跃占比
func (*GoroutineSettle) GetRecentStatusSettle ¶
func (g *GoroutineSettle) GetRecentStatusSettle() map[GoroutineStatus]time.Duration
获取最近时间状态总结
func (*GoroutineSettle) GetStatusSettle ¶
func (g *GoroutineSettle) GetStatusSettle() map[GoroutineStatus]time.Duration
获取所有时间状态总结
func (*GoroutineSettle) GetSurvivalDuration ¶
func (g *GoroutineSettle) GetSurvivalDuration() time.Duration
type GoroutineSettleMap ¶
type GoroutineSettleMap struct {
// contains filtered or unexported fields
}
多线程信息总结(线程安全)
func NewGoroutineSettleMap ¶
func NewGoroutineSettleMap() *GoroutineSettleMap
func (*GoroutineSettleMap) AutoSwitchGoRoutineStatus ¶
func (m *GoroutineSettleMap) AutoSwitchGoRoutineStatus(gid GoroutineUID) GoroutineStatus
切换线程状态
func (*GoroutineSettleMap) DeleteGoroutineSettle ¶
func (m *GoroutineSettleMap) DeleteGoroutineSettle(gid GoroutineUID)
终结一个线程
func (*GoroutineSettleMap) GetActiveGoroutineCount ¶
func (m *GoroutineSettleMap) GetActiveGoroutineCount() int
获取当前处于活跃状态的线程数
func (*GoroutineSettleMap) GetAllGoroutineStatusDuration ¶
func (m *GoroutineSettleMap) GetAllGoroutineStatusDuration() map[GoroutineStatus]time.Duration
获取当前所有存活线程的所有状态总结
func (*GoroutineSettleMap) GetAllGoroutineUID ¶
func (m *GoroutineSettleMap) GetAllGoroutineUID() []GoroutineUID
获取所有存活线程ID
func (*GoroutineSettleMap) GetCurrentStatus ¶
func (m *GoroutineSettleMap) GetCurrentStatus(gid GoroutineUID) GoroutineStatus
func (*GoroutineSettleMap) GetRecentActiveRatio ¶
func (m *GoroutineSettleMap) GetRecentActiveRatio(gid GoroutineUID) float64
获取指定线程最近活跃占比
func (*GoroutineSettleMap) GetRecentStatusSettle ¶
func (m *GoroutineSettleMap) GetRecentStatusSettle(gid GoroutineUID) map[GoroutineStatus]time.Duration
获取最近时间状态总结
func (*GoroutineSettleMap) GetStatusSettle ¶
func (m *GoroutineSettleMap) GetStatusSettle(gid GoroutineUID) map[GoroutineStatus]time.Duration
获取指定线程所有时间状态总结
func (*GoroutineSettleMap) GetSurvivalDuration ¶
func (m *GoroutineSettleMap) GetSurvivalDuration(gid GoroutineUID) time.Duration
获取线程存活时间
func (*GoroutineSettleMap) NewGoroutineSettle ¶
func (m *GoroutineSettleMap) NewGoroutineSettle(gid GoroutineUID, gs *GoroutineSettle) GoroutineUID
构建一个新的线程
type GoroutineStatus ¶
type GoroutineStatus int
const ( GoroutineStatusNone GoroutineStatus = 0 GoroutineStatusActive GoroutineStatus = 1 GoroutineStatusSleep GoroutineStatus = 2 )
func (GoroutineStatus) IsValid ¶
func (s GoroutineStatus) IsValid() bool
func (GoroutineStatus) ToString ¶
func (s GoroutineStatus) ToString() string
type GoroutineUID ¶
type GoroutineUID int
type IGenerator ¶
type IGenerator interface { Generate() GoroutineUID Collect(gid GoroutineUID) }
ID 生成器
type Latency ¶
type Latency struct {
// contains filtered or unexported fields
}
单种状态总结(线程安全)
func NewLatency ¶
func NewLatency(status GoroutineStatus) *Latency
func (*Latency) AmountDurationOfNow ¶
type LatencyMap ¶
type LatencyMap struct {
// contains filtered or unexported fields
}
多状态总结(线程安全)
func NewLatencyMap ¶
func NewLatencyMap() *LatencyMap
func (*LatencyMap) Clone ¶
func (g *LatencyMap) Clone() *LatencyMap
func (*LatencyMap) GetAll ¶
func (g *LatencyMap) GetAll() map[GoroutineStatus]time.Duration
func (*LatencyMap) IsStart ¶
func (g *LatencyMap) IsStart(status GoroutineStatus) bool
func (*LatencyMap) Set ¶
func (g *LatencyMap) Set(status GoroutineStatus, l *Latency)
func (*LatencyMap) Start ¶
func (g *LatencyMap) Start(status GoroutineStatus)
func (*LatencyMap) Stop ¶
func (g *LatencyMap) Stop(status GoroutineStatus)
type Options ¶
type RecentRecord ¶
type RecentRecord struct {
// contains filtered or unexported fields
}
存储最后d时长的切换记录
func NewRecentRecord ¶
func NewRecentRecord(d time.Duration) *RecentRecord
func (*RecentRecord) AddSwitchRecord ¶
func (l *RecentRecord) AddSwitchRecord(preStatus, status GoroutineStatus)
添加切换记录
func (*RecentRecord) GetRecentSettle ¶
func (l *RecentRecord) GetRecentSettle() map[GoroutineStatus]time.Duration
获取最近的状态总结
type StatusSettle ¶
type StatusSettle struct {
// contains filtered or unexported fields
}
单线程状态总结(线程安全)
func NewStatusSettle ¶
func NewStatusSettle(status GoroutineStatus, duration time.Duration) *StatusSettle
func (*StatusSettle) AddDuration ¶
func (s *StatusSettle) AddDuration(duration time.Duration)
func (*StatusSettle) GetDuration ¶
func (s *StatusSettle) GetDuration() time.Duration
type StatusSettleMap ¶
type StatusSettleMap struct {
// contains filtered or unexported fields
}
多线程状态总结(线程安全)
func NewStatusSettleMap ¶
func NewStatusSettleMap() *StatusSettleMap
func (*StatusSettleMap) AddMultiStatusDuration ¶
func (m *StatusSettleMap) AddMultiStatusDuration(multiStatusDuration map[GoroutineStatus]time.Duration)
func (*StatusSettleMap) AddStatusDuration ¶
func (m *StatusSettleMap) AddStatusDuration(status GoroutineStatus, duration time.Duration)
func (*StatusSettleMap) GetAllStatusDuration ¶
func (m *StatusSettleMap) GetAllStatusDuration() map[GoroutineStatus]time.Duration
func (*StatusSettleMap) GetOrCreate ¶
func (m *StatusSettleMap) GetOrCreate(status GoroutineStatus, duration time.Duration) *StatusSettle
type StatusSwitch ¶
type StatusSwitch struct { Time time.Time // 切换时间 PreStatus GoroutineStatus // 切换前状态 Status GoroutineStatus // 切换后状态 }
切换状态信息
func NewStatusSwitch ¶
func NewStatusSwitch(preStatus, status GoroutineStatus) *StatusSwitch
func (*StatusSwitch) Clone ¶
func (s *StatusSwitch) Clone() *StatusSwitch
Click to show internal directories.
Click to hide internal directories.