-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCargo.toml
More file actions
209 lines (182 loc) · 7.55 KB
/
Copy pathCargo.toml
File metadata and controls
209 lines (182 loc) · 7.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
[package]
name = "shortlinker"
version = "0.6.0"
description = "A minimalist URL shortener service supporting HTTP 307 redirection, built with Rust. Easy to deploy and lightning fast."
authors = ["AptS-1547 <apts-1547@esaps.net>"]
repository = "https://github.com/AptS-1547/shortlinker"
edition = "2024"
rust-version = "1.95.0"
[features]
default = ["server", "cli"] # 默认启用服务器和CLI功能
server = [] # 服务器功能(核心)
cli = ["server"] # CLI功能(依赖服务器)
metrics = [
"server",
"aster_forge_actix_observability/prometheus",
"aster_forge_metrics/backend-prometheus",
] # Prometheus 指标导出
openapi = [
"server",
"dep:utoipa",
"aster_forge_api_docs_macros/openapi",
] # OpenAPI 文档和前端类型生成
full = ["server", "cli", "metrics", "openapi"] # 全功能版本
# 开发构建优先缩短「改代码 -> 编译/测试」的反馈时间。
# 工作区代码保持 O0 以避免每次修改后重做优化;第三方依赖单独使用 O1,
# 避免 crypto/image/compression 等依赖在 debug/test 运行时过慢。
[profile.dev]
opt-level = 0
lto = false
codegen-units = 256
debug = 1
panic = "unwind"
strip = false
incremental = true
[profile.dev.package."*"]
opt-level = 1
debug = false
[profile.release]
opt-level = 2
lto = true
codegen-units = 1
# Keep ordinary request/task panics from taking down every HTTP worker. Stack overflow and OOM
# remain process-fatal and must be prevented at their input/allocation boundaries.
panic = "unwind"
strip = true
# 压测/火焰图采样用:接近 release,但保留符号并关闭 LTO,方便 perf 展开栈。
# frame pointer 需要通过 RUSTFLAGS 传入:
# RUSTFLAGS="-C force-frame-pointers=yes" cargo build --profile profiling
[profile.profiling]
inherits = "release"
opt-level = 2
codegen-units = 1
debug = true
strip = false
lto = false
panic = "unwind"
[profile.release-performance]
inherits = "release"
opt-level = 3
codegen-units = 1
panic = "abort"
strip = true
# 添加库配置
[lib]
name = "shortlinker"
path = "src/lib.rs"
# 二进制配置
[[bin]]
name = "shortlinker"
path = "src/main.rs"
[workspace]
members = [".", "migration"]
[dependencies]
aster_forge_actix_middleware = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_actix_middleware", features = ["metrics"] }
aster_forge_actix_observability = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_actix_observability" }
aster_forge_api_docs_macros = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_api_docs_macros" }
aster_forge_cache = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_cache", features = ["bloom", "memory", "redis"] }
aster_forge_config = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_config" }
aster_forge_crypto = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_crypto" }
aster_forge_db = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_db", features = ["system-config"] }
aster_forge_logging = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_logging" }
aster_forge_metrics = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_metrics" }
aster_forge_panic = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_panic" }
aster_forge_runtime = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_runtime" }
aster_forge_tasks = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_tasks", features = ["runtime-component"] }
aster_forge_utils = { git = "https://github.com/AsterCommunity/AsterForge", package = "aster_forge_utils" }
clap = { version = "4", features = ["derive"] }
migration = { path = "migration" }
actix-web = { version = "4.14", features = ["compress-brotli", "compress-gzip"] }
config = "0.15"
dotenvy = "0.15"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_repr = "0.1"
rand = { version = "0.10.2", default-features = false, features = ["std", "std_rng", "thread_rng"] }
chrono = { version = "0.4.45", default-features = false, features = ["clock", "serde"] }
async-trait = "0.1.92"
tokio = { version = "1.53.1", default-features = false, features = ["rt-multi-thread", "macros", "net", "io-util", "time"] }
bytes = "1.12"
tracing = { version = "0.1.44", default-features = false }
dashmap = "6.2.1"
crossbeam-channel = "0.5"
moka = { version = "0.12.16", default-features = false, features = ["future", "sync"] }
colored = "3.1.1"
num_cpus = { version = "1.17.0", default-features = false }
actix-service = "2.0.3"
futures-util = "0.3.34"
anyhow = { version = "1.0.104", features = ["backtrace"] }
rust-embed = "8.12.0"
uuid = { version = "1.24", features = ["v4"] }
rustls = "0.23.43"
toml = "1.1"
sea-orm = { version = "2.0.1", default-features = false, features = ["sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", "macros", "runtime-tokio-rustls", "chrono"] }
jsonwebtoken = { version = "11", features = ["rust_crypto"] }
arc-swap = "1"
actix-cors = "0.7"
utoipa = { version = "5.5.0", features = ["actix_extras", "chrono", "repr"], optional = true }
csv = "1.4"
actix-multipart = "0.8"
strum = { version = "0.28", features = ["derive"] }
governor = "0.10.4"
actix-governor = "0.10.0"
rpassword = "7"
tokio-util = "0.7"
subtle = "2"
base64 = "0.23"
maxminddb = "0.30"
ureq = { version = "3.4.0", features = ["json"] }
xxhash-rust = { version = "0.8", features = ["xxh64"] }
woothee = "0.13"
urlencoding = "2.1.3"
[target.'cfg(unix)'.dependencies]
nix = { version = "0.31", default-features = false, features = ["signal", "process"] }
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = [
"Win32_Foundation",
"Win32_Security",
"Win32_Security_Authorization",
"Win32_System_Console",
] }
[dev-dependencies]
actix-rt = "2.11"
tempfile = "3.27"
tokio = { version = "1.53.1", features = ["full"] }
criterion = { version = "0.8", features = ["async_tokio"] }
[[bench]]
name = "click_manager"
harness = false
[[bench]]
name = "password"
harness = false
[[bench]]
name = "utils"
harness = false
[[bench]]
name = "converters"
harness = false
[[bench]]
name = "ipc_protocol"
harness = false
[[bench]]
name = "import_conflict"
harness = false
# cargo-binstall 配置
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_{ target }{ binary-ext }"
bin-dir = "shortlinker_{ version }_{ target }{ binary-ext }"
pkg-fmt = "bin"
[package.metadata.binstall.overrides.x86_64-apple-darwin]
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_macos_x86_64"
[package.metadata.binstall.overrides.aarch64-apple-darwin]
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_macos_aarch64"
[package.metadata.binstall.overrides.x86_64-unknown-linux-gnu]
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_linux_x86_64"
[package.metadata.binstall.overrides.x86_64-unknown-linux-musl]
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_linux_x86_64"
[package.metadata.binstall.overrides.aarch64-unknown-linux-gnu]
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_linux_aarch64"
[package.metadata.binstall.overrides.x86_64-pc-windows-gnu]
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_windows_x86_64.exe"
[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-url = "{ repo }/releases/download/{ version }/shortlinker_{ version }_windows_x86_64.exe"