feat(structure-temp): add interface-temp

This commit is contained in:
bandl 2021-09-20 18:44:56 +08:00
parent 20b2272e7c
commit b03d096b53
6 changed files with 44 additions and 59 deletions

View File

@ -17,8 +17,8 @@ install:
dev: dev:
@./bin/storage storage @./bin/storage storage
.PHONY: gen-struct .PHONY: gen-struct-const
gen-struct: gen-struct-const:
@python3 ./shell/make-struct.py @python3 ./shell/make-struct.py
.PHONY: gen-protobuf .PHONY: gen-protobuf

View File

@ -1,34 +1,34 @@
// Code generated by gen-struct. DO NOT EDIT. // Code generated by gen-struct-const. DO NOT EDIT.
// make gen-struct generated // make gen-struct generated
package generate package generate
const ( const (
DEFAULT_KEY = iota DEFAULT_KEY = iota
{% for key in keys %} {% for key in keys -%}
{{key}} {{key}}
{% endfor %} {%- endfor %}
) )
const ( const (
DEFAULT_COMM = iota DEFAULT_COMM = iota
{% for key in sets %} {% for key in sets -%}
{{key}} {{key}}
{% endfor %} {% endfor %}
) )
var CommKeyString = map[string]int { var CommKeyString = map[string]int {
{% for kmp in key_maps %} {%- for kmp in key_maps -%}
{% for comm in kmp.val %} {% for comm in kmp.val -%}
"{{comm}}": {{kmp.key}}, "{{comm}}": {{kmp.key}},
{% endfor %} {% endfor -%}
{% endfor %} {% endfor %}
} }
var CommKey = map[int]int { var CommKey = map[int]int {
{% for kmp in key_maps %} {%- for kmp in key_maps -%}
{% for comm in kmp.upper %} {% for comm in kmp.upper -%}
{{comm}}: {{kmp.key}}, {{comm}}: {{kmp.key}},
{% endfor %} {% endfor -%}
{% endfor %} {% endfor %}
} }

View File

@ -0,0 +1,28 @@
package structure
import "gitee.com/timedb/wheatCache/pkg/proto"
type KeyBaseInterface interface {
SizeByte() int64
// TODO RollBack 事务相关, V2 实现
RollBack() error
// Begin 事务相关, V2 实现
Begin() error
// Comment 事务相关, V2 实现
Comment() error
Encode() ([]byte, error)
}
type StringXInterface interface {
KeyBaseInterface
Set(*proto.SetRequest) ([]string, error)
Get(*proto.GetRequest) ([]string, error)
}
type ListXInterface interface {
KeyBaseInterface
LSet(*proto.SetRequest) ([]string, error)
}

View File

@ -1,76 +1,38 @@
// Code generated by gen-struct. DO NOT EDIT. // Code generated by gen-struct-const. DO NOT EDIT.
// make gen-struct generated // make gen-struct generated
package generate package generate
const ( const (
DEFAULT_KEY = iota DEFAULT_KEY = iota
STRING_X STRING_X
LIST_X
) )
const ( const (
DEFAULT_COMM = iota DEFAULT_COMM = iota
SET
SET
GET GET
ADD ADD
REDUCE REDUCE
SETBIT SETBIT
GETBIT GETBIT
L_SET
) )
var CommKeyString = map[string]int { var CommKeyString = map[string]int {"set": STRING_X,
"set": STRING_X,
"get": STRING_X, "get": STRING_X,
"add": STRING_X, "add": STRING_X,
"reduce": STRING_X, "reduce": STRING_X,
"setbit": STRING_X, "setbit": STRING_X,
"getbit": STRING_X, "getbit": STRING_X,
"l_set": LIST_X,
} }
var CommKey = map[int]int { var CommKey = map[int]int {SET: STRING_X,
SET: STRING_X,
GET: STRING_X, GET: STRING_X,
ADD: STRING_X, ADD: STRING_X,
REDUCE: STRING_X, REDUCE: STRING_X,
SETBIT: STRING_X, SETBIT: STRING_X,
GETBIT: STRING_X, GETBIT: STRING_X,
L_SET: LIST_X,
} }

View File

@ -2,10 +2,6 @@ package structure
import "gitee.com/timedb/wheatCache/pkg/proto" import "gitee.com/timedb/wheatCache/pkg/proto"
type CacheValue interface {
LengthByte() int64
}
type KeyBaseInterface interface { type KeyBaseInterface interface {
SizeByte() int64 SizeByte() int64

View File

@ -56,7 +56,6 @@ def set_structure_const_template(conf: dict):
template = Template(tem_text) template = Template(tem_text)
text = template.render(keys=keys, key_maps=key_map, sets=val_set) text = template.render(keys=keys, key_maps=key_map, sets=val_set)
text.replace("\n\n", "\n")
temp_path = f"{tempPath}/structure.gen.go" temp_path = f"{tempPath}/structure.gen.go"
with open(temp_path, 'w', encoding='utf-8') as f: with open(temp_path, 'w', encoding='utf-8') as f: