-
Notifications
You must be signed in to change notification settings - Fork 124
feat: Load client config from arbitrary config block #1974
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,17 +46,22 @@ object GrpcClientSettings { | |
| * @param clientName of the client configuration to lookup config from the ActorSystem's config | ||
| */ | ||
| def fromConfig(clientName: String)(implicit actorSystem: ClassicActorSystemProvider): GrpcClientSettings = { | ||
| val system = actorSystem.classicSystem | ||
| val akkaGrpcClientConfig = system.settings.config.getConfig("akka.grpc.client") | ||
| val clientConfig = { | ||
| // Use config named "*" by default | ||
| val defaultServiceConfig = akkaGrpcClientConfig.getConfig("\"*\"") | ||
| require( | ||
| akkaGrpcClientConfig.hasPath(s""""$clientName""""), | ||
| s"Config path `akka.grpc.client.$clientName` does not exist") | ||
| akkaGrpcClientConfig.getConfig(s""""$clientName"""").withFallback(defaultServiceConfig) | ||
| } | ||
| val akkaGrpcClientConfig = actorSystem.classicSystem.settings.config.getConfig("akka.grpc.client") | ||
| fromConfig(clientName, akkaGrpcClientConfig) | ||
| } | ||
|
|
||
| /** | ||
| * Look up client settings from the given configuration. Will look for an entry with the given name client name | ||
| * directly in the config block. Each client configuration falls back to the defaults defined in reference.conf | ||
| * | ||
| * @param clientName of the client configuration to lookup config from the ActorSystem's config | ||
| */ | ||
| def fromConfig(clientName: String, config: Config)( | ||
| implicit actorSystem: ClassicActorSystemProvider): GrpcClientSettings = { | ||
| // Use config named "*" by default | ||
| val defaultServiceConfig = actorSystem.classicSystem.settings.config.getConfig("akka.grpc.client.\"*\"") | ||
|
Contributor
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. I was considering if this should be
Contributor
Author
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. Hmm, yeah, maybe not a bad idea.
Contributor
Author
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. Let's leave that and revisit in case we figure out that it is very useful. |
||
| require(config.hasPath(s""""$clientName""""), s"Config path `akka.grpc.client.$clientName` does not exist") | ||
| val clientConfig = config.getConfig(s""""$clientName"""").withFallback(defaultServiceConfig) | ||
| GrpcClientSettings.fromConfig(clientConfig) | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.