github.com/annwntech/go-micro/v2@v2.9.5/router/service/proto/router.pb.micro.go (about) 1 // Code generated by protoc-gen-micro. DO NOT EDIT. 2 // source: router/service/proto/router.proto 3 4 package router 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/annwntech/go-micro/v2/api" 15 client "github.com/annwntech/go-micro/v2/client" 16 server "github.com/annwntech/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 Router service 37 38 func NewRouterEndpoints() []*api.Endpoint { 39 return []*api.Endpoint{} 40 } 41 42 // Client API for Router service 43 44 type RouterService interface { 45 Lookup(ctx context.Context, in *LookupRequest, opts ...client.CallOption) (*LookupResponse, error) 46 Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Router_WatchService, error) 47 Advertise(ctx context.Context, in *Request, opts ...client.CallOption) (Router_AdvertiseService, error) 48 Process(ctx context.Context, in *Advert, opts ...client.CallOption) (*ProcessResponse, error) 49 } 50 51 type routerService struct { 52 c client.Client 53 name string 54 } 55 56 func NewRouterService(name string, c client.Client) RouterService { 57 return &routerService{ 58 c: c, 59 name: name, 60 } 61 } 62 63 func (c *routerService) Lookup(ctx context.Context, in *LookupRequest, opts ...client.CallOption) (*LookupResponse, error) { 64 req := c.c.NewRequest(c.name, "Router.Lookup", in) 65 out := new(LookupResponse) 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 *routerService) Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Router_WatchService, error) { 74 req := c.c.NewRequest(c.name, "Router.Watch", &WatchRequest{}) 75 stream, err := c.c.Stream(ctx, req, opts...) 76 if err != nil { 77 return nil, err 78 } 79 if err := stream.Send(in); err != nil { 80 return nil, err 81 } 82 return &routerServiceWatch{stream}, nil 83 } 84 85 type Router_WatchService interface { 86 Context() context.Context 87 SendMsg(interface{}) error 88 RecvMsg(interface{}) error 89 Close() error 90 Recv() (*Event, error) 91 } 92 93 type routerServiceWatch struct { 94 stream client.Stream 95 } 96 97 func (x *routerServiceWatch) Close() error { 98 return x.stream.Close() 99 } 100 101 func (x *routerServiceWatch) Context() context.Context { 102 return x.stream.Context() 103 } 104 105 func (x *routerServiceWatch) SendMsg(m interface{}) error { 106 return x.stream.Send(m) 107 } 108 109 func (x *routerServiceWatch) RecvMsg(m interface{}) error { 110 return x.stream.Recv(m) 111 } 112 113 func (x *routerServiceWatch) Recv() (*Event, error) { 114 m := new(Event) 115 err := x.stream.Recv(m) 116 if err != nil { 117 return nil, err 118 } 119 return m, nil 120 } 121 122 func (c *routerService) Advertise(ctx context.Context, in *Request, opts ...client.CallOption) (Router_AdvertiseService, error) { 123 req := c.c.NewRequest(c.name, "Router.Advertise", &Request{}) 124 stream, err := c.c.Stream(ctx, req, opts...) 125 if err != nil { 126 return nil, err 127 } 128 if err := stream.Send(in); err != nil { 129 return nil, err 130 } 131 return &routerServiceAdvertise{stream}, nil 132 } 133 134 type Router_AdvertiseService interface { 135 Context() context.Context 136 SendMsg(interface{}) error 137 RecvMsg(interface{}) error 138 Close() error 139 Recv() (*Advert, error) 140 } 141 142 type routerServiceAdvertise struct { 143 stream client.Stream 144 } 145 146 func (x *routerServiceAdvertise) Close() error { 147 return x.stream.Close() 148 } 149 150 func (x *routerServiceAdvertise) Context() context.Context { 151 return x.stream.Context() 152 } 153 154 func (x *routerServiceAdvertise) SendMsg(m interface{}) error { 155 return x.stream.Send(m) 156 } 157 158 func (x *routerServiceAdvertise) RecvMsg(m interface{}) error { 159 return x.stream.Recv(m) 160 } 161 162 func (x *routerServiceAdvertise) Recv() (*Advert, error) { 163 m := new(Advert) 164 err := x.stream.Recv(m) 165 if err != nil { 166 return nil, err 167 } 168 return m, nil 169 } 170 171 func (c *routerService) Process(ctx context.Context, in *Advert, opts ...client.CallOption) (*ProcessResponse, error) { 172 req := c.c.NewRequest(c.name, "Router.Process", in) 173 out := new(ProcessResponse) 174 err := c.c.Call(ctx, req, out, opts...) 175 if err != nil { 176 return nil, err 177 } 178 return out, nil 179 } 180 181 // Server API for Router service 182 183 type RouterHandler interface { 184 Lookup(context.Context, *LookupRequest, *LookupResponse) error 185 Watch(context.Context, *WatchRequest, Router_WatchStream) error 186 Advertise(context.Context, *Request, Router_AdvertiseStream) error 187 Process(context.Context, *Advert, *ProcessResponse) error 188 } 189 190 func RegisterRouterHandler(s server.Server, hdlr RouterHandler, opts ...server.HandlerOption) error { 191 type router interface { 192 Lookup(ctx context.Context, in *LookupRequest, out *LookupResponse) error 193 Watch(ctx context.Context, stream server.Stream) error 194 Advertise(ctx context.Context, stream server.Stream) error 195 Process(ctx context.Context, in *Advert, out *ProcessResponse) error 196 } 197 type Router struct { 198 router 199 } 200 h := &routerHandler{hdlr} 201 return s.Handle(s.NewHandler(&Router{h}, opts...)) 202 } 203 204 type routerHandler struct { 205 RouterHandler 206 } 207 208 func (h *routerHandler) Lookup(ctx context.Context, in *LookupRequest, out *LookupResponse) error { 209 return h.RouterHandler.Lookup(ctx, in, out) 210 } 211 212 func (h *routerHandler) Watch(ctx context.Context, stream server.Stream) error { 213 m := new(WatchRequest) 214 if err := stream.Recv(m); err != nil { 215 return err 216 } 217 return h.RouterHandler.Watch(ctx, m, &routerWatchStream{stream}) 218 } 219 220 type Router_WatchStream interface { 221 Context() context.Context 222 SendMsg(interface{}) error 223 RecvMsg(interface{}) error 224 Close() error 225 Send(*Event) error 226 } 227 228 type routerWatchStream struct { 229 stream server.Stream 230 } 231 232 func (x *routerWatchStream) Close() error { 233 return x.stream.Close() 234 } 235 236 func (x *routerWatchStream) Context() context.Context { 237 return x.stream.Context() 238 } 239 240 func (x *routerWatchStream) SendMsg(m interface{}) error { 241 return x.stream.Send(m) 242 } 243 244 func (x *routerWatchStream) RecvMsg(m interface{}) error { 245 return x.stream.Recv(m) 246 } 247 248 func (x *routerWatchStream) Send(m *Event) error { 249 return x.stream.Send(m) 250 } 251 252 func (h *routerHandler) Advertise(ctx context.Context, stream server.Stream) error { 253 m := new(Request) 254 if err := stream.Recv(m); err != nil { 255 return err 256 } 257 return h.RouterHandler.Advertise(ctx, m, &routerAdvertiseStream{stream}) 258 } 259 260 type Router_AdvertiseStream interface { 261 Context() context.Context 262 SendMsg(interface{}) error 263 RecvMsg(interface{}) error 264 Close() error 265 Send(*Advert) error 266 } 267 268 type routerAdvertiseStream struct { 269 stream server.Stream 270 } 271 272 func (x *routerAdvertiseStream) Close() error { 273 return x.stream.Close() 274 } 275 276 func (x *routerAdvertiseStream) Context() context.Context { 277 return x.stream.Context() 278 } 279 280 func (x *routerAdvertiseStream) SendMsg(m interface{}) error { 281 return x.stream.Send(m) 282 } 283 284 func (x *routerAdvertiseStream) RecvMsg(m interface{}) error { 285 return x.stream.Recv(m) 286 } 287 288 func (x *routerAdvertiseStream) Send(m *Advert) error { 289 return x.stream.Send(m) 290 } 291 292 func (h *routerHandler) Process(ctx context.Context, in *Advert, out *ProcessResponse) error { 293 return h.RouterHandler.Process(ctx, in, out) 294 } 295 296 // Api Endpoints for Table service 297 298 func NewTableEndpoints() []*api.Endpoint { 299 return []*api.Endpoint{} 300 } 301 302 // Client API for Table service 303 304 type TableService interface { 305 Create(ctx context.Context, in *Route, opts ...client.CallOption) (*CreateResponse, error) 306 Delete(ctx context.Context, in *Route, opts ...client.CallOption) (*DeleteResponse, error) 307 Update(ctx context.Context, in *Route, opts ...client.CallOption) (*UpdateResponse, error) 308 List(ctx context.Context, in *Request, opts ...client.CallOption) (*ListResponse, error) 309 Query(ctx context.Context, in *QueryRequest, opts ...client.CallOption) (*QueryResponse, error) 310 } 311 312 type tableService struct { 313 c client.Client 314 name string 315 } 316 317 func NewTableService(name string, c client.Client) TableService { 318 return &tableService{ 319 c: c, 320 name: name, 321 } 322 } 323 324 func (c *tableService) Create(ctx context.Context, in *Route, opts ...client.CallOption) (*CreateResponse, error) { 325 req := c.c.NewRequest(c.name, "Table.Create", in) 326 out := new(CreateResponse) 327 err := c.c.Call(ctx, req, out, opts...) 328 if err != nil { 329 return nil, err 330 } 331 return out, nil 332 } 333 334 func (c *tableService) Delete(ctx context.Context, in *Route, opts ...client.CallOption) (*DeleteResponse, error) { 335 req := c.c.NewRequest(c.name, "Table.Delete", in) 336 out := new(DeleteResponse) 337 err := c.c.Call(ctx, req, out, opts...) 338 if err != nil { 339 return nil, err 340 } 341 return out, nil 342 } 343 344 func (c *tableService) Update(ctx context.Context, in *Route, opts ...client.CallOption) (*UpdateResponse, error) { 345 req := c.c.NewRequest(c.name, "Table.Update", in) 346 out := new(UpdateResponse) 347 err := c.c.Call(ctx, req, out, opts...) 348 if err != nil { 349 return nil, err 350 } 351 return out, nil 352 } 353 354 func (c *tableService) List(ctx context.Context, in *Request, opts ...client.CallOption) (*ListResponse, error) { 355 req := c.c.NewRequest(c.name, "Table.List", in) 356 out := new(ListResponse) 357 err := c.c.Call(ctx, req, out, opts...) 358 if err != nil { 359 return nil, err 360 } 361 return out, nil 362 } 363 364 func (c *tableService) Query(ctx context.Context, in *QueryRequest, opts ...client.CallOption) (*QueryResponse, error) { 365 req := c.c.NewRequest(c.name, "Table.Query", in) 366 out := new(QueryResponse) 367 err := c.c.Call(ctx, req, out, opts...) 368 if err != nil { 369 return nil, err 370 } 371 return out, nil 372 } 373 374 // Server API for Table service 375 376 type TableHandler interface { 377 Create(context.Context, *Route, *CreateResponse) error 378 Delete(context.Context, *Route, *DeleteResponse) error 379 Update(context.Context, *Route, *UpdateResponse) error 380 List(context.Context, *Request, *ListResponse) error 381 Query(context.Context, *QueryRequest, *QueryResponse) error 382 } 383 384 func RegisterTableHandler(s server.Server, hdlr TableHandler, opts ...server.HandlerOption) error { 385 type table interface { 386 Create(ctx context.Context, in *Route, out *CreateResponse) error 387 Delete(ctx context.Context, in *Route, out *DeleteResponse) error 388 Update(ctx context.Context, in *Route, out *UpdateResponse) error 389 List(ctx context.Context, in *Request, out *ListResponse) error 390 Query(ctx context.Context, in *QueryRequest, out *QueryResponse) error 391 } 392 type Table struct { 393 table 394 } 395 h := &tableHandler{hdlr} 396 return s.Handle(s.NewHandler(&Table{h}, opts...)) 397 } 398 399 type tableHandler struct { 400 TableHandler 401 } 402 403 func (h *tableHandler) Create(ctx context.Context, in *Route, out *CreateResponse) error { 404 return h.TableHandler.Create(ctx, in, out) 405 } 406 407 func (h *tableHandler) Delete(ctx context.Context, in *Route, out *DeleteResponse) error { 408 return h.TableHandler.Delete(ctx, in, out) 409 } 410 411 func (h *tableHandler) Update(ctx context.Context, in *Route, out *UpdateResponse) error { 412 return h.TableHandler.Update(ctx, in, out) 413 } 414 415 func (h *tableHandler) List(ctx context.Context, in *Request, out *ListResponse) error { 416 return h.TableHandler.List(ctx, in, out) 417 } 418 419 func (h *tableHandler) Query(ctx context.Context, in *QueryRequest, out *QueryResponse) error { 420 return h.TableHandler.Query(ctx, in, out) 421 }