feat(conf): update const conf

This commit is contained in:
bandl 2021-09-28 22:42:11 +08:00
parent 0903477c22
commit ad0cdedba9
5 changed files with 63 additions and 29 deletions

View File

@ -5,4 +5,4 @@ env: 'dev'
storage:
host: '127.0.0.1'
port: 5890
timeOut: 2 # second

View File

@ -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
package generate
package structure
const (
DEFAULT_KEY = iota

View File

@ -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
package structure

View File

@ -1,45 +1,78 @@
// TODO 添加 storage server 模板
// Code generated by gen-struct. DO NOT EDIT.
// make gen-struct generated
package server
import (
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/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 {
ser := &server{}
ser := &serverSingle{}
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,
req *proto.GetRequest,
) (*proto.CommendResponse, error) {
panic("implement me")
}
req *proto.{{ fun }}Request,
) (*proto.{{ fun }}Response, error) {
lruEvent := event.NewEvent("lru event")
lruEvent.InitWaitEvent()
func (s *server) Set(
ctx context.Context,
req *proto.SetRequest,
) (*proto.CommendResponse, error) {
panic("implement me")
}
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
func (s *server) Add(ctx context.Context, request *proto.AddRequest) (*proto.CommendResponse, error) {
panic("implement me")
}
default:
return nil, errorx.New("value err")
}
func (s *server) Reduce(ctx context.Context, request *proto.ReduceRequest) (*proto.CommendResponse, error) {
panic("implement me")
}
})
func (s *server) Setbit(ctx context.Context, request *proto.SetbitRequest) (*proto.CommendResponse, error) {
panic("implement me")
}
lruEvent.SetValue("lru work", work)
s.lruProduce.Call(cxt, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.ttl)
if err != nil {
return nil, err
}
func (s *server) Getbit(ctx context.Context, request *proto.GetbitRequest) (*proto.CommendResponse, error) {
panic("implement me")
switch resp.(type) {
case *proto.{{ fun }}Response:
default:
return nil, errorx.New("value err")
}
return resp.(*proto.{{ fun }}Response), nil
}
{% endfor %}
{% endfor %}

View File

@ -1,4 +1,5 @@
# 这里定义结构体的支持的命令, 以后也许会添加结构体的命令验证
# 定义结构体名称以及方法使, 方法全部小写,结构体名称全部大写且结构体名称需要加上 _X, 如 LIST_X
STRING_X:
- set