redis rpc服务, 提供redis操作方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

443 lines
12 KiB

// Code generated by protoc-gen-go.
// source: redis.proto
// DO NOT EDIT!
/*
Package redisrpc is a generated protocol buffer package.
It is generated from these files:
redis.proto
It has these top-level messages:
GetRequest
SetRequest
DelRequest
HGetRequest
HSetRequest
HDelRequest
SetExpireRequest
GetStringResponse
HGetListResponse
SetResponse
DelResponse
HSetResponse
SetExpireResponse
*/
package redisrpc
import proto "github.com/chai2010/protorpc/proto"
import math "math"
import "io"
import "log"
import "net"
import "net/rpc"
import "time"
import protorpc "github.com/chai2010/protorpc"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = math.Inf
// 使用key查询
type GetRequest struct {
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GetRequest) Reset() { *m = GetRequest{} }
func (m *GetRequest) String() string { return proto.CompactTextString(m) }
func (*GetRequest) ProtoMessage() {}
func (m *GetRequest) GetKey() string {
if m != nil && m.Key != nil {
return *m.Key
}
return ""
}
// 设置key
type SetRequest struct {
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
Ttl *int64 `protobuf:"varint,3,opt,name=ttl" json:"ttl,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *SetRequest) Reset() { *m = SetRequest{} }
func (m *SetRequest) String() string { return proto.CompactTextString(m) }
func (*SetRequest) ProtoMessage() {}
func (m *SetRequest) GetKey() string {
if m != nil && m.Key != nil {
return *m.Key
}
return ""
}
func (m *SetRequest) GetValue() string {
if m != nil && m.Value != nil {
return *m.Value
}
return ""
}
func (m *SetRequest) GetTtl() int64 {
if m != nil && m.Ttl != nil {
return *m.Ttl
}
return 0
}
type DelRequest struct {
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *DelRequest) Reset() { *m = DelRequest{} }
func (m *DelRequest) String() string { return proto.CompactTextString(m) }
func (*DelRequest) ProtoMessage() {}
func (m *DelRequest) GetKey() string {
if m != nil && m.Key != nil {
return *m.Key
}
return ""
}
// 使用hash key查询
type HGetRequest struct {
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
Field *string `protobuf:"bytes,2,opt,name=field" json:"field,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *HGetRequest) Reset() { *m = HGetRequest{} }
func (m *HGetRequest) String() string { return proto.CompactTextString(m) }
func (*HGetRequest) ProtoMessage() {}
func (m *HGetRequest) GetKey() string {
if m != nil && m.Key != nil {
return *m.Key
}
return ""
}
func (m *HGetRequest) GetField() string {
if m != nil && m.Field != nil {
return *m.Field
}
return ""
}
// 设置hash key
type HSetRequest struct {
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
Field *string `protobuf:"bytes,2,opt,name=field" json:"field,omitempty"`
Value *string `protobuf:"bytes,3,opt,name=value" json:"value,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *HSetRequest) Reset() { *m = HSetRequest{} }
func (m *HSetRequest) String() string { return proto.CompactTextString(m) }
func (*HSetRequest) ProtoMessage() {}
func (m *HSetRequest) GetKey() string {
if m != nil && m.Key != nil {
return *m.Key
}
return ""
}
func (m *HSetRequest) GetField() string {
if m != nil && m.Field != nil {
return *m.Field
}
return ""
}
func (m *HSetRequest) GetValue() string {
if m != nil && m.Value != nil {
return *m.Value
}
return ""
}
// 删除hash key
type HDelRequest struct {
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
Field *string `protobuf:"bytes,2,opt,name=field" json:"field,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *HDelRequest) Reset() { *m = HDelRequest{} }
func (m *HDelRequest) String() string { return proto.CompactTextString(m) }
func (*HDelRequest) ProtoMessage() {}
func (m *HDelRequest) GetKey() string {
if m != nil && m.Key != nil {
return *m.Key
}
return ""
}
func (m *HDelRequest) GetField() string {
if m != nil && m.Field != nil {
return *m.Field
}
return ""
}
// 有效期
type SetExpireRequest struct {
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
Expire *int64 `protobuf:"varint,2,opt,name=expire" json:"expire,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *SetExpireRequest) Reset() { *m = SetExpireRequest{} }
func (m *SetExpireRequest) String() string { return proto.CompactTextString(m) }
func (*SetExpireRequest) ProtoMessage() {}
func (m *SetExpireRequest) GetKey() string {
if m != nil && m.Key != nil {
return *m.Key
}
return ""
}
func (m *SetExpireRequest) GetExpire() int64 {
if m != nil && m.Expire != nil {
return *m.Expire
}
return 0
}
// 使用key查询响应结构
type GetStringResponse struct {
Value *string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *GetStringResponse) Reset() { *m = GetStringResponse{} }
func (m *GetStringResponse) String() string { return proto.CompactTextString(m) }
func (*GetStringResponse) ProtoMessage() {}
func (m *GetStringResponse) GetValue() string {
if m != nil && m.Value != nil {
return *m.Value
}
return ""
}
// 使用key查询响应结构
type HGetListResponse struct {
List []byte `protobuf:"bytes,1,opt,name=list" json:"list,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *HGetListResponse) Reset() { *m = HGetListResponse{} }
func (m *HGetListResponse) String() string { return proto.CompactTextString(m) }
func (*HGetListResponse) ProtoMessage() {}
func (m *HGetListResponse) GetList() []byte {
if m != nil {
return m.List
}
return nil
}
// 设置key响应结构
type SetResponse struct {
Ret *string `protobuf:"bytes,1,opt,name=ret" json:"ret,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *SetResponse) Reset() { *m = SetResponse{} }
func (m *SetResponse) String() string { return proto.CompactTextString(m) }
func (*SetResponse) ProtoMessage() {}
func (m *SetResponse) GetRet() string {
if m != nil && m.Ret != nil {
return *m.Ret
}
return ""
}
// 删除key响应结构
type DelResponse struct {
Ret *int64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *DelResponse) Reset() { *m = DelResponse{} }
func (m *DelResponse) String() string { return proto.CompactTextString(m) }
func (*DelResponse) ProtoMessage() {}
func (m *DelResponse) GetRet() int64 {
if m != nil && m.Ret != nil {
return *m.Ret
}
return 0
}
// 设置key响应结构
type HSetResponse struct {
Ret *int64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *HSetResponse) Reset() { *m = HSetResponse{} }
func (m *HSetResponse) String() string { return proto.CompactTextString(m) }
func (*HSetResponse) ProtoMessage() {}
func (m *HSetResponse) GetRet() int64 {
if m != nil && m.Ret != nil {
return *m.Ret
}
return 0
}
// 设置key有效期
type SetExpireResponse struct {
Ret *int64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *SetExpireResponse) Reset() { *m = SetExpireResponse{} }
func (m *SetExpireResponse) String() string { return proto.CompactTextString(m) }
func (*SetExpireResponse) ProtoMessage() {}
func (m *SetExpireResponse) GetRet() int64 {
if m != nil && m.Ret != nil {
return *m.Ret
}
return 0
}
func init() {
}
type RedisService interface {
Get(in *GetRequest, out *GetStringResponse) error
Set(in *SetRequest, out *SetResponse) error
Del(in *DelRequest, out *DelResponse) error
HGet(in *HGetRequest, out *GetStringResponse) error
HSet(in *HSetRequest, out *HSetResponse) error
HDel(in *HDelRequest, out *DelResponse) error
SetExpire(in *SetExpireRequest, out *SetExpireResponse) error
HGetAll(in *GetRequest, out *HGetListResponse) error
}
// AcceptRedisServiceClient accepts connections on the listener and serves requests
// for each incoming connection. Accept blocks; the caller typically
// invokes it in a go statement.
func AcceptRedisServiceClient(lis net.Listener, x RedisService) {
srv := rpc.NewServer()
if err := srv.RegisterName("RedisService", x); err != nil {
log.Fatal(err)
}
for {
conn, err := lis.Accept()
if err != nil {
log.Fatalf("lis.Accept(): %v\n", err)
}
go srv.ServeCodec(protorpc.NewServerCodec(conn))
}
}
// RegisterRedisService publish the given RedisService implementation on the server.
func RegisterRedisService(srv *rpc.Server, x RedisService) error {
if err := srv.RegisterName("RedisService", x); err != nil {
return err
}
return nil
}
// NewRedisServiceServer returns a new RedisService Server.
func NewRedisServiceServer(x RedisService) *rpc.Server {
srv := rpc.NewServer()
if err := srv.RegisterName("RedisService", x); err != nil {
log.Fatal(err)
}
return srv
}
// ListenAndServeRedisService listen announces on the local network address laddr
// and serves the given RedisService implementation.
func ListenAndServeRedisService(network, addr string, x RedisService) error {
lis, err := net.Listen(network, addr)
if err != nil {
return err
}
defer lis.Close()
srv := rpc.NewServer()
if err := srv.RegisterName("RedisService", x); err != nil {
return err
}
for {
conn, err := lis.Accept()
if err != nil {
log.Fatalf("lis.Accept(): %v\n", err)
}
go srv.ServeCodec(protorpc.NewServerCodec(conn))
}
}
type RedisServiceClient struct {
*rpc.Client
}
// NewRedisServiceClient returns a RedisService rpc.Client and stub to handle
// requests to the set of RedisService at the other end of the connection.
func NewRedisServiceClient(conn io.ReadWriteCloser) (*RedisServiceClient, *rpc.Client) {
c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
return &RedisServiceClient{c}, c
}
func (c *RedisServiceClient) Get(in *GetRequest, out *GetStringResponse) error {
return c.Call("RedisService.Get", in, out)
}
func (c *RedisServiceClient) Set(in *SetRequest, out *SetResponse) error {
return c.Call("RedisService.Set", in, out)
}
func (c *RedisServiceClient) Del(in *DelRequest, out *DelResponse) error {
return c.Call("RedisService.Del", in, out)
}
func (c *RedisServiceClient) HGet(in *HGetRequest, out *GetStringResponse) error {
return c.Call("RedisService.HGet", in, out)
}
func (c *RedisServiceClient) HSet(in *HSetRequest, out *HSetResponse) error {
return c.Call("RedisService.HSet", in, out)
}
func (c *RedisServiceClient) HDel(in *HDelRequest, out *DelResponse) error {
return c.Call("RedisService.HDel", in, out)
}
func (c *RedisServiceClient) SetExpire(in *SetExpireRequest, out *SetExpireResponse) error {
return c.Call("RedisService.SetExpire", in, out)
}
func (c *RedisServiceClient) HGetAll(in *GetRequest, out *HGetListResponse) error {
return c.Call("RedisService.HGetAll", in, out)
}
// DialRedisService connects to an RedisService at the specified network address.
func DialRedisService(network, addr string) (*RedisServiceClient, *rpc.Client, error) {
c, err := protorpc.Dial(network, addr)
if err != nil {
return nil, nil, err
}
return &RedisServiceClient{c}, c, nil
}
// DialRedisServiceTimeout connects to an RedisService at the specified network address.
func DialRedisServiceTimeout(network, addr string,
timeout time.Duration) (*RedisServiceClient, *rpc.Client, error) {
c, err := protorpc.DialTimeout(network, addr, timeout)
if err != nil {
return nil, nil, err
}
return &RedisServiceClient{c}, c, nil
}