-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 #17106 from mkouba/issue-17062
gRPC - fail the build if an unsupported client stub is injected
- Loading branch information
Showing
7 changed files
with
222 additions
and
92 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcClientBuildItem.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,80 @@ | ||
package io.quarkus.grpc.deployment; | ||
|
||
import java.util.HashSet; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
import org.jboss.jandex.DotName; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
public final class GrpcClientBuildItem extends MultiBuildItem { | ||
|
||
private final String name; | ||
private final Set<StubInfo> stubs; | ||
|
||
public GrpcClientBuildItem(String name) { | ||
this.name = name; | ||
this.stubs = new HashSet<>(); | ||
} | ||
|
||
public Set<StubInfo> getStubs() { | ||
return stubs; | ||
} | ||
|
||
public void addStub(DotName stubClass, StubType type) { | ||
stubs.add(new StubInfo(stubClass, type)); | ||
} | ||
|
||
public String getServiceName() { | ||
return name; | ||
} | ||
|
||
public static final class StubInfo { | ||
|
||
public final DotName className; | ||
public final StubType type; | ||
|
||
public StubInfo(DotName className, StubType type) { | ||
this.className = className; | ||
this.type = type; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(className); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
StubInfo other = (StubInfo) obj; | ||
return Objects.equals(className, other.className); | ||
} | ||
|
||
} | ||
|
||
public enum StubType { | ||
|
||
BLOCKING("newBlockingStub"), | ||
MUTINY("newMutinyStub"); | ||
|
||
private final String factoryMethodName; | ||
|
||
StubType(String factoryMethodName) { | ||
this.factoryMethodName = factoryMethodName; | ||
} | ||
|
||
public String getFactoryMethodName() { | ||
return factoryMethodName; | ||
} | ||
} | ||
} |
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
30 changes: 0 additions & 30 deletions
30
...nsions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcServiceBuildItem.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.