Centralized configuration management, including online editing, persistence, especially the change of the configuration data can be perceived in runtime.
we use Akka persistence/Http/Distributed Data. thanks for Akka toolkit, it make the source code number decreased dramatically,the core code number no more than 300 lines.
a Configuration = Group + Key + Value
Mini Configuration Center(miniconf) consists of two parts: server side and client jar.
-
server side
expose RESTful service(use Akka Http) and use local/distributed akka persistence to save Add/Edit/Query configuration events and use akka Distributed Data to disseminate configuration events between cluster nodes. -
client jar
provide scala and java interface.
the main class is miniconf.server.MainApp, you can run it.
- the main page url is http://your server ip:9000/ (the default port is 9000)
###conf
in conf directory, you can edit application.conf for custom need.
Reference configuration
# cluster configure detail
akka.cluster {
seed-nodes = [
"akka.tcp://miniconf-system@127.0.0.1:2551"]
auto-down-unreachable-after = 30s
}
akka {
remote {
log-remote-lifecycle-events = off
netty.tcp {
hostname = "127.0.0.1"
port = 2551
}
}
}
# http service configure detail
miniconf {
httpService {
interface = "127.0.0.1"
port = 9000
}
}
// create MiniConfClient instance
val theMiniConfClient = new MiniConfClient("http://localhost:9000")
// saveOneConfItem
theMiniConfClient.saveOneConfItem("g2", "k1", "gv2")
val theMiniConfClient = new MiniConfClient("http://localhost:9000")
theMiniConfClient.getOneConfItem("g2", "k1")
val theMiniConfClient = new MiniConfClient("http://localhost:9000")
theMiniConfClient.registerListener("g2", "k1", {newValue => System.out.println("conf have modified "+newValue)})
- use Spray and Jetty to expose Rest Services.
- use Akka Persistence and CQRS to save all configures in local.
- use Akka 2.3.4.
- use Akka HTTP to expose Rest Services.
- use Akka Persistence to persist all configures in local.
- use Akka Distributed Data to disseminate configuration events between cluster nodes.
- use Multi Node Testing to do integration test.
- use Akka 2.4.1.
- use Akka 2.5.1 and akka http 10.0.5
This code is open source software licensed under the Apache 2.0 License.