1 /** 2 * Autogenerated by Thrift 3 * 4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 * @generated 6 */ 7 8 package test.fixtures.basicannotations; 9 10 import static com.facebook.swift.service.SwiftConstants.STICKY_HASH_KEY; 11 12 import java.util.*; 13 import java.util.concurrent.ConcurrentHashMap; 14 import java.util.concurrent.atomic.AtomicLong; 15 import org.apache.thrift.protocol.*; 16 import org.apache.thrift.ClientPushMetadata; 17 import org.apache.thrift.InteractionCreate; 18 import org.apache.thrift.InteractionTerminate; 19 import com.facebook.thrift.client.ResponseWrapper; 20 import com.facebook.thrift.client.RpcOptions; 21 22 public class MyServicePrioParentReactiveClient 23 implements MyServicePrioParent.Reactive { 24 private static final AtomicLong _interactionCounter = new AtomicLong(0); 25 26 private final org.apache.thrift.ProtocolId _protocolId; 27 private final reactor.core.publisher.Mono<? extends com.facebook.thrift.client.RpcClient> _rpcClient; 28 private final Map<String, String> _headers; 29 private final Map<String, String> _persistentHeaders; 30 private final Set<Long> _activeInteractions; 31 32 private static final java.util.Map<Short, com.facebook.thrift.payload.Reader> _ping_EXCEPTION_READERS = java.util.Collections.emptyMap(); 33 private static final java.util.Map<Short, com.facebook.thrift.payload.Reader> _pong_EXCEPTION_READERS = java.util.Collections.emptyMap(); 34 35 static { 36 } 37 MyServicePrioParentReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono<? extends com.facebook.thrift.client.RpcClient> _rpcClient)38 public MyServicePrioParentReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono<? extends com.facebook.thrift.client.RpcClient> _rpcClient) { 39 40 this._protocolId = _protocolId; 41 this._rpcClient = _rpcClient; 42 this._headers = java.util.Collections.emptyMap(); 43 this._persistentHeaders = java.util.Collections.emptyMap(); 44 this._activeInteractions = ConcurrentHashMap.newKeySet(); 45 } 46 MyServicePrioParentReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono<? extends com.facebook.thrift.client.RpcClient> _rpcClient, Map<String, String> _headers, Map<String, String> _persistentHeaders)47 public MyServicePrioParentReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono<? extends com.facebook.thrift.client.RpcClient> _rpcClient, Map<String, String> _headers, Map<String, String> _persistentHeaders) { 48 this(_protocolId, _rpcClient, _headers, _persistentHeaders, new AtomicLong(), ConcurrentHashMap.newKeySet()); 49 } 50 MyServicePrioParentReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono<? extends com.facebook.thrift.client.RpcClient> _rpcClient, Map<String, String> _headers, Map<String, String> _persistentHeaders, AtomicLong interactionCounter, Set<Long> activeInteractions)51 public MyServicePrioParentReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono<? extends com.facebook.thrift.client.RpcClient> _rpcClient, Map<String, String> _headers, Map<String, String> _persistentHeaders, AtomicLong interactionCounter, Set<Long> activeInteractions) { 52 53 this._protocolId = _protocolId; 54 this._rpcClient = _rpcClient; 55 this._headers = _headers; 56 this._persistentHeaders = _persistentHeaders; 57 this._activeInteractions = activeInteractions; 58 } 59 60 @java.lang.Override dispose()61 public void dispose() {} 62 _createpingWriter()63 private com.facebook.thrift.payload.Writer _createpingWriter() { 64 return oprot -> { 65 try { 66 67 } catch (Throwable _e) { 68 throw reactor.core.Exceptions.propagate(_e); 69 } 70 }; 71 } 72 73 private static final com.facebook.thrift.payload.Reader _ping_READER = 74 oprot -> { 75 try { 76 77 return null; 78 79 } catch (Throwable _e) { 80 throw reactor.core.Exceptions.propagate(_e); 81 } 82 }; 83 84 85 @java.lang.Override 86 public reactor.core.publisher.Mono<com.facebook.thrift.client.ResponseWrapper<Void>> pingWrapper( final com.facebook.thrift.client.RpcOptions rpcOptions) { 87 return _rpcClient 88 .flatMap(_rpc -> { 89 org.apache.thrift.RequestRpcMetadata _metadata = new org.apache.thrift.RequestRpcMetadata.Builder() 90 .setName("ping") 91 .setKind(org.apache.thrift.RpcKind.SINGLE_REQUEST_SINGLE_RESPONSE) 92 .setOtherMetadata(getHeaders(rpcOptions)) 93 .setProtocol(_protocolId) 94 .build(); 95 96 com.facebook.thrift.payload.ClientRequestPayload<Void> _crp = 97 com.facebook.thrift.payload.ClientRequestPayload.create( 98 _createpingWriter(), 99 _ping_READER, 100 _ping_EXCEPTION_READERS, 101 _metadata, 102 java.util.Collections.emptyMap()); 103 104 return _rpc 105 .singleRequestSingleResponse(_crp, rpcOptions).doOnNext(_p -> {if(_p.getException() != null) throw reactor.core.Exceptions.propagate(_p.getException());}); 106 }); 107 } 108 109 @java.lang.Override 110 public reactor.core.publisher.Mono<Void> ping( final com.facebook.thrift.client.RpcOptions rpcOptions) { 111 return pingWrapper( rpcOptions).then(); 112 } 113 114 @java.lang.Override 115 public reactor.core.publisher.Mono<Void> ping() { 116 return ping( com.facebook.thrift.client.RpcOptions.EMPTY); 117 } 118 119 private com.facebook.thrift.payload.Writer _createpongWriter() { 120 return oprot -> { 121 try { 122 123 } catch (Throwable _e) { 124 throw reactor.core.Exceptions.propagate(_e); 125 } 126 }; 127 } 128 129 private static final com.facebook.thrift.payload.Reader _pong_READER = 130 oprot -> { 131 try { 132 133 return null; 134 135 } catch (Throwable _e) { 136 throw reactor.core.Exceptions.propagate(_e); 137 } 138 }; 139 140 141 @java.lang.Override 142 public reactor.core.publisher.Mono<com.facebook.thrift.client.ResponseWrapper<Void>> pongWrapper( final com.facebook.thrift.client.RpcOptions rpcOptions) { 143 return _rpcClient 144 .flatMap(_rpc -> { 145 org.apache.thrift.RequestRpcMetadata _metadata = new org.apache.thrift.RequestRpcMetadata.Builder() 146 .setName("pong") 147 .setKind(org.apache.thrift.RpcKind.SINGLE_REQUEST_SINGLE_RESPONSE) 148 .setOtherMetadata(getHeaders(rpcOptions)) 149 .setProtocol(_protocolId) 150 .build(); 151 152 com.facebook.thrift.payload.ClientRequestPayload<Void> _crp = 153 com.facebook.thrift.payload.ClientRequestPayload.create( 154 _createpongWriter(), 155 _pong_READER, 156 _pong_EXCEPTION_READERS, 157 _metadata, 158 java.util.Collections.emptyMap()); 159 160 return _rpc 161 .singleRequestSingleResponse(_crp, rpcOptions).doOnNext(_p -> {if(_p.getException() != null) throw reactor.core.Exceptions.propagate(_p.getException());}); 162 }); 163 } 164 165 @java.lang.Override 166 public reactor.core.publisher.Mono<Void> pong( final com.facebook.thrift.client.RpcOptions rpcOptions) { 167 return pongWrapper( rpcOptions).then(); 168 } 169 170 @java.lang.Override 171 public reactor.core.publisher.Mono<Void> pong() { 172 return pong( com.facebook.thrift.client.RpcOptions.EMPTY); 173 } 174 175 176 177 private Map<String, String> getHeaders(com.facebook.thrift.client.RpcOptions rpcOptions) { 178 Map<String, String> headers = new HashMap<>(); 179 if (rpcOptions.getRequestHeaders() != null && !rpcOptions.getRequestHeaders().isEmpty()) { 180 headers.putAll(rpcOptions.getRequestHeaders()); 181 } 182 if (_headers != null && !_headers.isEmpty()) { 183 headers.putAll(_headers); 184 } 185 if (_persistentHeaders != null && !_persistentHeaders.isEmpty()) { 186 headers.putAll(_persistentHeaders); 187 } 188 return headers; 189 } 190 } 191