package talkerpb

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

// TalkerClient is the client API for Talker 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 TalkerClient interface {
	// Say hello with something OK to audit log in request/response.
	Hello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
	// Whisper with something sensitive (shouldn't be audit logged) in
	// request/response.
	Whisper(ctx context.Context, in *WhisperRequest, opts ...grpc.CallOption) (*WhisperResponse, error)
	// Say bye with something OK to audit log in request,
	// but we don't care the response at all.
	Bye(ctx context.Context, in *ByeRequest, opts ...grpc.CallOption) (*ByeResponse, error)
	Fibonacci(ctx context.Context, in *FibonacciRequest, opts ...grpc.CallOption) (Talker_FibonacciClient, error)
	Addition(ctx context.Context, opts ...grpc.CallOption) (Talker_AdditionClient, error)
	// An api that is intended to always throw an error.
	Fail(ctx context.Context, in *FailRequest, opts ...grpc.CallOption) (*FailResponse, error)
	// API for client streaming that throws an error if 4 is sent
	FailOnFour(ctx context.Context, opts ...grpc.CallOption) (Talker_FailOnFourClient, error)
}

type talkerClient struct {
	cc grpc.ClientConnInterface
}

func NewTalkerClient(cc grpc.ClientConnInterface) TalkerClient {
	return &talkerClient{cc}
}

