Add thrift client for testing
This commit is contained in:
parent
e64b128ddc
commit
eaecdc08f8
30
src/main/java/org/example/FinagleThriftClient.java
Normal file
30
src/main/java/org/example/FinagleThriftClient.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package org.example;
|
||||||
|
|
||||||
|
import com.twitter.finagle.ListeningServer;
|
||||||
|
import com.twitter.finagle.Service;
|
||||||
|
import com.twitter.finagle.Thrift;
|
||||||
|
import com.twitter.finagle.builder.ClientBuilder;
|
||||||
|
import com.twitter.finagle.thrift.ThriftClientRequest;
|
||||||
|
import com.twitter.util.Await;
|
||||||
|
import com.twitter.util.Future;
|
||||||
|
import com.twitter.util.FutureEventListener;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
|
public class FinagleThriftClient {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
HelloService.ServiceIface client = Thrift.client().newIface("localhost:8097", HelloService.ServiceIface.class);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Future<String> response = client.sayHello("Mihai ");
|
||||||
|
System.out.println(Await.result(response));
|
||||||
|
|
||||||
|
Future<Void> blockResponse = client.blocking_call();
|
||||||
|
Await.result(blockResponse);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,7 +7,7 @@ public class HelloServiceImpl implements HelloService.ServiceIface {
|
|||||||
@Override
|
@Override
|
||||||
public Future<String> sayHello(String name) {
|
public Future<String> sayHello(String name) {
|
||||||
// Implement the logic for sayHello method
|
// Implement the logic for sayHello method
|
||||||
return Future.value("Hello, " + name + "!");
|
return Future.value("Hell no, " + name + "!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user