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