2021-10-27 18:27:04 +03:00
|
|
|
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
2023-03-25 22:16:14 +03:00
|
|
|
// protoc-gen-go-micro version: v3.10.2
|
2021-03-22 08:42:38 +03:00
|
|
|
// source: broker.proto
|
2021-10-27 18:27:04 +03:00
|
|
|
|
|
|
|
package servicepb
|
2021-03-22 08:42:38 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
context "context"
|
2021-10-27 18:27:04 +03:00
|
|
|
proto "go.unistack.org/micro-broker-service/v3/proto"
|
|
|
|
client "go.unistack.org/micro/v3/client"
|
|
|
|
server "go.unistack.org/micro/v3/server"
|
2021-03-22 08:42:38 +03:00
|
|
|
)
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
type brokerServiceClient struct {
|
2021-03-22 08:42:38 +03:00
|
|
|
c client.Client
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func NewBrokerServiceClient(name string, c client.Client) BrokerServiceClient {
|
|
|
|
return &brokerServiceClient{c: c, name: name}
|
2021-03-22 08:42:38 +03:00
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (c *brokerServiceClient) Publish(ctx context.Context, req *proto.PublishRequest, opts ...client.CallOption) (*proto.PublishResponse, error) {
|
|
|
|
rsp := &proto.PublishResponse{}
|
|
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "BrokerService.Publish", req), rsp, opts...)
|
2021-03-22 08:42:38 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rsp, nil
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (c *brokerServiceClient) BatchPublish(ctx context.Context, req *proto.BatchPublishRequest, opts ...client.CallOption) (*proto.BatchPublishResponse, error) {
|
|
|
|
rsp := &proto.BatchPublishResponse{}
|
|
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "BrokerService.BatchPublish", req), rsp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rsp, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *brokerServiceClient) Subscribe(ctx context.Context, req *proto.SubscribeRequest, opts ...client.CallOption) (BrokerService_SubscribeClient, error) {
|
|
|
|
stream, err := c.c.Stream(ctx, c.c.NewRequest(c.name, "BrokerService.Subscribe", &proto.SubscribeRequest{}), opts...)
|
2021-03-22 08:42:38 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := stream.Send(req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-10-27 18:47:36 +03:00
|
|
|
return &brokerServiceClientSubscribe{stream}, nil
|
2021-03-22 08:42:38 +03:00
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
type brokerServiceClientSubscribe struct {
|
2021-03-22 08:42:38 +03:00
|
|
|
stream client.Stream
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceClientSubscribe) Close() error {
|
2021-03-22 08:42:38 +03:00
|
|
|
return s.stream.Close()
|
|
|
|
}
|
|
|
|
|
2023-03-25 22:16:14 +03:00
|
|
|
func (s *brokerServiceClientSubscribe) CloseSend() error {
|
|
|
|
return s.stream.CloseSend()
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceClientSubscribe) Context() context.Context {
|
2021-03-22 08:42:38 +03:00
|
|
|
return s.stream.Context()
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceClientSubscribe) SendMsg(msg interface{}) error {
|
2021-03-22 08:42:38 +03:00
|
|
|
return s.stream.Send(msg)
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceClientSubscribe) RecvMsg(msg interface{}) error {
|
2021-03-22 08:42:38 +03:00
|
|
|
return s.stream.Recv(msg)
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceClientSubscribe) Recv() (*proto.Message, error) {
|
2021-03-22 08:42:38 +03:00
|
|
|
msg := &proto.Message{}
|
|
|
|
if err := s.stream.Recv(msg); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return msg, nil
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (c *brokerServiceClient) BatchSubscribe(ctx context.Context, req *proto.BatchSubscribeRequest, opts ...client.CallOption) (BrokerService_BatchSubscribeClient, error) {
|
|
|
|
stream, err := c.c.Stream(ctx, c.c.NewRequest(c.name, "BrokerService.BatchSubscribe", &proto.BatchSubscribeRequest{}), opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := stream.Send(req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &brokerServiceClientBatchSubscribe{stream}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type brokerServiceClientBatchSubscribe struct {
|
|
|
|
stream client.Stream
|
2021-03-22 08:42:38 +03:00
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceClientBatchSubscribe) Close() error {
|
|
|
|
return s.stream.Close()
|
2021-03-22 08:42:38 +03:00
|
|
|
}
|
|
|
|
|
2023-03-25 22:16:14 +03:00
|
|
|
func (s *brokerServiceClientBatchSubscribe) CloseSend() error {
|
|
|
|
return s.stream.CloseSend()
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceClientBatchSubscribe) Context() context.Context {
|
|
|
|
return s.stream.Context()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *brokerServiceClientBatchSubscribe) SendMsg(msg interface{}) error {
|
|
|
|
return s.stream.Send(msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *brokerServiceClientBatchSubscribe) RecvMsg(msg interface{}) error {
|
|
|
|
return s.stream.Recv(msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *brokerServiceClientBatchSubscribe) Recv() (*proto.Message, error) {
|
|
|
|
msg := &proto.Message{}
|
|
|
|
if err := s.stream.Recv(msg); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return msg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type brokerServiceServer struct {
|
|
|
|
BrokerServiceServer
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *brokerServiceServer) Publish(ctx context.Context, req *proto.PublishRequest, rsp *proto.PublishResponse) error {
|
|
|
|
return h.BrokerServiceServer.Publish(ctx, req, rsp)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *brokerServiceServer) BatchPublish(ctx context.Context, req *proto.BatchPublishRequest, rsp *proto.BatchPublishResponse) error {
|
|
|
|
return h.BrokerServiceServer.BatchPublish(ctx, req, rsp)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *brokerServiceServer) Subscribe(ctx context.Context, stream server.Stream) error {
|
2021-03-22 08:42:38 +03:00
|
|
|
msg := &proto.SubscribeRequest{}
|
|
|
|
if err := stream.Recv(msg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-10-27 18:47:36 +03:00
|
|
|
return h.BrokerServiceServer.Subscribe(ctx, msg, &brokerServiceSubscribeStream{stream})
|
|
|
|
}
|
|
|
|
|
|
|
|
type brokerServiceSubscribeStream struct {
|
|
|
|
stream server.Stream
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *brokerServiceSubscribeStream) Close() error {
|
|
|
|
return s.stream.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *brokerServiceSubscribeStream) Context() context.Context {
|
|
|
|
return s.stream.Context()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *brokerServiceSubscribeStream) SendMsg(msg interface{}) error {
|
|
|
|
return s.stream.Send(msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *brokerServiceSubscribeStream) RecvMsg(msg interface{}) error {
|
|
|
|
return s.stream.Recv(msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *brokerServiceSubscribeStream) Send(msg *proto.Message) error {
|
|
|
|
return s.stream.Send(msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *brokerServiceServer) BatchSubscribe(ctx context.Context, stream server.Stream) error {
|
|
|
|
msg := &proto.BatchSubscribeRequest{}
|
|
|
|
if err := stream.Recv(msg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return h.BrokerServiceServer.BatchSubscribe(ctx, msg, &brokerServiceBatchSubscribeStream{stream})
|
2021-03-22 08:42:38 +03:00
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
type brokerServiceBatchSubscribeStream struct {
|
2021-03-22 08:42:38 +03:00
|
|
|
stream server.Stream
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceBatchSubscribeStream) Close() error {
|
2021-03-22 08:42:38 +03:00
|
|
|
return s.stream.Close()
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceBatchSubscribeStream) Context() context.Context {
|
2021-03-22 08:42:38 +03:00
|
|
|
return s.stream.Context()
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceBatchSubscribeStream) SendMsg(msg interface{}) error {
|
2021-03-22 08:42:38 +03:00
|
|
|
return s.stream.Send(msg)
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceBatchSubscribeStream) RecvMsg(msg interface{}) error {
|
2021-03-22 08:42:38 +03:00
|
|
|
return s.stream.Recv(msg)
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func (s *brokerServiceBatchSubscribeStream) Send(msg *proto.Message) error {
|
2021-03-22 08:42:38 +03:00
|
|
|
return s.stream.Send(msg)
|
|
|
|
}
|
|
|
|
|
2021-10-27 18:47:36 +03:00
|
|
|
func RegisterBrokerServiceServer(s server.Server, sh BrokerServiceServer, opts ...server.HandlerOption) error {
|
|
|
|
type brokerService interface {
|
|
|
|
Publish(ctx context.Context, req *proto.PublishRequest, rsp *proto.PublishResponse) error
|
|
|
|
BatchPublish(ctx context.Context, req *proto.BatchPublishRequest, rsp *proto.BatchPublishResponse) error
|
2021-03-22 08:42:38 +03:00
|
|
|
Subscribe(ctx context.Context, stream server.Stream) error
|
2021-10-27 18:47:36 +03:00
|
|
|
BatchSubscribe(ctx context.Context, stream server.Stream) error
|
2021-03-22 08:42:38 +03:00
|
|
|
}
|
2021-10-27 18:47:36 +03:00
|
|
|
type BrokerService struct {
|
|
|
|
brokerService
|
2021-03-22 08:42:38 +03:00
|
|
|
}
|
2021-10-27 18:47:36 +03:00
|
|
|
h := &brokerServiceServer{sh}
|
2021-10-27 18:27:04 +03:00
|
|
|
var nopts []server.HandlerOption
|
2021-10-27 18:47:36 +03:00
|
|
|
return s.Handle(s.NewHandler(&BrokerService{h}, append(nopts, opts...)...))
|
2021-03-22 08:42:38 +03:00
|
|
|
}
|