// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc             v4.25.3
// source: eventstream.proto

package eventstreamapi

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

// EventStreamClient is the client API for EventStream 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 EventStreamClient interface {
	Subscribe(ctx context.Context, opts ...grpc.CallOption) (EventStream_SubscribeClient, error)
	Push(ctx context.Context, opts ...grpc.CallOption) (EventStream_PushClient, error)
	Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PongReply, error)
}

type eventStreamClient struct {
	cc grpc.ClientConnInterface
}

func NewEventStreamClient(cc grpc.ClientConnInterface) EventStreamClient {
	return &eventStreamClient{cc}
}

func (c *eventStreamClient) Subscribe(ctx context.Context, opts ...grpc.CallOption) (EventStream_SubscribeClient, error) {
	stream, err := c.cc.NewStream(ctx, &EventStream_ServiceDesc.Streams[0], "/eventstreamapi.EventStream/Subscribe", opts...)
	if err != nil {
		return nil, err
	}
	x := &eventStreamSubscribeClient{stream}
	return x, nil
}

type EventStream_SubscribeClient interface {
	Send(*Event) error
	Recv() (*Event, error)
	grpc.ClientStream
}

type eventStreamSubscribeClient struct {
	grpc.ClientStream
}

func (x *eventStreamSubscribeClient) Send(m *Event) error {
	return x.ClientStream.SendMsg(m)
}

func (x *eventStreamSubscribeClient) Recv() (*Event, error) {
	m := new(Event)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func (c *eventStreamClient) Push(ctx context.Context, opts ...grpc.CallOption) (EventStream_PushClient, error) {
	stream, err := c.cc.NewStream(ctx, &EventStream_ServiceDesc.Streams[1], "/eventstreamapi.EventStream/Push", opts...)
	if err != nil {
		return nil, err
	}
	x := &eventStreamPushClient{stream}
	return x, nil
}

type EventStream_PushClient interface {
	Send(*Event) error
	CloseAndRecv() (*PushSummary, error)
	grpc.ClientStream
}

type eventStreamPushClient struct {
	grpc.ClientStream
}

func (x *eventStreamPushClient) Send(m *Event) error {
	return x.ClientStream.SendMsg(m)
}

func (x *eventStreamPushClient) CloseAndRecv() (*PushSummary, error) {
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	m := new(PushSummary)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func (c *eventStreamClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PongReply, error) {
	out := new(PongReply)
	err := c.cc.Invoke(ctx, "/eventstreamapi.EventStream/Ping", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// EventStreamServer is the server API for EventStream service.
// All implementations must embed UnimplementedEventStreamServer
// for forward compatibility
type EventStreamServer interface {
	Subscribe(EventStream_SubscribeServer) error
	Push(EventStream_PushServer) error
	Ping(context.Context, *PingRequest) (*PongReply, error)
	mustEmbedUnimplementedEventStreamServer()
}

// UnimplementedEventStreamServer must be embedded to have forward compatible implementations.
type UnimplementedEventStreamServer struct {
}

func (UnimplementedEventStreamServer) Subscribe(EventStream_SubscribeServer) error {
	return status.Errorf(codes.Unimplemented, "method Subscribe not implemented")
}
func (UnimplementedEventStreamServer) Push(EventStream_PushServer) error {
	return status.Errorf(codes.Unimplemented, "method Push not implemented")
}
func (UnimplementedEventStreamServer) Ping(context.Context, *PingRequest) (*PongReply, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented")
}
func (UnimplementedEventStreamServer) mustEmbedUnimplementedEventStreamServer() {}

// UnsafeEventStreamServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to EventStreamServer will
// result in compilation errors.
type UnsafeEventStreamServer interface {
	mustEmbedUnimplementedEventStreamServer()
}

func RegisterEventStreamServer(s grpc.ServiceRegistrar, srv EventStreamServer) {
	s.RegisterService(&EventStream_ServiceDesc, srv)
}

func _EventStream_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(EventStreamServer).Subscribe(&eventStreamSubscribeServer{stream})
}

type EventStream_SubscribeServer interface {
	Send(*Event) error
	Recv() (*Event, error)
	grpc.ServerStream
}

type eventStreamSubscribeServer struct {
	grpc.ServerStream
}

func (x *eventStreamSubscribeServer) Send(m *Event) error {
	return x.ServerStream.SendMsg(m)
}

func (x *eventStreamSubscribeServer) Recv() (*Event, error) {
	m := new(Event)
	if err := x.ServerStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func _EventStream_Push_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(EventStreamServer).Push(&eventStreamPushServer{stream})
}

type EventStream_PushServer interface {
	SendAndClose(*PushSummary) error
	Recv() (*Event, error)
	grpc.ServerStream
}

type eventStreamPushServer struct {
	grpc.ServerStream
}

func (x *eventStreamPushServer) SendAndClose(m *PushSummary) error {
	return x.ServerStream.SendMsg(m)
}

func (x *eventStreamPushServer) Recv() (*Event, error) {
	m := new(Event)
	if err := x.ServerStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func _EventStream_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(PingRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(EventStreamServer).Ping(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/eventstreamapi.EventStream/Ping",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(EventStreamServer).Ping(ctx, req.(*PingRequest))
	}
	return interceptor(ctx, in, info, handler)
}

// EventStream_ServiceDesc is the grpc.ServiceDesc for EventStream service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var EventStream_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "eventstreamapi.EventStream",
	HandlerType: (*EventStreamServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Ping",
			Handler:    _EventStream_Ping_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Subscribe",
			Handler:       _EventStream_Subscribe_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
		{
			StreamName:    "Push",
			Handler:       _EventStream_Push_Handler,
			ClientStreams: true,
		},
	},
	Metadata: "eventstream.proto",
}
