go.uber.org/yarpc@v1.72.1/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/extendemptyclient/client.go (about)

     1  // Code generated by thriftrw-plugin-yarpc
     2  // @generated
     3  
     4  package extendemptyclient
     5  
     6  import (
     7  	context "context"
     8  	wire "go.uber.org/thriftrw/wire"
     9  	yarpc "go.uber.org/yarpc"
    10  	transport "go.uber.org/yarpc/api/transport"
    11  	thrift "go.uber.org/yarpc/encoding/thrift"
    12  	common "go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common"
    13  	emptyserviceclient "go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/common/emptyserviceclient"
    14  	reflect "reflect"
    15  )
    16  
    17  // Interface is a client for the ExtendEmpty service.
    18  type Interface interface {
    19  	emptyserviceclient.Interface
    20  
    21  	Hello(
    22  		ctx context.Context,
    23  		opts ...yarpc.CallOption,
    24  	) error
    25  }
    26  
    27  // New builds a new client for the ExtendEmpty service.
    28  //
    29  //	client := extendemptyclient.New(dispatcher.ClientConfig("extendempty"))
    30  func New(c transport.ClientConfig, opts ...thrift.ClientOption) Interface {
    31  	return client{
    32  		c: thrift.New(thrift.Config{
    33  			Service:      "ExtendEmpty",
    34  			ClientConfig: c,
    35  		}, opts...),
    36  		nwc: thrift.NewNoWire(thrift.Config{
    37  			Service:      "ExtendEmpty",
    38  			ClientConfig: c,
    39  		}, opts...),
    40  
    41  		Interface: emptyserviceclient.New(
    42  			c,
    43  			append(
    44  				opts,
    45  				thrift.Named("ExtendEmpty"),
    46  			)...,
    47  		),
    48  	}
    49  }
    50  
    51  func init() {
    52  	yarpc.RegisterClientBuilder(
    53  		func(c transport.ClientConfig, f reflect.StructField) Interface {
    54  			return New(c, thrift.ClientBuilderOptions(c, f)...)
    55  		},
    56  	)
    57  }
    58  
    59  type client struct {
    60  	emptyserviceclient.Interface
    61  
    62  	c   thrift.Client
    63  	nwc thrift.NoWireClient
    64  }
    65  
    66  func (c client) Hello(
    67  	ctx context.Context,
    68  	opts ...yarpc.CallOption,
    69  ) (err error) {
    70  
    71  	var result common.ExtendEmpty_Hello_Result
    72  	args := common.ExtendEmpty_Hello_Helper.Args()
    73  
    74  	if c.nwc != nil && c.nwc.Enabled() {
    75  		if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
    76  			return
    77  		}
    78  	} else {
    79  		var body wire.Value
    80  		if body, err = c.c.Call(ctx, args, opts...); err != nil {
    81  			return
    82  		}
    83  
    84  		if err = result.FromWire(body); err != nil {
    85  			return
    86  		}
    87  	}
    88  
    89  	err = common.ExtendEmpty_Hello_Helper.UnwrapResponse(&result)
    90  	return
    91  }