github.com/annwntech/go-micro/v2@v2.9.5/broker/service/proto/broker.pb.micro.go (about) 1 // Code generated by protoc-gen-micro. DO NOT EDIT. 2 // source: broker/service/proto/broker.proto 3 4 package go_micro_broker 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 Broker service 37 38 func NewBrokerEndpoints() []*api.Endpoint { 39 return []*api.Endpoint{} 40 } 41 42 // Client API for Broker service 43 44 type BrokerService interface { 45 Publish(ctx context.Context, in *PublishRequest, opts ...client.CallOption) (*Empty, error) 46 Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Broker_SubscribeService, error) 47 } 48 49 type brokerService struct { 50 c client.Client 51 name string 52 } 53 54 func NewBrokerService(name string, c client.Client) BrokerService { 55 return &brokerService{ 56 c: c, 57 name: name, 58 } 59 } 60 61 func (c *brokerService) Publish(ctx context.Context, in *PublishRequest, opts ...client.CallOption) (*Empty, error) { 62 req := c.c.NewRequest(c.name, "Broker.Publish", in) 63 out := new(Empty) 64 err := c.c.Call(ctx, req, out, opts...) 65 if err != nil { 66 return nil, err 67 } 68 return out, nil 69 } 70 71 func (c *brokerService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Broker_SubscribeService, error) { 72 req := c.c.NewRequest(c.name, "Broker.Subscribe", &SubscribeRequest{}) 73 stream, err := c.c.Stream(ctx, req, opts...) 74 if err != nil { 75 return nil, err 76 } 77 if err := stream.Send(in); err != nil { 78 return nil, err 79 } 80 return &brokerServiceSubscribe{stream}, nil 81 } 82 83 type Broker_SubscribeService interface { 84 Context() context.Context 85 SendMsg(interface{}) error 86 RecvMsg(interface{}) error 87 Close() error 88 Recv() (*Message, error) 89 } 90 91 type brokerServiceSubscribe struct { 92 stream client.Stream 93 } 94 95 func (x *brokerServiceSubscribe) Close() error { 96 return x.stream.Close() 97 } 98 99 func (x *brokerServiceSubscribe) Context() context.Context { 100 return x.stream.Context() 101 } 102 103 func (x *brokerServiceSubscribe) SendMsg(m interface{}) error { 104 return x.stream.Send(m) 105 } 106 107 func (x *brokerServiceSubscribe) RecvMsg(m interface{}) error { 108 return x.stream.Recv(m) 109 } 110 111 func (x *brokerServiceSubscribe) Recv() (*Message, error) { 112 m := new(Message) 113 err := x.stream.Recv(m) 114 if err != nil { 115 return nil, err 116 } 117 return m, nil 118 } 119 120 // Server API for Broker service 121 122 type BrokerHandler interface { 123 Publish(context.Context, *PublishRequest, *Empty) error 124 Subscribe(context.Context, *SubscribeRequest, Broker_SubscribeStream) error 125 } 126 127 func RegisterBrokerHandler(s server.Server, hdlr BrokerHandler, opts ...server.HandlerOption) error { 128 type broker interface { 129 Publish(ctx context.Context, in *PublishRequest, out *Empty) error 130 Subscribe(ctx context.Context, stream server.Stream) error 131 } 132 type Broker struct { 133 broker 134 } 135 h := &brokerHandler{hdlr} 136 return s.Handle(s.NewHandler(&Broker{h}, opts...)) 137 } 138 139 type brokerHandler struct { 140 BrokerHandler 141 } 142 143 func (h *brokerHandler) Publish(ctx context.Context, in *PublishRequest, out *Empty) error { 144 return h.BrokerHandler.Publish(ctx, in, out) 145 } 146 147 func (h *brokerHandler) Subscribe(ctx context.Context, stream server.Stream) error { 148 m := new(SubscribeRequest) 149 if err := stream.Recv(m); err != nil { 150 return err 151 } 152 return h.BrokerHandler.Subscribe(ctx, m, &brokerSubscribeStream{stream}) 153 } 154 155 type Broker_SubscribeStream interface { 156 Context() context.Context 157 SendMsg(interface{}) error 158 RecvMsg(interface{}) error 159 Close() error 160 Send(*Message) error 161 } 162 163 type brokerSubscribeStream struct { 164 stream server.Stream 165 } 166 167 func (x *brokerSubscribeStream) Close() error { 168 return x.stream.Close() 169 } 170 171 func (x *brokerSubscribeStream) Context() context.Context { 172 return x.stream.Context() 173 } 174 175 func (x *brokerSubscribeStream) SendMsg(m interface{}) error { 176 return x.stream.Send(m) 177 } 178 179 func (x *brokerSubscribeStream) RecvMsg(m interface{}) error { 180 return x.stream.Recv(m) 181 } 182 183 func (x *brokerSubscribeStream) Send(m *Message) error { 184 return x.stream.Send(m) 185 }