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

package streamingservice

import (
	"context"
	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"
	pb "pb_generic_streaming_demo/kitex_gen/pb"
)

// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework.
type Client interface {
	StreamRequestEcho(ctx context.Context, callOptions ...callopt.Option) (stream StreamingService_StreamRequestEchoClient, err error)
	StreamResponseEcho(ctx context.Context, Req *pb.Request, callOptions ...callopt.Option) (stream StreamingService_StreamResponseEchoClient, err error)
	BidirectionalEcho(ctx context.Context, callOptions ...callopt.Option) (stream StreamingService_BidirectionalEchoClient, err error)
	UnaryEcho(ctx context.Context, Req *pb.Request, callOptions ...callopt.Option) (r *pb.Response, err error)
}

// StreamClient is designed to provide Interface for Streaming APIs.
type StreamClient interface {
	StreamRequestEcho(ctx context.Context, callOptions ...streamcall.Option) (stream StreamingService_StreamRequestEchoClient, err error)
	StreamResponseEcho(ctx context.Context, Req *pb.Request, callOptions ...streamcall.Option) (stream StreamingService_StreamResponseEchoClient, err error)
	BidirectionalEcho(ctx context.Context, callOptions ...streamcall.Option) (stream StreamingService_BidirectionalEchoClient, err error)
}

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

type StreamingService_StreamResponseEchoClient interface {
	streaming.Stream
	Recv() (*pb.Response, error)
}

type StreamingService_BidirectionalEchoClient interface {
	streaming.Stream
	Send(*pb.Request) error
	Recv() (*pb.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, client.WithTransportProtocol(transport.GRPC))

	options = append(options, opts...)

	kc, err := client.NewClient(serviceInfo(), options...)
	if err != nil {
		return nil, err
	}
	return &kStreamingServiceClient{
		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 kStreamingServiceClient struct {
	*kClient
}

func (p *kStreamingServiceClient) StreamRequestEcho(ctx context.Context, callOptions ...callopt.Option) (stream StreamingService_StreamRequestEchoClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.StreamRequestEcho(ctx)
}

func (p *kStreamingServiceClient) StreamResponseEcho(ctx context.Context, Req *pb.Request, callOptions ...callopt.Option) (stream StreamingService_StreamResponseEchoClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.StreamResponseEcho(ctx, Req)
}

func (p *kStreamingServiceClient) BidirectionalEcho(ctx context.Context, callOptions ...callopt.Option) (stream StreamingService_BidirectionalEchoClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.BidirectionalEcho(ctx)
}

func (p *kStreamingServiceClient) UnaryEcho(ctx context.Context, Req *pb.Request, callOptions ...callopt.Option) (r *pb.Response, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, callOptions)
	return p.kClient.UnaryEcho(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 &kStreamingServiceStreamClient{
		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 kStreamingServiceStreamClient struct {
	*kClient
}

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

func (p *kStreamingServiceStreamClient) StreamResponseEcho(ctx context.Context, Req *pb.Request, callOptions ...streamcall.Option) (stream StreamingService_StreamResponseEchoClient, err error) {
	ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions))
	return p.kClient.StreamResponseEcho(ctx, Req)
}

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