Comments (6)
ConfigFactory.load()
resolves the default configuration before it is merged with your overridden one. So all substitution are already replaced. What you want is to resolve the configuration after the merge occurred.
If you want to override the reference.conf
by a string in your code, you should merge with the unresolved default configuration. Something like:
private val config = ConfigFactory.parseString(
"""
akka {
persistence.journal.plugin = "akka-persistence-redis.journal"
}
akka-persistence-redis {
redis {
host = redis
}
}
""".stripMargin
).withFallback(ConfigFactory.parseResources("reference.conf")).resolve()
However I would recommend to use the standard mechanism described in the documentation
from akka-persistence-redis.
What? I don't thinks so, it is just a fallback for the primary :
private val config = ConfigFactory.parseString(
"""
akka {
persistence.journal.plugin = "akka-persistence-redis.journal"
}
akka-persistence-redis {
redis {
host = redis
}
}
""".stripMargin
).withFallback(ConfigFactory.load())
println(config.getString("akka-persistence-redis.redis.host"))
println(config.getString("akka-persistence-redis.redis.mode"))
Prints :
redis
simple
from akka-persistence-redis.
Yes, because the merge overrides the specific host key you are querying.
But the journal uses a substitution which default to to akka-persistence-redis.redis
which is resolved by the load
method before the merge occurs.
Try:
println(config.getConfig("akka-persistence-redis.journal.redis"))
Please try my solution and you will see the difference. That’s just the way the config library works.
from akka-persistence-redis.
Hmm, I still can't make it work :
redis.conf :
akka {
extensions = ["com.romix.akka.serialization.kryo.KryoSerializationExtension$"]
persistence.journal.plugin = "akka-persistence-redis.journal"
}
akka-persistence-redis {
redis {
host = redis
}
}
val system = ActorSystem("example", ConfigFactory.load("redis").withFallback(ConfigFactory.parseResources("reference.conf")).resolve())
Still connecting to localhost :-/
from akka-persistence-redis.
Still the same problem. load
resolves, but the resolution mechanism does not allow to resolve substitution in reference
that are overridden in application
(or redis
in your case) (see the documentation)
For your example to work, either provide your overloading in a reference.conf
file and simply call Configfactory.load
or try the solution I gave you, where we only parse (hence without resolving) all the configuration, then merge them, and finally resolve the result. Remember that load
method do resolve things.
ConfigFactory.load("redis")
parses, merges, and resolve all the reference.conf
files in your classpath, then parses redis.conf
, merges it with the already merged and resolved references.conf
, and resolves the result. What you want is to merge before any resolution is performed and that’s exactly what my first solution does.
Another way to do it is to have a redis.conf
file that looks like this:
akka {
persistence.journal.plugin = "akka-persistence-redis.journal"
}
akka-persistence-redis {
redis {
host = redis
}
journal.redis = ${akka-persistence-redis.redis}
}
and then just ConfigFactory.load("redis")
from akka-persistence-redis.
I see, 🤦♂️ I grasp the problem now, thank you for your help and patience @satabin
from akka-persistence-redis.
Related Issues (19)
- Publish on maven central
- Unexpected source state when querying: 2 HOT 2
- Problem with eventsByPersistenceId using large sequence number ranges HOT 4
- ScalaReadJournal cannot be instantiated in a test HOT 1
- Only call stage method in callback
- Using sentinel config fails with journal queries HOT 4
- What is the difference between hootsuite/akka-persistence-redis ? HOT 8
- Publish scaladoc
- bump to akkaVersion = "2.5.17" ? HOT 3
- why is it always looking for localhost ? HOT 7
- persistent query reader as competing consumer HOT 1
- Add support for scala 2.13.0
- Documentation akka.persistence.snapshot.plugin HOT 1
- Add support for sentinel server
- redis.actors.ReplyErrorException: NOAUTH Authentication required.
- upgrade akka version HOT 2
- "Redis query EventsByTag must not see new events after complete" test is not implemented properly HOT 8
- tagsKey set is not used anywhere
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from akka-persistence-redis.