works and doesn't exit suddenly

This commit is contained in:
Mihai Moldovanu 2022-08-02 20:50:39 +03:00
parent f1d17105a9
commit a78b97c5c1
3 changed files with 8 additions and 4 deletions

2
.idea/compiler.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<bytecodeTargetLevel target="15" /> <bytecodeTargetLevel target="9" />
</component> </component>
</project> </project>

View File

@ -11,7 +11,7 @@ import com.twitter.util.Future;
public class GreetingsService extends Service<Request, Response> { public class GreetingsService extends Service<Request, Response> {
@Override @Override
public Future<Response> apply(Request request) { public Future<Response> apply(Request request) {
String greeting = "Hello " + request.getParam("name"); String greeting = "Hello1 " + request.getParam("name");
Reader<Buf> reader = Reader.fromBuf(new Buf.ByteArray(greeting.getBytes(), 0, greeting.length())); Reader<Buf> reader = Reader.fromBuf(new Buf.ByteArray(greeting.getBytes(), 0, greeting.length()));
return Future.value(Response.apply(request.version(), Status.Ok(), reader)); return Future.value(Response.apply(request.version(), Status.Ok(), reader));
} }

View File

@ -1,10 +1,14 @@
package ro.mihai; package ro.mihai;
import com.twitter.finagle.Http; import com.twitter.finagle.Http;
public class Main { public class Main {
public static void main(String []args) { public static void main(String []args) {
GreetingsService sServ = new GreetingsService(); GreetingsService sServ = new GreetingsService();
Http.serve(":8080", sServ); Http.server().withAdmissionControl()
.concurrencyLimit(10, 0)
.serve(":8080", sServ);
System.out.println("seems that this is async .... so we wait for connections");
while( true) ;
} }
} }