Skip to content

Commit c90cdec

Browse files
committed
Chore: refine build-platform-specific.sh
1 parent 8742e1d commit c90cdec

2 files changed

Lines changed: 70 additions & 115 deletions

File tree

_src/openraft-read/2023-12-17-openraft-read.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ excerpt: "Openraft 中对 linearizable read 流程的优化"
6161
也就是说 `(Term_0, index_0)` 这条 log 是 `read_0` 看到的最后一条 log.
6262
那么其中的 `Term_0` 就有3种情况:
6363

64-
- **case-gt**: `Term_0 > Term_1`:
64+
- **case-gt**: `Term_0 > Term_1`:
6565

6666
为避免这种不可处理的情况发生, Leader 在时间 `t` 向一个 quorum 发 heartbeat 请求, 以确认在时间范围 `(0, t)` 内都没有更高的 Term;
6767

@@ -76,9 +76,9 @@ excerpt: "Openraft 中对 linearizable read 流程的优化"
7676

7777
在这种情况下要保证 linearizable read, 就要求 `read_1` 读时的 StateMachine 至少要包含到 `NoopIndex` 的 log.
7878

79-
- **case-eq**: `Term_0 == Term_1`:
79+
- **case-eq**: `Term_0 == Term_1`:
8080

81-
对这种情况, 读操作 `read_0` 一定是在当前 node 执行的读操作;
81+
对这种情况, 读操作 `read_0` 一定是在当前 node 执行的读操作;
8282

8383
我们又知道由于 Raft 协议规定只有已经 commit 的 log 才能被读取, 所以 `read_0` 读到的数据一定是当前 CommitIndex 之前的, 即 `index_0 <= CommitIndex`;
8484

build-platform-specific.sh

Lines changed: 67 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
11
#!/bin/sh
22

3-
# fn="$(ls _posts/*$1* | head -n1)"
4-
5-
# if [ "$fn." = "." ]; then
6-
# echo "Usage: $0 <fn_pattern>"
7-
# exit 1
8-
# fi
9-
10-
3+
# === Build for copying to other platform only ===
4+
#
5+
# It looks like gitee no longer support external access with refer
6+
# --repo git@gitee.com:drdrxp/bed.git@openacid-$platform-import-assets \
117

12-
# for platform in wechat simple; do
13-
# md2zhihu \
14-
# -r git@gitee.com:drdrxp/bed.git@openacid \
15-
# -p $platform \
16-
# --keep-meta \
17-
# --code-width 600 \
18-
# $fn \
19-
# -o ${fn%.md}-$platform.md
8+
set -o errexit
209

21-
# done
10+
# for example:
11+
# https://pub-e254240c5c35410cb21a0cf4fb58f73e.r2.dev/2023-12-17-openraft-read.html
12+
url_base="https://pub-e254240c5c35410cb21a0cf4fb58f73e.r2.dev"
2213

2314

24-
# === Build for copying to other platform only ===
25-
#
26-
# The assets do not need to be kept after publishing on other platforms.
2715

2816
# Call xp-md2html to convert md to html, using github-markdown.css
29-
# xp-md2html is my local rust repo
17+
# xp-md2html is a personal repo
3018
md2html()
3119
{
3220
local src_path="$1"
@@ -36,7 +24,6 @@ md2html()
3624

3725
{
3826
cat <<-END
39-
4027
<!doctype html>
4128
<html>
4229
<head>
@@ -63,7 +50,6 @@ md2html()
6350
<article class="markdown-body">
6451
END
6552

66-
# skip '---'
6753
cat "$src_path" | xp-md2html
6854

6955
cat <<-END
@@ -76,94 +62,63 @@ END
7662
} > "$output_path"
7763
}
7864

