Merge pull request !88 from bandl/feat-structure-hashx
This commit is contained in:
bandl 2021-11-05 12:51:13 +00:00 committed by Gitee
commit bbfd32cebc
21 changed files with 2724 additions and 173 deletions

View File

@ -94,7 +94,7 @@ func TestClient(t *testing.T) {
- [x] 基础类型
- [x] listx
- [x] stringx
- [ ] hashx
- [x] hashx
- [ ] setx
- [ ] zsetx
- [ ] channelx
@ -112,8 +112,8 @@ func TestClient(t *testing.T) {
- [ ] lru 消息推送
- 网关层
- [x] 基于 key 一致性 hash 的集群 transport
- [ ] 基于配置的主从 transpoart
- [ ] 基于配置的备份 transpoart
- [ ] 基于配置的主从 transport
- [ ] 基于配置的备份 transport
- 中间件以及插件层
- [x] 推送中间件
- [x] 事件驱动 v2

View File

@ -1,18 +1,3 @@
/*
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import "gitee.com/wheat-os/wheatCache/gateway/cmd"

1301
pkg/proto/hashx.pb.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -31,65 +31,88 @@ var File_storage_proto protoreflect.FileDescriptor
var file_storage_proto_rawDesc = []byte{
0x0a, 0x0d, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
0x0d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0b,
0x6c, 0x69, 0x73, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xff, 0x06, 0x0a, 0x0a,
0x43, 0x6f, 0x6d, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x03, 0x53, 0x65,
0x74, 0x12, 0x0b, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c,
0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x03,
0x47, 0x65, 0x74, 0x12, 0x0b, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x0c, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20,
0x0a, 0x03, 0x41, 0x64, 0x64, 0x12, 0x0b, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x29, 0x0a, 0x06, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x12, 0x0e, 0x2e, 0x52, 0x65, 0x64,
0x75, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x52, 0x65, 0x64,
0x75, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x53,
0x65, 0x74, 0x42, 0x69, 0x74, 0x12, 0x0e, 0x2e, 0x53, 0x65, 0x74, 0x42, 0x69, 0x74, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x53, 0x65, 0x74, 0x42, 0x69, 0x74, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x42, 0x69, 0x74,
0x12, 0x0e, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x2f, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x10, 0x2e,
0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x11, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x12, 0x0e, 0x2e, 0x47,
0x65, 0x74, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x47,
0x65, 0x74, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a,
0x06, 0x53, 0x74, 0x72, 0x4c, 0x65, 0x6e, 0x12, 0x0e, 0x2e, 0x53, 0x74, 0x72, 0x4c, 0x65, 0x6e,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x53, 0x74, 0x72, 0x4c, 0x65, 0x6e,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x53, 0x65, 0x74, 0x6e,
0x78, 0x12, 0x0d, 0x2e, 0x53, 0x65, 0x74, 0x6e, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x0e, 0x2e, 0x53, 0x65, 0x74, 0x6e, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x29, 0x0a, 0x06, 0x4c, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x0e, 0x2e, 0x4c, 0x49, 0x6e,
0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x4c, 0x49, 0x6e,
0x64, 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x4c,
0x4c, 0x65, 0x6e, 0x12, 0x0c, 0x2e, 0x4c, 0x4c, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x0d, 0x2e, 0x4c, 0x4c, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x23, 0x0a, 0x04, 0x4c, 0x50, 0x6f, 0x70, 0x12, 0x0c, 0x2e, 0x4c, 0x50, 0x6f, 0x70, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x4c, 0x50, 0x6f, 0x70, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x4c, 0x50, 0x75, 0x73, 0x68, 0x12, 0x0d,
0x2e, 0x4c, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e,
0x4c, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a,
0x06, 0x4c, 0x50, 0x75, 0x73, 0x68, 0x58, 0x12, 0x0e, 0x2e, 0x4c, 0x50, 0x75, 0x73, 0x68, 0x58,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x4c, 0x50, 0x75, 0x73, 0x68, 0x58,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x4c, 0x52, 0x61, 0x6e,
0x67, 0x65, 0x12, 0x0e, 0x2e, 0x4c, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x4c, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x52, 0x65, 0x6d, 0x12, 0x0c, 0x2e, 0x4c, 0x52,
0x65, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x4c, 0x52, 0x65, 0x6d,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x53, 0x65, 0x74,
0x12, 0x0c, 0x2e, 0x4c, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d,
0x2e, 0x4c, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a,
0x04, 0x52, 0x50, 0x6f, 0x70, 0x12, 0x0c, 0x2e, 0x52, 0x50, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x52, 0x50, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x4c, 0x54, 0x72, 0x69, 0x6d, 0x12, 0x0d, 0x2e, 0x4c, 0x54,
0x72, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x4c, 0x54, 0x72,
0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x52, 0x50,
0x75, 0x73, 0x68, 0x12, 0x0d, 0x2e, 0x52, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x52, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x52, 0x50, 0x75, 0x73, 0x68, 0x58, 0x12, 0x0e, 0x2e, 0x52,
0x50, 0x75, 0x73, 0x68, 0x58, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x52,
0x50, 0x75, 0x73, 0x68, 0x58, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a,
0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x6c, 0x69, 0x73, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0b, 0x68, 0x61, 0x73,
0x68, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xed, 0x09, 0x0a, 0x0a, 0x43, 0x6f, 0x6d,
0x6d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x03, 0x53, 0x65, 0x74, 0x12, 0x0b,
0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x53, 0x65,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x03, 0x47, 0x65, 0x74,
0x12, 0x0b, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e,
0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x03, 0x41,
0x64, 0x64, 0x12, 0x0b, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x0c, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a,
0x06, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x12, 0x0e, 0x2e, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x53, 0x65, 0x74, 0x42,
0x69, 0x74, 0x12, 0x0e, 0x2e, 0x53, 0x65, 0x74, 0x42, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x53, 0x65, 0x74, 0x42, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x42, 0x69, 0x74, 0x12, 0x0e, 0x2e,
0x47, 0x65, 0x74, 0x42, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e,
0x47, 0x65, 0x74, 0x42, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f,
0x0a, 0x08, 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x10, 0x2e, 0x47, 0x65, 0x74,
0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x47,
0x65, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x29, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x12, 0x0e, 0x2e, 0x47, 0x65, 0x74, 0x53,
0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x53,
0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x53, 0x74,
0x72, 0x4c, 0x65, 0x6e, 0x12, 0x0e, 0x2e, 0x53, 0x74, 0x72, 0x4c, 0x65, 0x6e, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x53, 0x74, 0x72, 0x4c, 0x65, 0x6e, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x53, 0x65, 0x74, 0x6e, 0x78, 0x12, 0x0d,
0x2e, 0x53, 0x65, 0x74, 0x6e, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e,
0x53, 0x65, 0x74, 0x6e, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a,
0x06, 0x4c, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x0e, 0x2e, 0x4c, 0x49, 0x6e, 0x64, 0x65, 0x78,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x4c, 0x49, 0x6e, 0x64, 0x65, 0x78,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x4c, 0x65, 0x6e,
0x12, 0x0c, 0x2e, 0x4c, 0x4c, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d,
0x2e, 0x4c, 0x4c, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a,
0x04, 0x4c, 0x50, 0x6f, 0x70, 0x12, 0x0c, 0x2e, 0x4c, 0x50, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x4c, 0x50, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x4c, 0x50, 0x75, 0x73, 0x68, 0x12, 0x0d, 0x2e, 0x4c, 0x50,
0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x4c, 0x50, 0x75,
0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x4c, 0x50,
0x75, 0x73, 0x68, 0x58, 0x12, 0x0e, 0x2e, 0x4c, 0x50, 0x75, 0x73, 0x68, 0x58, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x4c, 0x50, 0x75, 0x73, 0x68, 0x58, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x06, 0x4c, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12,
0x0e, 0x2e, 0x4c, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x0f, 0x2e, 0x4c, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x23, 0x0a, 0x04, 0x4c, 0x52, 0x65, 0x6d, 0x12, 0x0c, 0x2e, 0x4c, 0x52, 0x65, 0x6d, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x4c, 0x52, 0x65, 0x6d, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x4c, 0x53, 0x65, 0x74, 0x12, 0x0c, 0x2e,
0x4c, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x4c, 0x53,
0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x52, 0x50,
0x6f, 0x70, 0x12, 0x0c, 0x2e, 0x52, 0x50, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x0d, 0x2e, 0x52, 0x50, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x26, 0x0a, 0x05, 0x4c, 0x54, 0x72, 0x69, 0x6d, 0x12, 0x0d, 0x2e, 0x4c, 0x54, 0x72, 0x69, 0x6d,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x4c, 0x54, 0x72, 0x69, 0x6d, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x52, 0x50, 0x75, 0x73, 0x68,
0x12, 0x0d, 0x2e, 0x52, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x0e, 0x2e, 0x52, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x29, 0x0a, 0x06, 0x52, 0x50, 0x75, 0x73, 0x68, 0x58, 0x12, 0x0e, 0x2e, 0x52, 0x50, 0x75, 0x73,
0x68, 0x58, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x52, 0x50, 0x75, 0x73,
0x68, 0x58, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x48, 0x44,
0x65, 0x6c, 0x12, 0x0c, 0x2e, 0x48, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x0d, 0x2e, 0x48, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x2c, 0x0a, 0x07, 0x48, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x12, 0x0f, 0x2e, 0x48, 0x45, 0x78,
0x69, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x48, 0x45,
0x78, 0x69, 0x73, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a,
0x04, 0x48, 0x47, 0x65, 0x74, 0x12, 0x0c, 0x2e, 0x48, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x48, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x48, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x12, 0x0f, 0x2e,
0x48, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10,
0x2e, 0x48, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x2c, 0x0a, 0x07, 0x48, 0x49, 0x6e, 0x63, 0x72, 0x42, 0x79, 0x12, 0x0f, 0x2e, 0x48, 0x49,
0x6e, 0x63, 0x72, 0x42, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x48,
0x49, 0x6e, 0x63, 0x72, 0x42, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26,
0x0a, 0x05, 0x48, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x0d, 0x2e, 0x48, 0x4b, 0x65, 0x79, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x48, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x48, 0x4c, 0x65, 0x6e, 0x12, 0x0c,
0x2e, 0x48, 0x4c, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x48,
0x4c, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x48,
0x53, 0x65, 0x74, 0x12, 0x0c, 0x2e, 0x48, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x0d, 0x2e, 0x48, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x26, 0x0a, 0x05, 0x48, 0x53, 0x65, 0x74, 0x58, 0x12, 0x0d, 0x2e, 0x48, 0x53, 0x65, 0x74,
0x58, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x48, 0x53, 0x65, 0x74, 0x58,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_storage_proto_goTypes = []interface{}{
@ -115,28 +138,46 @@ var file_storage_proto_goTypes = []interface{}{
(*LTrimRequest)(nil), // 19: LTrimRequest
(*RPushRequest)(nil), // 20: RPushRequest
(*RPushXRequest)(nil), // 21: RPushXRequest
(*SetResponse)(nil), // 22: SetResponse
(*GetResponse)(nil), // 23: GetResponse
(*AddResponse)(nil), // 24: AddResponse
(*ReduceResponse)(nil), // 25: ReduceResponse
(*SetBitResponse)(nil), // 26: SetBitResponse
(*GetBitResponse)(nil), // 27: GetBitResponse
(*GetRangeResponse)(nil), // 28: GetRangeResponse
(*GetSetResponse)(nil), // 29: GetSetResponse
(*StrLenResponse)(nil), // 30: StrLenResponse
(*SetnxResponse)(nil), // 31: SetnxResponse
(*LIndexResponse)(nil), // 32: LIndexResponse
(*LLenResponse)(nil), // 33: LLenResponse
(*LPopResponse)(nil), // 34: LPopResponse
(*LPushResponse)(nil), // 35: LPushResponse
(*LPushXResponse)(nil), // 36: LPushXResponse
(*LRangeResponse)(nil), // 37: LRangeResponse
(*LRemResponse)(nil), // 38: LRemResponse
(*LSetResponse)(nil), // 39: LSetResponse
(*RPopResponse)(nil), // 40: RPopResponse
(*LTrimResponse)(nil), // 41: LTrimResponse
(*RPushResponse)(nil), // 42: RPushResponse
(*RPushXResponse)(nil), // 43: RPushXResponse
(*HDelRequest)(nil), // 22: HDelRequest
(*HExistsRequest)(nil), // 23: HExistsRequest
(*HGetRequest)(nil), // 24: HGetRequest
(*HGetAllRequest)(nil), // 25: HGetAllRequest
(*HIncrByRequest)(nil), // 26: HIncrByRequest
(*HKeysRequest)(nil), // 27: HKeysRequest
(*HLenRequest)(nil), // 28: HLenRequest
(*HSetRequest)(nil), // 29: HSetRequest
(*HSetXRequest)(nil), // 30: HSetXRequest
(*SetResponse)(nil), // 31: SetResponse
(*GetResponse)(nil), // 32: GetResponse
(*AddResponse)(nil), // 33: AddResponse
(*ReduceResponse)(nil), // 34: ReduceResponse
(*SetBitResponse)(nil), // 35: SetBitResponse
(*GetBitResponse)(nil), // 36: GetBitResponse
(*GetRangeResponse)(nil), // 37: GetRangeResponse
(*GetSetResponse)(nil), // 38: GetSetResponse
(*StrLenResponse)(nil), // 39: StrLenResponse
(*SetnxResponse)(nil), // 40: SetnxResponse
(*LIndexResponse)(nil), // 41: LIndexResponse
(*LLenResponse)(nil), // 42: LLenResponse
(*LPopResponse)(nil), // 43: LPopResponse
(*LPushResponse)(nil), // 44: LPushResponse
(*LPushXResponse)(nil), // 45: LPushXResponse
(*LRangeResponse)(nil), // 46: LRangeResponse
(*LRemResponse)(nil), // 47: LRemResponse
(*LSetResponse)(nil), // 48: LSetResponse
(*RPopResponse)(nil), // 49: RPopResponse
(*LTrimResponse)(nil), // 50: LTrimResponse
(*RPushResponse)(nil), // 51: RPushResponse
(*RPushXResponse)(nil), // 52: RPushXResponse
(*HDelResponse)(nil), // 53: HDelResponse
(*HExistsResponse)(nil), // 54: HExistsResponse
(*HGetResponse)(nil), // 55: HGetResponse
(*HGetAllResponse)(nil), // 56: HGetAllResponse
(*HIncrByResponse)(nil), // 57: HIncrByResponse
(*HKeysResponse)(nil), // 58: HKeysResponse
(*HLenResponse)(nil), // 59: HLenResponse
(*HSetResponse)(nil), // 60: HSetResponse
(*HSetXResponse)(nil), // 61: HSetXResponse
}
var file_storage_proto_depIdxs = []int32{
0, // 0: CommServer.Set:input_type -> SetRequest
@ -161,30 +202,48 @@ var file_storage_proto_depIdxs = []int32{
19, // 19: CommServer.LTrim:input_type -> LTrimRequest
20, // 20: CommServer.RPush:input_type -> RPushRequest
21, // 21: CommServer.RPushX:input_type -> RPushXRequest
22, // 22: CommServer.Set:output_type -> SetResponse
23, // 23: CommServer.Get:output_type -> GetResponse
24, // 24: CommServer.Add:output_type -> AddResponse
25, // 25: CommServer.Reduce:output_type -> ReduceResponse
26, // 26: CommServer.SetBit:output_type -> SetBitResponse
27, // 27: CommServer.GetBit:output_type -> GetBitResponse
28, // 28: CommServer.GetRange:output_type -> GetRangeResponse
29, // 29: CommServer.GetSet:output_type -> GetSetResponse
30, // 30: CommServer.StrLen:output_type -> StrLenResponse
31, // 31: CommServer.Setnx:output_type -> SetnxResponse
32, // 32: CommServer.LIndex:output_type -> LIndexResponse
33, // 33: CommServer.LLen:output_type -> LLenResponse
34, // 34: CommServer.LPop:output_type -> LPopResponse
35, // 35: CommServer.LPush:output_type -> LPushResponse
36, // 36: CommServer.LPushX:output_type -> LPushXResponse
37, // 37: CommServer.LRange:output_type -> LRangeResponse
38, // 38: CommServer.LRem:output_type -> LRemResponse
39, // 39: CommServer.LSet:output_type -> LSetResponse
40, // 40: CommServer.RPop:output_type -> RPopResponse
41, // 41: CommServer.LTrim:output_type -> LTrimResponse
42, // 42: CommServer.RPush:output_type -> RPushResponse
43, // 43: CommServer.RPushX:output_type -> RPushXResponse
22, // [22:44] is the sub-list for method output_type
0, // [0:22] is the sub-list for method input_type
22, // 22: CommServer.HDel:input_type -> HDelRequest
23, // 23: CommServer.HExists:input_type -> HExistsRequest
24, // 24: CommServer.HGet:input_type -> HGetRequest
25, // 25: CommServer.HGetAll:input_type -> HGetAllRequest
26, // 26: CommServer.HIncrBy:input_type -> HIncrByRequest
27, // 27: CommServer.HKeys:input_type -> HKeysRequest
28, // 28: CommServer.HLen:input_type -> HLenRequest
29, // 29: CommServer.HSet:input_type -> HSetRequest
30, // 30: CommServer.HSetX:input_type -> HSetXRequest
31, // 31: CommServer.Set:output_type -> SetResponse
32, // 32: CommServer.Get:output_type -> GetResponse
33, // 33: CommServer.Add:output_type -> AddResponse
34, // 34: CommServer.Reduce:output_type -> ReduceResponse
35, // 35: CommServer.SetBit:output_type -> SetBitResponse
36, // 36: CommServer.GetBit:output_type -> GetBitResponse
37, // 37: CommServer.GetRange:output_type -> GetRangeResponse
38, // 38: CommServer.GetSet:output_type -> GetSetResponse
39, // 39: CommServer.StrLen:output_type -> StrLenResponse
40, // 40: CommServer.Setnx:output_type -> SetnxResponse
41, // 41: CommServer.LIndex:output_type -> LIndexResponse
42, // 42: CommServer.LLen:output_type -> LLenResponse
43, // 43: CommServer.LPop:output_type -> LPopResponse
44, // 44: CommServer.LPush:output_type -> LPushResponse
45, // 45: CommServer.LPushX:output_type -> LPushXResponse
46, // 46: CommServer.LRange:output_type -> LRangeResponse
47, // 47: CommServer.LRem:output_type -> LRemResponse
48, // 48: CommServer.LSet:output_type -> LSetResponse
49, // 49: CommServer.RPop:output_type -> RPopResponse
50, // 50: CommServer.LTrim:output_type -> LTrimResponse
51, // 51: CommServer.RPush:output_type -> RPushResponse
52, // 52: CommServer.RPushX:output_type -> RPushXResponse
53, // 53: CommServer.HDel:output_type -> HDelResponse
54, // 54: CommServer.HExists:output_type -> HExistsResponse
55, // 55: CommServer.HGet:output_type -> HGetResponse
56, // 56: CommServer.HGetAll:output_type -> HGetAllResponse
57, // 57: CommServer.HIncrBy:output_type -> HIncrByResponse
58, // 58: CommServer.HKeys:output_type -> HKeysResponse
59, // 59: CommServer.HLen:output_type -> HLenResponse
60, // 60: CommServer.HSet:output_type -> HSetResponse
61, // 61: CommServer.HSetX:output_type -> HSetXResponse
31, // [31:62] is the sub-list for method output_type
0, // [0:31] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
@ -197,6 +256,7 @@ func file_storage_proto_init() {
}
file_stringx_proto_init()
file_listx_proto_init()
file_hashx_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
@ -250,6 +310,15 @@ type CommServerClient interface {
LTrim(ctx context.Context, in *LTrimRequest, opts ...grpc.CallOption) (*LTrimResponse, error)
RPush(ctx context.Context, in *RPushRequest, opts ...grpc.CallOption) (*RPushResponse, error)
RPushX(ctx context.Context, in *RPushXRequest, opts ...grpc.CallOption) (*RPushXResponse, error)
HDel(ctx context.Context, in *HDelRequest, opts ...grpc.CallOption) (*HDelResponse, error)
HExists(ctx context.Context, in *HExistsRequest, opts ...grpc.CallOption) (*HExistsResponse, error)
HGet(ctx context.Context, in *HGetRequest, opts ...grpc.CallOption) (*HGetResponse, error)
HGetAll(ctx context.Context, in *HGetAllRequest, opts ...grpc.CallOption) (*HGetAllResponse, error)
HIncrBy(ctx context.Context, in *HIncrByRequest, opts ...grpc.CallOption) (*HIncrByResponse, error)
HKeys(ctx context.Context, in *HKeysRequest, opts ...grpc.CallOption) (*HKeysResponse, error)
HLen(ctx context.Context, in *HLenRequest, opts ...grpc.CallOption) (*HLenResponse, error)
HSet(ctx context.Context, in *HSetRequest, opts ...grpc.CallOption) (*HSetResponse, error)
HSetX(ctx context.Context, in *HSetXRequest, opts ...grpc.CallOption) (*HSetXResponse, error)
}
type commServerClient struct {
@ -458,6 +527,87 @@ func (c *commServerClient) RPushX(ctx context.Context, in *RPushXRequest, opts .
return out, nil
}
func (c *commServerClient) HDel(ctx context.Context, in *HDelRequest, opts ...grpc.CallOption) (*HDelResponse, error) {
out := new(HDelResponse)
err := c.cc.Invoke(ctx, "/CommServer/HDel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commServerClient) HExists(ctx context.Context, in *HExistsRequest, opts ...grpc.CallOption) (*HExistsResponse, error) {
out := new(HExistsResponse)
err := c.cc.Invoke(ctx, "/CommServer/HExists", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commServerClient) HGet(ctx context.Context, in *HGetRequest, opts ...grpc.CallOption) (*HGetResponse, error) {
out := new(HGetResponse)
err := c.cc.Invoke(ctx, "/CommServer/HGet", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commServerClient) HGetAll(ctx context.Context, in *HGetAllRequest, opts ...grpc.CallOption) (*HGetAllResponse, error) {
out := new(HGetAllResponse)
err := c.cc.Invoke(ctx, "/CommServer/HGetAll", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commServerClient) HIncrBy(ctx context.Context, in *HIncrByRequest, opts ...grpc.CallOption) (*HIncrByResponse, error) {
out := new(HIncrByResponse)
err := c.cc.Invoke(ctx, "/CommServer/HIncrBy", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commServerClient) HKeys(ctx context.Context, in *HKeysRequest, opts ...grpc.CallOption) (*HKeysResponse, error) {
out := new(HKeysResponse)
err := c.cc.Invoke(ctx, "/CommServer/HKeys", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commServerClient) HLen(ctx context.Context, in *HLenRequest, opts ...grpc.CallOption) (*HLenResponse, error) {
out := new(HLenResponse)
err := c.cc.Invoke(ctx, "/CommServer/HLen", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commServerClient) HSet(ctx context.Context, in *HSetRequest, opts ...grpc.CallOption) (*HSetResponse, error) {
out := new(HSetResponse)
err := c.cc.Invoke(ctx, "/CommServer/HSet", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commServerClient) HSetX(ctx context.Context, in *HSetXRequest, opts ...grpc.CallOption) (*HSetXResponse, error) {
out := new(HSetXResponse)
err := c.cc.Invoke(ctx, "/CommServer/HSetX", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// CommServerServer is the server API for CommServer service.
type CommServerServer interface {
Set(context.Context, *SetRequest) (*SetResponse, error)
@ -482,6 +632,15 @@ type CommServerServer interface {
LTrim(context.Context, *LTrimRequest) (*LTrimResponse, error)
RPush(context.Context, *RPushRequest) (*RPushResponse, error)
RPushX(context.Context, *RPushXRequest) (*RPushXResponse, error)
HDel(context.Context, *HDelRequest) (*HDelResponse, error)
HExists(context.Context, *HExistsRequest) (*HExistsResponse, error)
HGet(context.Context, *HGetRequest) (*HGetResponse, error)
HGetAll(context.Context, *HGetAllRequest) (*HGetAllResponse, error)
HIncrBy(context.Context, *HIncrByRequest) (*HIncrByResponse, error)
HKeys(context.Context, *HKeysRequest) (*HKeysResponse, error)
HLen(context.Context, *HLenRequest) (*HLenResponse, error)
HSet(context.Context, *HSetRequest) (*HSetResponse, error)
HSetX(context.Context, *HSetXRequest) (*HSetXResponse, error)
}
// UnimplementedCommServerServer can be embedded to have forward compatible implementations.
@ -554,6 +713,33 @@ func (*UnimplementedCommServerServer) RPush(context.Context, *RPushRequest) (*RP
func (*UnimplementedCommServerServer) RPushX(context.Context, *RPushXRequest) (*RPushXResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RPushX not implemented")
}
func (*UnimplementedCommServerServer) HDel(context.Context, *HDelRequest) (*HDelResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HDel not implemented")
}
func (*UnimplementedCommServerServer) HExists(context.Context, *HExistsRequest) (*HExistsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HExists not implemented")
}
func (*UnimplementedCommServerServer) HGet(context.Context, *HGetRequest) (*HGetResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HGet not implemented")
}
func (*UnimplementedCommServerServer) HGetAll(context.Context, *HGetAllRequest) (*HGetAllResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HGetAll not implemented")
}
func (*UnimplementedCommServerServer) HIncrBy(context.Context, *HIncrByRequest) (*HIncrByResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HIncrBy not implemented")
}
func (*UnimplementedCommServerServer) HKeys(context.Context, *HKeysRequest) (*HKeysResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HKeys not implemented")
}
func (*UnimplementedCommServerServer) HLen(context.Context, *HLenRequest) (*HLenResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HLen not implemented")
}
func (*UnimplementedCommServerServer) HSet(context.Context, *HSetRequest) (*HSetResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HSet not implemented")
}
func (*UnimplementedCommServerServer) HSetX(context.Context, *HSetXRequest) (*HSetXResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HSetX not implemented")
}
func RegisterCommServerServer(s *grpc.Server, srv CommServerServer) {
s.RegisterService(&_CommServer_serviceDesc, srv)
@ -955,6 +1141,168 @@ func _CommServer_RPushX_Handler(srv interface{}, ctx context.Context, dec func(i
return interceptor(ctx, in, info, handler)
}
func _CommServer_HDel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HDelRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).HDel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/HDel",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).HDel(ctx, req.(*HDelRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CommServer_HExists_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HExistsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).HExists(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/HExists",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).HExists(ctx, req.(*HExistsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CommServer_HGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HGetRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).HGet(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/HGet",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).HGet(ctx, req.(*HGetRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CommServer_HGetAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HGetAllRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).HGetAll(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/HGetAll",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).HGetAll(ctx, req.(*HGetAllRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CommServer_HIncrBy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HIncrByRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).HIncrBy(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/HIncrBy",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).HIncrBy(ctx, req.(*HIncrByRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CommServer_HKeys_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HKeysRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).HKeys(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/HKeys",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).HKeys(ctx, req.(*HKeysRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CommServer_HLen_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HLenRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).HLen(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/HLen",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).HLen(ctx, req.(*HLenRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CommServer_HSet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HSetRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).HSet(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/HSet",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).HSet(ctx, req.(*HSetRequest))
}
return interceptor(ctx, in, info, handler)
}
func _CommServer_HSetX_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HSetXRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CommServerServer).HSetX(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/CommServer/HSetX",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommServerServer).HSetX(ctx, req.(*HSetXRequest))
}
return interceptor(ctx, in, info, handler)
}
var _CommServer_serviceDesc = grpc.ServiceDesc{
ServiceName: "CommServer",
HandlerType: (*CommServerServer)(nil),
@ -1047,6 +1395,42 @@ var _CommServer_serviceDesc = grpc.ServiceDesc{
MethodName: "RPushX",
Handler: _CommServer_RPushX_Handler,
},
{
MethodName: "HDel",
Handler: _CommServer_HDel_Handler,
},
{
MethodName: "HExists",
Handler: _CommServer_HExists_Handler,
},
{
MethodName: "HGet",
Handler: _CommServer_HGet_Handler,
},
{
MethodName: "HGetAll",
Handler: _CommServer_HGetAll_Handler,
},
{
MethodName: "HIncrBy",
Handler: _CommServer_HIncrBy_Handler,
},
{
MethodName: "HKeys",
Handler: _CommServer_HKeys_Handler,
},
{
MethodName: "HLen",
Handler: _CommServer_HLen_Handler,
},
{
MethodName: "HSet",
Handler: _CommServer_HSet_Handler,
},
{
MethodName: "HSetX",
Handler: _CommServer_HSetX_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "storage.proto",

View File

@ -53,3 +53,16 @@ type ListXInterface interface {
Range(start, end int) ([]string, error)
Remove(value string, count int) (int, UpdateLength)
}
type HashXInterface interface {
KeyBaseInterface
Set(key string, val string) UpdateLength
Get(key string) (string, error)
Del(key string) (UpdateLength, error)
Key() []string
Value() []string
Item() map[string]string
Add(renewal int, key ...string) (int, []string, error) // 访问影响成功的结果
SetX(key string, val string) (bool, UpdateLength) // 不存在才插入
Length() int
}

View File

@ -0,0 +1,120 @@
package hashx
import (
"gitee.com/wheat-os/wheatCache/pkg/errorx"
"gitee.com/wheat-os/wheatCache/pkg/structure"
)
type HashX map[string]*structure.Value
func NewHashXSingle() structure.HashXInterface {
return make(HashX)
}
func (h HashX) SizeByte() int64 {
var size int
for _, val := range h {
size += val.GetSize()
}
return int64(size)
}
// RollBack TODO 事务相关, V2 实现
func (h HashX) RollBack() error {
panic("not implemented") // TODO: Implement
}
// Begin 事务相关, V2 实现
func (h HashX) Begin() error {
panic("not implemented") // TODO: Implement
}
// Comment 事务相关, V2 实现
func (h HashX) Comment() error {
panic("not implemented") // TODO: Implement
}
func (h HashX) Encode() ([]byte, error) {
panic("not implemented") // TODO: Implement
}
func (h HashX) Set(key string, val string) structure.UpdateLength {
var Length structure.UpdateLength
if v, ok := h[key]; ok {
Length -= structure.UpdateLength(v.GetSize())
}
strVal := structure.NewValue(val)
h[key] = strVal
return Length + structure.UpdateLength(strVal.GetSize())
}
func (h HashX) Get(key string) (string, error) {
if v, ok := h[key]; ok {
return v.ToString(), nil
}
return "", errorx.New("this key does not exist in hashx, key:%s", key)
}
func (h HashX) Del(key string) (structure.UpdateLength, error) {
if v, ok := h[key]; ok {
delete(h, key)
return structure.UpdateLength(v.GetSize()), nil
}
return 0, errorx.New("this key does not exist in hashx, key:%s", key)
}
func (h HashX) Key() []string {
result := make([]string, 0, len(h))
for key := range h {
result = append(result, key)
}
return result
}
func (h HashX) Value() []string {
result := make([]string, 0, len(h))
for _, val := range h {
result = append(result, val.ToString())
}
return result
}
func (h HashX) Item() map[string]string {
result := make(map[string]string, len(h))
for key, val := range h {
result[key] = val.ToString()
}
return result
}
func (h HashX) Add(renewal int, keys ...string) (count int, result []string, err error) {
for _, key := range keys {
if v, ok := h[key]; ok {
res, err := v.Incr(int32(renewal))
if err != nil {
return count, result, errorx.New("option key err, key:%s, err:%v", key, err)
}
count += 1
result = append(result, res)
}
}
return count, result, nil
}
func (h HashX) SetX(key string, val string) (bool, structure.UpdateLength) {
if _, ok := h[key]; ok {
return false, 0
}
strVal := structure.NewValue(val)
h[key] = strVal
return true, structure.UpdateLength(strVal.GetSize())
}
func (h HashX) Length() int {
return len(h)
}

View File

@ -0,0 +1,62 @@
package hashx
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestHashX_Set_SetX(t *testing.T) {
h := NewHashXSingle()
h.Set("key", "opq")
res, err := h.Get("key")
require.NoError(t, err)
require.Equal(t, res, "opq")
b, _ := h.SetX("key", "opq")
require.Equal(t, b, false)
b, _ = h.SetX("key1", "opq")
require.Equal(t, b, true)
res, err = h.Get("key1")
require.NoError(t, err)
require.Equal(t, res, "opq")
}
func TestHashX_Del(t *testing.T) {
h := NewHashXSingle()
up := h.Set("key", "opq")
upu, err := h.Del("key")
require.NoError(t, err)
require.Equal(t, up, upu)
}
func TestHashX_Key(t *testing.T) {
h := NewHashXSingle()
h.Set("key", "opq")
h.Set("key1", "opq")
h.Set("key2", "opq")
require.Equal(t, h.Key(), []string{"key", "key1", "key2"})
}
func TestHashX_Value(t *testing.T) {
h := NewHashXSingle()
h.Set("key", "opq")
h.Set("key1", "opq")
h.Set("key2", "opq")
require.Equal(t, h.Value(), []string{"opq", "opq", "opq"})
}
func TestHashX_Add(t *testing.T) {
h := NewHashXSingle()
h.Set("1", "1")
c, res, err := h.Add(1, "1")
require.NoError(t, err)
require.Equal(t, c, 1)
require.Equal(t, res, []string{"2"})
s, err := h.Get("1")
require.NoError(t, err)
require.Equal(t, s, "2")
}

View File

@ -1,9 +1,6 @@
package stringx
import (
"strconv"
"gitee.com/wheat-os/wheatCache/pkg/errorx"
"gitee.com/wheat-os/wheatCache/pkg/structure"
)
@ -51,32 +48,8 @@ func (s *StringSingle) Get() string {
return s.val.ToString()
}
func updateValueNotString(s *StringSingle, val int32) (string, error) {
switch s.val.GetDynamicType() {
case structure.DynamicNull:
s.val.SetInt(int64(val))
return strconv.Itoa(int(val)), nil
case structure.DynamicFloat:
f, err := s.val.ToFloat64()
if err != nil {
return "", err
}
s.val.SetFloat64(f + float64(val))
return strconv.FormatFloat(f+float64(val), 'f', 2, 64), nil
case structure.DynamicInt:
i, err := s.val.ToInt()
if err != nil {
return "", err
}
s.val.SetInt(int64(val) + i)
return strconv.Itoa(int(i + int64(val))), nil
default:
return "", errorx.New("string cannot perform add operations")
}
}
func (s *StringSingle) Add(renewal int32) (string, error) {
result, err := updateValueNotString(s, renewal)
result, err := s.val.Incr(renewal)
if err != nil {
return "", err
}
@ -84,7 +57,7 @@ func (s *StringSingle) Add(renewal int32) (string, error) {
}
func (s *StringSingle) Reduce(renewal int32) (string, error) {
result, err := updateValueNotString(s, -1*renewal)
result, err := s.val.Incr(-1 * renewal)
if err != nil {
return "", err
}

View File

@ -187,3 +187,28 @@ func (v *Value) SliceByString(start, end int) ([]byte, error) {
return v.val[start:end], nil
}
// 自增
func (v *Value) Incr(renewal int32) (string, error) {
switch v.GetDynamicType() {
case DynamicNull:
v.SetInt(int64(renewal))
return strconv.Itoa(int(renewal)), nil
case DynamicFloat:
f, err := v.ToFloat64()
if err != nil {
return "", err
}
v.SetFloat64(f + float64(renewal))
return strconv.FormatFloat(f+float64(renewal), 'f', 2, 64), nil
case DynamicInt:
i, err := v.ToInt()
if err != nil {
return "", err
}
v.SetInt(int64(renewal) + i)
return strconv.Itoa(int(i + int64(renewal))), nil
default:
return "", errorx.New("string cannot perform add operations")
}
}

81
protobuf/hashx.proto Normal file
View File

@ -0,0 +1,81 @@
syntax = "proto3";
import "base.proto";
option go_package = "pkg/proto";
message HDelRequest {
BaseKey key = 1;
repeated string h_keys = 2;
}
message HDelResponse {
}
message HExistsRequest {
BaseKey key = 1;
string h_key = 2;
}
message HExistsResponse {
bool exists = 1;
}
message HGetRequest {
BaseKey key = 1;
repeated string h_keys = 2;
}
message HGetResponse {
map<string, string> items = 1;
}
message HGetAllRequest {
BaseKey key = 1;
}
message HGetAllResponse {
map<string, string> items = 1;
}
message HIncrByRequest {
BaseKey key = 1;
repeated string h_keys = 2;
int32 renewal = 3;
}
message HIncrByResponse {
int32 count = 1;
repeated string values = 2;
}
message HKeysRequest {
BaseKey key = 1;
}
message HKeysResponse {
repeated string keys = 1;
}
message HLenRequest {
BaseKey key = 1;
}
message HLenResponse {
int32 length = 1;
}
message HSetRequest {
BaseKey key = 1;
map<string, string> items = 2;
}
message HSetResponse {
}
message HSetXRequest {
BaseKey key = 1;
map<string, string> items = 2;
}
message HSetXResponse {
int32 count = 1;
}

View File

@ -7,6 +7,7 @@ option go_package = "pkg/proto";
import "stringx.proto";
import "listx.proto";
import "hashx.proto";
service CommServer {
@ -32,4 +33,13 @@ service CommServer {
rpc LTrim (LTrimRequest) returns (LTrimResponse);
rpc RPush (RPushRequest) returns (RPushResponse);
rpc RPushX (RPushXRequest) returns (RPushXResponse);
rpc HDel (HDelRequest) returns (HDelResponse);
rpc HExists (HExistsRequest) returns (HExistsResponse);
rpc HGet (HGetRequest) returns (HGetResponse);
rpc HGetAll (HGetAllRequest) returns (HGetAllResponse);
rpc HIncrBy (HIncrByRequest) returns (HIncrByResponse);
rpc HKeys (HKeysRequest) returns (HKeysResponse);
rpc HLen (HLenRequest) returns (HLenResponse);
rpc HSet (HSetRequest) returns (HSetResponse);
rpc HSetX (HSetXRequest) returns (HSetXResponse);
}

View File

@ -32,6 +32,9 @@ class ProtoOption(object):
def dist_to_ProOpt(req, resp) -> List[ProtoOption]:
def to_camel(val: str) -> str:
return "".join([k.capitalize() for k in val.split('_')])
def parse_type(l: str) -> List[str]:
l = l.strip()
if l == "":
@ -48,14 +51,19 @@ def dist_to_ProOpt(req, resp) -> List[ProtoOption]:
val = l_list[0]
if val == "BaseKey":
val = "*proto.BaseKey"
result.append([l_list[1].capitalize(), val])
result.append([to_camel(l_list[1]), val])
elif val == "repeated":
val = f"[]{l_list[1]}"
result.append([l_list[2].capitalize(), val])
result.append([to_camel(l_list[2]), val])
elif "map" in val:
resMap = re.findall(
r"^map\s*<(.*?)\s*,\s*(.*?)\s*>.*?(\w+).*?", l_opt)
if len(resMap[0]) == 3:
mapKey, mapVal, var = resMap[0]
result.append([to_camel(var), f"map[{mapKey}]{mapVal}"])
else:
result.append([l_list[1].capitalize(), val])
result.append([to_camel(l_list[1]), val])
return result
lists = []
@ -104,6 +112,7 @@ def load_protobuf() -> List[ProtoOption]:
li.extend(parse_protobuf_to_Opt(name))
return li
def go_fmt(path: str):
os.system(f"go fmt {path}")
@ -112,6 +121,7 @@ def load_template(name: str) -> str:
with open(f"{tempPath}/{name}", "r", encoding="utf-8") as fp:
return fp.read()
def gen_dao_interface(proto):
tem_text = load_template("dao.template")
@ -134,6 +144,7 @@ def gen_single_service(proto):
with open(temp_path, 'w', encoding='utf-8') as f:
f.write(text)
def gen_aof(proto):
tem_text = load_template("aof.template")
template = Template(tem_text)
@ -143,7 +154,7 @@ def gen_aof(proto):
temp_path = f"{aofPath}/codec.gen.go"
with open(temp_path, 'w', encoding='utf-8') as f:
f.write(text)
# 生成 AOF 恢复机制
tem_text = load_template("dao_aof.template")
template = Template(tem_text)
@ -154,12 +165,14 @@ def gen_aof(proto):
with open(temp_path, 'w', encoding='utf-8') as f:
f.write(text)
def format_code_go():
go_fmt(f"{daoPath}/interface.gen.go")
go_fmt(f"{servicePath}/single_service.gen.go")
go_fmt(f"{aofPath}/codec.gen.go")
go_fmt(f"{daoPath}/dao.gen.go")
def main():
# 加载 protobuf
protobuf = load_protobuf()
@ -174,5 +187,6 @@ def main():
gen_aof(protobuf)
format_code_go()
if __name__ == "__main__":
main()

View File

@ -17,6 +17,7 @@ def out_proto():
if err:
print(f, "-> out put err")
return os._exit(-1)
else:
print(f, "-> success")

View File

@ -59,6 +59,33 @@ func (d *Dao) ExecMessage(message protobuf.Message) error {
case *proto.RPushXRequest:
_, err := d.RPushX(req.Key, req.Values)
return err
case *proto.HDelRequest:
_, err := d.HDel(req.Key, req.HKeys)
return err
case *proto.HExistsRequest:
_, err := d.HExists(req.Key, req.HKey)
return err
case *proto.HGetRequest:
_, err := d.HGet(req.Key, req.HKeys)
return err
case *proto.HGetAllRequest:
_, err := d.HGetAll(req.Key)
return err
case *proto.HIncrByRequest:
_, err := d.HIncrBy(req.Key, req.HKeys, req.Renewal)
return err
case *proto.HKeysRequest:
_, err := d.HKeys(req.Key)
return err
case *proto.HLenRequest:
_, err := d.HLen(req.Key)
return err
case *proto.HSetRequest:
_, err := d.HSet(req.Key, req.Items)
return err
case *proto.HSetXRequest:
_, err := d.HSetX(req.Key, req.Items)
return err
case *proto.SetRequest:
_, err := d.Set(req.Key, req.Val)
return err

169
storage/dao/hashx.go Normal file
View File

@ -0,0 +1,169 @@
package dao
import (
"gitee.com/wheat-os/wheatCache/pkg/errorx"
"gitee.com/wheat-os/wheatCache/pkg/proto"
"gitee.com/wheat-os/wheatCache/pkg/structure"
"gitee.com/wheat-os/wheatCache/pkg/structure/hashx"
)
func (d *Dao) HDel(key *proto.BaseKey, hKeys []string) (*proto.HDelResponse, error) {
value, ok := d.lru.Get(key)
if !ok {
return nil, errorx.NotKeyErr(key.Key)
}
hashVal, ok := value.(structure.HashXInterface)
if !ok {
return nil, errorx.DaoTypeErr("hashx")
}
for _, hK := range hKeys {
up, err := hashVal.Del(hK)
if err != nil {
return nil, err
}
d.lru.UpdateLruSize(up)
}
return &proto.HDelResponse{}, nil
}
func (d *Dao) HExists(key *proto.BaseKey, hKeys string) (*proto.HExistsResponse, error) {
value, ok := d.lru.Get(key)
if !ok {
return nil, errorx.NotKeyErr(key.Key)
}
hashVal, ok := value.(structure.HashXInterface)
if !ok {
return nil, errorx.DaoTypeErr("hashx")
}
_, err := hashVal.Get(hKeys)
if err != nil {
return &proto.HExistsResponse{Exists: false}, nil
}
return &proto.HExistsResponse{Exists: true}, nil
}
func (d *Dao) HGet(key *proto.BaseKey, hKeys []string) (*proto.HGetResponse, error) {
value, ok := d.lru.Get(key)
if !ok {
return nil, errorx.NotKeyErr(key.Key)
}
hashVal, ok := value.(structure.HashXInterface)
if !ok {
return nil, errorx.DaoTypeErr("hashx")
}
result := make(map[string]string)
for _, hK := range hKeys {
res, err := hashVal.Get(hK)
if err != nil {
return nil, err
}
result[hK] = res
}
return &proto.HGetResponse{Items: result}, nil
}
func (d *Dao) HGetAll(key *proto.BaseKey) (*proto.HGetAllResponse, error) {
value, ok := d.lru.Get(key)
if !ok {
return nil, errorx.NotKeyErr(key.Key)
}
hashVal, ok := value.(structure.HashXInterface)
if !ok {
return nil, errorx.DaoTypeErr("hashx")
}
return &proto.HGetAllResponse{Items: hashVal.Item()}, nil
}
func (d *Dao) HIncrBy(key *proto.BaseKey, hKeys []string, renewal int32) (*proto.HIncrByResponse, error) {
value, ok := d.lru.Get(key)
if !ok {
return nil, errorx.NotKeyErr(key.Key)
}
hashVal, ok := value.(structure.HashXInterface)
if !ok {
return nil, errorx.DaoTypeErr("hashx")
}
count, result, err := hashVal.Add(int(renewal), hKeys...)
return &proto.HIncrByResponse{
Count: int32(count),
Values: result,
}, err
}
func (d *Dao) HKeys(key *proto.BaseKey) (*proto.HKeysResponse, error) {
value, ok := d.lru.Get(key)
if !ok {
return nil, errorx.NotKeyErr(key.Key)
}
hashVal, ok := value.(structure.HashXInterface)
if !ok {
return nil, errorx.DaoTypeErr("hashx")
}
return &proto.HKeysResponse{Keys: hashVal.Key()}, nil
}
func (d *Dao) HLen(key *proto.BaseKey) (*proto.HLenResponse, error) {
value, ok := d.lru.Get(key)
if !ok {
return nil, errorx.NotKeyErr(key.Key)
}
hashVal, ok := value.(structure.HashXInterface)
if !ok {
return nil, errorx.DaoTypeErr("hashx")
}
return &proto.HLenResponse{Length: int32(hashVal.Length())}, nil
}
func (d *Dao) HSet(key *proto.BaseKey, set map[string]string) (*proto.HSetResponse, error) {
value, ok := d.lru.Get(key)
if !ok {
hashVal := hashx.NewHashXSingle()
for k, v := range set {
hashVal.Set(k, v)
}
err := d.lru.Add(key, hashVal)
return &proto.HSetResponse{}, err
}
hashVal, ok := value.(structure.HashXInterface)
if !ok {
return nil, errorx.DaoTypeErr("hashx")
}
for k, v := range set {
upLength := hashVal.Set(k, v)
d.lru.UpdateLruSize(upLength)
}
return &proto.HSetResponse{}, nil
}
func (d *Dao) HSetX(key *proto.BaseKey, set map[string]string) (*proto.HSetXResponse, error) {
value, ok := d.lru.Get(key)
if !ok {
return &proto.HSetXResponse{}, errorx.NotKeyErr(key.Key)
}
hashVal, ok := value.(structure.HashXInterface)
if !ok {
return nil, errorx.DaoTypeErr("hashx")
}
for k, v := range set {
upLength := hashVal.Set(k, v)
d.lru.UpdateLruSize(upLength)
}
return &proto.HSetXResponse{}, nil
}

View File

@ -21,6 +21,15 @@ type Interface interface {
LTrim(*proto.BaseKey, int32, int32) (*proto.LTrimResponse, error)
RPush(*proto.BaseKey, []string) (*proto.RPushResponse, error)
RPushX(*proto.BaseKey, []string) (*proto.RPushXResponse, error)
HDel(*proto.BaseKey, []string) (*proto.HDelResponse, error)
HExists(*proto.BaseKey, string) (*proto.HExistsResponse, error)
HGet(*proto.BaseKey, []string) (*proto.HGetResponse, error)
HGetAll(*proto.BaseKey) (*proto.HGetAllResponse, error)
HIncrBy(*proto.BaseKey, []string, int32) (*proto.HIncrByResponse, error)
HKeys(*proto.BaseKey) (*proto.HKeysResponse, error)
HLen(*proto.BaseKey) (*proto.HLenResponse, error)
HSet(*proto.BaseKey, map[string]string) (*proto.HSetResponse, error)
HSetX(*proto.BaseKey, map[string]string) (*proto.HSetXResponse, error)
Set(*proto.BaseKey, string) (*proto.SetResponse, error)
Get(*proto.BaseKey) (*proto.GetResponse, error)
Add(*proto.BaseKey, int32) (*proto.AddResponse, error)

View File

@ -1,18 +1,3 @@
/*
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (

View File

@ -72,6 +72,24 @@ func decode(method string, buf []byte) (protobuf.Message, error) {
return decodeRPush(buf)
case "RPushX":
return decodeRPushX(buf)
case "HDel":
return decodeHDel(buf)
case "HExists":
return decodeHExists(buf)
case "HGet":
return decodeHGet(buf)
case "HGetAll":
return decodeHGetAll(buf)
case "HIncrBy":
return decodeHIncrBy(buf)
case "HKeys":
return decodeHKeys(buf)
case "HLen":
return decodeHLen(buf)
case "HSet":
return decodeHSet(buf)
case "HSetX":
return decodeHSetX(buf)
case "Set":
return decodeSet(buf)
case "Get":
@ -206,6 +224,87 @@ func decodeRPushX(buf []byte) (*proto.RPushXRequest, error) {
return req, nil
}
func decodeHDel(buf []byte) (*proto.HDelRequest, error) {
req := &proto.HDelRequest{}
err := protobuf.Unmarshal(buf, req)
if err != nil {
return nil, err
}
return req, nil
}
func decodeHExists(buf []byte) (*proto.HExistsRequest, error) {
req := &proto.HExistsRequest{}
err := protobuf.Unmarshal(buf, req)
if err != nil {
return nil, err
}
return req, nil
}
func decodeHGet(buf []byte) (*proto.HGetRequest, error) {
req := &proto.HGetRequest{}
err := protobuf.Unmarshal(buf, req)
if err != nil {
return nil, err
}
return req, nil
}
func decodeHGetAll(buf []byte) (*proto.HGetAllRequest, error) {
req := &proto.HGetAllRequest{}
err := protobuf.Unmarshal(buf, req)
if err != nil {
return nil, err
}
return req, nil
}
func decodeHIncrBy(buf []byte) (*proto.HIncrByRequest, error) {
req := &proto.HIncrByRequest{}
err := protobuf.Unmarshal(buf, req)
if err != nil {
return nil, err
}
return req, nil
}
func decodeHKeys(buf []byte) (*proto.HKeysRequest, error) {
req := &proto.HKeysRequest{}
err := protobuf.Unmarshal(buf, req)
if err != nil {
return nil, err
}
return req, nil
}
func decodeHLen(buf []byte) (*proto.HLenRequest, error) {
req := &proto.HLenRequest{}
err := protobuf.Unmarshal(buf, req)
if err != nil {
return nil, err
}
return req, nil
}
func decodeHSet(buf []byte) (*proto.HSetRequest, error) {
req := &proto.HSetRequest{}
err := protobuf.Unmarshal(buf, req)
if err != nil {
return nil, err
}
return req, nil
}
func decodeHSetX(buf []byte) (*proto.HSetXRequest, error) {
req := &proto.HSetXRequest{}
err := protobuf.Unmarshal(buf, req)
if err != nil {
return nil, err
}
return req, nil
}
func decodeSet(buf []byte) (*proto.SetRequest, error) {
req := &proto.SetRequest{}
err := protobuf.Unmarshal(buf, req)

View File

@ -346,6 +346,258 @@ func (s *singleService) RPushX(
return resp.(*proto.RPushXResponse), nil
}
func (s *singleService) HDel(
ctx context.Context,
req *proto.HDelRequest,
) (*proto.HDelResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HDel(req.Key, req.HKeys)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HDel", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HDelResponse), nil
}
func (s *singleService) HExists(
ctx context.Context,
req *proto.HExistsRequest,
) (*proto.HExistsResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HExists(req.Key, req.HKey)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HExists", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HExistsResponse), nil
}
func (s *singleService) HGet(
ctx context.Context,
req *proto.HGetRequest,
) (*proto.HGetResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HGet(req.Key, req.HKeys)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HGet", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HGetResponse), nil
}
func (s *singleService) HGetAll(
ctx context.Context,
req *proto.HGetAllRequest,
) (*proto.HGetAllResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HGetAll(req.Key)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HGetAll", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HGetAllResponse), nil
}
func (s *singleService) HIncrBy(
ctx context.Context,
req *proto.HIncrByRequest,
) (*proto.HIncrByResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HIncrBy(req.Key, req.HKeys, req.Renewal)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HIncrBy", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HIncrByResponse), nil
}
func (s *singleService) HKeys(
ctx context.Context,
req *proto.HKeysRequest,
) (*proto.HKeysResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HKeys(req.Key)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HKeys", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HKeysResponse), nil
}
func (s *singleService) HLen(
ctx context.Context,
req *proto.HLenRequest,
) (*proto.HLenResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HLen(req.Key)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HLen", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HLenResponse), nil
}
func (s *singleService) HSet(
ctx context.Context,
req *proto.HSetRequest,
) (*proto.HSetResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HSet(req.Key, req.Items)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HSet", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HSetResponse), nil
}
func (s *singleService) HSetX(
ctx context.Context,
req *proto.HSetXRequest,
) (*proto.HSetXResponse, error) {
work := event.EventWorkFunc(func() (interface{}, error) {
resp, err := s.dao.HSetX(req.Key, req.Items)
if err != nil {
return nil, err
}
if s.aof != nil {
s.aof.SendRequest("HSetX", req)
}
return resp, nil
})
lruEvent := s.lruProduce.NewEvent(lru.OptionEventName)
lruEvent.InitWaitEvent()
lruEvent.SetValue(lru.WorkFuncEventKey, work)
s.lruProduce.Call(ctx, lruEvent)
resp, err := lruEvent.StartWaitEvent(s.timeOut)
s.lruProduce.Recovery(lruEvent)
if err != nil {
return nil, err
}
return resp.(*proto.HSetXResponse), nil
}
func (s *singleService) Set(
ctx context.Context,
req *proto.SetRequest,

View File

@ -8,6 +8,7 @@ const (
STRING_X
LIST_X
HASH_X
)
const (
@ -34,6 +35,15 @@ const (
LTrim
RPush
RPushX
HDel
HExists
HGet
HGetAll
HIncrBy
HKeys
HLen
HSet
HSetX
)
var CommKeyString = map[string]int{
@ -60,6 +70,16 @@ var CommKeyString = map[string]int{
"LTrim": LIST_X,
"RPush": LIST_X,
"RPushX": LIST_X,
"HDel": HASH_X,
"HExists": HASH_X,
"HGet": HASH_X,
"HGetAll": HASH_X,
"HIncrBy": HASH_X,
"HKeys": HASH_X,
"HLen": HASH_X,
"HSet": HASH_X,
"HSetX": HASH_X,
}
var CommKey = map[int]int{
@ -86,4 +106,14 @@ var CommKey = map[int]int{
LTrim: LIST_X,
RPush: LIST_X,
RPushX: LIST_X,
HDel: HASH_X,
HExists: HASH_X,
HGet: HASH_X,
HGetAll: HASH_X,
HIncrBy: HASH_X,
HKeys: HASH_X,
HLen: HASH_X,
HSet: HASH_X,
HSetX: HASH_X,
}

View File

@ -25,4 +25,15 @@ LIST_X:
- r_pop
- l_trim # 对列表进行切片
- r_push
- r_push_x # 对已经存在的列表尾插
- r_push_x # 对已经存在的列表尾插
HASH_X:
- h_del
- h_exists
- h_get
- h_get_all
- h_incr_by
- h_keys
- h_len
- h_set
- h_set_x