// Code generated by Kitex v0.13.1. DO NOT EDIT.

package testservice

import (
	"context"
	echo "generic_streaming_demo_thrift/kitex_gen/echo"
	client "github.com/cloudwego/kitex/client"
	callopt "github.com/cloudwego/kitex/client/callopt"
	streamcall "github.com/cloudwego/kitex/client/callopt/streamcall"
	streamclient "github.com/cloudwego/kitex/client/streamclient"
	streaming "github.com/cloudwego/kitex/pkg/streaming"
	transport "github.com/cloudwego/kitex/transport"
)

// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework.
type Client interface {
	EchoPingPong(ctx context.Context, req *echo.Request, callOptions ...callopt.Option) (r *echo.Response, err error)
}

// StreamClient is designed to provide Interface for Streaming APIs.
type StreamClient interface {
	Echo(ctx context.Context, callOptions ...streamcall.Option) (stream TestService_EchoClient, err error)
	EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream TestService_EchoClientClient, err error)
	EchoServer(ctx context.Context, req *echo.Request, callOptions ...streamcall.Option) (stream TestService_EchoServerClient, err error)
}

type TestService_EchoClient interface {
	streaming.Stream
	Send(*echo.Request) error
	Recv() (*echo.Response, error)
}

type TestService_EchoClientClient interface {
	streaming.Stream
	Send(*echo.Request) error
	CloseAndRecv() (*echo.Response, error)
}

type TestService_EchoServerClient interface {
	streaming.Stream
	Recv() (*echo.Response, error)
}

// NewClient creates a client for the service defined in IDL.
func NewClient(destService string, opts ...client.Option) (Client, error) {
	var options []client.Option
	options = append(options, client.WithDestService(destService))

	options = append(options, opts...)

	kc, err := client.NewClient(serviceInfoForClient(), options...)
	if err != nil {
		return nil, err
	}
	return &kTestServiceClient{
		kClient: newServiceClient(kc),
	}, nil
}

// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs.
func MustNewClient(destService string, opts ...client.Option) Client {
	kc, err := NewClient(destService, opts...)
	if err != nil {
		panic(err)
	}
	return kc
}

type kTestServiceClient struct {
	*kClient
}

func (p *kTestServiceClient) EchoPingPong(ctx context.Context, req *echo.Request, callOptions ...callopt.Option) (r *echo.Response, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.EchoPingPong(ctx, req)
}

// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL.
func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) {
	var options []client.Option
	options = append(options, client.WithDestService(destService))
	options = append(options, client.WithTransportProtocol(transport.GRPC))
	options = append(options, streamclient.GetClientOptions(opts)...)

	kc, err := client.NewClient(serviceInfoForStreamClient(), options...)
	if err != nil {
		return nil, err
	}
	return &kTestServiceStreamClient{
		kClient: newServiceClient(kc),
	}, nil
}

// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL.
// It panics if any error occurs.
func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient {
	kc, err := NewStreamClient(destService, opts...)
	if err != nil {
		panic(err)
	}
	return kc
}

type kTestServiceStreamClient struct {
	*kClient
}

func (p *kTestServiceStreamClient) Echo(ctx context.Context, callOptions ...streamcall.Option) (stream TestService_EchoClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions))
	return p.kClient.Echo(ctx)
}

func (p *kTestServiceStreamClient) EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream TestService_EchoClientClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions))
	return p.kClient.EchoClient(ctx)
}

func (p *kTestServiceStreamClient) EchoServer(ctx context.Context, req *echo.Request, callOptions ...streamcall.Option) (stream TestService_EchoServerClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions))
	return p.kClient.EchoServer(ctx, req)
}
