-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from aureamunoz/add-grpc
refactor and add grpc getting started
- Loading branch information
Showing
10 changed files
with
84 additions
and
5 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
2 changes: 1 addition & 1 deletion
2
src/main/java/org/acme/GreetingResource.java → ...cme/getting/started/GreetingResource.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
2 changes: 1 addition & 1 deletion
2
src/main/java/org/acme/GreetingService.java → ...acme/getting/started/GreetingService.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
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 org.acme.grpc; | ||
|
||
import io.quarkus.example.Greeter; | ||
import io.quarkus.example.HelloRequest; | ||
import io.quarkus.grpc.GrpcClient; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Path("/greeting") | ||
public class ExampleResource { | ||
|
||
@GrpcClient | ||
Greeter hello; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
return "hello"; | ||
} | ||
|
||
@GET | ||
@Path("/{name}") | ||
public Uni<String> hello(String name) { | ||
return hello.sayHello(HelloRequest.newBuilder().setName(name).build()).onItem() | ||
.transform(helloReply -> helloReply.getMessage()); | ||
} | ||
} |
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,16 @@ | ||
package org.acme; | ||
|
||
import io.quarkus.example.Greeter; | ||
import io.quarkus.example.HelloReply; | ||
import io.quarkus.example.HelloRequest; | ||
import io.quarkus.grpc.GrpcService; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@GrpcService | ||
public class HelloService implements Greeter { | ||
|
||
@Override | ||
public Uni<HelloReply> sayHello(HelloRequest request) { | ||
return Uni.createFrom().item(() -> HelloReply.newBuilder().setMessage("Hello " + request.getName()).build()); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/org/acme/Book.java → ...ain/java/org/acme/orm/rest/data/Book.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.acme; | ||
package org.acme.orm.rest.data; | ||
|
||
import io.quarkus.hibernate.orm.panache.PanacheEntity; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
src/main/java/org/acme/BookRepository.java → ...rg/acme/orm/rest/data/BookRepository.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
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,23 @@ | ||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "io.quarkus.example"; | ||
option java_outer_classname = "HelloWorldProto"; | ||
|
||
package helloworld; | ||
|
||
// The greeting service definition. | ||
service Greeter { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
} | ||
|
||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} |
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