# README
xtime
time
辅助函数
- 时间函数
- 时间模拟
timewheel
例子
w := NewWheel(time.Second, 3)
defer w.Stop()
time.Sleep(500 * time.Millisecond)
t1 := time.Now()
go func() {
select {
case <-w.After(1 * time.Second):
fmt.Printf("expected 1s, got %s\n", time.Since(t1))
}
}()
Output:
expected 1s, got 1.498680893s
# Packages
No description provided by the author
# Functions
BeginningOfDay beginning of day.
BeginningOfHour beginning of hour.
BeginningOfHourSpec beginning of specified hour.
BeginningOfMinute beginning of minute.
BeginningOfMonth beginning of month.
BeginningOfWeek beginning of week.
BeginningOfYear beginning of year.
DaysInMonth days of current month.
EndOfDay end of day.
EndOfHour end of hour.
EndOfMinute end of minute.
EndOfMonth end of month.
EndOfWeek end of week.
EndOfYear end of year.
InstallOptionsWatchDog the installed func will called when NewOptions called.
IsLeapYear year is leap year.
IsThisWeek tt is current week.
IsToday tt is today.
IsTomorrow tt is tomorrow.
IsYesterday tt is yesterday.
Monday the monday of tt.
NewCop 新建Cop对象.
NewDispatcher 构造新的Dispatcher Note: - Dispatcher目前主要服务于pkg/skeleton,用于Actor类型对象的有序动作处理 - Dispatcher通过TimerNotify将事件通知到外层,并不执行注册的的回调方法,需逻辑层接管事件通知触发回调逻辑.
NewOptions new Options.
No description provided by the author
No description provided by the author
go:generate optionGen --option_return_previous=false.
SetAccuracy sets the accuracy for the timewheel.
SetNowProvider 设定now提供方法.
Stop 停止globalCop的时间,使用系统时间.
SubDays days of between start and end.
Sunday the sunday of tt.
ToLocal to local time.
WheelAfter 根据Duration复用时间轮 Note: 内部会根据Duration创建时间轮, 相同Duration可以共用,这样带来的副作用就是如果时间不固定则会创建特别的多的时间轮.
WithTickCount option func for filed TickCount.
WithTickDuration tick的duration,大于0是自动开启ticker.
WithTickHostingMode 全托管模式,内部起一个协程执行tick的func.
# Constants
No description provided by the author
# Variables
After Deprecated: https://github.com/sandwich-go/xtime instead.
CopToleranceCheckInterval 检测CopToleranceSecond的时间间隔.
CopToleranceSecond 时间容忍误差,误差超过CopToleranceSecond则后续使用系统时间.
Freeze Deprecated: https://github.com/sandwich-go/xtime instead.
mock属于测试类需求,stime对时间mock的支持仅限于Freeze,Scale,Travel,对于mock下的tick,after没有做完备支持,迁移到https://github.com/sandwich-go/xtime独立扩展支持 Mocked Deprecated: https://github.com/sandwich-go/xtime instead.
Now 获取当前时间,精度秒.
Return Deprecated: https://github.com/sandwich-go/xtime instead.
Scale Deprecated: https://github.com/sandwich-go/xtime instead.
Since Deprecated: https://github.com/sandwich-go/xtime instead.
Sleep Deprecated: https://github.com/sandwich-go/xtime instead.
Tick Deprecated: https://github.com/sandwich-go/xtime instead.
Travel Deprecated: https://github.com/sandwich-go/xtime instead.
Unix 获取当前时间戳,精度秒 time consume: time.Now().Unix() > atomic.LoadInt64(&_atomic_timestamp) > globalCop.Unix() > globalCop.ts.
UnixMilli 当前时间,单位毫秒.
WeekStartDay set week start day, default is sunday.
# Structs
Cop mock time like ruby's time cop.
No description provided by the author
No description provided by the author
Options should use NewOptions to initialize it.
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
No description provided by the author
Lifecycle manages the start and close lifecycle methods.
OptionsInterface visitor + ApplyOption interface for Options.
OptionsVisitor visitor interface for Options.
No description provided by the author
No description provided by the author
TimerDispatcher manages timer-related functionalities.