-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support remote endpoint. #877
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9f190d2
Support remote endpoint.
artursouza 3ea95a4
Merge branch 'master' into remote_endpoint
artursouza 591137a
Merge branch 'master' into remote_endpoint
mukundansundar 1f4bcf5
Use GRPC_ENDPOINT and HTTP_ENDPOINT in integration tests.
artursouza f5c1364
Fix happy path for waiting for sidecar test.
artursouza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.Closeable; | ||
import java.net.URI; | ||
|
||
/** | ||
* A builder for the DaprClient, | ||
|
@@ -162,19 +163,28 @@ private DaprClient buildDaprClient(DaprApiProtocol protocol) { | |
* @throws java.lang.IllegalStateException if either host is missing or if port is missing or a negative number. | ||
*/ | ||
private DaprClient buildDaprClientGrpc() { | ||
final ManagedChannel channel = buildGrpcManagedChanel(); | ||
final GrpcChannelFacade channelFacade = new GrpcChannelFacade(channel); | ||
DaprGrpc.DaprStub asyncStub = DaprGrpc.newStub(channel); | ||
return new DaprClientGrpc(channelFacade, asyncStub, this.objectSerializer, this.stateSerializer); | ||
} | ||
|
||
private ManagedChannel buildGrpcManagedChanel() { | ||
String host = Properties.SIDECAR_IP.get(); | ||
int port = Properties.GRPC_PORT.get(); | ||
if (port <= 0) { | ||
throw new IllegalArgumentException("Invalid port."); | ||
boolean insecure = true; | ||
String grpcEndpoint = Properties.GRPC_ENDPOINT.get(); | ||
if ((grpcEndpoint != null) && !grpcEndpoint.isEmpty()) { | ||
URI uri = URI.create(grpcEndpoint); | ||
insecure = uri.getScheme().equalsIgnoreCase("http"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See, we use the schema here. |
||
port = uri.getPort() > 0 ? uri.getPort() : (insecure ? 80 : 443); | ||
} | ||
ManagedChannel channel = ManagedChannelBuilder.forAddress( | ||
Properties.SIDECAR_IP.get(), port).usePlaintext().userAgent(Version.getSdkVersion()).build(); | ||
Closeable closeableChannel = () -> { | ||
if (channel != null && !channel.isShutdown()) { | ||
channel.shutdown(); | ||
} | ||
}; | ||
DaprGrpc.DaprStub asyncStub = DaprGrpc.newStub(channel); | ||
return new DaprClientGrpc(closeableChannel, asyncStub, this.objectSerializer, this.stateSerializer); | ||
ManagedChannelBuilder builder = ManagedChannelBuilder.forAddress(host, port) | ||
.userAgent(Version.getSdkVersion()); | ||
if (insecure) { | ||
builder = builder.usePlaintext(); | ||
} | ||
return builder.build(); | ||
} | ||
|
||
/** | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this just be
127.0.0.1
? Why is there anhttp
prefix?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an endpoint, so the schema is part of it. Users will also use http vs https and the port will be parsed automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we using a http scheme for a gRPC endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gRPC can operate over HTTP. In this case, we use to parse the port. The .NET SDK for gRPC communication takes in the entire URL as an endpoint. See https://learn.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start?view=aspnetcore-7.0&tabs=visual-studio#create-the-greeter-client