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:
@./bin/storage storage
.PHONY: gen-struct
gen-struct:
.PHONY: gen-struct-const
gen-struct-const:
@python3 ./shell/make-struct.py
.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
package generate
const (
DEFAULT_KEY = iota
{% for key in keys %}
{% for key in keys -%}
{{key}}
{% endfor %}
{%- endfor %}
)
const (
DEFAULT_COMM = iota
{% for key in sets %}
{% for key in sets -%}
{{key}}
{% endfor %}
)
var CommKeyString = map[string]int {
{% for kmp in key_maps %}
{% for comm in kmp.val %}
{%- for kmp in key_maps -%}
{% for comm in kmp.val -%}
"{{comm}}": {{kmp.key}},
{% endfor %}
{% endfor -%}
{% endfor %}
}
var CommKey = map[int]int {
{% for kmp in key_maps %}
{% for comm in kmp.upper %}
{%- for kmp in key_maps -%}
{% for comm in kmp.upper -%}
{{comm}}: {{kmp.key}},
{% 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
package generate
const (
DEFAULT_KEY = iota
STRING_X
LIST_X
)
const (
DEFAULT_COMM = iota
SET
SET
GET
ADD
REDUCE
SETBIT
GETBIT
L_SET
)
var CommKeyString = map[string]int {
"set": STRING_X,
var CommKeyString = map[string]int {"set": STRING_X,
"get": STRING_X,
"add": STRING_X,
"reduce": STRING_X,
"setbit": STRING_X,
"getbit": STRING_X,
"l_set": LIST_X,
}
var CommKey = map[int]int {
SET: STRING_X,
var CommKey = map[int]int {SET: STRING_X,
GET: STRING_X,
ADD: STRING_X,
REDUCE: STRING_X,
SETBIT: STRING_X,
GETBIT: STRING_X,
L_SET: LIST_X,
}

View File

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

View File

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