|
|
- // 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:
- GetKey
- GetHashKey
- GetResponse
- */
- 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 GetKey struct {
- Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
- XXX_unrecognized []byte `json:"-"`
- }
-
- func (m *GetKey) Reset() { *m = GetKey{} }
- func (m *GetKey) String() string { return proto.CompactTextString(m) }
- func (*GetKey) ProtoMessage() {}
-
- func (m *GetKey) GetKey() string {
- if m != nil && m.Key != nil {
- return *m.Key
- }
- return ""
- }
-
- // 使用hash key查询
- type GetHashKey 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 *GetHashKey) Reset() { *m = GetHashKey{} }
- func (m *GetHashKey) String() string { return proto.CompactTextString(m) }
- func (*GetHashKey) ProtoMessage() {}
-
- func (m *GetHashKey) GetKey() string {
- if m != nil && m.Key != nil {
- return *m.Key
- }
- return ""
- }
-
- func (m *GetHashKey) GetField() string {
- if m != nil && m.Field != nil {
- return *m.Field
- }
- return ""
- }
-
- // 使用key查询响应结构
- type GetResponse struct {
- String_ *string `protobuf:"bytes,1,opt,name=string" json:"string,omitempty"`
- XXX_unrecognized []byte `json:"-"`
- }
-
- func (m *GetResponse) Reset() { *m = GetResponse{} }
- func (m *GetResponse) String() string { return proto.CompactTextString(m) }
- func (*GetResponse) ProtoMessage() {}
-
- func (m *GetResponse) GetString_() string {
- if m != nil && m.String_ != nil {
- return *m.String_
- }
- return ""
- }
-
- func init() {
- }
-
- type RedisService interface {
- GetByKey(in *GetKey, out *GetResponse) error
- GetByHashKey(in *GetHashKey, out *GetResponse) 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) GetByKey(in *GetKey, out *GetResponse) error {
- return c.Call("RedisService.GetByKey", in, out)
- }
- func (c *RedisServiceClient) GetByHashKey(in *GetHashKey, out *GetResponse) error {
- return c.Call("RedisService.GetByHashKey", 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
- }
|