-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add support SSL/TLS connection (832) #930
Conversation
override def toString: String = ssl match { | ||
case true => s"rediss://$host:$port" | ||
case false => s"redis://$host:$port" | ||
} |
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.
override def toString: String = ssl match { | |
case true => s"rediss://$host:$port" | |
case false => s"redis://$host:$port" | |
} | |
override def toString: String = | |
if (ssl) s"rediss://$host:$port" else s"redis://$host:$port" |
@@ -101,7 +101,7 @@ object Output { | |||
val host = MultiStringOutput.unsafeDecode(values(0)) | |||
val port = LongOutput.unsafeDecode(values(1)) | |||
val nodeId = MultiStringOutput.unsafeDecode(values(2)) | |||
Node(nodeId, RedisUri(host, port.toInt)) | |||
Node(nodeId, RedisUri(host, port.toInt, false, None)) |
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.
Same here.
ZIO.attempt(docker.getServiceHost(s"cluster-node-$n", port)).map(host => RedisUri(host, port)) | ||
ZIO | ||
.attempt(docker.getServiceHost(s"cluster-node-$n", port)) | ||
.map(host => RedisUri(host, port, false, None)) |
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.
RedisUri change looks unnecessary (see RedisUri.apply
).
@@ -31,7 +31,7 @@ trait BaseSpec extends ZIOSpecDefault { | |||
for { | |||
docker <- ZIO.service[DockerComposeContainer] | |||
hostAndPort <- docker.getHostAndPort(BaseSpec.MasterNode)(6379) | |||
uri = RedisUri(hostAndPort._1, hostAndPort._2) | |||
uri = RedisUri(hostAndPort._1, hostAndPort._2, false, None) |
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 looks unnecessary (see RedisUri.apply
).
ssl: Boolean = false, | ||
sni: Option[String] = None, |
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.
Please keep the alphabetical ordering.
@@ -161,7 +161,7 @@ private[redis] object ClusterExecutor { | |||
private def redis(address: RedisUri) = | |||
for { | |||
closableScope <- Scope.make | |||
configLayer = ZLayer.succeed(RedisConfig(address.host, address.port)) | |||
configLayer = ZLayer.succeed(RedisConfig(address.host, address.port, address.ssl)) |
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.
What happened with sni
?
channel <- ssl match { | ||
case true => openTlsChannel(address, sni) | ||
case false => openChannel(address) | ||
} |
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.
channel <- ssl match { | |
case true => openTlsChannel(address, sni) | |
case false => openChannel(address) | |
} | |
channel <- if (ssl) openTlsChannel(address, sni) else openChannel(address) |
val sslContext = SSLContext.getDefault() | ||
val sslEngine = sslContext.createSSLEngine() | ||
val params = sslEngine.getSSLParameters | ||
sni match { |
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.
foreach
rawChannel.finishConnect() | ||
rawChannel.register(selector, SelectionKey.OP_WRITE) | ||
val channelGroup = new AsynchronousTlsChannelGroup() | ||
val channel = new AsynchronousTlsChannel(channelGroup, tlsChannel, rawChannel) |
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.
No need for this val
.
): ZIO[Scope, IOException, AsynchronousTlsChannel] = | ||
ZIO.fromAutoCloseable { | ||
for { | ||
channel <- ZIO.attempt { |
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.
I'd extract the attempt
block into a function, something like createChannel
Closes #832
Hi,
I added support for SSL/TLS