scala typesafe config库读取配置
这两天在看一个akka remote actor future超时的问题
之前的超时是在remoteActor里配置的
1 | def remoteActor = TypedActor.context.system.actorSelection(actorInfo.remoteActorPath) |
然后调用的时候是用1
Await.result(remoteActor.?(GetCarMonthlyInfo(date,parkCode))(Timeout.intToTimeout(5000000)), timeout)
结果发现还是会出现1
2
3
4
5
6
7
8
9
问题出在哪里呢?
其实出在TypedActor本身,默认配置读取的jar包里的reference.conf
```java
typed {
# Default timeout for typed actor methods with non-void return type
timeout = 5s
}
1 | TypedActor(system).DefaultReturnTimeout |
这里的配置会和应用的配置文件合并
1 | final val config: Config = { |
路径:config-1.2.1-sources.jar!\com\typesafe\config\impl\AbstractConfigValue.java1
2
3
4
5
6
7
8
9
10
11
12
13
14
15public AbstractConfigValue withFallback(ConfigMergeable mergeable) {
if (ignoresFallbacks()) {
return this;
} else {
ConfigValue other = ((MergeableValue) mergeable).toFallbackValue();
if (other instanceof Unmergeable) {
return mergedWithTheUnmergeable((Unmergeable) other);
} else if (other instanceof AbstractConfigObject) {
return mergedWithObject((AbstractConfigObject) other);
} else {
return mergedWithNonObject((AbstractConfigValue) other);
}
}
}