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

package greetservice

import (
	"context"

	proxyless "github.com/cloudwego/kitex-examples/proxyless/service/codec/thrift/kitex_gen/proxyless"
	client "github.com/cloudwego/kitex/client"
	kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
)

func serviceInfo() *kitex.ServiceInfo {
	return greetServiceServiceInfo
}

var greetServiceServiceInfo = NewServiceInfo()

func NewServiceInfo() *kitex.ServiceInfo {
	serviceName := "GreetService"
	handlerType := (*proxyless.GreetService)(nil)
	methods := map[string]kitex.MethodInfo{
		"SayHello1": kitex.NewMethodInfo(sayHello1Handler, newGreetServiceSayHello1Args, newGreetServiceSayHello1Result, false),
		"SayHello2": kitex.NewMethodInfo(sayHello2Handler, newGreetServiceSayHello2Args, newGreetServiceSayHello2Result, false),
	}
	extra := map[string]interface{}{
		"PackageName": "proxyless",
	}
	svcInfo := &kitex.ServiceInfo{
		ServiceName:     serviceName,
		HandlerType:     handlerType,
		Methods:         methods,
		PayloadCodec:    kitex.Thrift,
		KiteXGenVersion: "v0.3.4",
		Extra:           extra,
	}
	return svcInfo
}

func sayHello1Handler(ctx context.Context, handler, arg, result interface{}) error {
	realArg := arg.(*proxyless.GreetServiceSayHello1Args)
	realResult := result.(*proxyless.GreetServiceSayHello1Result)
	success, err := handler.(proxyless.GreetService).SayHello1(ctx, realArg.Request)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}

func newGreetServiceSayHello1Args() interface{} {
	return proxyless.NewGreetServiceSayHello1Args()
}

func newGreetServiceSayHello1Result() interface{} {
	return proxyless.NewGreetServiceSayHello1Result()
}

func sayHello2Handler(ctx context.Context, handler, arg, result interface{}) error {
	realArg := arg.(*proxyless.GreetServiceSayHello2Args)
	realResult := result.(*proxyless.GreetServiceSayHello2Result)
	success, err := handler.(proxyless.GreetService).SayHello2(ctx, realArg.Request)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}

func newGreetServiceSayHello2Args() interface{} {
	return proxyless.NewGreetServiceSayHello2Args()
}

func newGreetServiceSayHello2Result() interface{} {
	return proxyless.NewGreetServiceSayHello2Result()
}

type kClient struct {
	c client.Client
}

func newServiceClient(c client.Client) *kClient {
	return &kClient{
		c: c,
	}
}

func (p *kClient) SayHello1(ctx context.Context, request *proxyless.HelloRequest) (r *proxyless.HelloResponse, err error) {
	var _args proxyless.GreetServiceSayHello1Args
	_args.Request = request
	var _result proxyless.GreetServiceSayHello1Result
	if err = p.c.Call(ctx, "SayHello1", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) SayHello2(ctx context.Context, request *proxyless.HelloRequest) (r *proxyless.HelloResponse, err error) {
	var _args proxyless.GreetServiceSayHello2Args
	_args.Request = request
	var _result proxyless.GreetServiceSayHello2Result
	if err = p.c.Call(ctx, "SayHello2", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}
