From d49a7640bd845de15fbb9e398edeadae2846a018 Mon Sep 17 00:00:00 2001 From: guzeng Date: Wed, 23 Jun 2021 23:07:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E5=8C=85=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.balance.go | 2 +- client.go | 6 +++--- client_test.go | 2 +- site.pb.go | 48 +++++++++++++++++++++++------------------------ site.proto | 12 ++++++------ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/client.balance.go b/client.balance.go index d91a3da..8f1d7db 100644 --- a/client.balance.go +++ b/client.balance.go @@ -1,4 +1,4 @@ -package site +package siterpc // import ( // "encoding/json" diff --git a/client.go b/client.go index ded483c..dea2dbc 100644 --- a/client.go +++ b/client.go @@ -1,4 +1,4 @@ -package site +package siterpc import ( "crypto/md5" @@ -72,9 +72,9 @@ func getconfig(site_id, dbname, key string, url ...string) (*SiteConfigItemRes, sign := Sign(encryData, now) - req := &ConfigRequest{proto.String(encryData), proto.String(now), proto.String(sign), nil} + req := &Request{proto.String(encryData), proto.String(now), proto.String(sign), nil} - res := &ConfigResponse{} + res := &Response{} err = conn.GetConfig(req, res) diff --git a/client_test.go b/client_test.go index a20b19d..e3b8b4a 100644 --- a/client_test.go +++ b/client_test.go @@ -1,4 +1,4 @@ -package site +package siterpc import ( "testing" diff --git a/site.pb.go b/site.pb.go index ef94004..db26192 100644 --- a/site.pb.go +++ b/site.pb.go @@ -3,16 +3,16 @@ // DO NOT EDIT! /* -Package site is a generated protocol buffer package. +Package siterpc is a generated protocol buffer package. It is generated from these files: site.proto It has these top-level messages: - ConfigRequest - ConfigResponse + Request + Response */ -package site +package siterpc import proto "github.com/chai2010/protorpc/proto" import math "math" @@ -29,32 +29,32 @@ var _ = proto.Marshal var _ = math.Inf // 配置信息请求结构 -type ConfigRequest struct { +type Request struct { Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"` Time *string `protobuf:"bytes,2,opt,name=time" json:"time,omitempty"` Sign *string `protobuf:"bytes,3,opt,name=sign" json:"sign,omitempty"` XXX_unrecognized []byte `json:"-"` } -func (m *ConfigRequest) Reset() { *m = ConfigRequest{} } -func (m *ConfigRequest) String() string { return proto.CompactTextString(m) } -func (*ConfigRequest) ProtoMessage() {} +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} -func (m *ConfigRequest) GetData() string { +func (m *Request) GetData() string { if m != nil && m.Data != nil { return *m.Data } return "" } -func (m *ConfigRequest) GetTime() string { +func (m *Request) GetTime() string { if m != nil && m.Time != nil { return *m.Time } return "" } -func (m *ConfigRequest) GetSign() string { +func (m *Request) GetSign() string { if m != nil && m.Sign != nil { return *m.Sign } @@ -62,32 +62,32 @@ func (m *ConfigRequest) GetSign() string { } // 配置信息响应结构 -type ConfigResponse struct { +type Response struct { Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"` Time *string `protobuf:"bytes,2,opt,name=time" json:"time,omitempty"` Sign *string `protobuf:"bytes,3,opt,name=sign" json:"sign,omitempty"` XXX_unrecognized []byte `json:"-"` } -func (m *ConfigResponse) Reset() { *m = ConfigResponse{} } -func (m *ConfigResponse) String() string { return proto.CompactTextString(m) } -func (*ConfigResponse) ProtoMessage() {} +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} -func (m *ConfigResponse) GetData() string { +func (m *Response) GetData() string { if m != nil && m.Data != nil { return *m.Data } return "" } -func (m *ConfigResponse) GetTime() string { +func (m *Response) GetTime() string { if m != nil && m.Time != nil { return *m.Time } return "" } -func (m *ConfigResponse) GetSign() string { +func (m *Response) GetSign() string { if m != nil && m.Sign != nil { return *m.Sign } @@ -98,9 +98,9 @@ func init() { } type SiteService interface { - GetConfig(in *ConfigRequest, out *ConfigResponse) error - GetBalanceType(in *ConfigRequest, out *ConfigResponse) error - GetAllSite(in *ConfigRequest, out *ConfigResponse) error + GetConfig(in *Request, out *Response) error + GetBalanceType(in *Request, out *Response) error + GetAllSite(in *Request, out *Response) error } // AcceptSiteServiceClient accepts connections on the listener and serves requests @@ -172,13 +172,13 @@ func NewSiteServiceClient(conn io.ReadWriteCloser) (*SiteServiceClient, *rpc.Cli return &SiteServiceClient{c}, c } -func (c *SiteServiceClient) GetConfig(in *ConfigRequest, out *ConfigResponse) error { +func (c *SiteServiceClient) GetConfig(in *Request, out *Response) error { return c.Call("SiteService.GetConfig", in, out) } -func (c *SiteServiceClient) GetBalanceType(in *ConfigRequest, out *ConfigResponse) error { +func (c *SiteServiceClient) GetBalanceType(in *Request, out *Response) error { return c.Call("SiteService.GetBalanceType", in, out) } -func (c *SiteServiceClient) GetAllSite(in *ConfigRequest, out *ConfigResponse) error { +func (c *SiteServiceClient) GetAllSite(in *Request, out *Response) error { return c.Call("SiteService.GetAllSite", in, out) } diff --git a/site.proto b/site.proto index ce43e24..7880a60 100644 --- a/site.proto +++ b/site.proto @@ -1,15 +1,15 @@ syntax = "proto3"; -package site; +package siterpc; // 配置信息请求结构 -message ConfigRequest { +message Request { string data = 1; string time = 2; string sign = 3; } // 配置信息响应结构 -message ConfigResponse { +message Response { string data = 1; string time = 2; string sign = 3; @@ -18,7 +18,7 @@ message ConfigResponse { // rpc方法 service SiteService { - rpc getConfig (ConfigRequest) returns (ConfigResponse); // 查询配置信息 - rpc getBalanceType (ConfigRequest) returns (ConfigResponse); // 查询账户类型信息 - rpc getAllSite(ConfigRequest) returns (ConfigResponse);//缓存的所有站点 + rpc getConfig (Request) returns (Response); // 查询配置信息 + rpc getBalanceType (Request) returns (Response); // 查询账户类型信息 + rpc getAllSite(Request) returns (Response);//缓存的所有站点 } \ No newline at end of file