2023-07-18 18:38:30 +00:00
|
|
|
<!doctype html>
|
2022-12-25 19:13:58 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
<link
|
|
|
|
rel="stylesheet"
|
2024-02-04 15:04:33 +00:00
|
|
|
href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.5.1/github-markdown.min.css"
|
2022-12-25 19:13:58 +00:00
|
|
|
/>
|
2023-04-01 03:37:48 +00:00
|
|
|
<title>haunt98 posts</title>
|
2022-12-25 19:13:58 +00:00
|
|
|
</head>
|
|
|
|
<style>
|
|
|
|
.markdown-body {
|
|
|
|
box-sizing: border-box;
|
|
|
|
min-width: 200px;
|
|
|
|
max-width: 980px;
|
|
|
|
margin: 0 auto;
|
|
|
|
padding: 45px;
|
2024-03-01 10:11:20 +00:00
|
|
|
font-family:
|
|
|
|
Shantell Sans Normal,
|
|
|
|
Rec Mono Casual,
|
|
|
|
SF Pro,
|
|
|
|
Inter,
|
|
|
|
sans-serif;
|
|
|
|
font-weight: 500;
|
|
|
|
}
|
|
|
|
|
|
|
|
.markdown-body pre {
|
|
|
|
font-family:
|
|
|
|
Berkeley Mono,
|
|
|
|
IBM Plex Mono,
|
|
|
|
SF Mono,
|
|
|
|
Jetbrains Mono,
|
|
|
|
monospace;
|
2022-12-25 19:13:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 767px) {
|
|
|
|
.markdown-body {
|
|
|
|
padding: 15px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<body class="markdown-body">
|
2023-08-09 07:22:58 +00:00
|
|
|
<h2>
|
|
|
|
<a href="index.html"><code>~</code></a>
|
|
|
|
</h2>
|
2024-02-29 12:29:26 +00:00
|
|
|
<div class="markdown-heading">
|
|
|
|
<h1 class="heading-element">Reload config</h1>
|
2023-11-19 15:59:21 +00:00
|
|
|
<a
|
|
|
|
id="user-content-reload-config"
|
2024-03-08 08:12:41 +00:00
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
aria-label="Permalink: Reload config"
|
2023-11-19 15:59:21 +00:00
|
|
|
href="#reload-config"
|
2024-02-29 12:29:26 +00:00
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
></a>
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
<p>This serves as design draft of reload config system</p>
|
|
|
|
<div class="highlight highlight-source-wsd">
|
|
|
|
<pre><span class="pl-k">@startuml</span> Reload config
|
2022-12-25 19:13:58 +00:00
|
|
|
|
|
|
|
<span class="pl-k">skinparam</span> <span class="pl-k">defaultFontName</span> <span class="pl-s">Iosevka Term SS08</span>
|
|
|
|
|
|
|
|
<span class="pl-k">participant</span> <span class="pl-c1">admin</span>
|
|
|
|
<span class="pl-k">participant</span> <span class="pl-c1">other_service</span>
|
|
|
|
<span class="pl-k">participant</span> <span class="pl-c1">config_service</span>
|
|
|
|
<span class="pl-k">participant</span> <span class="pl-c1">storage</span>
|
|
|
|
|
|
|
|
<span class="pl-k">==</span> <span class="pl-s">Admin handle</span> <span class="pl-k">==</span>
|
|
|
|
|
|
|
|
<span class="pl-c1">admin</span> <span class="pl-k">-></span> <span class="pl-c1">config_service</span>: set/update/delete config
|
|
|
|
|
|
|
|
<span class="pl-c1">config_service</span> <span class="pl-k">-></span> <span class="pl-c1">storage</span>: set/update/delete config
|
|
|
|
|
|
|
|
<span class="pl-k">==</span> <span class="pl-s">Other service handle</span> <span class="pl-k">==</span>
|
|
|
|
|
|
|
|
<span class="pl-c1">other_service</span> <span class="pl-k">-></span> <span class="pl-c1">other_service</span>: init service
|
|
|
|
|
|
|
|
<span class="pl-k">activate</span> <span class="pl-c1">other_service</span>
|
|
|
|
|
|
|
|
<span class="pl-c1">other_service</span> <span class="pl-k">-></span> <span class="pl-c1">storage</span>: make connection
|
|
|
|
|
|
|
|
<span class="pl-k">loop</span>
|
|
|
|
|
|
|
|
<span class="pl-c1">other_service</span> <span class="pl-k">-></span> <span class="pl-c1">storage</span>: listen on config change
|
|
|
|
|
|
|
|
<span class="pl-c1">other_service</span> <span class="pl-k">-></span> <span class="pl-c1">other_service</span>: save config to memory
|
|
|
|
|
|
|
|
<span class="pl-k">end</span>
|
|
|
|
|
|
|
|
<span class="pl-k">deactivate</span> <span class="pl-c1">other_service</span>
|
|
|
|
|
|
|
|
<span class="pl-c1">other_service</span> <span class="pl-k">-></span> <span class="pl-c1">other_service</span>: do business
|
|
|
|
|
|
|
|
<span class="pl-k">activate</span> <span class="pl-c1">other_service</span>
|
|
|
|
|
|
|
|
<span class="pl-c1">other_service</span> <span class="pl-k">-></span> <span class="pl-c1">other_service</span>: get config
|
|
|
|
|
|
|
|
<span class="pl-c1">other_service</span> <span class="pl-k">-></span> <span class="pl-c1">other_service</span>: do other business
|
|
|
|
|
|
|
|
<span class="pl-k">deactivate</span> <span class="pl-c1">other_service</span>
|
|
|
|
|
2022-12-30 09:26:06 +00:00
|
|
|
<span class="pl-k">@enduml</span></pre>
|
|
|
|
</div>
|
|
|
|
<p>
|
|
|
|
Config storage can be any key value storage or database like etcd, Consul,
|
|
|
|
mySQL, ...
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
If storage is key value storage, maybe there is API to listen on config
|
|
|
|
change. Otherwise we should create a loop to get all config from storage
|
|
|
|
for some interval, for example each 5 minute.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
Each <code>other_service</code> need to get config from its memory, not
|
|
|
|
hit <code>storage</code>. 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>
|
|
|
|
<p>Pros:</p>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<p>
|
|
|
|
Config can be dynamic, service does not need to restart to apply new
|
|
|
|
config.
|
|
|
|
</p>
|
|
|
|
</li>
|
|
|
|
<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.
|
|
|
|
</p>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p>Cons:</p>
|
|
|
|
<ul>
|
|
|
|
<li>Each service has 1 more dependency, aka <code>storage</code>.</li>
|
|
|
|
<li>
|
|
|
|
Need to handle fallback config, incase <code>storage</code> failure.
|
|
|
|
</li>
|
|
|
|
<li>Delay between upstream/downstream config</li>
|
|
|
|
</ul>
|
2022-12-25 19:13:58 +00:00
|
|
|
|
2022-12-25 19:22:39 +00:00
|
|
|
<div>
|
|
|
|
Feel free to ask me via
|
|
|
|
<a href="mailto:hauvipapro+posts@gmail.com">email</a> or
|
2023-08-20 17:29:13 +00:00
|
|
|
<a rel="me" href="https://hachyderm.io/@haunguyen">Mastodon</a>.
|
|
|
|
<br />Source code is available on
|
2022-12-30 09:55:38 +00:00
|
|
|
<a href="https://github.com/haunt98/posts-go">GitHub</a>
|
2023-08-20 17:29:13 +00:00
|
|
|
<a href="https://codeberg.org/yoshie/posts-go">Codeberg</a>
|
|
|
|
<a href="https://git.sr.ht/~youngyoshie/posts-go">sourcehut</a>
|
|
|
|
<a href="https://gitea.treehouse.systems/yoshie/posts-go">Treehouse</a>
|
|
|
|
<a href="https://gitlab.com/youngyoshie/posts-go">GitLab</a>
|
2022-12-25 19:22:39 +00:00
|
|
|
</div>
|
2022-12-25 19:13:58 +00:00
|
|
|
</body>
|
|
|
|
</html>
|