gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/client/proto/client.pb.micro.go (about) 1 // Code generated by protoc-gen-micro. DO NOT EDIT. 2 // source: gitee.com/liuxuezhan/go-micro-v1.18.0/client/proto/client.proto 3 4 package go_micro_client 5 6 import ( 7 fmt "fmt" 8 proto "github.com/golang/protobuf/proto" 9 math "math" 10 ) 11 12 import ( 13 context "context" 14 client "gitee.com/liuxuezhan/go-micro-v1.18.0/client" 15 server "gitee.com/liuxuezhan/go-micro-v1.18.0/server" 16 ) 17 18 // Reference imports to suppress errors if they are not otherwise used. 19 var _ = proto.Marshal 20 var _ = fmt.Errorf 21 var _ = math.Inf 22 23 // This is a compile-time assertion to ensure that this generated file 24 // is compatible with the proto package it is being compiled against. 25 // A compilation error at this line likely means your copy of the 26 // proto package needs to be updated. 27 const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package 28 29 // Reference imports to suppress errors if they are not otherwise used. 30 var _ context.Context 31 var _ client.Option 32 var _ server.Option 33 34 // Client API for Client service 35 36 type ClientService interface { 37 // Call allows a single request to be made 38 Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) 39 // Stream is a bidirectional stream 40 Stream(ctx context.Context, opts ...client.CallOption) (Client_StreamService, error) 41 // Publish publishes a message and returns an empty Message 42 Publish(ctx context.Context, in *Message, opts ...client.CallOption) (*Message, error) 43 } 44 45 type clientService struct { 46 c client.Client 47 name string 48 } 49 50 func NewClientService(name string, c client.Client) ClientService { 51 if c == nil { 52 c = client.NewClient() 53 } 54 if len(name) == 0 { 55 name = "go.micro.client" 56 } 57 return &clientService{ 58 c: c, 59 name: name, 60 } 61 } 62 63 func (c *clientService) Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) { 64 req := c.c.NewRequest(c.name, "Client.Call", in) 65 out := new(Response) 66 err := c.c.Call(ctx, req, out, opts...) 67 if err != nil { 68 return nil, err 69 } 70 return out, nil 71 } 72 73 func (c *clientService) Stream(ctx context.Context, opts ...client.CallOption) (Client_StreamService, error) { 74 req := c.c.NewRequest(c.name, "Client.Stream", &Request{}) 75 stream, err := c.c.Stream(ctx, req, opts...) 76 if err != nil { 77 return nil, err 78 } 79 return &clientServiceStream{stream}, nil 80 } 81 82 type Client_StreamService interface { 83 SendMsg(interface{}) error 84 RecvMsg(interface{}) error 85 Close() error 86 Send(*Request) error 87 Recv() (*Response, error) 88 } 89 90 type clientServiceStream struct { 91 stream client.Stream 92 } 93 94 func (x *clientServiceStream) Close() error { 95 return x.stream.Close() 96 } 97 98 func (x *clientServiceStream) SendMsg(m interface{}) error { 99 return x.stream.Send(m) 100 } 101 102 func (x *clientServiceStream) RecvMsg(m interface{}) error { 103 return x.stream.Recv(m) 104 } 105 106 func (x *clientServiceStream) Send(m *Request) error { 107 return x.stream.Send(m) 108 } 109 110 func (x *clientServiceStream) Recv() (*Response, error) { 111 m := new(Response) 112 err := x.stream.Recv(m) 113 if err != nil { 114 return nil, err 115 } 116 return m, nil 117 } 118 119 func (c *clientService) Publish(ctx context.Context, in *Message, opts ...client.CallOption) (*Message, error) { 120 req := c.c.NewRequest(c.name, "Client.Publish", in) 121 out := new(Message) 122 err := c.c.Call(ctx, req, out, opts...) 123 if err != nil { 124 return nil, err 125 } 126 return out, nil 127 } 128 129 // Server API for Client service 130 131 type ClientHandler interface { 132 // Call allows a single request to be made 133 Call(context.Context, *Request, *Response) error 134 // Stream is a bidirectional stream 135 Stream(context.Context, Client_StreamStream) error 136 // Publish publishes a message and returns an empty Message 137 Publish(context.Context, *Message, *Message) error 138 } 139 140 func RegisterClientHandler(s server.Server, hdlr ClientHandler, opts ...server.HandlerOption) error { 141 type client interface { 142 Call(ctx context.Context, in *Request, out *Response) error 143 Stream(ctx context.Context, stream server.Stream) error 144 Publish(ctx context.Context, in *Message, out *Message) error 145 } 146 type Client struct { 147 client 148 } 149 h := &clientHandler{hdlr} 150 return s.Handle(s.NewHandler(&Client{h}, opts...)) 151 } 152 153 type clientHandler struct { 154 ClientHandler 155 } 156 157 func (h *clientHandler) Call(ctx context.Context, in *Request, out *Response) error { 158 return h.ClientHandler.Call(ctx, in, out) 159 } 160 161 func (h *clientHandler) Stream(ctx context.Context, stream server.Stream) error { 162 return h.ClientHandler.Stream(ctx, &clientStreamStream{stream}) 163 } 164 165 type Client_StreamStream interface { 166 SendMsg(interface{}) error 167 RecvMsg(interface{}) error 168 Close() error 169 Send(*Response) error 170 Recv() (*Request, error) 171 } 172 173 type clientStreamStream struct { 174 stream server.Stream 175 } 176 177 func (x *clientStreamStream) Close() error { 178 return x.stream.Close() 179 } 180 181 func (x *clientStreamStream) SendMsg(m interface{}) error { 182 return x.stream.Send(m) 183 } 184 185 func (x *clientStreamStream) RecvMsg(m interface{}) error { 186 return x.stream.Recv(m) 187 } 188 189 func (x *clientStreamStream) Send(m *Response) error { 190 return x.stream.Send(m) 191 } 192 193 func (x *clientStreamStream) Recv() (*Request, error) { 194 m := new(Request) 195 if err := x.stream.Recv(m); err != nil { 196 return nil, err 197 } 198 return m, nil 199 } 200 201 func (h *clientHandler) Publish(ctx context.Context, in *Message, out *Message) error { 202 return h.ClientHandler.Publish(ctx, in, out) 203 }