2021-08-31 23:31:31 +08:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
context "context"
|
2021-09-19 11:53:17 +08:00
|
|
|
"errors"
|
|
|
|
|
2021-09-18 16:05:20 +08:00
|
|
|
"gitee.com/timedb/wheatCache/pkg/proto"
|
2021-09-19 11:53:17 +08:00
|
|
|
"gitee.com/timedb/wheatCache/pkg/structure/stringx"
|
2021-08-31 23:31:31 +08:00
|
|
|
)
|
|
|
|
|
2021-09-19 11:53:17 +08:00
|
|
|
type server struct {
|
|
|
|
}
|
2021-08-31 23:31:31 +08:00
|
|
|
|
|
|
|
func NewServer() proto.CommServerServer {
|
|
|
|
ser := &server{}
|
|
|
|
return ser
|
|
|
|
}
|
|
|
|
|
2021-09-19 11:53:17 +08:00
|
|
|
func (s *server) Get(
|
|
|
|
cxt context.Context,
|
|
|
|
req *proto.GetRequest,
|
|
|
|
) (*proto.CommendResponse, error) {
|
|
|
|
|
|
|
|
var value interface{}
|
|
|
|
|
|
|
|
switch value.(type) {
|
|
|
|
case *stringx.StringX:
|
|
|
|
default:
|
|
|
|
return nil, errors.New("awdwd")
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err := value.(*stringx.StringX).Get(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &proto.CommendResponse{
|
|
|
|
Result: result,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *server) Set(
|
2021-08-31 23:31:31 +08:00
|
|
|
ctx context.Context,
|
2021-09-19 11:53:17 +08:00
|
|
|
req *proto.SetRequest,
|
2021-08-31 23:31:31 +08:00
|
|
|
) (*proto.CommendResponse, error) {
|
2021-09-19 11:53:17 +08:00
|
|
|
var value interface{}
|
|
|
|
|
|
|
|
switch value.(type) {
|
|
|
|
case *stringx.StringX:
|
|
|
|
default:
|
|
|
|
return nil, errors.New("awdwd")
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err := value.(*stringx.StringX).Set(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &proto.CommendResponse{
|
|
|
|
Result: result,
|
|
|
|
}, nil
|
2021-08-31 23:31:31 +08:00
|
|
|
}
|