- 在 sqrt_test.go 中添加了 fastSqr1 测试函数,用于测试事件驱动模型 - 新增了 Event 和 Uint32AsyncEvent 类型用于测试 - 更新了 go.work、go.mod 和
37 lines
500 B
Go
37 lines
500 B
Go
package events
|
|
|
|
type UserRegisteredEvent struct {
|
|
UserName string
|
|
Phone string
|
|
}
|
|
|
|
func (e UserRegisteredEvent) Async() bool {
|
|
return true
|
|
}
|
|
|
|
type SMSRequestEvent struct {
|
|
Number string
|
|
Message string
|
|
}
|
|
|
|
func (e SMSRequestEvent) Async() bool {
|
|
return true
|
|
}
|
|
|
|
type SMSSentEvent struct {
|
|
Request SMSRequestEvent
|
|
Status string
|
|
}
|
|
|
|
func (e SMSSentEvent) Async() bool {
|
|
return true
|
|
}
|
|
|
|
type DummyEvent struct {
|
|
AlteredAsync bool
|
|
}
|
|
|
|
func (e *DummyEvent) Async() bool {
|
|
return e.AlteredAsync
|
|
}
|