-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow configuring clients from application.conf (#254)
- Loading branch information
Showing
3 changed files
with
98 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
akka.grpc.client."*" { | ||
host = "" | ||
port = 0 | ||
deadline = infinite | ||
override-authority = "" | ||
trusted-ca-certificate = "" | ||
user-agent = "" | ||
} |
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
46 changes: 46 additions & 0 deletions
46
runtime/src/test/scala/akka/grpc/GrpcClientSettingsSpec.scala
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,46 @@ | ||
/* | ||
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package akka.grpc | ||
|
||
import com.typesafe.config.ConfigFactory | ||
|
||
import scala.concurrent.duration._ | ||
|
||
import akka.actor.ActorSystem | ||
|
||
import org.scalatest.{ Matchers, WordSpec } | ||
|
||
class GrpcClientSettingsSpec extends WordSpec with Matchers { | ||
"The gRPC client settings spec" should { | ||
val sys = ActorSystem("test", ConfigFactory.parseString( | ||
""" | ||
|akka.grpc.client { | ||
| "project.WithSpecificConfiguration" { | ||
| host = "myhost" | ||
| port = 42 | ||
| override-authority = "google.fr" | ||
| trusted-ca-certificate = "ca.pem" | ||
| deadline = 10m | ||
| user-agent = "Akka-gRPC" | ||
| } | ||
|} | ||
""".stripMargin).withFallback(ConfigFactory.load())) | ||
|
||
"fall back to the default configuration if no specific configuration is found" in { | ||
// Should not crash: | ||
GrpcClientSettings("project.WithoutSpecificConfiguration", sys) | ||
} | ||
|
||
"parse configuration values" in { | ||
val parsed = GrpcClientSettings("project.WithSpecificConfiguration", sys) | ||
parsed.host should be("myhost") | ||
parsed.port should be(42) | ||
parsed.overrideAuthority should be(Some("google.fr")) | ||
parsed.trustedCaCertificate should be(Some("ca.pem")) | ||
parsed.deadline should be(10.minutes) | ||
parsed.userAgent should be(Some("Akka-gRPC")) | ||
} | ||
} | ||
} |