func (c *talkerClient) Hello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error) {
	out := new(HelloResponse)
	err := c.cc.Invoke(ctx, "/abcxyz.test.Talker/Hello", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *talkerClient) Whisper(ctx context.Context, in *WhisperRequest, opts ...grpc.CallOption) (*WhisperResponse, error) {
	out := new(WhisperResponse)
	err := c.cc.Invoke(ctx, "/abcxyz.test.Talker/Whisper", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *talkerClient) Bye(ctx context.Context, in *ByeRequest, opts ...grpc.CallOption) (*ByeResponse, error) {
	out := new(ByeResponse)
	err := c.cc.Invoke(ctx, "/abcxyz.test.Talker/Bye", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *talkerClient) Fibonacci(ctx context.Context, in *FibonacciRequest, opts ...grpc.CallOption) (Talker_FibonacciClient, error) {
	stream, err := c.cc.NewStream(ctx, &Talker_ServiceDesc.Streams[0], "/abcxyz.test.Talker/Fibonacci", opts...)
	if err != nil {
		return nil, err
	}
	x := &talkerFibonacciClient{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 Talker_FibonacciClient interface {
	Recv() (*FibonacciResponse, error)
	grpc.ClientStream
}

type talkerFibonacciClient struct {
	grpc.ClientStream
}

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

func (c *talkerClient) Addition(ctx context.Context, opts ...grpc.CallOption) (Talker_AdditionClient, error) {
	stream, err := c.cc.NewStream(ctx, &Talker_ServiceDesc.Streams[1], "/abcxyz.test.Talker/Addition", opts...)
	if err != nil {
		return nil, err
	}
	x := &talkerAdditionClient{stream}
	return x, nil
}

type Talker_AdditionClient interface {
	Send(*AdditionRequest) error
	CloseAndRecv() (*AdditionResponse, error)
	grpc.ClientStream
}

type talkerAdditionClient struct {
	grpc.ClientStream
}

func (x *talkerAdditionClient) Send(m *AdditionRequest) error {
	return x.ClientStream.SendMsg(m)
}

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

func (c *talkerClient) Fail(ctx context.Context, in *FailRequest, opts ...grpc.CallOption) (*FailResponse, error) {
	out := new(FailResponse)
	err := c.cc.Invoke(ctx, "/abcxyz.test.Talker/Fail", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *talkerClient) FailOnFour(ctx context.Context, opts ...grpc.CallOption) (Talker_FailOnFourClient, error) {
	stream, err := c.cc.NewStream(ctx, &Talker_ServiceDesc.Streams[2], "/abcxyz.test.Talker/FailOnFour", opts...)
	if err != nil {
		return nil, err
	}
	x := &talkerFailOnFourClient{stream}
	return x, nil
}

type Talker_FailOnFourClient interface {
	Send(*FailOnFourRequest) error
	CloseAndRecv() (*FailOnFourResponse, error)
	grpc.ClientStream
}

type talkerFailOnFourClient struct {
	grpc.ClientStream
}

func (x *talkerFailOnFourClient) Send(m *FailOnFourRequest) error {
	return x.ClientStream.SendMsg(m)
}

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

// TalkerServer is the server API for Talker service.
// All implementations must embed UnimplementedTalkerServer
// for forward compatibility
type TalkerServer interface {
	// Say hello with something OK to audit log in request/response.
	Hello(context.Context, *HelloRequest) (*HelloResponse, error)
	// Whisper with something sensitive (shouldn't be audit logged) in
	// request/response.
	Whisper(context.Context, *WhisperRequest) (*WhisperResponse, error)
	// Say bye with something OK to audit log in request,
	// but we don't care the response at all.
	Bye(context.Context, *ByeRequest) (*ByeResponse, error)
	Fibonacci(*FibonacciRequest, Talker_FibonacciServer) error
	Addition(Talker_AdditionServer) error
	// An api that is intended to always throw an error.
	Fail(context.Context, *FailRequest) (*FailResponse, error)
	// API for client streaming that throws an error if 4 is sent
	FailOnFour(Talker_FailOnFourServer) error
	mustEmbedUnimplementedTalkerServer()
}

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

func (UnimplementedTalkerServer) Hello(context.Context, *HelloRequest) (*HelloResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Hello not implemented")
}
func (UnimplementedTalkerServer) Whisper(context.Context, *WhisperRequest) (*WhisperResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Whisper not implemented")
}
func (UnimplementedTalkerServer) Bye(context.Context, *ByeRequest) (*ByeResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Bye not implemented")
}
func (UnimplementedTalkerServer) Fibonacci(*FibonacciRequest, Talker_FibonacciServer) error {
	return status.Errorf(codes.Unimplemented, "method Fibonacci not implemented")
}
func (UnimplementedTalkerServer) Addition(Talker_AdditionServer) error {
	return status.Errorf(codes.Unimplemented, "method Addition not implemented")
}
func (UnimplementedTalkerServer) Fail(context.Context, *FailRequest) (*FailResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Fail not implemented")
}
func (UnimplementedTalkerServer) FailOnFour(Talker_FailOnFourServer) error {
	return status.Errorf(codes.Unimplemented, "method FailOnFour not implemented")
}
func (UnimplementedTalkerServer) mustEmbedUnimplementedTalkerServer() {}

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

func RegisterTalkerServer(s grpc.ServiceRegistrar, srv TalkerServer) {
	s.RegisterService(&Talker_ServiceDesc, srv)
}

func _Talker_Hello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(HelloRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(TalkerServer).Hello(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/abcxyz.test.Talker/Hello",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(TalkerServer).Hello(ctx, req.(*HelloRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _Talker_Whisper_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(WhisperRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(TalkerServer).Whisper(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/abcxyz.test.Talker/Whisper",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(TalkerServer).Whisper(ctx, req.(*WhisperRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _Talker_Bye_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(ByeRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(TalkerServer).Bye(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/abcxyz.test.Talker/Bye",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(TalkerServer).Bye(ctx, req.(*ByeRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _Talker_Fibonacci_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(FibonacciRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(TalkerServer).Fibonacci(m, &talkerFibonacciServer{stream})
}

type Talker_FibonacciServer interface {
	Send(*FibonacciResponse) error
	grpc.ServerStream
}

type talkerFibonacciServer struct {
	grpc.ServerStream
}

func (x *talkerFibonacciServer) Send(m *FibonacciResponse) error {
	return x.ServerStream.SendMsg(m)
}

func _Talker_Addition_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(TalkerServer).Addition(&talkerAdditionServer{stream})
}

type Talker_AdditionServer interface {
	SendAndClose(*AdditionResponse) error
	Recv() (*AdditionRequest, error)
	grpc.ServerStream
}

type talkerAdditionServer struct {
	grpc.ServerStream
}

func (x *talkerAdditionServer) SendAndClose(m *AdditionResponse) error {
	return x.ServerStream.SendMsg(m)
}

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

func _Talker_Fail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(FailRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(TalkerServer).Fail(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/abcxyz.test.Talker/Fail",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(TalkerServer).Fail(ctx, req.(*FailRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _Talker_FailOnFour_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(TalkerServer).FailOnFour(&talkerFailOnFourServer{stream})
}

type Talker_FailOnFourServer interface {
	SendAndClose(*FailOnFourResponse) error
	Recv() (*FailOnFourRequest, error)
	grpc.ServerStream
}

type talkerFailOnFourServer struct {
	grpc.ServerStream
}

func (x *talkerFailOnFourServer) SendAndClose(m *FailOnFourResponse) error {
	return x.ServerStream.SendMsg(m)
}

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

// Talker_ServiceDesc is the grpc.ServiceDesc for Talker service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Talker_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "abcxyz.test.Talker",
	HandlerType: (*TalkerServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Hello",
			Handler:    _Talker_Hello_Handler,
		},
		{
			MethodName: "Whisper",
			Handler:    _Talker_Whisper_Handler,
		},
		{
			MethodName: "Bye",
			Handler:    _Talker_Bye_Handler,
		},
		{
			MethodName: "Fail",
			Handler:    _Talker_Fail_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Fibonacci",
			Handler:       _Talker_Fibonacci_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "Addition",
			Handler:       _Talker_Addition_Handler,
			ClientStreams: true,
		},
		{
			StreamName:    "FailOnFour",
			Handler:       _Talker_FailOnFour_Handler,
			ClientStreams: true,
		},
	},
	Metadata: "integration/protos/talker.proto",
}
