forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes quarkusio#9327 fixes quarkusio#9328
- Loading branch information
1 parent
d5c4999
commit 8464e72
Showing
25 changed files
with
824 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
.../grpc/deployment/src/test/java/io/quarkus/grpc/server/devmode/DevModeTestInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.quarkus.grpc.server.devmode; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import io.grpc.ForwardingServerCall; | ||
import io.grpc.Metadata; | ||
import io.grpc.ServerCall; | ||
import io.grpc.ServerCallHandler; | ||
import io.grpc.ServerInterceptor; | ||
|
||
@ApplicationScoped | ||
public class DevModeTestInterceptor implements ServerInterceptor { | ||
|
||
private volatile String lastStatus = "initial"; | ||
|
||
@Override | ||
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall, | ||
Metadata metadata, ServerCallHandler<ReqT, RespT> serverCallHandler) { | ||
return serverCallHandler | ||
.startCall(new ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT>(serverCall) { | ||
@Override | ||
protected ServerCall<ReqT, RespT> delegate() { | ||
lastStatus = getStatus(); | ||
return super.delegate(); | ||
} | ||
}, metadata); | ||
} | ||
|
||
public String getLastStatus() { | ||
return lastStatus; | ||
} | ||
|
||
private String getStatus() { | ||
return "status"; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...grpc/deployment/src/test/java/io/quarkus/grpc/server/devmode/DevModeTestRestResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.quarkus.grpc.server.devmode; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
/** | ||
* @author Michal Szynkiewicz, [email protected] | ||
* <br> | ||
* Date: 4/28/20 | ||
*/ | ||
@Path("/test") | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public class DevModeTestRestResource { | ||
|
||
@Inject | ||
DevModeTestInterceptor interceptor; | ||
|
||
@GET | ||
public String get() { | ||
return "testresponse"; | ||
} | ||
|
||
@GET | ||
@Path("/interceptor-status") | ||
public String getInterceptorStatus() { | ||
return interceptor.getLastStatus(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ions/grpc/deployment/src/test/java/io/quarkus/grpc/server/devmode/DevModeTestService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.grpc.server.devmode; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import devmodetest.v1.Devmodetest; | ||
import io.grpc.examples.helloworld.GreeterGrpc; | ||
import io.grpc.examples.helloworld.HelloReply; | ||
import io.grpc.examples.helloworld.HelloRequest; | ||
import io.grpc.stub.StreamObserver; | ||
|
||
/** | ||
* @author Michal Szynkiewicz, [email protected] | ||
* <br> | ||
* Date: 4/28/20 | ||
*/ | ||
@Singleton | ||
public class DevModeTestService extends GreeterGrpc.GreeterImplBase { | ||
|
||
@Override | ||
public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) { | ||
String greeting = "Hello, "; | ||
String response; | ||
if (request.getName().equals("HACK_TO_GET_STATUS_NUMBER")) { | ||
response = Integer.toString(Devmodetest.DevModeResponse.Status.TEST_ONE.getNumber()); | ||
} else { | ||
response = greeting + request.getName(); | ||
} | ||
responseObserver.onNext(HelloReply.newBuilder().setMessage(response).build()); | ||
responseObserver.onCompleted(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...rpc/deployment/src/test/java/io/quarkus/grpc/server/devmode/DevModeTestStreamService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.grpc.server.devmode; | ||
|
||
import java.time.Duration; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import com.example.test.MutinyStreamsGrpc; | ||
import com.example.test.StreamsOuterClass.Item; | ||
|
||
import io.smallrye.mutiny.Multi; | ||
|
||
/** | ||
* @author Michal Szynkiewicz, [email protected] | ||
* <br> | ||
* Date: 4/29/20 | ||
*/ | ||
@Singleton | ||
public class DevModeTestStreamService extends MutinyStreamsGrpc.StreamsImplBase { | ||
|
||
public static final String PREFIX = "echo::"; | ||
|
||
@Override | ||
public Multi<Item> echo(Multi<Item> request) { | ||
return request.flatMap(value -> Multi.createFrom().ticks().every(Duration.ofMillis(20)) | ||
.map(whatever -> Item.newBuilder().setName(PREFIX + value.getName()).build())); | ||
} | ||
} |
Oops, something went wrong.