forked from p93542168/wheat-cache
feat(conf): update const conf
This commit is contained in:
parent
0903477c22
commit
ad0cdedba9
|
@ -5,4 +5,4 @@ env: 'dev'
|
||||||
storage:
|
storage:
|
||||||
host: '127.0.0.1'
|
host: '127.0.0.1'
|
||||||
port: 5890
|
port: 5890
|
||||||
|
timeOut: 2 # second
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Code generated by gen-struct-const. DO NOT EDIT.
|
// Code generated by gen-struct. DO NOT EDIT.
|
||||||
// make gen-struct generated
|
// make gen-struct generated
|
||||||
|
|
||||||
package generate
|
package structure
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DEFAULT_KEY = iota
|
DEFAULT_KEY = iota
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by gen-struct-const. DO NOT EDIT.
|
// Code generated by gen-struct. DO NOT EDIT.
|
||||||
// make gen-struct generated
|
// make gen-struct generated
|
||||||
|
|
||||||
package structure
|
package structure
|
||||||
|
|
|
@ -1,45 +1,78 @@
|
||||||
// TODO 添加 storage server 模板
|
// Code generated by gen-struct. DO NOT EDIT.
|
||||||
|
// make gen-struct generated
|
||||||
|
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
"gitee.com/timedb/wheatCache/pkg/errorx"
|
||||||
|
"gitee.com/timedb/wheatCache/pkg/event"
|
||||||
"gitee.com/timedb/wheatCache/pkg/proto"
|
"gitee.com/timedb/wheatCache/pkg/proto"
|
||||||
|
"gitee.com/timedb/wheatCache/pkg/structure"
|
||||||
|
|
||||||
|
{% for name in mod_name %}
|
||||||
|
"gitee.com/timedb/wheatCache/pkg/structure/{{name}}"
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type server struct {
|
type serverSingle struct {
|
||||||
|
middleProduce event.ProduceInterface
|
||||||
|
lruProduce event.ProduceInterface
|
||||||
|
ttl time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer() proto.CommServerServer {
|
func NewServer() proto.CommServerServer {
|
||||||
ser := &server{}
|
ser := &serverSingle{}
|
||||||
return ser
|
return ser
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) Get(
|
// TODO 移除
|
||||||
|
func mockLruValue() structure.KeyBaseInterface {
|
||||||
|
return stringx.NewStringSingle()
|
||||||
|
}
|
||||||
|
|
||||||
|
{% for opt in option %}
|
||||||
|
|
||||||
|
{% for fun in opt.option %}
|
||||||
|
func (s *serverSingle) {{ fun }} (
|
||||||
cxt context.Context,
|
cxt context.Context,
|
||||||
req *proto.GetRequest,
|
req *proto.{{ fun }}Request,
|
||||||
) (*proto.CommendResponse, error) {
|
) (*proto.{{ fun }}Response, error) {
|
||||||
panic("implement me")
|
lruEvent := event.NewEvent("lru event")
|
||||||
|
lruEvent.InitWaitEvent()
|
||||||
|
|
||||||
|
work := event.EventWorkFunc(func() (interface{}, error) {
|
||||||
|
value := mockLruValue() // TODO 替换为从 lru 获取
|
||||||
|
switch value.(type) {
|
||||||
|
case structure.{{ opt.key }}Interface:
|
||||||
|
resp, err := value.(structure.{{ opt.key }}Interface).{{ fun }}(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil, errorx.New("value err")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) Set(
|
})
|
||||||
ctx context.Context,
|
|
||||||
req *proto.SetRequest,
|
lruEvent.SetValue("lru work", work)
|
||||||
) (*proto.CommendResponse, error) {
|
s.lruProduce.Call(cxt, lruEvent)
|
||||||
panic("implement me")
|
resp, err := lruEvent.StartWaitEvent(s.ttl)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) Add(ctx context.Context, request *proto.AddRequest) (*proto.CommendResponse, error) {
|
switch resp.(type) {
|
||||||
panic("implement me")
|
case *proto.{{ fun }}Response:
|
||||||
|
default:
|
||||||
|
return nil, errorx.New("value err")
|
||||||
}
|
}
|
||||||
|
return resp.(*proto.{{ fun }}Response), nil
|
||||||
|
}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
func (s *server) Reduce(ctx context.Context, request *proto.ReduceRequest) (*proto.CommendResponse, error) {
|
{% endfor %}
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) Setbit(ctx context.Context, request *proto.SetbitRequest) (*proto.CommendResponse, error) {
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) Getbit(ctx context.Context, request *proto.GetbitRequest) (*proto.CommendResponse, error) {
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# 这里定义结构体的支持的命令, 以后也许会添加结构体的命令验证
|
# 这里定义结构体的支持的命令, 以后也许会添加结构体的命令验证
|
||||||
|
# 定义结构体名称以及方法使, 方法全部小写,结构体名称全部大写且结构体名称需要加上 _X, 如 LIST_X
|
||||||
|
|
||||||
STRING_X:
|
STRING_X:
|
||||||
- set
|
- set
|
||||||
|
|
Loading…
Reference in New Issue