go.uber.org/yarpc@v1.72.1/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/storeclient/client.go (about) 1 // Code generated by thriftrw-plugin-yarpc 2 // @generated 3 4 package storeclient 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 readonlystoreclient "go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/atomic/readonlystoreclient" 14 reflect "reflect" 15 ) 16 17 // Interface is a client for the Store service. 18 type Interface interface { 19 readonlystoreclient.Interface 20 21 CompareAndSwap( 22 ctx context.Context, 23 Request *atomic.CompareAndSwap, 24 opts ...yarpc.CallOption, 25 ) error 26 27 Forget( 28 ctx context.Context, 29 Key *string, 30 opts ...yarpc.CallOption, 31 ) (yarpc.Ack, error) 32 33 Increment( 34 ctx context.Context, 35 Key *string, 36 Value *int64, 37 opts ...yarpc.CallOption, 38 ) error 39 } 40 41 // New builds a new client for the Store service. 42 // 43 // client := storeclient.New(dispatcher.ClientConfig("store")) 44 func New(c transport.ClientConfig, opts ...thrift.ClientOption) Interface { 45 return client{ 46 c: thrift.New(thrift.Config{ 47 Service: "Store", 48 ClientConfig: c, 49 }, opts...), 50 nwc: thrift.NewNoWire(thrift.Config{ 51 Service: "Store", 52 ClientConfig: c, 53 }, opts...), 54 55 Interface: readonlystoreclient.New( 56 c, 57 append( 58 opts, 59 thrift.Named("Store"), 60 )..., 61 ), 62 } 63 } 64 65 func init() { 66 yarpc.RegisterClientBuilder( 67 func(c transport.ClientConfig, f reflect.StructField) Interface { 68 return New(c, thrift.ClientBuilderOptions(c, f)...) 69 }, 70 ) 71 } 72 73 type client struct { 74 readonlystoreclient.Interface 75 76 c thrift.Client 77 nwc thrift.NoWireClient 78 } 79 80 func (c client) CompareAndSwap( 81 ctx context.Context, 82 _Request *atomic.CompareAndSwap, 83 opts ...yarpc.CallOption, 84 ) (err error) { 85 86 var result atomic.Store_CompareAndSwap_Result 87 args := atomic.Store_CompareAndSwap_Helper.Args(_Request) 88 89 if c.nwc != nil && c.nwc.Enabled() { 90 if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { 91 return 92 } 93 } else { 94 var body wire.Value 95 if body, err = c.c.Call(ctx, args, opts...); err != nil { 96 return 97 } 98 99 if err = result.FromWire(body); err != nil { 100 return 101 } 102 } 103 104 err = atomic.Store_CompareAndSwap_Helper.UnwrapResponse(&result) 105 return 106 } 107 108 func (c client) Forget( 109 ctx context.Context, 110 _Key *string, 111 opts ...yarpc.CallOption, 112 ) (yarpc.Ack, error) { 113 args := atomic.Store_Forget_Helper.Args(_Key) 114 return c.c.CallOneway(ctx, args, opts...) 115 } 116 117 func (c client) Increment( 118 ctx context.Context, 119 _Key *string, 120 _Value *int64, 121 opts ...yarpc.CallOption, 122 ) (err error) { 123 124 var result atomic.Store_Increment_Result 125 args := atomic.Store_Increment_Helper.Args(_Key, _Value) 126 127 if c.nwc != nil && c.nwc.Enabled() { 128 if err = c.nwc.Call(ctx, args, &result, opts...); err != nil { 129 return 130 } 131 } else { 132 var body wire.Value 133 if body, err = c.c.Call(ctx, args, opts...); err != nil { 134 return 135 } 136 137 if err = result.FromWire(body); err != nil { 138 return 139 } 140 } 141 142 err = atomic.Store_Increment_Helper.UnwrapResponse(&result) 143 return 144 }