2019-06-26 16:23:10 +01:00
|
|
|
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
2019-07-25 23:24:46 +01:00
|
|
|
// source: router.proto
|
2019-06-26 16:23:10 +01:00
|
|
|
|
2019-07-26 18:07:36 -07:00
|
|
|
package go_micro_router
|
2019-06-26 16:23:10 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
fmt "fmt"
|
|
|
|
proto "github.com/golang/protobuf/proto"
|
|
|
|
math "math"
|
|
|
|
)
|
|
|
|
|
|
|
|
import (
|
|
|
|
context "context"
|
|
|
|
client "github.com/micro/go-micro/client"
|
|
|
|
server "github.com/micro/go-micro/server"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
|
|
var _ = proto.Marshal
|
|
|
|
var _ = fmt.Errorf
|
|
|
|
var _ = math.Inf
|
|
|
|
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
|
|
// is compatible with the proto package it is being compiled against.
|
|
|
|
// A compilation error at this line likely means your copy of the
|
|
|
|
// proto package needs to be updated.
|
|
|
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
|
|
|
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
|
|
var _ context.Context
|
|
|
|
var _ client.Option
|
|
|
|
var _ server.Option
|
|
|
|
|
|
|
|
// Client API for Router service
|
|
|
|
|
|
|
|
type RouterService interface {
|
2019-07-10 17:21:55 +01:00
|
|
|
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
|
2019-07-25 23:24:46 +01:00
|
|
|
Lookup(ctx context.Context, in *LookupRequest, opts ...client.CallOption) (*LookupResponse, error)
|
|
|
|
Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Router_WatchService, error)
|
2019-07-24 21:07:04 +01:00
|
|
|
Advertise(ctx context.Context, in *AdvertiseRequest, opts ...client.CallOption) (Router_AdvertiseService, error)
|
|
|
|
Process(ctx context.Context, in *Advert, opts ...client.CallOption) (*ProcessResponse, error)
|
2019-07-25 23:24:46 +01:00
|
|
|
Create(ctx context.Context, in *Route, opts ...client.CallOption) (*CreateResponse, error)
|
|
|
|
Delete(ctx context.Context, in *Route, opts ...client.CallOption) (*DeleteResponse, error)
|
|
|
|
Update(ctx context.Context, in *Route, opts ...client.CallOption) (*UpdateResponse, error)
|
2019-06-26 16:23:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type routerService struct {
|
|
|
|
c client.Client
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewRouterService(name string, c client.Client) RouterService {
|
|
|
|
if c == nil {
|
|
|
|
c = client.NewClient()
|
|
|
|
}
|
|
|
|
if len(name) == 0 {
|
2019-07-26 18:07:36 -07:00
|
|
|
name = "go.micro.router"
|
2019-06-26 16:23:10 +01:00
|
|
|
}
|
|
|
|
return &routerService{
|
|
|
|
c: c,
|
|
|
|
name: name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-25 23:24:46 +01:00
|
|
|
func (c *routerService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Router.List", in)
|
|
|
|
out := new(ListResponse)
|
|
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *routerService) Lookup(ctx context.Context, in *LookupRequest, opts ...client.CallOption) (*LookupResponse, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Router.Lookup", in)
|
|
|
|
out := new(LookupResponse)
|
|
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
2019-07-10 17:21:55 +01:00
|
|
|
func (c *routerService) Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Router_WatchService, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Router.Watch", &WatchRequest{})
|
|
|
|
stream, err := c.c.Stream(ctx, req, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := stream.Send(in); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &routerServiceWatch{stream}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type Router_WatchService interface {
|
|
|
|
SendMsg(interface{}) error
|
|
|
|
RecvMsg(interface{}) error
|
|
|
|
Close() error
|
2019-07-11 21:14:34 +01:00
|
|
|
Recv() (*Event, error)
|
2019-07-10 17:21:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type routerServiceWatch struct {
|
|
|
|
stream client.Stream
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerServiceWatch) Close() error {
|
|
|
|
return x.stream.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerServiceWatch) SendMsg(m interface{}) error {
|
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerServiceWatch) RecvMsg(m interface{}) error {
|
|
|
|
return x.stream.Recv(m)
|
|
|
|
}
|
|
|
|
|
2019-07-11 21:14:34 +01:00
|
|
|
func (x *routerServiceWatch) Recv() (*Event, error) {
|
|
|
|
m := new(Event)
|
2019-07-10 17:21:55 +01:00
|
|
|
err := x.stream.Recv(m)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return m, nil
|
|
|
|
}
|
|
|
|
|
2019-07-24 21:07:04 +01:00
|
|
|
func (c *routerService) Advertise(ctx context.Context, in *AdvertiseRequest, opts ...client.CallOption) (Router_AdvertiseService, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Router.Advertise", &AdvertiseRequest{})
|
|
|
|
stream, err := c.c.Stream(ctx, req, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := stream.Send(in); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &routerServiceAdvertise{stream}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type Router_AdvertiseService interface {
|
|
|
|
SendMsg(interface{}) error
|
|
|
|
RecvMsg(interface{}) error
|
|
|
|
Close() error
|
|
|
|
Recv() (*Advert, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type routerServiceAdvertise struct {
|
|
|
|
stream client.Stream
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerServiceAdvertise) Close() error {
|
|
|
|
return x.stream.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerServiceAdvertise) SendMsg(m interface{}) error {
|
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerServiceAdvertise) RecvMsg(m interface{}) error {
|
|
|
|
return x.stream.Recv(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerServiceAdvertise) Recv() (*Advert, error) {
|
|
|
|
m := new(Advert)
|
|
|
|
err := x.stream.Recv(m)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return m, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *routerService) Process(ctx context.Context, in *Advert, opts ...client.CallOption) (*ProcessResponse, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Router.Process", in)
|
|
|
|
out := new(ProcessResponse)
|
|
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
2019-07-25 23:24:46 +01:00
|
|
|
func (c *routerService) Create(ctx context.Context, in *Route, opts ...client.CallOption) (*CreateResponse, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Router.Create", in)
|
|
|
|
out := new(CreateResponse)
|
|
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *routerService) Delete(ctx context.Context, in *Route, opts ...client.CallOption) (*DeleteResponse, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Router.Delete", in)
|
|
|
|
out := new(DeleteResponse)
|
|
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *routerService) Update(ctx context.Context, in *Route, opts ...client.CallOption) (*UpdateResponse, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Router.Update", in)
|
|
|
|
out := new(UpdateResponse)
|
|
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
2019-06-26 16:23:10 +01:00
|
|
|
// Server API for Router service
|
|
|
|
|
|
|
|
type RouterHandler interface {
|
2019-07-10 17:21:55 +01:00
|
|
|
List(context.Context, *ListRequest, *ListResponse) error
|
2019-07-25 23:24:46 +01:00
|
|
|
Lookup(context.Context, *LookupRequest, *LookupResponse) error
|
|
|
|
Watch(context.Context, *WatchRequest, Router_WatchStream) error
|
2019-07-24 21:07:04 +01:00
|
|
|
Advertise(context.Context, *AdvertiseRequest, Router_AdvertiseStream) error
|
|
|
|
Process(context.Context, *Advert, *ProcessResponse) error
|
2019-07-25 23:24:46 +01:00
|
|
|
Create(context.Context, *Route, *CreateResponse) error
|
|
|
|
Delete(context.Context, *Route, *DeleteResponse) error
|
|
|
|
Update(context.Context, *Route, *UpdateResponse) error
|
2019-06-26 16:23:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func RegisterRouterHandler(s server.Server, hdlr RouterHandler, opts ...server.HandlerOption) error {
|
|
|
|
type router interface {
|
2019-07-10 17:21:55 +01:00
|
|
|
List(ctx context.Context, in *ListRequest, out *ListResponse) error
|
2019-07-25 23:24:46 +01:00
|
|
|
Lookup(ctx context.Context, in *LookupRequest, out *LookupResponse) error
|
|
|
|
Watch(ctx context.Context, stream server.Stream) error
|
2019-07-24 21:07:04 +01:00
|
|
|
Advertise(ctx context.Context, stream server.Stream) error
|
|
|
|
Process(ctx context.Context, in *Advert, out *ProcessResponse) error
|
2019-07-25 23:24:46 +01:00
|
|
|
Create(ctx context.Context, in *Route, out *CreateResponse) error
|
|
|
|
Delete(ctx context.Context, in *Route, out *DeleteResponse) error
|
|
|
|
Update(ctx context.Context, in *Route, out *UpdateResponse) error
|
2019-06-26 16:23:10 +01:00
|
|
|
}
|
|
|
|
type Router struct {
|
|
|
|
router
|
|
|
|
}
|
|
|
|
h := &routerHandler{hdlr}
|
|
|
|
return s.Handle(s.NewHandler(&Router{h}, opts...))
|
|
|
|
}
|
|
|
|
|
|
|
|
type routerHandler struct {
|
|
|
|
RouterHandler
|
|
|
|
}
|
|
|
|
|
2019-07-25 23:24:46 +01:00
|
|
|
func (h *routerHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
|
|
|
|
return h.RouterHandler.List(ctx, in, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *routerHandler) Lookup(ctx context.Context, in *LookupRequest, out *LookupResponse) error {
|
|
|
|
return h.RouterHandler.Lookup(ctx, in, out)
|
|
|
|
}
|
|
|
|
|
2019-07-10 17:21:55 +01:00
|
|
|
func (h *routerHandler) Watch(ctx context.Context, stream server.Stream) error {
|
|
|
|
m := new(WatchRequest)
|
|
|
|
if err := stream.Recv(m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return h.RouterHandler.Watch(ctx, m, &routerWatchStream{stream})
|
|
|
|
}
|
|
|
|
|
|
|
|
type Router_WatchStream interface {
|
|
|
|
SendMsg(interface{}) error
|
|
|
|
RecvMsg(interface{}) error
|
|
|
|
Close() error
|
2019-07-11 21:14:34 +01:00
|
|
|
Send(*Event) error
|
2019-07-10 17:21:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type routerWatchStream struct {
|
|
|
|
stream server.Stream
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerWatchStream) Close() error {
|
|
|
|
return x.stream.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerWatchStream) SendMsg(m interface{}) error {
|
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerWatchStream) RecvMsg(m interface{}) error {
|
|
|
|
return x.stream.Recv(m)
|
|
|
|
}
|
|
|
|
|
2019-07-11 21:14:34 +01:00
|
|
|
func (x *routerWatchStream) Send(m *Event) error {
|
2019-07-10 17:21:55 +01:00
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
2019-07-24 21:07:04 +01:00
|
|
|
func (h *routerHandler) Advertise(ctx context.Context, stream server.Stream) error {
|
|
|
|
m := new(AdvertiseRequest)
|
|
|
|
if err := stream.Recv(m); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return h.RouterHandler.Advertise(ctx, m, &routerAdvertiseStream{stream})
|
|
|
|
}
|
|
|
|
|
|
|
|
type Router_AdvertiseStream interface {
|
|
|
|
SendMsg(interface{}) error
|
|
|
|
RecvMsg(interface{}) error
|
|
|
|
Close() error
|
|
|
|
Send(*Advert) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type routerAdvertiseStream struct {
|
|
|
|
stream server.Stream
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerAdvertiseStream) Close() error {
|
|
|
|
return x.stream.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerAdvertiseStream) SendMsg(m interface{}) error {
|
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerAdvertiseStream) RecvMsg(m interface{}) error {
|
|
|
|
return x.stream.Recv(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *routerAdvertiseStream) Send(m *Advert) error {
|
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *routerHandler) Process(ctx context.Context, in *Advert, out *ProcessResponse) error {
|
|
|
|
return h.RouterHandler.Process(ctx, in, out)
|
|
|
|
}
|
2019-07-25 23:24:46 +01:00
|
|
|
|
|
|
|
func (h *routerHandler) Create(ctx context.Context, in *Route, out *CreateResponse) error {
|
|
|
|
return h.RouterHandler.Create(ctx, in, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *routerHandler) Delete(ctx context.Context, in *Route, out *DeleteResponse) error {
|
|
|
|
return h.RouterHandler.Delete(ctx, in, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *routerHandler) Update(ctx context.Context, in *Route, out *UpdateResponse) error {
|
|
|
|
return h.RouterHandler.Update(ctx, in, out)
|
|
|
|
}
|