45 lines
2.5 KiB
HTML
45 lines
2.5 KiB
HTML
<!doctype html><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link rel=preconnect href=https://fonts.googleapis.com><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link href="https://fonts.googleapis.com/css2?family=Recursive:wght,CASL,MONO@300..800,0..1,0..1&display=swap" rel=stylesheet><link href=https://haunt98.github.io/iosevka_webfont/iosevka-term-ss08/iosevka-term-ss08.css rel=stylesheet><link rel=stylesheet href=styles.css><a href=index>Index</a><h1>Reload config</h1><p>This serves as design draft of reload config system<pre><code class=language-plantuml>@startuml Reload config
|
|
|
|
skinparam defaultFontName Iosevka Term SS08
|
|
|
|
participant admin
|
|
participant other_service
|
|
participant config_service
|
|
participant storage
|
|
|
|
== Admin handle ==
|
|
|
|
admin -> config_service: set/update/delete config
|
|
|
|
config_service -> storage: set/update/delete config
|
|
|
|
== Other service handle ==
|
|
|
|
other_service -> other_service: init service
|
|
|
|
activate other_service
|
|
|
|
other_service -> storage: make connection
|
|
|
|
loop
|
|
|
|
other_service -> storage: listen on config change
|
|
|
|
other_service -> other_service: save config to memory
|
|
|
|
end
|
|
|
|
deactivate other_service
|
|
|
|
other_service -> other_service: do business
|
|
|
|
activate other_service
|
|
|
|
other_service -> other_service: get config
|
|
|
|
other_service -> other_service: do other business
|
|
|
|
deactivate other_service
|
|
|
|
@enduml
|
|
</code></pre><p>Config storage can be any key value storage or database like etcd, Consul, mySQL, ...<p>If storage is key value storage, maybe there is API to listen on config change.<br>Otherwise we should create a loop to get all config from storage for some interval, for example each 5 minute.<p>Each <code>other_service</code> need to get config from its memory, not hit <code>storage</code>.<br>So there is some delay between upstream config (config in <code>storage</code>) and downstream config (config in <code>other_service</code>), but maybe we can forgive that delay (???).<p>Pros:<ul><li><p>Config can be dynamic, service does not need to restart to apply new config.<li><p>Each service only keep 1 connection to <code>storage</code> to listen to config change, not hit <code>storage</code> for each request.</ul><p>Cons:<ul><li>Each service has 1 more dependency, aka <code>storage</code>.<li>Need to handle fallback config, incase <code>storage</code> failure.<li>Delay between upstream/downstream config</ul><a href=mailto:hauvipapro+posts@gmail.com>Feel free to ask me via email</a> |