wheat-cache/storage/temp/service.template

42 lines
1.0 KiB
Plaintext

// Code generated by gen-struct. DO NOT EDIT.
// make gen-service generated
package service
import (
context "context"
"gitee.com/wheat-os/wheatCache/pkg/event2"
"gitee.com/wheat-os/wheatCache/pkg/lru"
"gitee.com/wheat-os/wheatCache/pkg/proto"
)
{% 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) {
resp, err := s.dao.{{key.method}}({% for opt in key.option %}req.{{opt[0]}}, {% endfor %})
if err != nil{
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("{{key.method}}", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(event2.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
lruEvent.Recovery()
if err != nil {
return nil, err
}
return resp.(*proto.{{key.method}}Response), nil
}
{% endfor %}