refactor(worker): refactor
This commit is contained in:
parent
e3171a8b3e
commit
83febdd482
|
@ -2,8 +2,8 @@ package lru
|
|||
|
||||
import (
|
||||
"context"
|
||||
"gitee.com/timedb/wheatCache/pkg/errorx"
|
||||
"gitee.com/timedb/wheatCache/pkg/event"
|
||||
"log"
|
||||
)
|
||||
|
||||
func (lru *SingleCache) lruSingleWork() interface{} {
|
||||
|
@ -11,16 +11,20 @@ func (lru *SingleCache) lruSingleWork() interface{} {
|
|||
for {
|
||||
workEvent := lru.lruConsumer.Receive(ctx)
|
||||
|
||||
workFunc, ok := workEvent.GetValue(WorkFuncEventKey)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch workEvent.GetEventName() {
|
||||
case OptionEventName:
|
||||
workFunc, ok := workEvent.GetValue(WorkFuncEventKey)
|
||||
if !ok {
|
||||
workEvent.ExecWorkAndSendResult(func() (interface{}, error) {
|
||||
return nil, errorx.New("the event haven't work of function")
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
switch workFunc.(type) {
|
||||
case event.EventWorkFunc:
|
||||
workEvent.ExecWorkAndSendResult(workFunc.(event.EventWorkFunc))
|
||||
default:
|
||||
log.Print("this is debug ")
|
||||
if work, ok := workFunc.(event.EventWorkFunc); ok {
|
||||
workEvent.ExecWorkAndSendResult(work)
|
||||
}
|
||||
case CleanEventName:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue