Skip to content

Commit

Permalink
fix(kotlin-runtime): correctly determine port for FTL endpoint (#464)
Browse files Browse the repository at this point in the history
Also close TODO for supporting https.
  • Loading branch information
alecthomas authored Oct 6, 2023
1 parent 238369f commit e54edd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions bin/hermit.hcl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
env = {
"FTL_ENDPOINT": "http://localhost:8892",
"FTL_SOURCE": "${HERMIT_ENV}",
"GOOSE_DBSTRING": "postgres://postgres:[email protected]:5432/ftl",
"GOOSE_DRIVER": "postgres",
"OTEL_METRIC_EXPORT_INTERVAL": "5000",
"PATH": "${HERMIT_ENV}/scripts:${HERMIT_ENV}/console/client/node_modules/.bin:${PATH}",
}
sources = ["env:///bin/packages", "https://github.com/cashapp/hermit-packages.git"]
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ import java.util.concurrent.TimeUnit.SECONDS

internal fun makeGrpcClient(endpoint: String): ManagedChannel {
val url = URL(endpoint)
// TODO: Check if URL is https and use SSL?
return NettyChannelBuilder
.forAddress(InetSocketAddress(url.host, url.port))
val port = if (url.port == -1) when (url.protocol) {
"http" -> 80
"https" -> 443
else -> throw IllegalArgumentException("Unsupported protocol: ${url.protocol}")
} else url.port
var builder = NettyChannelBuilder
.forAddress(InetSocketAddress(url.host, port))
.keepAliveTime(5, SECONDS)
.intercept(VerbServiceClientInterceptor())
.usePlaintext()
.build()
if (url.protocol == "http")
builder = builder.usePlaintext()
return builder.build()
}

private class VerbServiceClientInterceptor : ClientInterceptor {
Expand Down

0 comments on commit e54edd2

Please sign in to comment.