79-
# for example:
80-
# https://pub-e254240c5c35410cb21a0cf4fb58f73e.r2.dev/2023-12-17-openraft-read.html
81-
url_base="https://pub-e254240c5c35410cb21a0cf4fb58f73e.r2.dev"
82-
83-
84-
85-
fn=_src/openraft-read/2023-12-17-openraft-read.md
86-
name=${fn##*/}
87-
name=${name%.md}
88-
title=${name#20??-??-??-}
89-
90-
echo "fn: $fn"
91-
echo "name: $name"
92-
echo "title: $title"
93-
94-
95-
# Build local markdown
96-
mkdir -p md2-local
97-
98-
# reference local resource
99-
platform=wechat
100-
md2zhihu \
101-
--platform $platform \
102-
--code-width 600 \
103-
--refs _data/refs.yml \
104-
--output-dir ./md2-local \
105-
--asset-output-dir ./md2-local/ \
106-
--md-output ./md2-local/$name.md \
107-
$fn
108-
109-
# reference remote resource
110-
md2zhihu \
111-
--platform $platform \
112-
--code-width 600 \
113-
--refs _data/refs.yml \
114-
--output-dir ./md2-local \
115-
--asset-output-dir ./md2-local/ \
116-
--md-output ./md2-local/$name-remote.md \
117-
--rewrite "^$title/" "$url_base/$title/" \
118-
$fn
119-
120-
cp assets/images/qrcode-hori.jpg ./md2-local/
121-
cp assets/css/github-markdown.css ./md2-local/
122-
123-
# Build html
124-
md2html "./md2-local/$name.md" "./md2-local/$name.html"
125-
md2html "./md2-local/$name-remote.md" "./md2-local/$name-remote.html"
126-
127-
# Upload
128-
aws s3 sync ./md2-local/ s3://bed/
129-
130-
echo ""
131-
echo "$url_base/$name.html"
132-
echo "$url_base/$name-remote.html"
133-
134-
exit 0
135-
136-
# Build zhihu specific md
137-
#
138-
# Usage: import md to zhihu
139-
140-
platform=zhihu
141-
md2zhihu \
142-
--platform $platform \
143-
--code-width 600 \
144-
--refs _data/refs.yml \
145-
--output-dir ./md2-$platform \
146-
--asset-output-dir ./md2-$platform/ \
147-
--md-output ./md2-$platform/ \
148-
--repo git@gitee.com:drdrxp/bed.git@openacid-$platform-import-assets \
149-
$fn
150-
151-
152-
# Build wechat specific html.
153-
# Render it to the last article.
154-
#
155-
# Usage: push and let github build it and copy the html on a browser.
156-
157-
platform=wechat
158-
md2zhihu \
159-
--platform $platform \
160-
--code-width 600 \
161-
--refs _data/refs.yml \
162-
--keep-meta \
163-
--output-dir ./md2-$platform \
164-
--asset-output-dir ./md2-$platform/ \
165-
--md-output ./_posts/2000-01-01-wechat-import.md \
166-
--repo git@gitee.com:drdrxp/bed.git@openacid-$platform-import-assets \
167-
$fn
16865

66+
build()
67+
{
68+
local platform="$1"
69+
local fn="$2"
70+
71+
local name_suffix=${fn##*/}
72+
local name=${name_suffix%.md}
73+
# remove date
74+
local title=${name#20??-??-??-}
75+
76+
echo ""
77+
echo "fn: $fn"
78+
echo "name: $name"
79+
echo "title: $title"
80+
echo ""
81+
82+
# Build local markdown
83+
mkdir -p md2-local
84+
85+
# reference local resource
86+
md2zhihu \
87+
--platform $platform \
88+
--code-width 600 \
89+
--refs _data/refs.yml \
90+
--output-dir ./md2-local \
91+
--asset-output-dir ./md2-local/ \
92+
--md-output ./md2-local/$name-$platform.md \
93+
$fn
94+
95+
# reference remote resource
96+
md2zhihu \
97+
--platform $platform \
98+
--code-width 600 \
99+
--refs _data/refs.yml \
100+
--output-dir ./md2-local \
101+
--asset-output-dir ./md2-local/ \
102+
--md-output ./md2-local/$name-$platform-remote.md \
103+
--rewrite "^$title/" "$url_base/$title/" \
104+
$fn
105+
106+
cp assets/images/qrcode-hori.jpg ./md2-local/
107+
cp assets/css/github-markdown.css ./md2-local/
108+
109+
# Build html
110+
md2html "./md2-local/$name-$platform.md" "./md2-local/$name-$platform.html"
111+
md2html "./md2-local/$name-$platform-remote.md" "./md2-local/$name-$platform-remote.html"
112+
113+
# Upload
114+
aws s3 sync ./md2-local/ s3://bed/
115+
116+
echo "Built online md:"
117+
echo ""
118+
echo " $url_base/$name-$platform.html"
119+
echo " $url_base/$name-$platform-remote.html"
120+
echo ""
121+
}
169122

123+
build "wechat" _src/openraft-read/2023-12-17-openraft-read.md
124+
build "wechat" _src/openraft-read/raft-read-proof.md

0 commit comments

Comments
 (0)