wheat-cache/storage/temp/service.template

42 lines
1.0 KiB
Plaintext
Raw Normal View History

2021-10-27 23:51:54 +08:00
// Code generated by gen-struct. DO NOT EDIT.
// make gen-service generated
package service
import (
context "context"
"gitee.com/wheat-os/wheatCache/pkg/event2"
2021-11-02 14:45:08 +08:00
"gitee.com/wheat-os/wheatCache/pkg/lru"
"gitee.com/wheat-os/wheatCache/pkg/proto"
2021-10-27 23:51:54 +08:00
)
{% for key in keys %}
func (s *singleService) {{key.method}}(
ctx context.Context,
req *proto.{{key.method}}Request,
) (*proto.{{key.method}}Response, error) {
work := event2.EventWorkFunc(func() (interface{}, error) {
2021-11-01 23:55:12 +08:00
resp, err := s.dao.{{key.method}}({% for opt in key.option %}req.{{opt[0]}}, {% endfor %})
if err != nil{
return nil, err
}
2021-11-02 13:02:02 +08:00
if s.aof != nil {
s.aof.SendRequest("{{key.method}}", req)
}
2021-11-01 23:55:12 +08:00
return resp, nil
2021-10-27 23:51:54 +08:00
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(event2.WorkFuncEventKey, work)
2021-10-27 23:51:54 +08:00
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
lruEvent.Recovery()
2021-10-27 23:51:54 +08:00
if err != nil {
return nil, err
}
return resp.(*proto.{{key.method}}Response), nil
}
{% endfor %}