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

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