166 lines
4.9 KiB
Go
166 lines
4.9 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
|
|
package servicepb
|
|
|
|
import (
|
|
context "context"
|
|
grpc "google.golang.org/grpc"
|
|
codes "google.golang.org/grpc/codes"
|
|
status "google.golang.org/grpc/status"
|
|
)
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the grpc package it is being compiled against.
|
|
// Requires gRPC-Go v1.32.0 or later.
|
|
const _ = grpc.SupportPackageIsVersion7
|
|
|
|
// BrokerClient is the client API for Broker service.
|
|
//
|
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
type BrokerClient interface {
|
|
Publish(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*Empty, error)
|
|
Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (Broker_SubscribeClient, error)
|
|
}
|
|
|
|
type brokerClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewBrokerClient(cc grpc.ClientConnInterface) BrokerClient {
|
|
return &brokerClient{cc}
|
|
}
|
|
|
|
func (c *brokerClient) Publish(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*Empty, error) {
|
|
out := new(Empty)
|
|
err := c.cc.Invoke(ctx, "/servicepb.Broker/Publish", in, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *brokerClient) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (Broker_SubscribeClient, error) {
|
|
stream, err := c.cc.NewStream(ctx, &Broker_ServiceDesc.Streams[0], "/servicepb.Broker/Subscribe", opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
x := &brokerSubscribeClient{stream}
|
|
if err := x.ClientStream.SendMsg(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := x.ClientStream.CloseSend(); err != nil {
|
|
return nil, err
|
|
}
|
|
return x, nil
|
|
}
|
|
|
|
type Broker_SubscribeClient interface {
|
|
Recv() (*Message, error)
|
|
grpc.ClientStream
|
|
}
|
|
|
|
type brokerSubscribeClient struct {
|
|
grpc.ClientStream
|
|
}
|
|
|
|
func (x *brokerSubscribeClient) Recv() (*Message, error) {
|
|
m := new(Message)
|
|
if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// BrokerServer is the server API for Broker service.
|
|
// All implementations must embed UnimplementedBrokerServer
|
|
// for forward compatibility
|
|
type BrokerServer interface {
|
|
Publish(context.Context, *PublishRequest) (*Empty, error)
|
|
Subscribe(*SubscribeRequest, Broker_SubscribeServer) error
|
|
mustEmbedUnimplementedBrokerServer()
|
|
}
|
|
|
|
// UnimplementedBrokerServer must be embedded to have forward compatible implementations.
|
|
type UnimplementedBrokerServer struct {
|
|
}
|
|
|
|
func (UnimplementedBrokerServer) Publish(context.Context, *PublishRequest) (*Empty, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method Publish not implemented")
|
|
}
|
|
func (UnimplementedBrokerServer) Subscribe(*SubscribeRequest, Broker_SubscribeServer) error {
|
|
return status.Errorf(codes.Unimplemented, "method Subscribe not implemented")
|
|
}
|
|
func (UnimplementedBrokerServer) mustEmbedUnimplementedBrokerServer() {}
|
|
|
|
// UnsafeBrokerServer may be embedded to opt out of forward compatibility for this service.
|
|
// Use of this interface is not recommended, as added methods to BrokerServer will
|
|
// result in compilation errors.
|
|
type UnsafeBrokerServer interface {
|
|
mustEmbedUnimplementedBrokerServer()
|
|
}
|
|
|
|
func RegisterBrokerServer(s grpc.ServiceRegistrar, srv BrokerServer) {
|
|
s.RegisterService(&Broker_ServiceDesc, srv)
|
|
}
|
|
|
|
func _Broker_Publish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(PublishRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(BrokerServer).Publish(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: "/servicepb.Broker/Publish",
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(BrokerServer).Publish(ctx, req.(*PublishRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Broker_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
m := new(SubscribeRequest)
|
|
if err := stream.RecvMsg(m); err != nil {
|
|
return err
|
|
}
|
|
return srv.(BrokerServer).Subscribe(m, &brokerSubscribeServer{stream})
|
|
}
|
|
|
|
type Broker_SubscribeServer interface {
|
|
Send(*Message) error
|
|
grpc.ServerStream
|
|
}
|
|
|
|
type brokerSubscribeServer struct {
|
|
grpc.ServerStream
|
|
}
|
|
|
|
func (x *brokerSubscribeServer) Send(m *Message) error {
|
|
return x.ServerStream.SendMsg(m)
|
|
}
|
|
|
|
// Broker_ServiceDesc is the grpc.ServiceDesc for Broker service.
|
|
// It's only intended for direct use with grpc.RegisterService,
|
|
// and not to be introspected or modified (even as a copy)
|
|
var Broker_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "servicepb.Broker",
|
|
HandlerType: (*BrokerServer)(nil),
|
|
Methods: []grpc.MethodDesc{
|
|
{
|
|
MethodName: "Publish",
|
|
Handler: _Broker_Publish_Handler,
|
|
},
|
|
},
|
|
Streams: []grpc.StreamDesc{
|
|
{
|
|
StreamName: "Subscribe",
|
|
Handler: _Broker_Subscribe_Handler,
|
|
ServerStreams: true,
|
|
},
|
|
},
|
|
Metadata: "broker.proto",
|
|
}
|