mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 09:40:32 +00:00
Compare commits
1186 Commits
1.0.0-alph
...
dev_object
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9948b1f709 | ||
|
|
4d67c1d0a6 | ||
|
|
ff264f3385 | ||
|
|
ff4da5cd47 | ||
|
|
4cc915fb45 | ||
|
|
751abeca2b | ||
|
|
5ab2ce3cfe | ||
|
|
4d26fa48d7 | ||
|
|
5c65368729 | ||
|
|
c16ce7b61b | ||
|
|
25388ba70c | ||
|
|
9cc34f9f01 | ||
|
|
02ad3d3832 | ||
|
|
1c5ba761ef | ||
|
|
7fec5b250a | ||
|
|
c861635332 | ||
|
|
f4d0a81e06 | ||
|
|
b6a5094382 | ||
|
|
9865b5aa3e | ||
|
|
5850c3e8a3 | ||
|
|
b52198d7f2 | ||
|
|
58c3a46138 | ||
|
|
bd4e7c23bb | ||
|
|
66c2a2fd93 | ||
|
|
cdd41752e0 | ||
|
|
bf407715d0 | ||
|
|
5e3c97b0e9 | ||
|
|
2f20fe9749 | ||
|
|
5e13fc3be2 | ||
|
|
1d45123968 | ||
|
|
03af4369bd | ||
|
|
88b2d893dc | ||
|
|
756e70cc93 | ||
|
|
d2a0c9fd62 | ||
|
|
d6de724517 | ||
|
|
8dfb3643ec | ||
|
|
d2857467e0 | ||
|
|
8887b7ea90 | ||
|
|
18ca25fbfd | ||
|
|
f3c1116935 | ||
|
|
2fd5ef75cf | ||
|
|
c673fa0e3d | ||
|
|
707406e4c5 | ||
|
|
8a7a6599c8 | ||
|
|
881afbfae6 | ||
|
|
e050fffcae | ||
|
|
41e378fc28 | ||
|
|
751be4bdf6 | ||
|
|
659869e8ad | ||
|
|
52da2569dd | ||
|
|
c9ff699030 | ||
|
|
3a32517f79 | ||
|
|
d5539bf22f | ||
|
|
1993a7036f | ||
|
|
0782f05388 | ||
|
|
2f697d0635 | ||
|
|
ad2c1a15b7 | ||
|
|
5ef7571211 | ||
|
|
b0174122c8 | ||
|
|
7f70ab3cd6 | ||
|
|
fefa8cb2c8 | ||
|
|
ae4c23e316 | ||
|
|
fffc79e981 | ||
|
|
4cd2c8e99c | ||
|
|
a8bd8809b0 | ||
|
|
6f7d279fce | ||
|
|
bcbd72d849 | ||
|
|
b73e4ac7e8 | ||
|
|
ea8dfa43a4 | ||
|
|
b50e88a5a0 | ||
|
|
b0447bb692 | ||
|
|
9ec22255e0 | ||
|
|
249a46bc8e | ||
|
|
920551ca92 | ||
|
|
f056b3fb44 | ||
|
|
b675e01707 | ||
|
|
1c93a5e4e0 | ||
|
|
d65c58d9de | ||
|
|
28a8977308 | ||
|
|
35cf7db9ed | ||
|
|
e1513aa00e | ||
|
|
670636b3aa | ||
|
|
2b62560f48 | ||
|
|
01a340d596 | ||
|
|
3a6e3d49b3 | ||
|
|
86a99d214c | ||
|
|
7fe325f47e | ||
|
|
671263e22c | ||
|
|
e4e923b4b2 | ||
|
|
87482e82f4 | ||
|
|
902993a133 | ||
|
|
609e55a5a2 | ||
|
|
1e3287f610 | ||
|
|
27c6030f09 | ||
|
|
1e00db816c | ||
|
|
366fd98aeb | ||
|
|
f1ef7149e3 | ||
|
|
ab88166990 | ||
|
|
34dadee8a6 | ||
|
|
021dc36f2f | ||
|
|
09b24d5d41 | ||
|
|
947ced1d92 | ||
|
|
8f01696dbe | ||
|
|
bfb4c6dfd4 | ||
|
|
992b0c2cb6 | ||
|
|
01220f88d9 | ||
|
|
42e020c0bb | ||
|
|
4e5d6ff772 | ||
|
|
ea4a225d70 | ||
|
|
d4bd8b66a9 | ||
|
|
defdcf528f | ||
|
|
69cb6ead25 | ||
|
|
0403c23492 | ||
|
|
413d581d7c | ||
|
|
1777994de7 | ||
|
|
e8efd8ef79 | ||
|
|
1380598a0c | ||
|
|
142281e96a | ||
|
|
af6bb3ae5b | ||
|
|
9734d4cfa5 | ||
|
|
9ad152c14f | ||
|
|
b40b6a17f4 | ||
|
|
eae1ccc629 | ||
|
|
295b502e2a | ||
|
|
a3214222af | ||
|
|
257e858017 | ||
|
|
9c90426032 | ||
|
|
5c7b105b4a | ||
|
|
a032c401d1 | ||
|
|
a608e0dd65 | ||
|
|
2ef98ee43a | ||
|
|
8d4e68fe5f | ||
|
|
4e5345d01f | ||
|
|
8a09a81a69 | ||
|
|
62d994c103 | ||
|
|
41373960bc | ||
|
|
bf543f9628 | ||
|
|
e24d74b1f0 | ||
|
|
f81bef28df | ||
|
|
7730e6cd3a | ||
|
|
a18f549c1f | ||
|
|
3592ffb791 | ||
|
|
ad5bb38e2b | ||
|
|
6434728aea | ||
|
|
df7e690c47 | ||
|
|
65be8145ff | ||
|
|
4ac4b35c5e | ||
|
|
ab54ff49eb | ||
|
|
a9de8e0d53 | ||
|
|
cebe84a896 | ||
|
|
96de156763 | ||
|
|
93f1b5dbf1 | ||
|
|
ff908f19e7 | ||
|
|
9b85384305 | ||
|
|
ca0bfcfc7e | ||
|
|
70a3c49b61 | ||
|
|
c43876ee46 | ||
|
|
3bd25b63c8 | ||
|
|
797d7218ee | ||
|
|
21289797c2 | ||
|
|
ff6d2fe84e | ||
|
|
f220b04074 | ||
|
|
e0c02fa5bc | ||
|
|
1a8574c96f | ||
|
|
f2c9464eb0 | ||
|
|
22d085a5c9 | ||
|
|
d0bc3dec23 | ||
|
|
0a0fb41037 | ||
|
|
845f503739 | ||
|
|
143017f925 | ||
|
|
38377f81ed | ||
|
|
f80595e048 | ||
|
|
d5ba9cdf28 | ||
|
|
a39f622402 | ||
|
|
26d4726181 | ||
|
|
0b4c050b21 | ||
|
|
cf56a0650e | ||
|
|
31adf1486d | ||
|
|
be5bdc0b20 | ||
|
|
bf1bb0823b | ||
|
|
45249ccf28 | ||
|
|
022304d046 | ||
|
|
3b2b4f08fc | ||
|
|
e9a31279bd | ||
|
|
6f50b69c5f | ||
|
|
e0bfedae75 | ||
|
|
c1355481cb | ||
|
|
7c119d6c92 | ||
|
|
eeabaa71fb | ||
|
|
2ec135c9c0 | ||
|
|
21bff0075f | ||
|
|
2a86608ee9 | ||
|
|
84ae72f71d | ||
|
|
6be4eb0322 | ||
|
|
df5e3dad27 | ||
|
|
f31d9c3f97 | ||
|
|
301a7a20c5 | ||
|
|
fc67fbfadb | ||
|
|
89709184c2 | ||
|
|
2949b7d203 | ||
|
|
4e68d72de9 | ||
|
|
02cef27230 | ||
|
|
ba5cbcb3f1 | ||
|
|
922330ded2 | ||
|
|
87c63193ae | ||
|
|
835b7fbac5 | ||
|
|
fe456be075 | ||
|
|
b492342e55 | ||
|
|
b80f64d9b4 | ||
|
|
dbbcd2a21b | ||
|
|
fc9d433038 | ||
|
|
d852f62757 | ||
|
|
b0f14e69f6 | ||
|
|
6584bf9607 | ||
|
|
84f9989752 | ||
|
|
a01897211e | ||
|
|
88159507e3 | ||
|
|
91eb469a7d | ||
|
|
e251ffe85d | ||
|
|
91cfc335ba | ||
|
|
3985330da3 | ||
|
|
d8f9161ae8 | ||
|
|
aef13a77a3 | ||
|
|
44a514246b | ||
|
|
5364779766 | ||
|
|
7eefafaad5 | ||
|
|
6e17a91919 | ||
|
|
6f2b4b34b9 | ||
|
|
dbb5625199 | ||
|
|
89785dc06b | ||
|
|
46c3134487 | ||
|
|
b1a6da8d73 | ||
|
|
dde551ef94 | ||
|
|
65f036442a | ||
|
|
2167f5e728 | ||
|
|
9fc284bef3 | ||
|
|
b57b92e382 | ||
|
|
0d28c1cbf8 | ||
|
|
e3af3d1b94 | ||
|
|
7411283fc8 | ||
|
|
c331365ebf | ||
|
|
0e9d1d63d3 | ||
|
|
4e9e63dff6 | ||
|
|
ad528935ad | ||
|
|
e634ffdd23 | ||
|
|
165660e106 | ||
|
|
14425be416 | ||
|
|
47afb1a651 | ||
|
|
95d59d7206 | ||
|
|
e2b7a9772c | ||
|
|
5ccb08e73f | ||
|
|
778ca76607 | ||
|
|
c78338df9f | ||
|
|
adf401e09a | ||
|
|
bb6324b4e5 | ||
|
|
9b6170e94f | ||
|
|
8d865eb048 | ||
|
|
8fefb8f7cb | ||
|
|
443fbeee38 | ||
|
|
31addf01dd | ||
|
|
2a6554a3c6 | ||
|
|
691a0bed5d | ||
|
|
5088f51236 | ||
|
|
aeb1beab17 | ||
|
|
d4b4ef1108 | ||
|
|
16bbe517b4 | ||
|
|
f1add9dc58 | ||
|
|
2363a3706f | ||
|
|
08e8c7258c | ||
|
|
5df2bdb063 | ||
|
|
115d9ea780 | ||
|
|
70b65343ab | ||
|
|
77c7146677 | ||
|
|
980ecb8bd3 | ||
|
|
0408f29301 | ||
|
|
1d7a97197a | ||
|
|
5152be44f0 | ||
|
|
a36730220e | ||
|
|
54069d7cc3 | ||
|
|
abf3c5a5b5 | ||
|
|
c2dd6e2a6a | ||
|
|
0cd10a9352 | ||
|
|
3cc4eb55b3 | ||
|
|
c1f781256f | ||
|
|
4fa63bec31 | ||
|
|
56ce9d2776 | ||
|
|
c16bd2fec1 | ||
|
|
e25d444cdf | ||
|
|
58b08ddbd1 | ||
|
|
015eeb0c9f | ||
|
|
5e36f7f107 | ||
|
|
662563c216 | ||
|
|
35065bc65a | ||
|
|
b9cf1765f8 | ||
|
|
15c815cae6 | ||
|
|
85368b38d3 | ||
|
|
61ea8fc988 | ||
|
|
928ccb1c80 | ||
|
|
48ec993b60 | ||
|
|
983f4f0316 | ||
|
|
b03d17bc97 | ||
|
|
cba5eb2cc3 | ||
|
|
b221458d4d | ||
|
|
de5fdb9299 | ||
|
|
fe7abc2611 | ||
|
|
344fc6fb91 | ||
|
|
5a34318947 | ||
|
|
6c363c8149 | ||
|
|
76948cae65 | ||
|
|
689d3ae03e | ||
|
|
8f0e239f3d | ||
|
|
a4a5170c1c | ||
|
|
0f87cb1e72 | ||
|
|
b7a7dcead8 | ||
|
|
1cfd459b83 | ||
|
|
8d3d11b07e | ||
|
|
e3a81df926 | ||
|
|
3cc2f25450 | ||
|
|
fd7e3cabca | ||
|
|
79be7370ed | ||
|
|
375012bd17 | ||
|
|
7c186a84c6 | ||
|
|
59a66bdbd6 | ||
|
|
4e05fab8e0 | ||
|
|
39950a4ca2 | ||
|
|
a770600fa7 | ||
|
|
b39b8838cc | ||
|
|
aca64b8c36 | ||
|
|
f50c320fda | ||
|
|
00de1d2c89 | ||
|
|
1b5a181c1c | ||
|
|
074c66fa00 | ||
|
|
a4aa197a37 | ||
|
|
25e70692ec | ||
|
|
ec2dd25f92 | ||
|
|
bded37e2be | ||
|
|
188875933e | ||
|
|
24559537ab | ||
|
|
7f4f40f3ba | ||
|
|
9c5abf6831 | ||
|
|
59c64d4458 | ||
|
|
c7394e1147 | ||
|
|
ed340c1345 | ||
|
|
2e4f444847 | ||
|
|
a4fda6d21e | ||
|
|
c615d35cd0 | ||
|
|
3a404c347c | ||
|
|
456a56cd80 | ||
|
|
587c7d41e9 | ||
|
|
6616a4862f | ||
|
|
f70b654c35 | ||
|
|
a0261b4c82 | ||
|
|
4e6f1e787b | ||
|
|
173bacdb23 | ||
|
|
27e5cafa22 | ||
|
|
1408913afe | ||
|
|
15f5962dc0 | ||
|
|
7ebbb91553 | ||
|
|
6d6a8a2d6e | ||
|
|
f4f764218d | ||
|
|
a7305de3ad | ||
|
|
38411c675d | ||
|
|
b3d43ce795 | ||
|
|
bcfcb97c8d | ||
|
|
8790e1e4db | ||
|
|
a2284af3ea | ||
|
|
b145dfd437 | ||
|
|
4d423b6510 | ||
|
|
cd238f9b5a | ||
|
|
9a6178beee | ||
|
|
5a636d3254 | ||
|
|
5a5e1f6bd1 | ||
|
|
811a9e3964 | ||
|
|
cfff691a58 | ||
|
|
b64e78246d | ||
|
|
8b7c33814f | ||
|
|
6321dd5c72 | ||
|
|
ff67a4382d | ||
|
|
bbee212b38 | ||
|
|
2f94beff93 | ||
|
|
9c062f18b6 | ||
|
|
49b68327bb | ||
|
|
8fb44cd89e | ||
|
|
07ffb83356 | ||
|
|
87790721c5 | ||
|
|
900722e800 | ||
|
|
c5d6bc20f8 | ||
|
|
6176f0b00e | ||
|
|
4dc2551e1d | ||
|
|
de4aec519b | ||
|
|
bcb9db7c59 | ||
|
|
93dcfc0cdd | ||
|
|
2f25c74b32 | ||
|
|
cebf5699a4 | ||
|
|
3d4760181d | ||
|
|
1ead472da2 | ||
|
|
4dee6d5c76 | ||
|
|
f0bf2bed74 | ||
|
|
4032e5459e | ||
|
|
1ad3a76c3c | ||
|
|
47b9d45ff8 | ||
|
|
f6b9964dcd | ||
|
|
1453a0fc5a | ||
|
|
6d344d2aff | ||
|
|
cc4a8a8e51 | ||
|
|
db1d0cf3df | ||
|
|
35a7bc310b | ||
|
|
8983db39ae | ||
|
|
ae06d87f10 | ||
|
|
d724c6132d | ||
|
|
283b2981e3 | ||
|
|
3b2df514a7 | ||
|
|
9b0f498add | ||
|
|
eedeb188f2 | ||
|
|
6727e15055 | ||
|
|
e758ef4022 | ||
|
|
4e09e0a11a | ||
|
|
693b06eefd | ||
|
|
2e4a63c4a0 | ||
|
|
1d58a07f29 | ||
|
|
53d4cb81de | ||
|
|
aaf39a4301 | ||
|
|
f50406c789 | ||
|
|
6356b3409a | ||
|
|
ec268dcb5a | ||
|
|
2ae714be31 | ||
|
|
666a3db95d | ||
|
|
895317ec80 | ||
|
|
47c4e2ac73 | ||
|
|
8413ac6be3 | ||
|
|
8aaa916b31 | ||
|
|
6a8a653f9d | ||
|
|
9866f959c1 | ||
|
|
c9f6da9732 | ||
|
|
381f5f0a53 | ||
|
|
1bed82420e | ||
|
|
f965662514 | ||
|
|
da6ec62be5 | ||
|
|
b73439bce1 | ||
|
|
23be31e1f2 | ||
|
|
eaa8ce4bf7 | ||
|
|
c0658a8223 | ||
|
|
373d97ce97 | ||
|
|
2568582271 | ||
|
|
2d285ca504 | ||
|
|
ea0393f4c0 | ||
|
|
ff18894d5d | ||
|
|
b4caff13cf | ||
|
|
c70994ee9d | ||
|
|
75fd8da685 | ||
|
|
54ca354d7e | ||
|
|
218e06a3fe | ||
|
|
a95c9b32d8 | ||
|
|
48f2fdc45d | ||
|
|
ace5857959 | ||
|
|
1022bbec1e | ||
|
|
9c19e1aa41 | ||
|
|
c338ea3c86 | ||
|
|
8cb4d72a7b | ||
|
|
2b1dcb77cc | ||
|
|
f64d6751a6 | ||
|
|
e25cd9b5f6 | ||
|
|
40f6185b24 | ||
|
|
6ee30b8bfc | ||
|
|
8284d7d92c | ||
|
|
67ae916968 | ||
|
|
990db0636a | ||
|
|
9ba6f89dc5 | ||
|
|
20e7dc919f | ||
|
|
79351da42a | ||
|
|
cb9ecd890c | ||
|
|
ca4a936c6e | ||
|
|
d7417d841f | ||
|
|
e65bee049a | ||
|
|
87d6083807 | ||
|
|
d8198cc01f | ||
|
|
1505429c5f | ||
|
|
24fe747b69 | ||
|
|
4c0fbd238b | ||
|
|
df4b285e46 | ||
|
|
1744d8f23a | ||
|
|
3695bce742 | ||
|
|
0295229e7e | ||
|
|
0122343075 | ||
|
|
475d758645 | ||
|
|
0dd21e9075 | ||
|
|
4a0bc24aa6 | ||
|
|
3d5cfab7c5 | ||
|
|
dddfb8cbc2 | ||
|
|
ec9b1262cb | ||
|
|
c844d16c2e | ||
|
|
b3890cd07d | ||
|
|
5aa8616268 | ||
|
|
784e3c82f8 | ||
|
|
984faa2e85 | ||
|
|
b562bd20bb | ||
|
|
ad6c7ca623 | ||
|
|
9e57981114 | ||
|
|
41e7dfea55 | ||
|
|
f2767239af | ||
|
|
bf5c2b6a9c | ||
|
|
7e7ab2cab3 | ||
|
|
66910bdfee | ||
|
|
c9f9edfcf5 | ||
|
|
cb9457ae09 | ||
|
|
3aee1598a9 | ||
|
|
a9dbd5f341 | ||
|
|
0ff795f67a | ||
|
|
93f7370157 | ||
|
|
cb4732fe2f | ||
|
|
e65b7975fb | ||
|
|
c0243ce329 | ||
|
|
12a1e667e2 | ||
|
|
6ec7748677 | ||
|
|
671f2b7473 | ||
|
|
1968bdc219 | ||
|
|
59c28b4f86 | ||
|
|
672f06eb80 | ||
|
|
b9712afd29 | ||
|
|
0531437c94 | ||
|
|
bb3ea541a2 | ||
|
|
e4e2fa23ce | ||
|
|
682f3009ba | ||
|
|
9bfd259b03 | ||
|
|
3266af774c | ||
|
|
36f8101c21 | ||
|
|
dd83f870b9 | ||
|
|
2c3a9a3bc8 | ||
|
|
10a4769115 | ||
|
|
dc292ca657 | ||
|
|
7fc3a500d3 | ||
|
|
ccb0f15655 | ||
|
|
426f4cf569 | ||
|
|
2585a09219 | ||
|
|
83edaef6d3 | ||
|
|
1551360dda | ||
|
|
977cef9d29 | ||
|
|
f7b63ebac1 | ||
|
|
c90a98e427 | ||
|
|
2cd2f99723 | ||
|
|
b5a1f6fcd6 | ||
|
|
b99a9b68dc | ||
|
|
3ec7f90d95 | ||
|
|
86b4cae95d | ||
|
|
c3dd28c510 | ||
|
|
bec2b2a5e0 | ||
|
|
d01d3f9c96 | ||
|
|
057b6b63b3 | ||
|
|
b522e15328 | ||
|
|
86247e59a0 | ||
|
|
7e0926febf | ||
|
|
141ad15a48 | ||
|
|
39483d90d1 | ||
|
|
c0f0823076 | ||
|
|
ebee564436 | ||
|
|
11d99845ce | ||
|
|
f0fe3e30af | ||
|
|
21713ebea7 | ||
|
|
f4f818277e | ||
|
|
3316a6e073 | ||
|
|
6246e8a675 | ||
|
|
861a714014 | ||
|
|
343aeda8ba | ||
|
|
53c1184c1f | ||
|
|
43b52b32f2 | ||
|
|
d1521c021d | ||
|
|
bd7f82ce45 | ||
|
|
3ad460c6e9 | ||
|
|
175a636755 | ||
|
|
9e482e9dd4 | ||
|
|
ce4842afd7 | ||
|
|
ffa49aecea | ||
|
|
a19c75f1ee | ||
|
|
55bf4d9597 | ||
|
|
f0149c3e04 | ||
|
|
2e1742c1f4 | ||
|
|
a0e956e61f | ||
|
|
907c606bbd | ||
|
|
baa8b62dc3 | ||
|
|
c5b8a20092 | ||
|
|
5afc578951 | ||
|
|
92a28b1639 | ||
|
|
5f6ee3f9f2 | ||
|
|
8033cc7d72 | ||
|
|
3138f23648 | ||
|
|
fffe24bd2c | ||
|
|
bc05217322 | ||
|
|
0dbc66af7a | ||
|
|
130a719465 | ||
|
|
bdf11fe3b3 | ||
|
|
1e8bea42c7 | ||
|
|
acb6f72ee7 | ||
|
|
74220acb2e | ||
|
|
a15bda1bce | ||
|
|
f8f6d7d9be | ||
|
|
0135ddcb36 | ||
|
|
cd306cd450 | ||
|
|
c4823c4c89 | ||
|
|
cf99ca2cf8 | ||
|
|
9c0364b0c3 | ||
|
|
39ffccbf45 | ||
|
|
dc42003969 | ||
|
|
55583294c9 | ||
|
|
73c3f202d0 | ||
|
|
b0b01c105f | ||
|
|
ba0b1c93d2 | ||
|
|
e5ba415ec5 | ||
|
|
74434317d3 | ||
|
|
558d077ef6 | ||
|
|
354fa5470c | ||
|
|
dcac6fae70 | ||
|
|
e9b00bb369 | ||
|
|
623869ce25 | ||
|
|
052a27ddaf | ||
|
|
7133e492b6 | ||
|
|
e7b94e9698 | ||
|
|
6af228d82b | ||
|
|
705d51c818 | ||
|
|
469d2cc321 | ||
|
|
056b611125 | ||
|
|
55827b0720 | ||
|
|
a8b8ea10d1 | ||
|
|
8f98bb6897 | ||
|
|
3c76ee9109 | ||
|
|
93f06e431e | ||
|
|
1e04c65f76 | ||
|
|
b4696f8c60 | ||
|
|
cced40b5cb | ||
|
|
fb24c4550b | ||
|
|
11fee7db63 | ||
|
|
c28dc2f441 | ||
|
|
fefd96a5d3 | ||
|
|
e7042f4429 | ||
|
|
ad51ab6273 | ||
|
|
2b05500ae3 | ||
|
|
5dafee2c0f | ||
|
|
7370973a79 | ||
|
|
e1703d287b | ||
|
|
8a0a25f0bf | ||
|
|
b350323440 | ||
|
|
420df51e47 | ||
|
|
7f74ae6e79 | ||
|
|
2e04dee223 | ||
|
|
20e434be5a | ||
|
|
caec2767ab | ||
|
|
73b003b0bc | ||
|
|
352416e309 | ||
|
|
47d3d4f845 | ||
|
|
b08878c75a | ||
|
|
1b99041e5f | ||
|
|
8eb6a6fc8a | ||
|
|
96e3b5c9e0 | ||
|
|
8f8d353eb2 | ||
|
|
86497d41e0 | ||
|
|
4129700cf3 | ||
|
|
5d1f9d5cd9 | ||
|
|
8465f10648 | ||
|
|
8b2450cdcf | ||
|
|
baf03dffd4 | ||
|
|
807be52e8f | ||
|
|
bd42ff1393 | ||
|
|
b167a7b384 | ||
|
|
9f2b3a27fa | ||
|
|
865f0aca80 | ||
|
|
c3546a1931 | ||
|
|
b0e65f71d4 | ||
|
|
f763218864 | ||
|
|
9c4fc0c55c | ||
|
|
893fa3131b | ||
|
|
0a49a986a4 | ||
|
|
0930ec2d3d | ||
|
|
e20f556f37 | ||
|
|
f78b0d82e9 | ||
|
|
e4a58abd7b | ||
|
|
ff28415863 | ||
|
|
975d15a8ef | ||
|
|
653d2753d4 | ||
|
|
d301765263 | ||
|
|
a03f9a0f3e | ||
|
|
a80f26ec36 | ||
|
|
c6088d97d3 | ||
|
|
e9339a16b1 | ||
|
|
4de6c838b4 | ||
|
|
3cf262afbf | ||
|
|
36f9592a10 | ||
|
|
cc57d2a073 | ||
|
|
9d7baa855e | ||
|
|
01d7bbe0bd | ||
|
|
f470b380b8 | ||
|
|
e33956d584 | ||
|
|
821af69bbe | ||
|
|
d5cac7acbf | ||
|
|
185a24ff12 | ||
|
|
f6a9df54d2 | ||
|
|
28b273c38e | ||
|
|
cdedd1b8bf | ||
|
|
abd875983f | ||
|
|
30c2f1d1f8 | ||
|
|
a65c2dbd8f | ||
|
|
72eb8d0d73 | ||
|
|
90b884fe64 | ||
|
|
29e9683c35 | ||
|
|
870ab67be4 | ||
|
|
ecc73efe2b | ||
|
|
345d4d2f95 | ||
|
|
97fd6ca57b | ||
|
|
e021b911d9 | ||
|
|
6bb9737237 | ||
|
|
f0594cec77 | ||
|
|
eef8271d07 | ||
|
|
5dab98ec49 | ||
|
|
b3b9f128e2 | ||
|
|
3a0efcdbc7 | ||
|
|
13a7220af9 | ||
|
|
83d3a7a8b1 | ||
|
|
de315e4b7e | ||
|
|
d053662cf6 | ||
|
|
390da76f68 | ||
|
|
04d480012c | ||
|
|
b6ebb66966 | ||
|
|
602b721c0e | ||
|
|
33f0221c9e | ||
|
|
51b47fc389 | ||
|
|
5e6d636f82 | ||
|
|
24a8be7848 | ||
|
|
7b2f775723 | ||
|
|
5a5990f201 | ||
|
|
572e912c22 | ||
|
|
087b01a243 | ||
|
|
15d9665ac2 | ||
|
|
cc694a4c2b | ||
|
|
2071df6f58 | ||
|
|
6dc0d4e301 | ||
|
|
fad9582eac | ||
|
|
52edbfc6dc | ||
|
|
e9999befa9 | ||
|
|
b622ff69e2 | ||
|
|
3e8189f092 | ||
|
|
99918b8c62 | ||
|
|
ac8600451f | ||
|
|
bf8fac7809 | ||
|
|
1ebd16e2ce | ||
|
|
210558b353 | ||
|
|
f73e85d7ec | ||
|
|
de16e0b35d | ||
|
|
fc8d2a3a3e | ||
|
|
7862430a18 | ||
|
|
1dd0860bef | ||
|
|
ea3b182e2f | ||
|
|
68799ad044 | ||
|
|
1f2cb78b9d | ||
|
|
a127fafc26 | ||
|
|
44f673317f | ||
|
|
a93f03df54 | ||
|
|
e8e74052c2 | ||
|
|
06a129de07 | ||
|
|
5931d1bbfd | ||
|
|
dc95a7bd9c | ||
|
|
708c4d7251 | ||
|
|
c1c44ba070 | ||
|
|
2c3e1facc1 | ||
|
|
472883ab03 | ||
|
|
f8958f9335 | ||
|
|
e508b6b38e | ||
|
|
e931b5a6ad | ||
|
|
de25c7af4b | ||
|
|
b53bb46bdf | ||
|
|
d0a06d0b92 | ||
|
|
9f498ecce1 | ||
|
|
e9bfa182b1 | ||
|
|
13c0353dae | ||
|
|
4241a702b6 | ||
|
|
34a05c9bde | ||
|
|
eb300839ca | ||
|
|
4aaeac88aa | ||
|
|
fac9640263 | ||
|
|
e1b02b270a | ||
|
|
d41c9c90a9 | ||
|
|
fc5a3715c7 | ||
|
|
269aeac18c | ||
|
|
bc76582c96 | ||
|
|
bb6a6a3172 | ||
|
|
192898995d | ||
|
|
b5c824ebbd | ||
|
|
1b966ecaf6 | ||
|
|
15e5333b09 | ||
|
|
51d3b8dfea | ||
|
|
883e6b17d2 | ||
|
|
c849fac54e | ||
|
|
61c1521fcb | ||
|
|
6c53ee503c | ||
|
|
46b1f80611 | ||
|
|
1201649474 | ||
|
|
9d7f8ee80a | ||
|
|
870ac2f371 | ||
|
|
4ff41d9416 | ||
|
|
52bb25cf2a | ||
|
|
2acfecfafc | ||
|
|
52aabcbdfc | ||
|
|
76cb6e7806 | ||
|
|
e5e6ac6064 | ||
|
|
a65cf09830 | ||
|
|
c77a0d1ef9 | ||
|
|
5cf1bcef28 | ||
|
|
4dd65ee9b2 | ||
|
|
967e7b65b1 | ||
|
|
bb84439dc6 | ||
|
|
aa66366ea2 | ||
|
|
4994dd026c | ||
|
|
0d43debd32 | ||
|
|
18821d3feb | ||
|
|
a65ad217a3 | ||
|
|
1b29a6ba3a | ||
|
|
77fdec48a9 | ||
|
|
b21846cf76 | ||
|
|
e4599113fa | ||
|
|
394667637c | ||
|
|
5a99a9a78a | ||
|
|
21c3c36d7c | ||
|
|
cea15032c9 | ||
|
|
e73a055bc3 | ||
|
|
ce93715287 | ||
|
|
09d3a0edc3 | ||
|
|
805d6c9de2 | ||
|
|
7f5ffab148 | ||
|
|
a551cbcedd | ||
|
|
d27b74a9ab | ||
|
|
a69ad3bbdb | ||
|
|
8d57a375ac | ||
|
|
84324e4340 | ||
|
|
3f58472ea7 | ||
|
|
a383d271e5 | ||
|
|
cc70b9766f | ||
|
|
c92a45a386 | ||
|
|
abda820c0d | ||
|
|
5320b8f260 | ||
|
|
dd2bf7085a | ||
|
|
f70365534a | ||
|
|
b744a29df6 | ||
|
|
77905adc56 | ||
|
|
192200a2cf | ||
|
|
5cd7441052 | ||
|
|
81bba2a7a0 | ||
|
|
447884250e | ||
|
|
0bf5e1be22 | ||
|
|
d7004cf045 | ||
|
|
c57db2454c | ||
|
|
9a0916aca0 | ||
|
|
b8d66ffe92 | ||
|
|
5838df0cde | ||
|
|
37bd73591f | ||
|
|
0dc8ce65b3 | ||
|
|
f977545374 | ||
|
|
719e1091b6 | ||
|
|
b3f951a5d7 | ||
|
|
c07817f0ec | ||
|
|
ef6262867f | ||
|
|
88572a28f6 | ||
|
|
965b7b7fa8 | ||
|
|
f825ef4d85 | ||
|
|
c943779387 | ||
|
|
c11e6314a3 | ||
|
|
f86d2127d1 | ||
|
|
b18c3e60ea | ||
|
|
271c709be6 | ||
|
|
173bd3f679 | ||
|
|
66cac921b9 | ||
|
|
3a1d0cffaf | ||
|
|
6a6e4c5dd4 | ||
|
|
5b5082fd1a | ||
|
|
4e5297e12b | ||
|
|
a29399fde4 | ||
|
|
6b1217d862 | ||
|
|
bfd7d80b9f | ||
|
|
3cb233f2de | ||
|
|
6e3a8bc8aa | ||
|
|
a6a582ec08 | ||
|
|
6d08904602 | ||
|
|
8aa9fbf47b | ||
|
|
7ebe59502a | ||
|
|
2b0d2a1ad0 | ||
|
|
139d107bad | ||
|
|
87534580d6 | ||
|
|
1619024818 | ||
|
|
cd22fda858 | ||
|
|
ee873711b7 | ||
|
|
a519a2f9a2 | ||
|
|
a834b5e926 | ||
|
|
5b133a8e53 | ||
|
|
251e1a06c5 | ||
|
|
7d59544b61 | ||
|
|
ba83b04da4 | ||
|
|
1cf1354abf | ||
|
|
9ecb045131 | ||
|
|
2fe9d75cb5 | ||
|
|
641497a88c | ||
|
|
2fcc4f0db1 | ||
|
|
96948e8b8d | ||
|
|
17cdf17473 | ||
|
|
766d33ec94 | ||
|
|
1484b696c5 | ||
|
|
3053cd9238 | ||
|
|
18dd8c8ee1 | ||
|
|
0d6b43e02e | ||
|
|
d5c02a28c2 | ||
|
|
77eab865a0 | ||
|
|
308e16afa0 | ||
|
|
39a4d6bc5b | ||
|
|
823da21de1 | ||
|
|
fc7c584719 | ||
|
|
11ccd098ed | ||
|
|
1ea83b8748 | ||
|
|
bd0c404396 | ||
|
|
f117dd453d | ||
|
|
26a6a004c1 | ||
|
|
8707518433 | ||
|
|
fdd12fc6b6 | ||
|
|
04989f3554 | ||
|
|
c4ed189e28 | ||
|
|
2cb425c9fc | ||
|
|
029964d886 | ||
|
|
526effa743 | ||
|
|
5dca424132 | ||
|
|
c76a633de3 | ||
|
|
b6db68b064 | ||
|
|
0b1cfb3b43 | ||
|
|
4c14710596 | ||
|
|
1006cd9b56 | ||
|
|
d55e369a7f | ||
|
|
3edcac4d3c | ||
|
|
70ff8e22f2 | ||
|
|
b7824075a3 | ||
|
|
96644d3430 | ||
|
|
6c8b88eb7e | ||
|
|
33aa966937 | ||
|
|
80776c2442 | ||
|
|
c9a52da723 | ||
|
|
a79b788b27 | ||
|
|
31981f473b | ||
|
|
7194bbe18f | ||
|
|
c600d85e7a | ||
|
|
de7d80f1a7 | ||
|
|
8d287f9106 | ||
|
|
24b90ae6f8 | ||
|
|
65d4ae8e65 | ||
|
|
f76cde683d | ||
|
|
8970fc912f | ||
|
|
144da0a212 | ||
|
|
ac96a99b9f | ||
|
|
4b3a5e9bcb | ||
|
|
8a8d33b437 | ||
|
|
e0eb3860fa | ||
|
|
67aeadff42 | ||
|
|
5140ce43d1 | ||
|
|
fe3cb81209 | ||
|
|
0c7aaeeee5 | ||
|
|
9afaada3fb | ||
|
|
a697ffe442 | ||
|
|
d720064919 | ||
|
|
b09e3ed8c7 | ||
|
|
556b650133 | ||
|
|
8da69d6ad1 | ||
|
|
47182c0544 | ||
|
|
5dcd1e9aca | ||
|
|
e60933819a | ||
|
|
18dd4db147 | ||
|
|
a601be3af0 | ||
|
|
ac60c9984c | ||
|
|
0c3f6b8ffa | ||
|
|
6b4b662d2c | ||
|
|
facd77dbf8 | ||
|
|
8b6aa1dedd | ||
|
|
11a87bab8c | ||
|
|
fa92edff2f | ||
|
|
3686afafc0 | ||
|
|
86f50f7262 | ||
|
|
c3d0e621a7 | ||
|
|
4e1d1bdc2f | ||
|
|
fc018cb5bb | ||
|
|
a2b661965a | ||
|
|
ab9bd0cc9b | ||
|
|
7e3aee4a1a | ||
|
|
2a0d7a047d | ||
|
|
59b38976fa | ||
|
|
a1bba52b49 | ||
|
|
f0d1488cf9 | ||
|
|
cc79d5590a | ||
|
|
3caeb73bb8 | ||
|
|
6b226847aa | ||
|
|
9d30d8c8d8 | ||
|
|
635cf9d568 | ||
|
|
ee517f09ec | ||
|
|
124d3f6a4f | ||
|
|
d6bd189a5b | ||
|
|
05746b346a | ||
|
|
c0ff822fc6 | ||
|
|
38846b36a0 | ||
|
|
28c357a6ad | ||
|
|
68c02f88ef | ||
|
|
01705a2e0d | ||
|
|
3a1f814ef2 | ||
|
|
2a3bc4c5ea | ||
|
|
2acc3e19ef | ||
|
|
6db989620a | ||
|
|
6111c43a65 | ||
|
|
bec61d8ad6 | ||
|
|
599491f578 | ||
|
|
dd18d57a9b | ||
|
|
b5daa5c51f | ||
|
|
dec3b45d70 | ||
|
|
88c1e76300 | ||
|
|
852cbd8b65 | ||
|
|
ccde55c4e3 | ||
|
|
6651dcd873 | ||
|
|
953f31662b | ||
|
|
97ad2285b9 | ||
|
|
3f1d99273f | ||
|
|
b1df4aa615 | ||
|
|
a006cad19e | ||
|
|
cc86719898 | ||
|
|
480ef9005a | ||
|
|
128fe42d98 | ||
|
|
51fe557b2f | ||
|
|
e42a3315ae | ||
|
|
6b41e8e7bc | ||
|
|
0d1686412e | ||
|
|
04635ae321 | ||
|
|
300d006e6b | ||
|
|
ca85999d8f | ||
|
|
7b9467a972 | ||
|
|
9aa2c7bedd | ||
|
|
51e2333890 | ||
|
|
472df9dbb9 | ||
|
|
819e417d17 | ||
|
|
a430771e03 | ||
|
|
bb83f4bef3 | ||
|
|
4058d66644 | ||
|
|
c73dbd31d2 | ||
|
|
41152cbd56 | ||
|
|
15ef8aabf4 | ||
|
|
fd85572b87 | ||
|
|
8fbff623e2 | ||
|
|
13bf39004e | ||
|
|
403c50b233 | ||
|
|
1849e8ef6a | ||
|
|
d1989c6990 | ||
|
|
40ab19b380 | ||
|
|
fb69061f99 | ||
|
|
6c630cb33a | ||
|
|
3dfa4d83b9 | ||
|
|
85915a2f11 | ||
|
|
8acc1127e5 | ||
|
|
e5b75ca056 | ||
|
|
c3cee07c78 | ||
|
|
48e2c86d5e | ||
|
|
bc79ea515d | ||
|
|
94f98c35b8 | ||
|
|
b15d01c59d | ||
|
|
32592289dc | ||
|
|
dfdfded371 | ||
|
|
e0e31ba5e1 | ||
|
|
4f1306fe5d | ||
|
|
56d05e3dca | ||
|
|
67f6726c25 | ||
|
|
4519c01fd0 | ||
|
|
4db7d77381 | ||
|
|
0417e3035d | ||
|
|
33c4249013 | ||
|
|
6c2071eeb9 | ||
|
|
ad9dad49e3 | ||
|
|
0b8b70a990 | ||
|
|
8d1dca3b8e | ||
|
|
c071a19d54 | ||
|
|
4a0419520f | ||
|
|
ed6ba83768 | ||
|
|
5986bc3b39 | ||
|
|
12cd756920 | ||
|
|
08c238957d | ||
|
|
d08fc72052 | ||
|
|
d2c09c2182 | ||
|
|
c063b19418 | ||
|
|
ca19c4849e | ||
|
|
cc22a9f7ef | ||
|
|
b9e907b401 | ||
|
|
4324c3e006 | ||
|
|
b630dfb229 | ||
|
|
527ef74b6d | ||
|
|
47d1b545d5 | ||
|
|
6c8a41ece1 | ||
|
|
0dcd704c55 | ||
|
|
d1d38cb2e2 | ||
|
|
906c27a9ba | ||
|
|
acaad6c58c | ||
|
|
83e0e6d8ab | ||
|
|
c9dfef95fb | ||
|
|
62fe12fed7 | ||
|
|
106fc7f063 | ||
|
|
7e4b782aed | ||
|
|
59866b8867 | ||
|
|
ea04ce8545 | ||
|
|
df6cbb4660 | ||
|
|
9ab742168c | ||
|
|
f51cabc3d9 | ||
|
|
c8fdbcf548 | ||
|
|
9ac0565a19 | ||
|
|
30cd97004f | ||
|
|
4f189b6216 | ||
|
|
28e7498e9a | ||
|
|
af59922112 | ||
|
|
327fb687ca | ||
|
|
44a7d8d315 | ||
|
|
3224a39ed8 | ||
|
|
c1a3442cd5 | ||
|
|
ad85245743 | ||
|
|
df82aa5ef1 | ||
|
|
16767cc36d | ||
|
|
c494167bee | ||
|
|
a8ee7d45d5 | ||
|
|
536519328c | ||
|
|
1e902f4688 | ||
|
|
4afd8872d0 | ||
|
|
d0d82adc85 | ||
|
|
4b5dbbf4c3 | ||
|
|
d7264dc7d2 | ||
|
|
90ac002c42 | ||
|
|
495a6ffa05 | ||
|
|
0876e8845c | ||
|
|
872017243f | ||
|
|
4a514f4ab3 | ||
|
|
80688be059 | ||
|
|
16f7368514 | ||
|
|
3f2d94687f | ||
|
|
ad9a20337b | ||
|
|
79a0992773 | ||
|
|
55c6b1b498 | ||
|
|
31e13a966a | ||
|
|
ca915a5f6d | ||
|
|
9778c91ac7 | ||
|
|
24544a30a1 | ||
|
|
dc041da402 | ||
|
|
8aa966a31a | ||
|
|
ea70c607eb | ||
|
|
0f9b8df1b8 | ||
|
|
c9e2319c3a | ||
|
|
e85b469df7 | ||
|
|
de59cd2deb | ||
|
|
91db1fc3dc | ||
|
|
9d7e2b439c | ||
|
|
85ffa447f3 | ||
|
|
9880a0e039 | ||
|
|
b14826f05c | ||
|
|
36fa900817 | ||
|
|
50d61d96d9 | ||
|
|
64c37260b7 | ||
|
|
0b8c698392 | ||
|
|
65bde5555c | ||
|
|
5794017cdd | ||
|
|
a9239be2e1 | ||
|
|
fdfa68be2e | ||
|
|
2649b0edb5 | ||
|
|
ed1e3676b1 | ||
|
|
1215ed152b | ||
|
|
938ad4ec44 | ||
|
|
21bceecccb | ||
|
|
e1f265c940 | ||
|
|
dbf0d46a08 | ||
|
|
7eca5ea9dc | ||
|
|
0206b84b63 | ||
|
|
15675927ad | ||
|
|
4e2d5c7107 | ||
|
|
5d3166168e | ||
|
|
570ada9050 | ||
|
|
617bd38a01 | ||
|
|
43e5e7dd55 | ||
|
|
de9f69dd54 | ||
|
|
241c80880c | ||
|
|
2e5c3b2d09 | ||
|
|
85daac92b5 | ||
|
|
aeb81908c7 | ||
|
|
2c1d0bf792 | ||
|
|
d9c8871da0 | ||
|
|
0a5c9c8376 | ||
|
|
d68f7c7b72 | ||
|
|
f7b0bfa76a | ||
|
|
df7e31380b | ||
|
|
a2df4128ed |
389
.cursorrules
389
.cursorrules
@@ -3,7 +3,6 @@
|
|||||||
## ⚠️ CRITICAL DEVELOPMENT RULES ⚠️
|
## ⚠️ CRITICAL DEVELOPMENT RULES ⚠️
|
||||||
|
|
||||||
### 🚨 NEVER COMMIT DIRECTLY TO MASTER/MAIN BRANCH 🚨
|
### 🚨 NEVER COMMIT DIRECTLY TO MASTER/MAIN BRANCH 🚨
|
||||||
|
|
||||||
- **This is the most important rule - NEVER modify code directly on main or master branch**
|
- **This is the most important rule - NEVER modify code directly on main or master branch**
|
||||||
- **Always work on feature branches and use pull requests for all changes**
|
- **Always work on feature branches and use pull requests for all changes**
|
||||||
- **Any direct commits to master/main branch are strictly forbidden**
|
- **Any direct commits to master/main branch are strictly forbidden**
|
||||||
@@ -16,50 +15,31 @@
|
|||||||
6. Create a pull request for review
|
6. Create a pull request for review
|
||||||
|
|
||||||
## Project Overview
|
## Project Overview
|
||||||
|
|
||||||
RustFS is a high-performance distributed object storage system written in Rust, compatible with S3 API. The project adopts a modular architecture, supporting erasure coding storage, multi-tenant management, observability, and other enterprise-level features.
|
RustFS is a high-performance distributed object storage system written in Rust, compatible with S3 API. The project adopts a modular architecture, supporting erasure coding storage, multi-tenant management, observability, and other enterprise-level features.
|
||||||
|
|
||||||
## Core Architecture Principles
|
## Core Architecture Principles
|
||||||
|
|
||||||
### 1. Modular Design
|
### 1. Modular Design
|
||||||
|
|
||||||
- Project uses Cargo workspace structure, containing multiple independent crates
|
- Project uses Cargo workspace structure, containing multiple independent crates
|
||||||
- Core modules: `rustfs` (main service), `ecstore` (erasure coding storage), `common` (shared components)
|
- Core modules: `rustfs` (main service), `ecstore` (erasure coding storage), `common` (shared components)
|
||||||
- Functional modules: `iam` (identity management), `madmin` (management interface), `crypto` (encryption), etc.
|
- Functional modules: `iam` (identity management), `madmin` (management interface), `crypto` (encryption), etc.
|
||||||
- Tool modules: `cli` (command line tool), `crates/*` (utility libraries)
|
- Tool modules: `cli` (command line tool), `crates/*` (utility libraries)
|
||||||
|
|
||||||
### 2. Asynchronous Programming Pattern
|
### 2. Asynchronous Programming Pattern
|
||||||
|
|
||||||
- Comprehensive use of `tokio` async runtime
|
- Comprehensive use of `tokio` async runtime
|
||||||
- Prioritize `async/await` syntax
|
- Prioritize `async/await` syntax
|
||||||
- Use `async-trait` for async methods in traits
|
- Use `async-trait` for async methods in traits
|
||||||
- Avoid blocking operations, use `spawn_blocking` when necessary
|
- Avoid blocking operations, use `spawn_blocking` when necessary
|
||||||
|
|
||||||
### 3. Error Handling Strategy
|
### 3. Error Handling Strategy
|
||||||
|
- Use unified error type `common::error::Error`
|
||||||
- **Use modular, type-safe error handling with `thiserror`**
|
- Support error chains and context information
|
||||||
- Each module should define its own error type using `thiserror::Error` derive macro
|
- Use `thiserror` to define specific error types
|
||||||
- Support error chains and context information through `#[from]` and `#[source]` attributes
|
- Error conversion uses `downcast_ref` for type checking
|
||||||
- Use `Result<T>` type aliases for consistency within each module
|
|
||||||
- Error conversion between modules should use explicit `From` implementations
|
|
||||||
- Follow the pattern: `pub type Result<T> = core::result::Result<T, Error>`
|
|
||||||
- Use `#[error("description")]` attributes for clear error messages
|
|
||||||
- Support error downcasting when needed through `other()` helper methods
|
|
||||||
- Implement `Clone` for errors when required by the domain logic
|
|
||||||
- **Current module error types:**
|
|
||||||
- `ecstore::error::StorageError` - Storage layer errors
|
|
||||||
- `ecstore::disk::error::DiskError` - Disk operation errors
|
|
||||||
- `iam::error::Error` - Identity and access management errors
|
|
||||||
- `policy::error::Error` - Policy-related errors
|
|
||||||
- `crypto::error::Error` - Cryptographic operation errors
|
|
||||||
- `filemeta::error::Error` - File metadata errors
|
|
||||||
- `rustfs::error::ApiError` - API layer errors
|
|
||||||
- Module-specific error types for specialized functionality
|
|
||||||
|
|
||||||
## Code Style Guidelines
|
## Code Style Guidelines
|
||||||
|
|
||||||
### 1. Formatting Configuration
|
### 1. Formatting Configuration
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
max_width = 130
|
max_width = 130
|
||||||
fn_call_width = 90
|
fn_call_width = 90
|
||||||
@@ -75,25 +55,21 @@ single_line_let_else_max_width = 100
|
|||||||
Before every commit, you **MUST**:
|
Before every commit, you **MUST**:
|
||||||
|
|
||||||
1. **Format your code**:
|
1. **Format your code**:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo fmt --all
|
cargo fmt --all
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Verify formatting**:
|
2. **Verify formatting**:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo fmt --all --check
|
cargo fmt --all --check
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Pass clippy checks**:
|
3. **Pass clippy checks**:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo clippy --all-targets --all-features -- -D warnings
|
cargo clippy --all-targets --all-features -- -D warnings
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **Ensure compilation**:
|
4. **Ensure compilation**:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo check --all-targets
|
cargo check --all-targets
|
||||||
```
|
```
|
||||||
@@ -168,7 +144,6 @@ Example output when formatting fails:
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 3. Naming Conventions
|
### 3. Naming Conventions
|
||||||
|
|
||||||
- Use `snake_case` for functions, variables, modules
|
- Use `snake_case` for functions, variables, modules
|
||||||
- Use `PascalCase` for types, traits, enums
|
- Use `PascalCase` for types, traits, enums
|
||||||
- Constants use `SCREAMING_SNAKE_CASE`
|
- Constants use `SCREAMING_SNAKE_CASE`
|
||||||
@@ -178,7 +153,6 @@ Example output when formatting fails:
|
|||||||
- Choose names that clearly express the purpose and intent
|
- Choose names that clearly express the purpose and intent
|
||||||
|
|
||||||
### 4. Type Declaration Guidelines
|
### 4. Type Declaration Guidelines
|
||||||
|
|
||||||
- **Prefer type inference over explicit type declarations** when the type is obvious from context
|
- **Prefer type inference over explicit type declarations** when the type is obvious from context
|
||||||
- Let the Rust compiler infer types whenever possible to reduce verbosity and improve maintainability
|
- Let the Rust compiler infer types whenever possible to reduce verbosity and improve maintainability
|
||||||
- Only specify types explicitly when:
|
- Only specify types explicitly when:
|
||||||
@@ -188,7 +162,6 @@ Example output when formatting fails:
|
|||||||
- Needed to resolve ambiguity between multiple possible types
|
- Needed to resolve ambiguity between multiple possible types
|
||||||
|
|
||||||
**Good examples (prefer these):**
|
**Good examples (prefer these):**
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Compiler can infer the type
|
// Compiler can infer the type
|
||||||
let items = vec![1, 2, 3, 4];
|
let items = vec![1, 2, 3, 4];
|
||||||
@@ -200,7 +173,6 @@ let filtered: Vec<_> = items.iter().filter(|&&x| x > 2).collect();
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Avoid unnecessary explicit types:**
|
**Avoid unnecessary explicit types:**
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Unnecessary - type is obvious
|
// Unnecessary - type is obvious
|
||||||
let items: Vec<i32> = vec![1, 2, 3, 4];
|
let items: Vec<i32> = vec![1, 2, 3, 4];
|
||||||
@@ -209,7 +181,6 @@ let result: ProcessResult = process_data(&input);
|
|||||||
```
|
```
|
||||||
|
|
||||||
**When explicit types are beneficial:**
|
**When explicit types are beneficial:**
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// API boundaries - always specify types
|
// API boundaries - always specify types
|
||||||
pub fn process_data(input: &[u8]) -> Result<ProcessResult, Error> { ... }
|
pub fn process_data(input: &[u8]) -> Result<ProcessResult, Error> { ... }
|
||||||
@@ -222,7 +193,6 @@ let cache: HashMap<String, Arc<Mutex<CacheEntry>>> = HashMap::new();
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 5. Documentation Comments
|
### 5. Documentation Comments
|
||||||
|
|
||||||
- Public APIs must have documentation comments
|
- Public APIs must have documentation comments
|
||||||
- Use `///` for documentation comments
|
- Use `///` for documentation comments
|
||||||
- Complex functions add `# Examples` and `# Parameters` descriptions
|
- Complex functions add `# Examples` and `# Parameters` descriptions
|
||||||
@@ -231,7 +201,6 @@ let cache: HashMap<String, Arc<Mutex<CacheEntry>>> = HashMap::new();
|
|||||||
- Avoid meaningless comments like "debug 111" or placeholder text
|
- Avoid meaningless comments like "debug 111" or placeholder text
|
||||||
|
|
||||||
### 6. Import Guidelines
|
### 6. Import Guidelines
|
||||||
|
|
||||||
- Standard library imports first
|
- Standard library imports first
|
||||||
- Third-party crate imports in the middle
|
- Third-party crate imports in the middle
|
||||||
- Project internal imports last
|
- Project internal imports last
|
||||||
@@ -240,7 +209,6 @@ let cache: HashMap<String, Arc<Mutex<CacheEntry>>> = HashMap::new();
|
|||||||
## Asynchronous Programming Guidelines
|
## Asynchronous Programming Guidelines
|
||||||
|
|
||||||
### 1. Trait Definition
|
### 1. Trait Definition
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
pub trait StorageAPI: Send + Sync {
|
pub trait StorageAPI: Send + Sync {
|
||||||
@@ -249,7 +217,6 @@ pub trait StorageAPI: Send + Sync {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 2. Error Handling
|
### 2. Error Handling
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Use ? operator to propagate errors
|
// Use ? operator to propagate errors
|
||||||
async fn example_function() -> Result<()> {
|
async fn example_function() -> Result<()> {
|
||||||
@@ -260,7 +227,6 @@ async fn example_function() -> Result<()> {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 3. Concurrency Control
|
### 3. Concurrency Control
|
||||||
|
|
||||||
- Use `Arc` and `Mutex`/`RwLock` for shared state management
|
- Use `Arc` and `Mutex`/`RwLock` for shared state management
|
||||||
- Prioritize async locks from `tokio::sync`
|
- Prioritize async locks from `tokio::sync`
|
||||||
- Avoid holding locks for long periods
|
- Avoid holding locks for long periods
|
||||||
@@ -268,7 +234,6 @@ async fn example_function() -> Result<()> {
|
|||||||
## Logging and Tracing Guidelines
|
## Logging and Tracing Guidelines
|
||||||
|
|
||||||
### 1. Tracing Usage
|
### 1. Tracing Usage
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[tracing::instrument(skip(self, data))]
|
#[tracing::instrument(skip(self, data))]
|
||||||
async fn process_data(&self, data: &[u8]) -> Result<()> {
|
async fn process_data(&self, data: &[u8]) -> Result<()> {
|
||||||
@@ -278,7 +243,6 @@ async fn process_data(&self, data: &[u8]) -> Result<()> {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 2. Log Levels
|
### 2. Log Levels
|
||||||
|
|
||||||
- `error!`: System errors requiring immediate attention
|
- `error!`: System errors requiring immediate attention
|
||||||
- `warn!`: Warning information that may affect functionality
|
- `warn!`: Warning information that may affect functionality
|
||||||
- `info!`: Important business information
|
- `info!`: Important business information
|
||||||
@@ -286,7 +250,6 @@ async fn process_data(&self, data: &[u8]) -> Result<()> {
|
|||||||
- `trace!`: Detailed execution paths
|
- `trace!`: Detailed execution paths
|
||||||
|
|
||||||
### 3. Structured Logging
|
### 3. Structured Logging
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
info!(
|
info!(
|
||||||
counter.rustfs_api_requests_total = 1_u64,
|
counter.rustfs_api_requests_total = 1_u64,
|
||||||
@@ -299,213 +262,45 @@ info!(
|
|||||||
## Error Handling Guidelines
|
## Error Handling Guidelines
|
||||||
|
|
||||||
### 1. Error Type Definition
|
### 1. Error Type Definition
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Use thiserror for module-specific error types
|
#[derive(Debug, thiserror::Error)]
|
||||||
#[derive(thiserror::Error, Debug)]
|
|
||||||
pub enum MyError {
|
pub enum MyError {
|
||||||
#[error("IO error: {0}")]
|
#[error("IO error: {0}")]
|
||||||
Io(#[from] std::io::Error),
|
Io(#[from] std::io::Error),
|
||||||
|
|
||||||
#[error("Storage error: {0}")]
|
|
||||||
Storage(#[from] ecstore::error::StorageError),
|
|
||||||
|
|
||||||
#[error("Custom error: {message}")]
|
#[error("Custom error: {message}")]
|
||||||
Custom { message: String },
|
Custom { message: String },
|
||||||
|
|
||||||
#[error("File not found: {path}")]
|
|
||||||
FileNotFound { path: String },
|
|
||||||
|
|
||||||
#[error("Invalid configuration: {0}")]
|
|
||||||
InvalidConfig(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Provide Result type alias for the module
|
|
||||||
pub type Result<T> = core::result::Result<T, MyError>;
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Error Helper Methods
|
|
||||||
|
|
||||||
```rust
|
|
||||||
impl MyError {
|
|
||||||
/// Create error from any compatible error type
|
|
||||||
pub fn other<E>(error: E) -> Self
|
|
||||||
where
|
|
||||||
E: Into<Box<dyn std::error::Error + Send + Sync>>,
|
|
||||||
{
|
|
||||||
MyError::Io(std::io::Error::other(error))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Error Conversion Between Modules
|
### 2. Error Conversion
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Convert between different module error types
|
pub fn to_s3_error(err: Error) -> S3Error {
|
||||||
impl From<ecstore::error::StorageError> for MyError {
|
if let Some(storage_err) = err.downcast_ref::<StorageError>() {
|
||||||
fn from(e: ecstore::error::StorageError) -> Self {
|
match storage_err {
|
||||||
match e {
|
StorageError::ObjectNotFound(bucket, object) => {
|
||||||
ecstore::error::StorageError::FileNotFound => {
|
s3_error!(NoSuchKey, "{}/{}", bucket, object)
|
||||||
MyError::FileNotFound { path: "unknown".to_string() }
|
|
||||||
}
|
}
|
||||||
_ => MyError::Storage(e),
|
// Other error types...
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Provide reverse conversion when needed
|
|
||||||
impl From<MyError> for ecstore::error::StorageError {
|
|
||||||
fn from(e: MyError) -> Self {
|
|
||||||
match e {
|
|
||||||
MyError::FileNotFound { .. } => ecstore::error::StorageError::FileNotFound,
|
|
||||||
MyError::Storage(e) => e,
|
|
||||||
_ => ecstore::error::StorageError::other(e),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Default error handling
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. Error Context and Propagation
|
### 3. Error Context
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Use ? operator for clean error propagation
|
// Add error context
|
||||||
async fn example_function() -> Result<()> {
|
.map_err(|e| Error::from_string(format!("Failed to process {}: {}", path, e)))?
|
||||||
let data = read_file("path").await?;
|
|
||||||
process_data(data).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add context to errors
|
|
||||||
fn process_with_context(path: &str) -> Result<()> {
|
|
||||||
std::fs::read(path)
|
|
||||||
.map_err(|e| MyError::Custom {
|
|
||||||
message: format!("Failed to read {}: {}", path, e)
|
|
||||||
})?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5. API Error Conversion (S3 Example)
|
|
||||||
|
|
||||||
```rust
|
|
||||||
// Convert storage errors to API-specific errors
|
|
||||||
use s3s::{S3Error, S3ErrorCode};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ApiError {
|
|
||||||
pub code: S3ErrorCode,
|
|
||||||
pub message: String,
|
|
||||||
pub source: Option<Box<dyn std::error::Error + Send + Sync>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ecstore::error::StorageError> for ApiError {
|
|
||||||
fn from(err: ecstore::error::StorageError) -> Self {
|
|
||||||
let code = match &err {
|
|
||||||
ecstore::error::StorageError::BucketNotFound(_) => S3ErrorCode::NoSuchBucket,
|
|
||||||
ecstore::error::StorageError::ObjectNotFound(_, _) => S3ErrorCode::NoSuchKey,
|
|
||||||
ecstore::error::StorageError::BucketExists(_) => S3ErrorCode::BucketAlreadyExists,
|
|
||||||
ecstore::error::StorageError::InvalidArgument(_, _, _) => S3ErrorCode::InvalidArgument,
|
|
||||||
ecstore::error::StorageError::MethodNotAllowed => S3ErrorCode::MethodNotAllowed,
|
|
||||||
ecstore::error::StorageError::StorageFull => S3ErrorCode::ServiceUnavailable,
|
|
||||||
_ => S3ErrorCode::InternalError,
|
|
||||||
};
|
|
||||||
|
|
||||||
ApiError {
|
|
||||||
code,
|
|
||||||
message: err.to_string(),
|
|
||||||
source: Some(Box::new(err)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ApiError> for S3Error {
|
|
||||||
fn from(err: ApiError) -> Self {
|
|
||||||
let mut s3e = S3Error::with_message(err.code, err.message);
|
|
||||||
if let Some(source) = err.source {
|
|
||||||
s3e.set_source(source);
|
|
||||||
}
|
|
||||||
s3e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 6. Error Handling Best Practices
|
|
||||||
|
|
||||||
#### Pattern Matching and Error Classification
|
|
||||||
|
|
||||||
```rust
|
|
||||||
// Use pattern matching for specific error handling
|
|
||||||
async fn handle_storage_operation() -> Result<()> {
|
|
||||||
match storage.get_object("bucket", "key").await {
|
|
||||||
Ok(object) => process_object(object),
|
|
||||||
Err(ecstore::error::StorageError::ObjectNotFound(bucket, key)) => {
|
|
||||||
warn!("Object not found: {}/{}", bucket, key);
|
|
||||||
create_default_object(bucket, key).await
|
|
||||||
}
|
|
||||||
Err(ecstore::error::StorageError::BucketNotFound(bucket)) => {
|
|
||||||
error!("Bucket not found: {}", bucket);
|
|
||||||
Err(MyError::Custom {
|
|
||||||
message: format!("Bucket {} does not exist", bucket)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
error!("Storage operation failed: {}", e);
|
|
||||||
Err(MyError::Storage(e))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Error Aggregation and Reporting
|
|
||||||
|
|
||||||
```rust
|
|
||||||
// Collect and report multiple errors
|
|
||||||
pub fn validate_configuration(config: &Config) -> Result<()> {
|
|
||||||
let mut errors = Vec::new();
|
|
||||||
|
|
||||||
if config.bucket_name.is_empty() {
|
|
||||||
errors.push("Bucket name cannot be empty");
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.region.is_empty() {
|
|
||||||
errors.push("Region must be specified");
|
|
||||||
}
|
|
||||||
|
|
||||||
if !errors.is_empty() {
|
|
||||||
return Err(MyError::Custom {
|
|
||||||
message: format!("Configuration validation failed: {}", errors.join(", "))
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Contextual Error Information
|
|
||||||
|
|
||||||
```rust
|
|
||||||
// Add operation context to errors
|
|
||||||
#[tracing::instrument(skip(self))]
|
|
||||||
async fn upload_file(&self, bucket: &str, key: &str, data: Vec<u8>) -> Result<()> {
|
|
||||||
self.storage
|
|
||||||
.put_object(bucket, key, data)
|
|
||||||
.await
|
|
||||||
.map_err(|e| MyError::Custom {
|
|
||||||
message: format!("Failed to upload {}/{}: {}", bucket, key, e)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Performance Optimization Guidelines
|
## Performance Optimization Guidelines
|
||||||
|
|
||||||
### 1. Memory Management
|
### 1. Memory Management
|
||||||
|
|
||||||
- Use `Bytes` instead of `Vec<u8>` for zero-copy operations
|
- Use `Bytes` instead of `Vec<u8>` for zero-copy operations
|
||||||
- Avoid unnecessary cloning, use reference passing
|
- Avoid unnecessary cloning, use reference passing
|
||||||
- Use `Arc` for sharing large objects
|
- Use `Arc` for sharing large objects
|
||||||
|
|
||||||
### 2. Concurrency Optimization
|
### 2. Concurrency Optimization
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Use join_all for concurrent operations
|
// Use join_all for concurrent operations
|
||||||
let futures = disks.iter().map(|disk| disk.operation());
|
let futures = disks.iter().map(|disk| disk.operation());
|
||||||
@@ -513,14 +308,12 @@ let results = join_all(futures).await;
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 3. Caching Strategy
|
### 3. Caching Strategy
|
||||||
|
|
||||||
- Use `lazy_static` or `OnceCell` for global caching
|
- Use `lazy_static` or `OnceCell` for global caching
|
||||||
- Implement LRU cache to avoid memory leaks
|
- Implement LRU cache to avoid memory leaks
|
||||||
|
|
||||||
## Testing Guidelines
|
## Testing Guidelines
|
||||||
|
|
||||||
### 1. Unit Tests
|
### 1. Unit Tests
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
@@ -538,55 +331,14 @@ mod tests {
|
|||||||
fn test_with_cases(input: &str, expected: &str) {
|
fn test_with_cases(input: &str, expected: &str) {
|
||||||
assert_eq!(function(input), expected);
|
assert_eq!(function(input), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_error_conversion() {
|
|
||||||
use ecstore::error::StorageError;
|
|
||||||
|
|
||||||
let storage_err = StorageError::BucketNotFound("test-bucket".to_string());
|
|
||||||
let api_err: ApiError = storage_err.into();
|
|
||||||
|
|
||||||
assert_eq!(api_err.code, S3ErrorCode::NoSuchBucket);
|
|
||||||
assert!(api_err.message.contains("test-bucket"));
|
|
||||||
assert!(api_err.source.is_some());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_error_types() {
|
|
||||||
let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "file not found");
|
|
||||||
let my_err = MyError::Io(io_err);
|
|
||||||
|
|
||||||
// Test error matching
|
|
||||||
match my_err {
|
|
||||||
MyError::Io(_) => {}, // Expected
|
|
||||||
_ => panic!("Unexpected error type"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_error_context() {
|
|
||||||
let result = process_with_context("nonexistent_file.txt");
|
|
||||||
assert!(result.is_err());
|
|
||||||
|
|
||||||
let err = result.unwrap_err();
|
|
||||||
match err {
|
|
||||||
MyError::Custom { message } => {
|
|
||||||
assert!(message.contains("Failed to read"));
|
|
||||||
assert!(message.contains("nonexistent_file.txt"));
|
|
||||||
}
|
|
||||||
_ => panic!("Expected Custom error"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Integration Tests
|
### 2. Integration Tests
|
||||||
|
|
||||||
- Use `e2e_test` module for end-to-end testing
|
- Use `e2e_test` module for end-to-end testing
|
||||||
- Simulate real storage environments
|
- Simulate real storage environments
|
||||||
|
|
||||||
### 3. Test Quality Standards
|
### 3. Test Quality Standards
|
||||||
|
|
||||||
- Write meaningful test cases that verify actual functionality
|
- Write meaningful test cases that verify actual functionality
|
||||||
- Avoid placeholder or debug content like "debug 111", "test test", etc.
|
- Avoid placeholder or debug content like "debug 111", "test test", etc.
|
||||||
- Use descriptive test names that clearly indicate what is being tested
|
- Use descriptive test names that clearly indicate what is being tested
|
||||||
@@ -596,11 +348,9 @@ mod tests {
|
|||||||
## Cross-Platform Compatibility Guidelines
|
## Cross-Platform Compatibility Guidelines
|
||||||
|
|
||||||
### 1. CPU Architecture Compatibility
|
### 1. CPU Architecture Compatibility
|
||||||
|
|
||||||
- **Always consider multi-platform and different CPU architecture compatibility** when writing code
|
- **Always consider multi-platform and different CPU architecture compatibility** when writing code
|
||||||
- Support major architectures: x86_64, aarch64 (ARM64), and other target platforms
|
- Support major architectures: x86_64, aarch64 (ARM64), and other target platforms
|
||||||
- Use conditional compilation for architecture-specific code:
|
- Use conditional compilation for architecture-specific code:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn optimized_x86_64_function() { /* x86_64 specific implementation */ }
|
fn optimized_x86_64_function() { /* x86_64 specific implementation */ }
|
||||||
@@ -613,19 +363,16 @@ fn generic_function() { /* Generic fallback implementation */ }
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 2. Platform-Specific Dependencies
|
### 2. Platform-Specific Dependencies
|
||||||
|
|
||||||
- Use feature flags for platform-specific dependencies
|
- Use feature flags for platform-specific dependencies
|
||||||
- Provide fallback implementations for unsupported platforms
|
- Provide fallback implementations for unsupported platforms
|
||||||
- Test on multiple architectures in CI/CD pipeline
|
- Test on multiple architectures in CI/CD pipeline
|
||||||
|
|
||||||
### 3. Endianness Considerations
|
### 3. Endianness Considerations
|
||||||
|
|
||||||
- Use explicit byte order conversion when dealing with binary data
|
- Use explicit byte order conversion when dealing with binary data
|
||||||
- Prefer `to_le_bytes()`, `from_le_bytes()` for consistent little-endian format
|
- Prefer `to_le_bytes()`, `from_le_bytes()` for consistent little-endian format
|
||||||
- Use `byteorder` crate for complex binary format handling
|
- Use `byteorder` crate for complex binary format handling
|
||||||
|
|
||||||
### 4. SIMD and Performance Optimizations
|
### 4. SIMD and Performance Optimizations
|
||||||
|
|
||||||
- Use portable SIMD libraries like `wide` or `packed_simd`
|
- Use portable SIMD libraries like `wide` or `packed_simd`
|
||||||
- Provide fallback implementations for non-SIMD architectures
|
- Provide fallback implementations for non-SIMD architectures
|
||||||
- Use runtime feature detection when appropriate
|
- Use runtime feature detection when appropriate
|
||||||
@@ -633,12 +380,10 @@ fn generic_function() { /* Generic fallback implementation */ }
|
|||||||
## Security Guidelines
|
## Security Guidelines
|
||||||
|
|
||||||
### 1. Memory Safety
|
### 1. Memory Safety
|
||||||
|
|
||||||
- Disable `unsafe` code (workspace.lints.rust.unsafe_code = "deny")
|
- Disable `unsafe` code (workspace.lints.rust.unsafe_code = "deny")
|
||||||
- Use `rustls` instead of `openssl`
|
- Use `rustls` instead of `openssl`
|
||||||
|
|
||||||
### 2. Authentication and Authorization
|
### 2. Authentication and Authorization
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Use IAM system for permission checks
|
// Use IAM system for permission checks
|
||||||
let identity = iam.authenticate(&access_key, &secret_key).await?;
|
let identity = iam.authenticate(&access_key, &secret_key).await?;
|
||||||
@@ -648,13 +393,11 @@ iam.authorize(&identity, &action, &resource).await?;
|
|||||||
## Configuration Management Guidelines
|
## Configuration Management Guidelines
|
||||||
|
|
||||||
### 1. Environment Variables
|
### 1. Environment Variables
|
||||||
|
|
||||||
- Use `RUSTFS_` prefix
|
- Use `RUSTFS_` prefix
|
||||||
- Support both configuration files and environment variables
|
- Support both configuration files and environment variables
|
||||||
- Provide reasonable default values
|
- Provide reasonable default values
|
||||||
|
|
||||||
### 2. Configuration Structure
|
### 2. Configuration Structure
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
@@ -668,12 +411,10 @@ pub struct Config {
|
|||||||
## Dependency Management Guidelines
|
## Dependency Management Guidelines
|
||||||
|
|
||||||
### 1. Workspace Dependencies
|
### 1. Workspace Dependencies
|
||||||
|
|
||||||
- Manage versions uniformly at workspace level
|
- Manage versions uniformly at workspace level
|
||||||
- Use `workspace = true` to inherit configuration
|
- Use `workspace = true` to inherit configuration
|
||||||
|
|
||||||
### 2. Feature Flags
|
### 2. Feature Flags
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
[features]
|
[features]
|
||||||
default = ["file"]
|
default = ["file"]
|
||||||
@@ -684,18 +425,15 @@ kafka = ["dep:rdkafka"]
|
|||||||
## Deployment and Operations Guidelines
|
## Deployment and Operations Guidelines
|
||||||
|
|
||||||
### 1. Containerization
|
### 1. Containerization
|
||||||
|
|
||||||
- Provide Dockerfile and docker-compose configuration
|
- Provide Dockerfile and docker-compose configuration
|
||||||
- Support multi-stage builds to optimize image size
|
- Support multi-stage builds to optimize image size
|
||||||
|
|
||||||
### 2. Observability
|
### 2. Observability
|
||||||
|
|
||||||
- Integrate OpenTelemetry for distributed tracing
|
- Integrate OpenTelemetry for distributed tracing
|
||||||
- Support Prometheus metrics collection
|
- Support Prometheus metrics collection
|
||||||
- Provide Grafana dashboards
|
- Provide Grafana dashboards
|
||||||
|
|
||||||
### 3. Health Checks
|
### 3. Health Checks
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Implement health check endpoint
|
// Implement health check endpoint
|
||||||
async fn health_check() -> Result<HealthStatus> {
|
async fn health_check() -> Result<HealthStatus> {
|
||||||
@@ -706,7 +444,6 @@ async fn health_check() -> Result<HealthStatus> {
|
|||||||
## Code Review Checklist
|
## Code Review Checklist
|
||||||
|
|
||||||
### 1. **Code Formatting and Quality (MANDATORY)**
|
### 1. **Code Formatting and Quality (MANDATORY)**
|
||||||
|
|
||||||
- [ ] **Code is properly formatted** (`cargo fmt --all --check` passes)
|
- [ ] **Code is properly formatted** (`cargo fmt --all --check` passes)
|
||||||
- [ ] **All clippy warnings are resolved** (`cargo clippy --all-targets --all-features -- -D warnings` passes)
|
- [ ] **All clippy warnings are resolved** (`cargo clippy --all-targets --all-features -- -D warnings` passes)
|
||||||
- [ ] **Code compiles successfully** (`cargo check --all-targets` passes)
|
- [ ] **Code compiles successfully** (`cargo check --all-targets` passes)
|
||||||
@@ -714,32 +451,27 @@ async fn health_check() -> Result<HealthStatus> {
|
|||||||
- [ ] **No formatting-related changes** mixed with functional changes (separate commits)
|
- [ ] **No formatting-related changes** mixed with functional changes (separate commits)
|
||||||
|
|
||||||
### 2. Functionality
|
### 2. Functionality
|
||||||
|
|
||||||
- [ ] Are all error cases properly handled?
|
- [ ] Are all error cases properly handled?
|
||||||
- [ ] Is there appropriate logging?
|
- [ ] Is there appropriate logging?
|
||||||
- [ ] Is there necessary test coverage?
|
- [ ] Is there necessary test coverage?
|
||||||
|
|
||||||
### 3. Performance
|
### 3. Performance
|
||||||
|
|
||||||
- [ ] Are unnecessary memory allocations avoided?
|
- [ ] Are unnecessary memory allocations avoided?
|
||||||
- [ ] Are async operations used correctly?
|
- [ ] Are async operations used correctly?
|
||||||
- [ ] Are there potential deadlock risks?
|
- [ ] Are there potential deadlock risks?
|
||||||
|
|
||||||
### 4. Security
|
### 4. Security
|
||||||
|
|
||||||
- [ ] Are input parameters properly validated?
|
- [ ] Are input parameters properly validated?
|
||||||
- [ ] Are there appropriate permission checks?
|
- [ ] Are there appropriate permission checks?
|
||||||
- [ ] Is information leakage avoided?
|
- [ ] Is information leakage avoided?
|
||||||
|
|
||||||
### 5. Cross-Platform Compatibility
|
### 5. Cross-Platform Compatibility
|
||||||
|
|
||||||
- [ ] Does the code work on different CPU architectures (x86_64, aarch64)?
|
- [ ] Does the code work on different CPU architectures (x86_64, aarch64)?
|
||||||
- [ ] Are platform-specific features properly gated with conditional compilation?
|
- [ ] Are platform-specific features properly gated with conditional compilation?
|
||||||
- [ ] Is byte order handling correct for binary data?
|
- [ ] Is byte order handling correct for binary data?
|
||||||
- [ ] Are there appropriate fallback implementations for unsupported platforms?
|
- [ ] Are there appropriate fallback implementations for unsupported platforms?
|
||||||
|
|
||||||
### 6. Code Commits and Documentation
|
### 6. Code Commits and Documentation
|
||||||
|
|
||||||
- [ ] Does it comply with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)?
|
- [ ] Does it comply with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)?
|
||||||
- [ ] Are commit messages concise and under 72 characters for the title line?
|
- [ ] Are commit messages concise and under 72 characters for the title line?
|
||||||
- [ ] Commit titles should be concise and in English, avoid Chinese
|
- [ ] Commit titles should be concise and in English, avoid Chinese
|
||||||
@@ -748,7 +480,6 @@ async fn health_check() -> Result<HealthStatus> {
|
|||||||
## Common Patterns and Best Practices
|
## Common Patterns and Best Practices
|
||||||
|
|
||||||
### 1. Resource Management
|
### 1. Resource Management
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Use RAII pattern for resource management
|
// Use RAII pattern for resource management
|
||||||
pub struct ResourceGuard {
|
pub struct ResourceGuard {
|
||||||
@@ -763,7 +494,6 @@ impl Drop for ResourceGuard {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 2. Dependency Injection
|
### 2. Dependency Injection
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Use dependency injection pattern
|
// Use dependency injection pattern
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
@@ -773,7 +503,6 @@ pub struct Service {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 3. Graceful Shutdown
|
### 3. Graceful Shutdown
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// Implement graceful shutdown
|
// Implement graceful shutdown
|
||||||
async fn shutdown_gracefully(shutdown_rx: &mut Receiver<()>) {
|
async fn shutdown_gracefully(shutdown_rx: &mut Receiver<()>) {
|
||||||
@@ -792,19 +521,16 @@ async fn shutdown_gracefully(shutdown_rx: &mut Receiver<()>) {
|
|||||||
## Domain-Specific Guidelines
|
## Domain-Specific Guidelines
|
||||||
|
|
||||||
### 1. Storage Operations
|
### 1. Storage Operations
|
||||||
|
|
||||||
- All storage operations must support erasure coding
|
- All storage operations must support erasure coding
|
||||||
- Implement read/write quorum mechanisms
|
- Implement read/write quorum mechanisms
|
||||||
- Support data integrity verification
|
- Support data integrity verification
|
||||||
|
|
||||||
### 2. Network Communication
|
### 2. Network Communication
|
||||||
|
|
||||||
- Use gRPC for internal service communication
|
- Use gRPC for internal service communication
|
||||||
- HTTP/HTTPS support for S3-compatible API
|
- HTTP/HTTPS support for S3-compatible API
|
||||||
- Implement connection pooling and retry mechanisms
|
- Implement connection pooling and retry mechanisms
|
||||||
|
|
||||||
### 3. Metadata Management
|
### 3. Metadata Management
|
||||||
|
|
||||||
- Use FlatBuffers for serialization
|
- Use FlatBuffers for serialization
|
||||||
- Support version control and migration
|
- Support version control and migration
|
||||||
- Implement metadata caching
|
- Implement metadata caching
|
||||||
@@ -814,12 +540,11 @@ These rules should serve as guiding principles when developing the RustFS projec
|
|||||||
### 4. Code Operations
|
### 4. Code Operations
|
||||||
|
|
||||||
#### Branch Management
|
#### Branch Management
|
||||||
|
- **🚨 CRITICAL: NEVER modify code directly on main or master branch - THIS IS ABSOLUTELY FORBIDDEN 🚨**
|
||||||
- **🚨 CRITICAL: NEVER modify code directly on main or master branch - THIS IS ABSOLUTELY FORBIDDEN 🚨**
|
- **⚠️ ANY DIRECT COMMITS TO MASTER/MAIN WILL BE REJECTED AND MUST BE REVERTED IMMEDIATELY ⚠️**
|
||||||
- **⚠️ ANY DIRECT COMMITS TO MASTER/MAIN WILL BE REJECTED AND MUST BE REVERTED IMMEDIATELY ⚠️**
|
- **Always work on feature branches - NO EXCEPTIONS**
|
||||||
- **Always work on feature branches - NO EXCEPTIONS**
|
- Always check the .cursorrules file before starting to ensure you understand the project guidelines
|
||||||
- Always check the .cursorrules file before starting to ensure you understand the project guidelines
|
- **MANDATORY workflow for ALL changes:**
|
||||||
- **MANDATORY workflow for ALL changes:**
|
|
||||||
1. `git checkout main` (switch to main branch)
|
1. `git checkout main` (switch to main branch)
|
||||||
2. `git pull` (get latest changes)
|
2. `git pull` (get latest changes)
|
||||||
3. `git checkout -b feat/your-feature-name` (create and switch to feature branch)
|
3. `git checkout -b feat/your-feature-name` (create and switch to feature branch)
|
||||||
@@ -827,54 +552,28 @@ These rules should serve as guiding principles when developing the RustFS projec
|
|||||||
5. Test thoroughly before committing
|
5. Test thoroughly before committing
|
||||||
6. Commit and push to the feature branch
|
6. Commit and push to the feature branch
|
||||||
7. Create a pull request for code review
|
7. Create a pull request for code review
|
||||||
- Use descriptive branch names following the pattern: `feat/feature-name`, `fix/issue-name`, `refactor/component-name`, etc.
|
- Use descriptive branch names following the pattern: `feat/feature-name`, `fix/issue-name`, `refactor/component-name`, etc.
|
||||||
- **Double-check current branch before ANY commit: `git branch` to ensure you're NOT on main/master**
|
- **Double-check current branch before ANY commit: `git branch` to ensure you're NOT on main/master**
|
||||||
- Ensure all changes are made on feature branches and merged through pull requests
|
- Ensure all changes are made on feature branches and merged through pull requests
|
||||||
|
|
||||||
#### Development Workflow
|
#### Development Workflow
|
||||||
|
- Use English for all code comments, documentation, and variable names
|
||||||
- Use English for all code comments, documentation, and variable names
|
- Write meaningful and descriptive names for variables, functions, and methods
|
||||||
- Write meaningful and descriptive names for variables, functions, and methods
|
- Avoid meaningless test content like "debug 111" or placeholder values
|
||||||
- Avoid meaningless test content like "debug 111" or placeholder values
|
- Before each change, carefully read the existing code to ensure you understand the code structure and implementation, do not break existing logic implementation, do not introduce new issues
|
||||||
- Before each change, carefully read the existing code to ensure you understand the code structure and implementation, do not break existing logic implementation, do not introduce new issues
|
- Ensure each change provides sufficient test cases to guarantee code correctness
|
||||||
- Ensure each change provides sufficient test cases to guarantee code correctness
|
- Do not arbitrarily modify numbers and constants in test cases, carefully analyze their meaning to ensure test case correctness
|
||||||
- Do not arbitrarily modify numbers and constants in test cases, carefully analyze their meaning to ensure test case correctness
|
- When writing or modifying tests, check existing test cases to ensure they have scientific naming and rigorous logic testing, if not compliant, modify test cases to ensure scientific and rigorous testing
|
||||||
- When writing or modifying tests, check existing test cases to ensure they have scientific naming and rigorous logic testing, if not compliant, modify test cases to ensure scientific and rigorous testing
|
- **Before committing any changes, run `cargo clippy --all-targets --all-features -- -D warnings` to ensure all code passes Clippy checks**
|
||||||
- **Before committing any changes, run `cargo clippy --all-targets --all-features -- -D warnings` to ensure all code passes Clippy checks**
|
- After each development completion, first git add . then git commit -m "feat: feature description" or "fix: issue description", ensure compliance with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
||||||
- After each development completion, first git add . then git commit -m "feat: feature description" or "fix: issue description", ensure compliance with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
- **Keep commit messages concise and under 72 characters** for the title line, use body for detailed explanations if needed
|
||||||
- **Keep commit messages concise and under 72 characters** for the title line, use body for detailed explanations if needed
|
- After each development completion, first git push to remote repository
|
||||||
- After each development completion, first git push to remote repository
|
- After each change completion, summarize the changes, do not create summary files, provide a brief change description, ensure compliance with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
||||||
- After each change completion, summarize the changes, do not create summary files, provide a brief change description, ensure compliance with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
- Provide change descriptions needed for PR in the conversation, ensure compliance with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
||||||
- Provide change descriptions needed for PR in the conversation, ensure compliance with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
- **Always provide PR descriptions in English** after completing any changes, including:
|
||||||
- **Always provide PR descriptions in English** after completing any changes, including:
|
- Clear and concise title following Conventional Commits format
|
||||||
- Clear and concise title following Conventional Commits format
|
- Detailed description of what was changed and why
|
||||||
- Detailed description of what was changed and why
|
- List of key changes and improvements
|
||||||
- List of key changes and improvements
|
- Any breaking changes or migration notes if applicable
|
||||||
- Any breaking changes or migration notes if applicable
|
- Testing information and verification steps
|
||||||
- Testing information and verification steps
|
- **Provide PR descriptions in copyable markdown format** enclosed in code blocks for easy one-click copying
|
||||||
- **Provide PR descriptions in copyable markdown format** enclosed in code blocks for easy one-click copying
|
|
||||||
|
|
||||||
## 🚫 AI 文档生成限制
|
|
||||||
|
|
||||||
### 禁止生成总结文档
|
|
||||||
|
|
||||||
- **严格禁止创建任何形式的AI生成总结文档**
|
|
||||||
- **不得创建包含大量表情符号、详细格式化表格和典型AI风格的文档**
|
|
||||||
- **不得在项目中生成以下类型的文档:**
|
|
||||||
- 基准测试总结文档(BENCHMARK*.md)
|
|
||||||
- 实现对比分析文档(IMPLEMENTATION_COMPARISON*.md)
|
|
||||||
- 性能分析报告文档
|
|
||||||
- 架构总结文档
|
|
||||||
- 功能对比文档
|
|
||||||
- 任何带有大量表情符号和格式化内容的文档
|
|
||||||
- **如果需要文档,请只在用户明确要求时创建,并保持简洁实用的风格**
|
|
||||||
- **文档应当专注于实际需要的信息,避免过度格式化和装饰性内容**
|
|
||||||
- **任何发现的AI生成总结文档都应该立即删除**
|
|
||||||
|
|
||||||
### 允许的文档类型
|
|
||||||
|
|
||||||
- README.md(项目介绍,保持简洁)
|
|
||||||
- 技术文档(仅在明确需要时创建)
|
|
||||||
- 用户手册(仅在明确需要时创建)
|
|
||||||
- API文档(从代码生成)
|
|
||||||
- 变更日志(CHANGELOG.md)
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM ubuntu:22.04
|
FROM m.daocloud.io/docker.io/library/ubuntu:22.04
|
||||||
|
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
@@ -7,10 +7,9 @@ RUN sed -i s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g /etc/apt/
|
|||||||
RUN apt-get clean && apt-get update && apt-get install wget git curl unzip gcc pkg-config libssl-dev lld libdbus-1-dev libwayland-dev libwebkit2gtk-4.1-dev libxdo-dev -y
|
RUN apt-get clean && apt-get update && apt-get install wget git curl unzip gcc pkg-config libssl-dev lld libdbus-1-dev libwayland-dev libwebkit2gtk-4.1-dev libxdo-dev -y
|
||||||
|
|
||||||
# install protoc
|
# install protoc
|
||||||
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-linux-x86_64.zip \
|
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip \
|
||||||
&& unzip protoc-31.1-linux-x86_64.zip -d protoc3 \
|
&& unzip protoc-30.2-linux-x86_64.zip -d protoc3 \
|
||||||
&& mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc \
|
&& mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc && mv protoc3/include/* /usr/local/include/ && rm -rf protoc-30.2-linux-x86_64.zip protoc3
|
||||||
&& mv protoc3/include/* /usr/local/include/ && rm -rf protoc-31.1-linux-x86_64.zip protoc3
|
|
||||||
|
|
||||||
# install flatc
|
# install flatc
|
||||||
RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \
|
RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \
|
||||||
@@ -18,7 +17,10 @@ RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.
|
|||||||
&& mv flatc /usr/local/bin/ && chmod +x /usr/local/bin/flatc && rm -rf Linux.flatc.binary.g++-13.zip
|
&& mv flatc /usr/local/bin/ && chmod +x /usr/local/bin/flatc && rm -rf Linux.flatc.binary.g++-13.zip
|
||||||
|
|
||||||
# install rust
|
# install rust
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
ENV RUSTUP_DIST_SERVER="https://rsproxy.cn"
|
||||||
|
ENV RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
|
||||||
|
RUN curl -o rustup-init.sh --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh \
|
||||||
|
&& sh rustup-init.sh -y && rm -rf rustup-init.sh
|
||||||
|
|
||||||
COPY .docker/cargo.config.toml /root/.cargo/config.toml
|
COPY .docker/cargo.config.toml /root/.cargo/config.toml
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM rockylinux:9.3 AS builder
|
FROM m.daocloud.io/docker.io/library/rockylinux:9.3 AS builder
|
||||||
|
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
@@ -13,10 +13,10 @@ RUN dnf makecache
|
|||||||
RUN yum install wget git unzip gcc openssl-devel pkgconf-pkg-config -y
|
RUN yum install wget git unzip gcc openssl-devel pkgconf-pkg-config -y
|
||||||
|
|
||||||
# install protoc
|
# install protoc
|
||||||
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-linux-x86_64.zip \
|
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip \
|
||||||
&& unzip protoc-31.1-linux-x86_64.zip -d protoc3 \
|
&& unzip protoc-30.2-linux-x86_64.zip -d protoc3 \
|
||||||
&& mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc \
|
&& mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc \
|
||||||
&& mv protoc3/include/* /usr/local/include/ && rm -rf protoc-31.1-linux-x86_64.zip protoc3
|
&& rm -rf protoc-30.2-linux-x86_64.zip protoc3
|
||||||
|
|
||||||
# install flatc
|
# install flatc
|
||||||
RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \
|
RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \
|
||||||
@@ -25,7 +25,10 @@ RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.
|
|||||||
&& rm -rf Linux.flatc.binary.g++-13.zip
|
&& rm -rf Linux.flatc.binary.g++-13.zip
|
||||||
|
|
||||||
# install rust
|
# install rust
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
ENV RUSTUP_DIST_SERVER="https://rsproxy.cn"
|
||||||
|
ENV RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
|
||||||
|
RUN curl -o rustup-init.sh --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh \
|
||||||
|
&& sh rustup-init.sh -y && rm -rf rustup-init.sh
|
||||||
|
|
||||||
COPY .docker/cargo.config.toml /root/.cargo/config.toml
|
COPY .docker/cargo.config.toml /root/.cargo/config.toml
|
||||||
|
|
||||||
|
|||||||
22
.docker/Dockerfile.rustyvault
Normal file
22
.docker/Dockerfile.rustyvault
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
FROM vault:1.13
|
||||||
|
|
||||||
|
# Configure Vault for dev mode
|
||||||
|
ENV VAULT_DEV_ROOT_TOKEN_ID=rustfs-root-token
|
||||||
|
ENV VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200
|
||||||
|
|
||||||
|
# Install curl for health checks
|
||||||
|
USER root
|
||||||
|
RUN apk add --no-cache curl jq
|
||||||
|
|
||||||
|
# Copy the Vault initialization script
|
||||||
|
COPY vault-init.sh /usr/local/bin/vault-init.sh
|
||||||
|
RUN chmod +x /usr/local/bin/vault-init.sh
|
||||||
|
|
||||||
|
# Switch back to vault user
|
||||||
|
USER vault
|
||||||
|
|
||||||
|
# Expose Vault port
|
||||||
|
EXPOSE 8200
|
||||||
|
|
||||||
|
# Start Vault in dev mode and run the initialization script
|
||||||
|
ENTRYPOINT ["sh", "-c", "vault server -dev & sleep 5 && vault-init.sh"]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM ubuntu:22.04
|
FROM m.daocloud.io/docker.io/library/ubuntu:22.04
|
||||||
|
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
@@ -7,10 +7,9 @@ RUN sed -i s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g /etc/apt/
|
|||||||
RUN apt-get clean && apt-get update && apt-get install wget git curl unzip gcc pkg-config libssl-dev lld libdbus-1-dev libwayland-dev libwebkit2gtk-4.1-dev libxdo-dev -y
|
RUN apt-get clean && apt-get update && apt-get install wget git curl unzip gcc pkg-config libssl-dev lld libdbus-1-dev libwayland-dev libwebkit2gtk-4.1-dev libxdo-dev -y
|
||||||
|
|
||||||
# install protoc
|
# install protoc
|
||||||
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-linux-x86_64.zip \
|
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip \
|
||||||
&& unzip protoc-31.1-linux-x86_64.zip -d protoc3 \
|
&& unzip protoc-30.2-linux-x86_64.zip -d protoc3 \
|
||||||
&& mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc \
|
&& mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc && mv protoc3/include/* /usr/local/include/ && rm -rf protoc-30.2-linux-x86_64.zip protoc3
|
||||||
&& mv protoc3/include/* /usr/local/include/ && rm -rf protoc-31.1-linux-x86_64.zip protoc3
|
|
||||||
|
|
||||||
# install flatc
|
# install flatc
|
||||||
RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \
|
RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \
|
||||||
@@ -18,7 +17,10 @@ RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.
|
|||||||
&& mv flatc /usr/local/bin/ && chmod +x /usr/local/bin/flatc && rm -rf Linux.flatc.binary.g++-13.zip
|
&& mv flatc /usr/local/bin/ && chmod +x /usr/local/bin/flatc && rm -rf Linux.flatc.binary.g++-13.zip
|
||||||
|
|
||||||
# install rust
|
# install rust
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
ENV RUSTUP_DIST_SERVER="https://rsproxy.cn"
|
||||||
|
ENV RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
|
||||||
|
RUN curl -o rustup-init.sh --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh \
|
||||||
|
&& sh rustup-init.sh -y && rm -rf rustup-init.sh
|
||||||
|
|
||||||
COPY .docker/cargo.config.toml /root/.cargo/config.toml
|
COPY .docker/cargo.config.toml /root/.cargo/config.toml
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
[source.crates-io]
|
[source.crates-io]
|
||||||
registry = "https://github.com/rust-lang/crates.io-index"
|
registry = "https://github.com/rust-lang/crates.io-index"
|
||||||
|
replace-with = 'rsproxy-sparse'
|
||||||
|
|
||||||
|
[source.rsproxy]
|
||||||
|
registry = "https://rsproxy.cn/crates.io-index"
|
||||||
|
[registries.rsproxy]
|
||||||
|
index = "https://rsproxy.cn/crates.io-index"
|
||||||
|
[source.rsproxy-sparse]
|
||||||
|
registry = "sparse+https://rsproxy.cn/index/"
|
||||||
|
|
||||||
[net]
|
[net]
|
||||||
git-fetch-with-cli = true
|
git-fetch-with-cli = true
|
||||||
|
|||||||
26
.docker/kms/docker-compose.yml
Normal file
26
.docker/kms/docker-compose.yml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
services:
|
||||||
|
rustyvault:
|
||||||
|
build:
|
||||||
|
context: ./.docker
|
||||||
|
dockerfile: Dockerfile.rustyvault
|
||||||
|
container_name: rustyvault
|
||||||
|
hostname: rustyvault
|
||||||
|
ports:
|
||||||
|
- "8200:8200" # Vault API port
|
||||||
|
volumes:
|
||||||
|
- vault-data:/vault/data
|
||||||
|
- vault-config:/vault/config
|
||||||
|
cap_add:
|
||||||
|
- IPC_LOCK # Allow the vault to lock sensitive data in memory
|
||||||
|
environment:
|
||||||
|
- VAULT_DEV_ROOT_TOKEN_ID=rustfs-root-token
|
||||||
|
- VAULT_ADDR=http://0.0.0.0:8200
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-s", "http://127.0.0.1:8200/v1/sys/health"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
driver: bridge
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
# 节点配置
|
|
||||||
node.name = "emqx@127.0.0.1"
|
|
||||||
node.cookie = "aBcDeFgHiJkLmNoPqRsTuVwXyZ012345"
|
|
||||||
node.data_dir = "/opt/emqx/data"
|
|
||||||
|
|
||||||
# 日志配置
|
|
||||||
log.console = {level = info, enable = true}
|
|
||||||
log.file = {path = "/opt/emqx/log/emqx.log", enable = true, level = info}
|
|
||||||
|
|
||||||
# MQTT TCP 监听器
|
|
||||||
listeners.tcp.default = {bind = "0.0.0.0:1883", max_connections = 1000000, enable = true}
|
|
||||||
|
|
||||||
# MQTT SSL 监听器
|
|
||||||
listeners.ssl.default = {bind = "0.0.0.0:8883", enable = false}
|
|
||||||
|
|
||||||
# MQTT WebSocket 监听器
|
|
||||||
listeners.ws.default = {bind = "0.0.0.0:8083", enable = true}
|
|
||||||
|
|
||||||
# MQTT WebSocket SSL 监听器
|
|
||||||
listeners.wss.default = {bind = "0.0.0.0:8084", enable = false}
|
|
||||||
|
|
||||||
# 管理控制台
|
|
||||||
dashboard.listeners.http = {bind = "0.0.0.0:18083", enable = true}
|
|
||||||
|
|
||||||
# HTTP API
|
|
||||||
management.listeners.http = {bind = "0.0.0.0:8081", enable = true}
|
|
||||||
|
|
||||||
# 认证配置
|
|
||||||
authentication = [
|
|
||||||
{enable = true, mechanism = password_based, backend = built_in_database, user_id_type = username}
|
|
||||||
]
|
|
||||||
|
|
||||||
# 授权配置
|
|
||||||
authorization.sources = [{type = built_in_database, enable = true}]
|
|
||||||
|
|
||||||
# 持久化消息存储
|
|
||||||
message.storage.backend = built_in_database
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
-name emqx@127.0.0.1
|
|
||||||
-setcookie aBcDeFgHiJkLmNoPqRsTuVwXyZ012345
|
|
||||||
+P 2097152
|
|
||||||
+t 1048576
|
|
||||||
+zdbbl 32768
|
|
||||||
-kernel inet_dist_listen_min 6000
|
|
||||||
-kernel inet_dist_listen_max 6100
|
|
||||||
-smp enable
|
|
||||||
-mnesia dir "/opt/emqx/data/mnesia"
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
services:
|
|
||||||
emqx:
|
|
||||||
image: emqx/emqx:latest
|
|
||||||
container_name: emqx
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
- EMQX_NODE__NAME=emqx@127.0.0.1
|
|
||||||
- EMQX_NODE__COOKIE=aBcDeFgHiJkLmNoPqRsTuVwXyZ012345
|
|
||||||
- EMQX_NODE__DATA_DIR=/opt/emqx/data
|
|
||||||
- EMQX_LOG__CONSOLE__LEVEL=info
|
|
||||||
- EMQX_LOG__CONSOLE__ENABLE=true
|
|
||||||
- EMQX_LOG__FILE__PATH=/opt/emqx/log/emqx.log
|
|
||||||
- EMQX_LOG__FILE__LEVEL=info
|
|
||||||
- EMQX_LOG__FILE__ENABLE=true
|
|
||||||
- EMQX_LISTENERS__TCP__DEFAULT__BIND=0.0.0.0:1883
|
|
||||||
- EMQX_LISTENERS__TCP__DEFAULT__MAX_CONNECTIONS=1000000
|
|
||||||
- EMQX_LISTENERS__TCP__DEFAULT__ENABLE=true
|
|
||||||
- EMQX_LISTENERS__SSL__DEFAULT__BIND=0.0.0.0:8883
|
|
||||||
- EMQX_LISTENERS__SSL__DEFAULT__ENABLE=false
|
|
||||||
- EMQX_LISTENERS__WS__DEFAULT__BIND=0.0.0.0:8083
|
|
||||||
- EMQX_LISTENERS__WS__DEFAULT__ENABLE=true
|
|
||||||
- EMQX_LISTENERS__WSS__DEFAULT__BIND=0.0.0.0:8084
|
|
||||||
- EMQX_LISTENERS__WSS__DEFAULT__ENABLE=false
|
|
||||||
- EMQX_DASHBOARD__LISTENERS__HTTP__BIND=0.0.0.0:18083
|
|
||||||
- EMQX_DASHBOARD__LISTENERS__HTTP__ENABLE=true
|
|
||||||
- EMQX_MANAGEMENT__LISTENERS__HTTP__BIND=0.0.0.0:8081
|
|
||||||
- EMQX_MANAGEMENT__LISTENERS__HTTP__ENABLE=true
|
|
||||||
- EMQX_AUTHENTICATION__1__ENABLE=true
|
|
||||||
- EMQX_AUTHENTICATION__1__MECHANISM=password_based
|
|
||||||
- EMQX_AUTHENTICATION__1__BACKEND=built_in_database
|
|
||||||
- EMQX_AUTHENTICATION__1__USER_ID_TYPE=username
|
|
||||||
- EMQX_AUTHORIZATION__SOURCES__1__TYPE=built_in_database
|
|
||||||
- EMQX_AUTHORIZATION__SOURCES__1__ENABLE=true
|
|
||||||
ports:
|
|
||||||
- "1883:1883" # MQTT TCP
|
|
||||||
- "8883:8883" # MQTT SSL
|
|
||||||
- "8083:8083" # MQTT WebSocket
|
|
||||||
- "8084:8084" # MQTT WebSocket SSL
|
|
||||||
- "18083:18083" # Web 管理控制台
|
|
||||||
- "8081:8081" # HTTP API
|
|
||||||
volumes:
|
|
||||||
- ./data:/opt/emqx/data
|
|
||||||
- ./log:/opt/emqx/log
|
|
||||||
- ./config:/opt/emqx/etc
|
|
||||||
networks:
|
|
||||||
- mqtt-net
|
|
||||||
healthcheck:
|
|
||||||
test: [ "CMD", "/opt/emqx/bin/emqx_ctl", "status" ]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
logging:
|
|
||||||
driver: "json-file"
|
|
||||||
options:
|
|
||||||
max-size: "100m"
|
|
||||||
max-file: "3"
|
|
||||||
|
|
||||||
networks:
|
|
||||||
mqtt-net:
|
|
||||||
driver: bridge
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
services:
|
|
||||||
emqx:
|
|
||||||
image: emqx/emqx:latest
|
|
||||||
container_name: emqx
|
|
||||||
ports:
|
|
||||||
- "1883:1883"
|
|
||||||
- "8083:8083"
|
|
||||||
- "8084:8084"
|
|
||||||
- "8883:8883"
|
|
||||||
- "18083:18083"
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
networks:
|
|
||||||
default:
|
|
||||||
driver: bridge
|
|
||||||
@@ -22,6 +22,21 @@ docker compose -f docker-compose.yml up -d
|
|||||||
|
|
||||||
## 配置可观测性
|
## 配置可观测性
|
||||||
|
|
||||||
```shell
|
### 创建配置文件
|
||||||
export RUSTFS_OBS_ENDPOINT="http://localhost:4317" # OpenTelemetry Collector 地址
|
|
||||||
```
|
1. 进入 `deploy/config` 目录
|
||||||
|
2. 复制示例配置:`cp obs.toml.example obs.toml`
|
||||||
|
3. 编辑 `obs.toml` 配置文件,修改以下关键参数:
|
||||||
|
|
||||||
|
| 配置项 | 说明 | 示例值 |
|
||||||
|
|-----------------|----------------------------|-----------------------|
|
||||||
|
| endpoint | OpenTelemetry Collector 地址 | http://localhost:4317 |
|
||||||
|
| service_name | 服务名称 | rustfs |
|
||||||
|
| service_version | 服务版本 | 1.0.0 |
|
||||||
|
| environment | 运行环境 | production |
|
||||||
|
| meter_interval | 指标导出间隔 (秒) | 30 |
|
||||||
|
| sample_ratio | 采样率 | 1.0 |
|
||||||
|
| use_stdout | 是否输出到控制台 | true/false |
|
||||||
|
| logger_level | 日志级别 | info |
|
||||||
|
|
||||||
|
```
|
||||||
34
.docker/observability/config/obs-multi.toml
Normal file
34
.docker/observability/config/obs-multi.toml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[observability]
|
||||||
|
endpoint = "http://otel-collector:4317" # Default is "http://localhost:4317" if not specified
|
||||||
|
use_stdout = false # Output with stdout, true output, false no output
|
||||||
|
sample_ratio = 2.0
|
||||||
|
meter_interval = 30
|
||||||
|
service_name = "rustfs"
|
||||||
|
service_version = "0.1.0"
|
||||||
|
environments = "production"
|
||||||
|
logger_level = "debug"
|
||||||
|
local_logging_enabled = true
|
||||||
|
|
||||||
|
#[[sinks]]
|
||||||
|
#type = "Kafka"
|
||||||
|
#brokers = "localhost:9092"
|
||||||
|
#topic = "logs"
|
||||||
|
#batch_size = 100 # Default is 100 if not specified
|
||||||
|
#batch_timeout_ms = 1000 # Default is 1000ms if not specified
|
||||||
|
#
|
||||||
|
#[[sinks]]
|
||||||
|
#type = "Webhook"
|
||||||
|
#endpoint = "http://localhost:8080/webhook"
|
||||||
|
#auth_token = ""
|
||||||
|
#batch_size = 100 # Default is 3 if not specified
|
||||||
|
#batch_timeout_ms = 1000 # Default is 100ms if not specified
|
||||||
|
|
||||||
|
[[sinks]]
|
||||||
|
type = "File"
|
||||||
|
path = "/root/data/logs/rustfs.log"
|
||||||
|
buffer_size = 100 # Default is 8192 bytes if not specified
|
||||||
|
flush_interval_ms = 1000
|
||||||
|
flush_threshold = 100
|
||||||
|
|
||||||
|
[logger]
|
||||||
|
queue_capacity = 10
|
||||||
34
.docker/observability/config/obs.toml
Normal file
34
.docker/observability/config/obs.toml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[observability]
|
||||||
|
endpoint = "http://localhost:4317" # Default is "http://localhost:4317" if not specified
|
||||||
|
use_stdout = false # Output with stdout, true output, false no output
|
||||||
|
sample_ratio = 2.0
|
||||||
|
meter_interval = 30
|
||||||
|
service_name = "rustfs"
|
||||||
|
service_version = "0.1.0"
|
||||||
|
environments = "production"
|
||||||
|
logger_level = "debug"
|
||||||
|
local_logging_enabled = true
|
||||||
|
|
||||||
|
#[[sinks]]
|
||||||
|
#type = "Kafka"
|
||||||
|
#brokers = "localhost:9092"
|
||||||
|
#topic = "logs"
|
||||||
|
#batch_size = 100 # Default is 100 if not specified
|
||||||
|
#batch_timeout_ms = 1000 # Default is 1000ms if not specified
|
||||||
|
#
|
||||||
|
#[[sinks]]
|
||||||
|
#type = "Webhook"
|
||||||
|
#endpoint = "http://localhost:8080/webhook"
|
||||||
|
#auth_token = ""
|
||||||
|
#batch_size = 100 # Default is 3 if not specified
|
||||||
|
#batch_timeout_ms = 1000 # Default is 100ms if not specified
|
||||||
|
|
||||||
|
[[sinks]]
|
||||||
|
type = "File"
|
||||||
|
path = "/root/data/logs/rustfs.log"
|
||||||
|
buffer_size = 100 # Default is 8192 bytes if not specified
|
||||||
|
flush_interval_ms = 1000
|
||||||
|
flush_threshold = 100
|
||||||
|
|
||||||
|
[logger]
|
||||||
|
queue_capacity = 10
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
otel-collector:
|
otel-collector:
|
||||||
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.127.0
|
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.127.0
|
||||||
@@ -30,7 +16,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- otel-network
|
- otel-network
|
||||||
jaeger:
|
jaeger:
|
||||||
image: jaegertracing/jaeger:2.7.0
|
image: jaegertracing/jaeger:2.6.0
|
||||||
environment:
|
environment:
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
ports:
|
ports:
|
||||||
@@ -61,7 +47,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- otel-network
|
- otel-network
|
||||||
grafana:
|
grafana:
|
||||||
image: grafana/grafana:12.0.2
|
image: grafana/grafana:12.0.1
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000" # Web UI
|
- "3000:3000" # Web UI
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
service:
|
service:
|
||||||
extensions: [ jaeger_storage, jaeger_query, remote_sampling, healthcheckv2 ]
|
extensions: [ jaeger_storage, jaeger_query, remote_sampling, healthcheckv2 ]
|
||||||
pipelines:
|
pipelines:
|
||||||
@@ -64,10 +50,10 @@ extensions:
|
|||||||
backends:
|
backends:
|
||||||
some_store:
|
some_store:
|
||||||
memory:
|
memory:
|
||||||
max_traces: 1000000
|
max_traces: 100000
|
||||||
another_store:
|
another_store:
|
||||||
memory:
|
memory:
|
||||||
max_traces: 1000000
|
max_traces: 100000
|
||||||
metric_backends:
|
metric_backends:
|
||||||
some_metrics_storage:
|
some_metrics_storage:
|
||||||
prometheus:
|
prometheus:
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
auth_enabled: false
|
auth_enabled: false
|
||||||
|
|
||||||
server:
|
server:
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
receivers:
|
receivers:
|
||||||
otlp:
|
otlp:
|
||||||
protocols:
|
protocols:
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
global:
|
global:
|
||||||
scrape_interval: 5s # 刮取间隔
|
scrape_interval: 5s # 刮取间隔
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
openobserve:
|
openobserve:
|
||||||
image: public.ecr.aws/zinclabs/openobserve:latest
|
image: public.ecr.aws/zinclabs/openobserve:latest
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
receivers:
|
receivers:
|
||||||
otlp:
|
otlp:
|
||||||
protocols:
|
protocols:
|
||||||
|
|||||||
71
.docker/vault-init.sh
Normal file
71
.docker/vault-init.sh
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# vault-init.sh - Initialize Vault for RustFS SSE-KMS
|
||||||
|
|
||||||
|
# Wait for Vault to start
|
||||||
|
until curl -s http://127.0.0.1:8200/v1/sys/health | grep "initialized" > /dev/null; do
|
||||||
|
echo "Waiting for Vault to start..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Set the Vault token
|
||||||
|
export VAULT_TOKEN="$VAULT_DEV_ROOT_TOKEN_ID"
|
||||||
|
export VAULT_ADDR="http://127.0.0.1:8200"
|
||||||
|
|
||||||
|
echo "Vault is running and initialized"
|
||||||
|
|
||||||
|
# Enable the Transit secrets engine (for encryption operations)
|
||||||
|
vault secrets enable transit
|
||||||
|
echo "Transit secrets engine enabled"
|
||||||
|
|
||||||
|
# Create a key for RustFS encryption
|
||||||
|
vault write -f transit/keys/rustfs-encryption-key
|
||||||
|
echo "Created rustfs-encryption-key"
|
||||||
|
|
||||||
|
# Create another key for RustFS with rotation capability
|
||||||
|
vault write -f transit/keys/rustfs-rotating-key
|
||||||
|
echo "Created rustfs-rotating-key"
|
||||||
|
|
||||||
|
# Set up key rotation policy
|
||||||
|
vault write transit/keys/rustfs-rotating-key/config auto_rotate_period="30d"
|
||||||
|
echo "Set up auto rotation for rustfs-rotating-key"
|
||||||
|
|
||||||
|
# Create a policy for RustFS to access these keys
|
||||||
|
cat > /tmp/rustfs-policy.hcl << EOF
|
||||||
|
# Policy for RustFS encryption operations
|
||||||
|
path "transit/encrypt/rustfs-encryption-key" {
|
||||||
|
capabilities = ["create", "update"]
|
||||||
|
}
|
||||||
|
|
||||||
|
path "transit/decrypt/rustfs-encryption-key" {
|
||||||
|
capabilities = ["create", "update"]
|
||||||
|
}
|
||||||
|
|
||||||
|
path "transit/encrypt/rustfs-rotating-key" {
|
||||||
|
capabilities = ["create", "update"]
|
||||||
|
}
|
||||||
|
|
||||||
|
path "transit/decrypt/rustfs-rotating-key" {
|
||||||
|
capabilities = ["create", "update"]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Create the policy
|
||||||
|
vault policy write rustfs-encryption-policy /tmp/rustfs-policy.hcl
|
||||||
|
echo "Created rustfs-encryption-policy"
|
||||||
|
|
||||||
|
# Create a token for RustFS to use
|
||||||
|
RUSTFS_TOKEN=$(vault token create -policy=rustfs-encryption-policy -field=token)
|
||||||
|
echo "Created token for RustFS: $RUSTFS_TOKEN"
|
||||||
|
|
||||||
|
# Store the token for RustFS to use
|
||||||
|
echo "RUSTFS_KMS_VAULT_TOKEN=$RUSTFS_TOKEN" > /vault/config/rustfs-kms.env
|
||||||
|
echo "RUSTFS_KMS_VAULT_ENDPOINT=http://rustyvault:8200" >> /vault/config/rustfs-kms.env
|
||||||
|
echo "RUSTFS_KMS_VAULT_KEY_NAME=rustfs-encryption-key" >> /vault/config/rustfs-kms.env
|
||||||
|
|
||||||
|
echo "RustFS KMS configuration has been created"
|
||||||
|
echo "============================================"
|
||||||
|
echo "Vault is ready for use with RustFS SSE-KMS"
|
||||||
|
echo "============================================"
|
||||||
|
|
||||||
|
# Keep the container running
|
||||||
|
tail -f /dev/null
|
||||||
25
.github/actions/setup/action.yml
vendored
25
.github/actions/setup/action.yml
vendored
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
name: "setup"
|
name: "setup"
|
||||||
|
|
||||||
description: "setup environment for rustfs"
|
description: "setup environment for rustfs"
|
||||||
@@ -27,9 +13,9 @@ inputs:
|
|||||||
description: "Cache key for shared cache"
|
description: "Cache key for shared cache"
|
||||||
cache-save-if:
|
cache-save-if:
|
||||||
required: true
|
required: true
|
||||||
default: ${{ github.ref == 'refs/heads/main' }}
|
default: true
|
||||||
description: "Cache save condition"
|
description: "Cache save condition"
|
||||||
runs-on:
|
run-os:
|
||||||
required: true
|
required: true
|
||||||
default: "ubuntu-latest"
|
default: "ubuntu-latest"
|
||||||
description: "Running system"
|
description: "Running system"
|
||||||
@@ -38,7 +24,7 @@ runs:
|
|||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
if: inputs.runs-on == 'ubuntu-latest'
|
if: inputs.run-os == 'ubuntu-latest'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
@@ -46,11 +32,11 @@ runs:
|
|||||||
|
|
||||||
- uses: arduino/setup-protoc@v3
|
- uses: arduino/setup-protoc@v3
|
||||||
with:
|
with:
|
||||||
version: "31.1"
|
version: "30.2"
|
||||||
|
|
||||||
- uses: Nugine/setup-flatc@v1
|
- uses: Nugine/setup-flatc@v1
|
||||||
with:
|
with:
|
||||||
version: "25.2.10"
|
version: "24.3.25"
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@master
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
@@ -59,6 +45,7 @@ runs:
|
|||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
|
cache-on-failure: true
|
||||||
cache-all-crates: true
|
cache-all-crates: true
|
||||||
shared-key: ${{ inputs.cache-shared-key }}
|
shared-key: ${{ inputs.cache-shared-key }}
|
||||||
save-if: ${{ inputs.cache-save-if }}
|
save-if: ${{ inputs.cache-save-if }}
|
||||||
|
|||||||
14
.github/dependabot.yml
vendored
14
.github/dependabot.yml
vendored
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# To get started with Dependabot version updates, you'll need to specify which
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
# package ecosystems to update and where the package manifests are located.
|
# package ecosystems to update and where the package manifests are located.
|
||||||
# Please see the documentation for all configuration options:
|
# Please see the documentation for all configuration options:
|
||||||
|
|||||||
20
.github/workflows/audit.yml
vendored
20
.github/workflows/audit.yml
vendored
@@ -1,30 +1,16 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
name: Audit
|
name: Audit
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- '**/Cargo.toml'
|
- '**/Cargo.toml'
|
||||||
- '**/Cargo.lock'
|
- '**/Cargo.lock'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- '**/Cargo.toml'
|
- '**/Cargo.toml'
|
||||||
- '**/Cargo.lock'
|
- '**/Cargo.lock'
|
||||||
schedule:
|
schedule:
|
||||||
@@ -34,6 +20,6 @@ jobs:
|
|||||||
audit:
|
audit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4.2.2
|
- uses: actions/checkout@v4
|
||||||
- uses: taiki-e/install-action@cargo-audit
|
- uses: taiki-e/install-action@cargo-audit
|
||||||
- run: cargo audit -D warnings
|
- run: cargo audit -D warnings
|
||||||
|
|||||||
255
.github/workflows/build.yml
vendored
255
.github/workflows/build.yml
vendored
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
name: Build RustFS And GUI
|
name: Build RustFS And GUI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -19,132 +5,54 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 * * 0" # at midnight of each sunday
|
- cron: "0 0 * * 0" # at midnight of each sunday
|
||||||
push:
|
push:
|
||||||
tags: ["v*", "*"]
|
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
tags: [ "v*", "*" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-rustfs:
|
build-rustfs:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
# Only execute in the following cases: 1) tag push 2) scheduled run 3) commit message contains --build
|
|
||||||
if: |
|
|
||||||
startsWith(github.ref, 'refs/tags/') ||
|
|
||||||
github.event_name == 'schedule' ||
|
|
||||||
github.event_name == 'workflow_dispatch' ||
|
|
||||||
contains(github.event.head_commit.message, '--build')
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
||||||
variant:
|
variant:
|
||||||
- {
|
- { profile: release, target: x86_64-unknown-linux-musl, glibc: "default" }
|
||||||
profile: release,
|
- { profile: release, target: x86_64-unknown-linux-gnu, glibc: "default" }
|
||||||
target: x86_64-unknown-linux-musl,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
profile: release,
|
|
||||||
target: x86_64-unknown-linux-gnu,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- { profile: release, target: aarch64-apple-darwin, glibc: "default" }
|
- { profile: release, target: aarch64-apple-darwin, glibc: "default" }
|
||||||
#- { profile: release, target: aarch64-unknown-linux-gnu, glibc: "default" }
|
#- { profile: release, target: aarch64-unknown-linux-gnu, glibc: "default" }
|
||||||
- {
|
- { profile: release, target: aarch64-unknown-linux-musl, glibc: "default" }
|
||||||
profile: release,
|
|
||||||
target: aarch64-unknown-linux-musl,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
#- { profile: release, target: x86_64-pc-windows-msvc, glibc: "default" }
|
#- { profile: release, target: x86_64-pc-windows-msvc, glibc: "default" }
|
||||||
exclude:
|
exclude:
|
||||||
# Linux targets on non-Linux systems
|
# Linux targets on non-Linux systems
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
variant:
|
variant: { profile: release, target: x86_64-unknown-linux-gnu, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: x86_64-unknown-linux-gnu,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
variant:
|
variant: { profile: release, target: x86_64-unknown-linux-musl, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: x86_64-unknown-linux-musl,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
variant:
|
variant: { profile: release, target: aarch64-unknown-linux-gnu, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: aarch64-unknown-linux-gnu,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
variant:
|
variant: { profile: release, target: aarch64-unknown-linux-musl, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: aarch64-unknown-linux-musl,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
variant:
|
variant: { profile: release, target: x86_64-unknown-linux-gnu, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: x86_64-unknown-linux-gnu,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
variant:
|
variant: { profile: release, target: x86_64-unknown-linux-musl, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: x86_64-unknown-linux-musl,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
variant:
|
variant: { profile: release, target: aarch64-unknown-linux-gnu, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: aarch64-unknown-linux-gnu,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
variant:
|
variant: { profile: release, target: aarch64-unknown-linux-musl, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: aarch64-unknown-linux-musl,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
|
|
||||||
# Apple targets on non-macOS systems
|
# Apple targets on non-macOS systems
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
variant:
|
variant: { profile: release, target: aarch64-apple-darwin, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: aarch64-apple-darwin,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
variant:
|
variant: { profile: release, target: aarch64-apple-darwin, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: aarch64-apple-darwin,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
|
|
||||||
# Windows targets on non-Windows systems
|
# Windows targets on non-Windows systems
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
variant:
|
variant: { profile: release, target: x86_64-pc-windows-msvc, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: x86_64-pc-windows-msvc,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
variant:
|
variant: { profile: release, target: x86_64-pc-windows-msvc, glibc: "default" }
|
||||||
{
|
|
||||||
profile: release,
|
|
||||||
target: x86_64-pc-windows-msvc,
|
|
||||||
glibc: "default",
|
|
||||||
}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -173,7 +81,7 @@ jobs:
|
|||||||
uses: actions/cache@v4.2.3
|
uses: actions/cache@v4.2.3
|
||||||
with:
|
with:
|
||||||
path: /Users/runner/hostedtoolcache/protoc
|
path: /Users/runner/hostedtoolcache/protoc
|
||||||
key: protoc-${{ runner.os }}-31.1
|
key: protoc-${{ runner.os }}-30.2
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
protoc-${{ runner.os }}-
|
protoc-${{ runner.os }}-
|
||||||
|
|
||||||
@@ -181,7 +89,7 @@ jobs:
|
|||||||
if: steps.cache-protoc.outputs.cache-hit != 'true'
|
if: steps.cache-protoc.outputs.cache-hit != 'true'
|
||||||
uses: arduino/setup-protoc@v3
|
uses: arduino/setup-protoc@v3
|
||||||
with:
|
with:
|
||||||
version: "31.1"
|
version: '30.2'
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Setup Flatc
|
- name: Setup Flatc
|
||||||
@@ -199,10 +107,10 @@ jobs:
|
|||||||
|
|
||||||
# Set up Zig for cross-compilation
|
# Set up Zig for cross-compilation
|
||||||
- uses: mlugg/setup-zig@v2
|
- uses: mlugg/setup-zig@v2
|
||||||
if: matrix.variant.glibc != 'default' || contains(matrix.variant.target, 'aarch64-unknown-linux')
|
if: matrix.variant.glibc != 'default' || contains(matrix.variant.target, 'linux')
|
||||||
|
|
||||||
- uses: taiki-e/install-action@cargo-zigbuild
|
- uses: taiki-e/install-action@cargo-zigbuild
|
||||||
if: matrix.variant.glibc != 'default' || contains(matrix.variant.target, 'aarch64-unknown-linux')
|
if: matrix.variant.glibc != 'default' || contains(matrix.variant.target, 'linux')
|
||||||
|
|
||||||
# Download static resources
|
# Download static resources
|
||||||
- name: Download and Extract Static Assets
|
- name: Download and Extract Static Assets
|
||||||
@@ -242,7 +150,7 @@ jobs:
|
|||||||
|
|
||||||
# Determine whether to use zigbuild
|
# Determine whether to use zigbuild
|
||||||
USE_ZIGBUILD=false
|
USE_ZIGBUILD=false
|
||||||
if [[ "$GLIBC" != "default" || "$TARGET" == *"aarch64-unknown-linux"* ]]; then
|
if [[ "$GLIBC" != "default" || "$TARGET" == *"linux"* ]]; then
|
||||||
USE_ZIGBUILD=true
|
USE_ZIGBUILD=true
|
||||||
echo "Using zigbuild for cross-compilation"
|
echo "Using zigbuild for cross-compilation"
|
||||||
fi
|
fi
|
||||||
@@ -272,14 +180,14 @@ jobs:
|
|||||||
if [[ "$GLIBC" != "default" ]]; then
|
if [[ "$GLIBC" != "default" ]]; then
|
||||||
BIN_NAME="${BIN_NAME}.glibc${GLIBC}"
|
BIN_NAME="${BIN_NAME}.glibc${GLIBC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Windows systems use exe suffix, and other systems do not have suffix
|
# Windows systems use exe suffix, and other systems do not have suffix
|
||||||
if [[ "${{ matrix.variant.target }}" == *"windows"* ]]; then
|
if [[ "${{ matrix.variant.target }}" == *"windows"* ]]; then
|
||||||
BIN_NAME="${BIN_NAME}.exe"
|
BIN_NAME="${BIN_NAME}.exe"
|
||||||
else
|
else
|
||||||
BIN_NAME="${BIN_NAME}.bin"
|
BIN_NAME="${BIN_NAME}.bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Binary name will be: $BIN_NAME"
|
echo "Binary name will be: $BIN_NAME"
|
||||||
|
|
||||||
echo "::group::Building rustfs"
|
echo "::group::Building rustfs"
|
||||||
@@ -357,89 +265,17 @@ jobs:
|
|||||||
path: ${{ steps.package.outputs.artifact_name }}.zip
|
path: ${{ steps.package.outputs.artifact_name }}.zip
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
# Install ossutil2 tool for OSS upload
|
|
||||||
- name: Install ossutil2
|
|
||||||
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "::group::Installing ossutil2"
|
|
||||||
# Download and install ossutil based on platform
|
|
||||||
if [ "${{ runner.os }}" = "Linux" ]; then
|
|
||||||
curl -o ossutil.zip https://gosspublic.alicdn.com/ossutil/v2/2.1.1/ossutil-2.1.1-linux-amd64.zip
|
|
||||||
unzip -o ossutil.zip
|
|
||||||
chmod 755 ossutil-2.1.1-linux-amd64/ossutil
|
|
||||||
sudo mv ossutil-2.1.1-linux-amd64/ossutil /usr/local/bin/
|
|
||||||
rm -rf ossutil.zip ossutil-2.1.1-linux-amd64
|
|
||||||
elif [ "${{ runner.os }}" = "macOS" ]; then
|
|
||||||
if [ "$(uname -m)" = "arm64" ]; then
|
|
||||||
curl -o ossutil.zip https://gosspublic.alicdn.com/ossutil/v2/2.1.1/ossutil-2.1.1-mac-arm64.zip
|
|
||||||
else
|
|
||||||
curl -o ossutil.zip https://gosspublic.alicdn.com/ossutil/v2/2.1.1/ossutil-2.1.1-mac-amd64.zip
|
|
||||||
fi
|
|
||||||
unzip -o ossutil.zip
|
|
||||||
chmod 755 ossutil-*/ossutil
|
|
||||||
sudo mv ossutil-*/ossutil /usr/local/bin/
|
|
||||||
rm -rf ossutil.zip ossutil-*
|
|
||||||
elif [ "${{ runner.os }}" = "Windows" ]; then
|
|
||||||
curl -o ossutil.zip https://gosspublic.alicdn.com/ossutil/v2/2.1.1/ossutil-2.1.1-windows-amd64.zip
|
|
||||||
unzip -o ossutil.zip
|
|
||||||
mv ossutil-*/ossutil.exe /usr/bin/ossutil.exe
|
|
||||||
rm -rf ossutil.zip ossutil-*
|
|
||||||
fi
|
|
||||||
echo "ossutil2 installation completed"
|
|
||||||
|
|
||||||
- name: Upload to Aliyun OSS
|
- name: Upload to Aliyun OSS
|
||||||
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
|
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
|
||||||
shell: bash
|
uses: JohnGuan/oss-upload-action@main
|
||||||
env:
|
with:
|
||||||
OSS_ACCESS_KEY_ID: ${{ secrets.ALICLOUDOSS_KEY_ID }}
|
key-id: ${{ secrets.ALICLOUDOSS_KEY_ID }}
|
||||||
OSS_ACCESS_KEY_SECRET: ${{ secrets.ALICLOUDOSS_KEY_SECRET }}
|
key-secret: ${{ secrets.ALICLOUDOSS_KEY_SECRET }}
|
||||||
OSS_REGION: cn-beijing
|
region: oss-cn-beijing
|
||||||
OSS_ENDPOINT: https://oss-cn-beijing.aliyuncs.com
|
bucket: rustfs-artifacts
|
||||||
run: |
|
assets: |
|
||||||
echo "::group::Uploading files to OSS"
|
${{ steps.package.outputs.artifact_name }}.zip:/artifacts/rustfs/${{ steps.package.outputs.artifact_name }}.zip
|
||||||
# Upload the artifact file to two different paths
|
${{ steps.package.outputs.artifact_name }}.zip:/artifacts/rustfs/${{ steps.package.outputs.artifact_name }}.latest.zip
|
||||||
ossutil cp "${{ steps.package.outputs.artifact_name }}.zip" "oss://rustfs-artifacts/artifacts/rustfs/${{ steps.package.outputs.artifact_name }}.zip" --force
|
|
||||||
ossutil cp "${{ steps.package.outputs.artifact_name }}.zip" "oss://rustfs-artifacts/artifacts/rustfs/${{ steps.package.outputs.artifact_name }}.latest.zip" --force
|
|
||||||
echo "Successfully uploaded artifacts to OSS"
|
|
||||||
|
|
||||||
# Create and upload latest version info
|
|
||||||
- name: Create and Upload latest.json
|
|
||||||
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' && matrix.variant.target == 'x86_64-unknown-linux-musl'
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
OSS_ACCESS_KEY_ID: ${{ secrets.ALICLOUDOSS_KEY_ID }}
|
|
||||||
OSS_ACCESS_KEY_SECRET: ${{ secrets.ALICLOUDOSS_KEY_SECRET }}
|
|
||||||
OSS_REGION: cn-beijing
|
|
||||||
OSS_ENDPOINT: https://oss-cn-beijing.aliyuncs.com
|
|
||||||
run: |
|
|
||||||
echo "::group::Creating latest.json file"
|
|
||||||
|
|
||||||
# Extract version from tag (remove 'refs/tags/' prefix)
|
|
||||||
VERSION="${GITHUB_REF#refs/tags/}"
|
|
||||||
# Remove 'v' prefix if present
|
|
||||||
VERSION="${VERSION#v}"
|
|
||||||
|
|
||||||
# Get current timestamp in ISO 8601 format
|
|
||||||
RELEASE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
||||||
|
|
||||||
# Create latest.json content
|
|
||||||
cat > latest.json << EOF
|
|
||||||
{
|
|
||||||
"version": "${VERSION}",
|
|
||||||
"release_date": "${RELEASE_DATE}",
|
|
||||||
"release_notes": "Release ${VERSION}",
|
|
||||||
"download_url": "https://github.com/rustfs/rustfs/releases/tag/${GITHUB_REF#refs/tags/}"
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
echo "Generated latest.json:"
|
|
||||||
cat latest.json
|
|
||||||
|
|
||||||
echo "::group::Uploading latest.json to OSS"
|
|
||||||
# Upload latest.json to rustfs-version bucket
|
|
||||||
ossutil cp latest.json "oss://rustfs-version/latest.json" --force
|
|
||||||
echo "Successfully uploaded latest.json to OSS"
|
|
||||||
|
|
||||||
# Determine whether to perform GUI construction based on conditions
|
# Determine whether to perform GUI construction based on conditions
|
||||||
- name: Prepare for GUI build
|
- name: Prepare for GUI build
|
||||||
@@ -557,23 +393,20 @@ jobs:
|
|||||||
# Upload GUI to Alibaba Cloud OSS
|
# Upload GUI to Alibaba Cloud OSS
|
||||||
- name: Upload GUI to Aliyun OSS
|
- name: Upload GUI to Aliyun OSS
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
shell: bash
|
uses: JohnGuan/oss-upload-action@main
|
||||||
env:
|
with:
|
||||||
OSS_ACCESS_KEY_ID: ${{ secrets.ALICLOUDOSS_KEY_ID }}
|
key-id: ${{ secrets.ALICLOUDOSS_KEY_ID }}
|
||||||
OSS_ACCESS_KEY_SECRET: ${{ secrets.ALICLOUDOSS_KEY_SECRET }}
|
key-secret: ${{ secrets.ALICLOUDOSS_KEY_SECRET }}
|
||||||
OSS_REGION: cn-beijing
|
region: oss-cn-beijing
|
||||||
OSS_ENDPOINT: https://oss-cn-beijing.aliyuncs.com
|
bucket: rustfs-artifacts
|
||||||
run: |
|
assets: |
|
||||||
echo "::group::Uploading GUI files to OSS"
|
${{ steps.build_gui.outputs.gui_artifact_name }}.zip:/artifacts/rustfs/${{ steps.build_gui.outputs.gui_artifact_name }}.zip
|
||||||
# Upload the GUI artifact file to two different paths
|
${{ steps.build_gui.outputs.gui_artifact_name }}.zip:/artifacts/rustfs/${{ steps.build_gui.outputs.gui_artifact_name }}.latest.zip
|
||||||
ossutil cp "${{ steps.build_gui.outputs.gui_artifact_name }}.zip" "oss://rustfs-artifacts/artifacts/rustfs/${{ steps.build_gui.outputs.gui_artifact_name }}.zip" --force
|
|
||||||
ossutil cp "${{ steps.build_gui.outputs.gui_artifact_name }}.zip" "oss://rustfs-artifacts/artifacts/rustfs/${{ steps.build_gui.outputs.gui_artifact_name }}.latest.zip" --force
|
|
||||||
echo "Successfully uploaded GUI artifacts to OSS"
|
|
||||||
|
|
||||||
merge:
|
merge:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-rustfs]
|
needs: [ build-rustfs ]
|
||||||
# Only execute merge operation when tag is pushed
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/upload-artifact/merge@v4
|
- uses: actions/upload-artifact/merge@v4
|
||||||
|
|||||||
146
.github/workflows/ci.yml
vendored
146
.github/workflows/ci.yml
vendored
@@ -1,66 +1,19 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths-ignore:
|
|
||||||
- "**.md"
|
|
||||||
- "**.txt"
|
|
||||||
- "docs/**"
|
|
||||||
- "deploy/**"
|
|
||||||
- "scripts/dev_*.sh"
|
|
||||||
- "scripts/probe.sh"
|
|
||||||
- "LICENSE*"
|
|
||||||
- ".gitignore"
|
|
||||||
- ".dockerignore"
|
|
||||||
- "README*"
|
|
||||||
- "**/*.png"
|
|
||||||
- "**/*.jpg"
|
|
||||||
- "**/*.svg"
|
|
||||||
- ".github/workflows/build.yml"
|
|
||||||
- ".github/workflows/docker.yml"
|
|
||||||
- ".github/workflows/audit.yml"
|
|
||||||
- ".github/workflows/samply.yml"
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths-ignore:
|
|
||||||
- "**.md"
|
|
||||||
- "**.txt"
|
|
||||||
- "docs/**"
|
|
||||||
- "deploy/**"
|
|
||||||
- "scripts/dev_*.sh"
|
|
||||||
- "scripts/probe.sh"
|
|
||||||
- "LICENSE*"
|
|
||||||
- ".gitignore"
|
|
||||||
- ".dockerignore"
|
|
||||||
- "README*"
|
|
||||||
- "**/*.png"
|
|
||||||
- "**/*.jpg"
|
|
||||||
- "**/*.svg"
|
|
||||||
- ".github/workflows/build.yml"
|
|
||||||
- ".github/workflows/docker.yml"
|
|
||||||
- ".github/workflows/audit.yml"
|
|
||||||
- ".github/workflows/samply.yml"
|
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 * * 0" # at midnight of each sunday
|
- cron: '0 0 * * 0' # at midnight of each sunday
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
skip-check:
|
skip-check:
|
||||||
permissions:
|
permissions:
|
||||||
@@ -73,54 +26,95 @@ jobs:
|
|||||||
- id: skip_check
|
- id: skip_check
|
||||||
uses: fkirc/skip-duplicate-actions@v5
|
uses: fkirc/skip-duplicate-actions@v5
|
||||||
with:
|
with:
|
||||||
concurrent_skipping: "same_content_newer"
|
concurrent_skipping: 'same_content_newer'
|
||||||
cancel_others: true
|
cancel_others: true
|
||||||
paths_ignore: '["*.md"]'
|
paths_ignore: '["*.md"]'
|
||||||
|
|
||||||
develop:
|
# Quality checks for pull requests
|
||||||
needs: skip-check
|
pr-checks:
|
||||||
if: needs.skip-check.outputs.should_skip != 'true'
|
name: Pull Request Quality Checks
|
||||||
runs-on: ubuntu-latest
|
if: github.event_name == 'pull_request'
|
||||||
timeout-minutes: 60
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: ./.github/actions/setup
|
- uses: ./.github/actions/setup
|
||||||
|
|
||||||
- name: Test
|
- name: Format Check
|
||||||
|
run: cargo fmt --all --check
|
||||||
|
|
||||||
|
- name: Lint Check
|
||||||
|
run: cargo check --all-targets
|
||||||
|
|
||||||
|
- name: Clippy Check
|
||||||
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
|
- name: Unit Tests
|
||||||
run: cargo test --all --exclude e2e_test
|
run: cargo test --all --exclude e2e_test
|
||||||
|
|
||||||
|
develop:
|
||||||
|
needs: skip-check
|
||||||
|
if: needs.skip-check.outputs.should_skip != 'true'
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: ./.github/actions/setup
|
||||||
|
|
||||||
- name: Format
|
- name: Format
|
||||||
run: cargo fmt --all --check
|
run: cargo fmt --all --check
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
|
run: cargo check --all-targets
|
||||||
|
|
||||||
|
- name: Clippy
|
||||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
s3s-e2e:
|
- name: Test
|
||||||
name: E2E (s3s-e2e)
|
run: cargo test --all --exclude e2e_test
|
||||||
needs: skip-check
|
|
||||||
if: needs.skip-check.outputs.should_skip != 'true'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 30
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4.2.2
|
|
||||||
- uses: ./.github/actions/setup
|
|
||||||
|
|
||||||
- name: Install s3s-e2e
|
|
||||||
uses: taiki-e/cache-cargo-install-action@v2
|
|
||||||
with:
|
|
||||||
tool: s3s-e2e
|
|
||||||
git: https://github.com/Nugine/s3s.git
|
|
||||||
rev: b7714bfaa17ddfa9b23ea01774a1e7bbdbfc2ca3
|
|
||||||
|
|
||||||
- name: Build debug
|
- name: Build debug
|
||||||
run: |
|
run: |
|
||||||
touch rustfs/build.rs
|
touch rustfs/build.rs
|
||||||
cargo build -p rustfs --bins
|
cargo build -p rustfs --bins
|
||||||
|
|
||||||
- name: Run s3s-e2e
|
- name: Pack artifacts
|
||||||
run: |
|
run: |
|
||||||
|
mkdir -p ./target/artifacts
|
||||||
|
cp target/debug/rustfs ./target/artifacts/rustfs-debug
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: rustfs
|
||||||
|
path: ./target/artifacts/*
|
||||||
|
|
||||||
|
s3s-e2e:
|
||||||
|
name: E2E (s3s-e2e)
|
||||||
|
needs:
|
||||||
|
- skip-check
|
||||||
|
- develop
|
||||||
|
if: needs.skip-check.outputs.should_skip != 'true'
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
cache-on-failure: true
|
||||||
|
cache-all-crates: true
|
||||||
|
|
||||||
|
- name: Install s3s-e2e
|
||||||
|
run: |
|
||||||
|
cargo install s3s-e2e --git https://github.com/Nugine/s3s.git
|
||||||
s3s-e2e --version
|
s3s-e2e --version
|
||||||
./scripts/e2e-run.sh ./target/debug/rustfs /tmp/rustfs
|
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: rustfs
|
||||||
|
path: ./target/artifacts
|
||||||
|
|
||||||
|
- name: Run s3s-e2e
|
||||||
|
timeout-minutes: 10
|
||||||
|
run: |
|
||||||
|
./scripts/e2e-run.sh ./target/artifacts/rustfs-debug /tmp/rustfs
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
242
.github/workflows/docker.yml
vendored
242
.github/workflows/docker.yml
vendored
@@ -1,242 +0,0 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
name: Build and Push Docker Images
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
push_to_registry:
|
|
||||||
description: "Push images to registry"
|
|
||||||
required: false
|
|
||||||
default: true
|
|
||||||
type: boolean
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY_IMAGE_DOCKERHUB: rustfs/rustfs
|
|
||||||
REGISTRY_IMAGE_GHCR: ghcr.io/${{ github.repository }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# Skip duplicate job runs
|
|
||||||
skip-check:
|
|
||||||
permissions:
|
|
||||||
actions: write
|
|
||||||
contents: read
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
|
||||||
steps:
|
|
||||||
- id: skip_check
|
|
||||||
uses: fkirc/skip-duplicate-actions@v5
|
|
||||||
with:
|
|
||||||
concurrent_skipping: "same_content_newer"
|
|
||||||
cancel_others: true
|
|
||||||
paths_ignore: '["*.md", "docs/**"]'
|
|
||||||
|
|
||||||
# Build RustFS binary for different platforms
|
|
||||||
build-binary:
|
|
||||||
needs: skip-check
|
|
||||||
# Only execute in the following cases: 1) tag push 2) commit message contains --build 3) workflow_dispatch 4) PR
|
|
||||||
if: needs.skip-check.outputs.should_skip != 'true' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '--build') || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request')
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- target: x86_64-unknown-linux-musl
|
|
||||||
os: ubuntu-latest
|
|
||||||
arch: amd64
|
|
||||||
use_cross: false
|
|
||||||
- target: aarch64-unknown-linux-gnu
|
|
||||||
os: ubuntu-latest
|
|
||||||
arch: arm64
|
|
||||||
use_cross: true
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
timeout-minutes: 120
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Rust toolchain
|
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
||||||
with:
|
|
||||||
target: ${{ matrix.target }}
|
|
||||||
components: rustfmt, clippy
|
|
||||||
|
|
||||||
- name: Install cross-compilation dependencies (native build)
|
|
||||||
if: matrix.use_cross == false
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y musl-tools
|
|
||||||
|
|
||||||
- name: Install cross tool (cross compilation)
|
|
||||||
if: matrix.use_cross == true
|
|
||||||
uses: taiki-e/install-action@v2
|
|
||||||
with:
|
|
||||||
tool: cross
|
|
||||||
|
|
||||||
- name: Install protoc
|
|
||||||
uses: arduino/setup-protoc@v3
|
|
||||||
with:
|
|
||||||
version: "31.1"
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Install flatc
|
|
||||||
uses: Nugine/setup-flatc@v1
|
|
||||||
with:
|
|
||||||
version: "25.2.10"
|
|
||||||
|
|
||||||
- name: Cache cargo dependencies
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/registry
|
|
||||||
~/.cargo/git
|
|
||||||
target
|
|
||||||
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-cargo-${{ matrix.target }}-
|
|
||||||
${{ runner.os }}-cargo-
|
|
||||||
|
|
||||||
- name: Generate protobuf code
|
|
||||||
run: cargo run --bin gproto
|
|
||||||
|
|
||||||
- name: Build RustFS binary (native)
|
|
||||||
if: matrix.use_cross == false
|
|
||||||
run: |
|
|
||||||
cargo build --release --target ${{ matrix.target }} --bin rustfs
|
|
||||||
|
|
||||||
- name: Build RustFS binary (cross)
|
|
||||||
if: matrix.use_cross == true
|
|
||||||
run: |
|
|
||||||
cross build --release --target ${{ matrix.target }} --bin rustfs
|
|
||||||
|
|
||||||
- name: Upload binary artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: rustfs-${{ matrix.arch }}
|
|
||||||
path: target/${{ matrix.target }}/release/rustfs
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
# Build and push multi-arch Docker images
|
|
||||||
build-images:
|
|
||||||
needs: [skip-check, build-binary]
|
|
||||||
if: needs.skip-check.outputs.should_skip != 'true'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 60
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
image-type: [production, ubuntu, rockylinux, devenv]
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Download binary artifacts
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
path: ./artifacts
|
|
||||||
|
|
||||||
- name: Setup binary files
|
|
||||||
run: |
|
|
||||||
mkdir -p target/x86_64-unknown-linux-musl/release
|
|
||||||
mkdir -p target/aarch64-unknown-linux-gnu/release
|
|
||||||
cp artifacts/rustfs-amd64/rustfs target/x86_64-unknown-linux-musl/release/
|
|
||||||
cp artifacts/rustfs-arm64/rustfs target/aarch64-unknown-linux-gnu/release/
|
|
||||||
chmod +x target/*/release/rustfs
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set Dockerfile and context
|
|
||||||
id: dockerfile
|
|
||||||
run: |
|
|
||||||
case "${{ matrix.image-type }}" in
|
|
||||||
production)
|
|
||||||
echo "dockerfile=Dockerfile" >> $GITHUB_OUTPUT
|
|
||||||
echo "context=." >> $GITHUB_OUTPUT
|
|
||||||
echo "suffix=" >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
ubuntu)
|
|
||||||
echo "dockerfile=.docker/Dockerfile.ubuntu22.04" >> $GITHUB_OUTPUT
|
|
||||||
echo "context=." >> $GITHUB_OUTPUT
|
|
||||||
echo "suffix=-ubuntu22.04" >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
rockylinux)
|
|
||||||
echo "dockerfile=.docker/Dockerfile.rockylinux9.3" >> $GITHUB_OUTPUT
|
|
||||||
echo "context=." >> $GITHUB_OUTPUT
|
|
||||||
echo "suffix=-rockylinux9.3" >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
devenv)
|
|
||||||
echo "dockerfile=.docker/Dockerfile.devenv" >> $GITHUB_OUTPUT
|
|
||||||
echo "context=." >> $GITHUB_OUTPUT
|
|
||||||
echo "suffix=-devenv" >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
- name: Extract metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ env.REGISTRY_IMAGE_DOCKERHUB }}
|
|
||||||
${{ env.REGISTRY_IMAGE_GHCR }}
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch,suffix=${{ steps.dockerfile.outputs.suffix }}
|
|
||||||
type=ref,event=pr,suffix=${{ steps.dockerfile.outputs.suffix }}
|
|
||||||
type=semver,pattern={{version}},suffix=${{ steps.dockerfile.outputs.suffix }}
|
|
||||||
type=semver,pattern={{major}}.{{minor}},suffix=${{ steps.dockerfile.outputs.suffix }}
|
|
||||||
type=semver,pattern={{major}},suffix=${{ steps.dockerfile.outputs.suffix }}
|
|
||||||
type=raw,value=latest,suffix=${{ steps.dockerfile.outputs.suffix }},enable={{is_default_branch}}
|
|
||||||
flavor: |
|
|
||||||
latest=false
|
|
||||||
|
|
||||||
- name: Build and push multi-arch Docker image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: ${{ steps.dockerfile.outputs.context }}
|
|
||||||
file: ${{ steps.dockerfile.outputs.dockerfile }}
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: ${{ (github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))) || github.event.inputs.push_to_registry == 'true' }}
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha,scope=${{ matrix.image-type }}
|
|
||||||
cache-to: type=gha,mode=max,scope=${{ matrix.image-type }}
|
|
||||||
build-args: |
|
|
||||||
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
|
|
||||||
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
|
|
||||||
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
|
||||||
16
.github/workflows/samply.yml
vendored
16
.github/workflows/samply.yml
vendored
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
name: Profile with Samply
|
name: Profile with Samply
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -21,7 +7,7 @@ jobs:
|
|||||||
profile:
|
profile:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4.2.2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@nightly
|
- uses: dtolnay/rust-toolchain@nightly
|
||||||
with:
|
with:
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,6 +10,7 @@ rustfs/static/*
|
|||||||
!rustfs/static/.gitkeep
|
!rustfs/static/.gitkeep
|
||||||
vendor
|
vendor
|
||||||
cli/rustfs-gui/embedded-rustfs/rustfs
|
cli/rustfs-gui/embedded-rustfs/rustfs
|
||||||
|
deploy/config/obs.toml
|
||||||
*.log
|
*.log
|
||||||
deploy/certs/*
|
deploy/certs/*
|
||||||
*jsonl
|
*jsonl
|
||||||
@@ -18,4 +19,3 @@ deploy/certs/*
|
|||||||
.cargo
|
.cargo
|
||||||
profile.json
|
profile.json
|
||||||
.docker/openobserve-otel/data
|
.docker/openobserve-otel/data
|
||||||
*.zst
|
|
||||||
|
|||||||
51
.vscode/launch.json
vendored
51
.vscode/launch.json
vendored
@@ -20,19 +20,33 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"RUST_LOG": "rustfs=debug,ecstore=info,s3s=debug"
|
"RUST_LOG": "rustfs=debug,ecstore=info,s3s=debug",
|
||||||
|
"RUSTFS_VOLUMES": "./target/volume/test{0...3}",
|
||||||
|
"RUSTFS_ADDRESS": "[::]:9000",
|
||||||
|
"RUSTFS_CONSOLE_ENABLE": "true",
|
||||||
|
"RUSTFS_CONSOLE_ADDRESS": "[::]:9002",
|
||||||
|
"RUSTFS_SERVER_DOMAINS": "localhost:9000",
|
||||||
|
"RUSTFS_TLS_PATH": "./deploy/certs",
|
||||||
|
"RUSTFS_OBS_CONFIG": "./deploy/config/obs.example.toml",
|
||||||
|
"RUSTFS__OBSERVABILITY__ENDPOINT": "http://localhost:4317",
|
||||||
|
"RUSTFS__OBSERVABILITY__USE_STDOUT": "true",
|
||||||
|
"RUSTFS__OBSERVABILITY__SAMPLE_RATIO": "2.0",
|
||||||
|
"RUSTFS__OBSERVABILITY__METER_INTERVAL": "30",
|
||||||
|
"RUSTFS__OBSERVABILITY__SERVICE_NAME": "rustfs",
|
||||||
|
"RUSTFS__OBSERVABILITY__SERVICE_VERSION": "0.1.0",
|
||||||
|
"RUSTFS__OBSERVABILITY__ENVIRONMENT": "develop",
|
||||||
|
"RUSTFS__OBSERVABILITY__LOGGER_LEVEL": "info",
|
||||||
|
"RUSTFS__SINKS__FILE__ENABLED": "true",
|
||||||
|
"RUSTFS__SINKS__FILE__PATH": "./deploy/logs/rustfs.log",
|
||||||
|
"RUSTFS__SINKS__WEBHOOK__ENABLED": "false",
|
||||||
|
"RUSTFS__SINKS__WEBHOOK__ENDPOINT": "",
|
||||||
|
"RUSTFS__SINKS__WEBHOOK__AUTH_TOKEN": "",
|
||||||
|
"RUSTFS__SINKS__KAFKA__ENABLED": "false",
|
||||||
|
"RUSTFS__SINKS__KAFKA__BOOTSTRAP_SERVERS": "",
|
||||||
|
"RUSTFS__SINKS__KAFKA__TOPIC": "",
|
||||||
|
"RUSTFS__LOGGER__QUEUE_CAPACITY": "10"
|
||||||
|
|
||||||
},
|
},
|
||||||
"args": [
|
|
||||||
"--access-key",
|
|
||||||
"AKEXAMPLERUSTFS",
|
|
||||||
"--secret-key",
|
|
||||||
"SKEXAMPLERUSTFS",
|
|
||||||
"--address",
|
|
||||||
"0.0.0.0:9010",
|
|
||||||
"--domain-name",
|
|
||||||
"127.0.0.1:9010",
|
|
||||||
"./target/volume/test{0...4}"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}"
|
"cwd": "${workspaceFolder}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -72,19 +86,6 @@
|
|||||||
},
|
},
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}"
|
"cwd": "${workspaceFolder}"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Debug executable target/debug/rustfs",
|
|
||||||
"type": "lldb",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/target/debug/rustfs",
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
//"stopAtEntry": false,
|
|
||||||
//"preLaunchTask": "cargo build",
|
|
||||||
"sourceLanguages": [
|
|
||||||
"rust"
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
1648
Cargo.lock
generated
1648
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
160
Cargo.toml
160
Cargo.toml
@@ -1,49 +1,32 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"rustfs", # Core file system implementation
|
"appauth", # Application authentication and authorization
|
||||||
"cli/rustfs-gui", # Graphical user interface client
|
"cli/rustfs-gui", # Graphical user interface client
|
||||||
"crates/appauth", # Application authentication and authorization
|
"common/common", # Shared utilities and data structures
|
||||||
"crates/common", # Shared utilities and data structures
|
"common/lock", # Distributed locking implementation
|
||||||
|
"common/protos", # Protocol buffer definitions
|
||||||
|
"common/workers", # Worker thread pools and task scheduling
|
||||||
"crates/config", # Configuration management
|
"crates/config", # Configuration management
|
||||||
"crates/crypto", # Cryptography and security features
|
"crates/event-notifier", # Event notification system
|
||||||
"crates/ecstore", # Erasure coding storage implementation
|
|
||||||
"crates/e2e_test", # End-to-end test suite
|
|
||||||
"crates/filemeta", # File metadata management
|
|
||||||
"crates/iam", # Identity and Access Management
|
|
||||||
"crates/lock", # Distributed locking implementation
|
|
||||||
"crates/madmin", # Management dashboard and admin API interface
|
|
||||||
"crates/notify", # Notification system for events
|
|
||||||
"crates/obs", # Observability utilities
|
"crates/obs", # Observability utilities
|
||||||
"crates/protos", # Protocol buffer definitions
|
|
||||||
"crates/rio", # Rust I/O utilities and abstractions
|
|
||||||
"crates/s3select-api", # S3 Select API interface
|
|
||||||
"crates/s3select-query", # S3 Select query engine
|
|
||||||
"crates/signer", # client signer
|
|
||||||
"crates/utils", # Utility functions and helpers
|
"crates/utils", # Utility functions and helpers
|
||||||
"crates/workers", # Worker thread pools and task scheduling
|
"crypto", # Cryptography and security features
|
||||||
"crates/zip", # ZIP file handling and compression
|
"ecstore", # Erasure coding storage implementation
|
||||||
|
"e2e_test", # End-to-end test suite
|
||||||
|
"iam", # Identity and Access Management
|
||||||
|
"madmin", # Management dashboard and admin API interface
|
||||||
|
"rustfs", # Core file system implementation
|
||||||
|
"s3select/api", # S3 Select API interface
|
||||||
|
"s3select/query", # S3 Select query engine
|
||||||
|
"crates/zip",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
edition = "2024"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
repository = "https://github.com/rustfs/rustfs"
|
repository = "https://github.com/rustfs/rustfs"
|
||||||
rust-version = "1.85"
|
rust-version = "1.75"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
|
||||||
[workspace.lints.rust]
|
[workspace.lints.rust]
|
||||||
@@ -53,82 +36,64 @@ unsafe_code = "deny"
|
|||||||
all = "warn"
|
all = "warn"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
rustfs-s3select-api = { path = "crates/s3select-api", version = "0.0.1" }
|
api = { path = "./s3select/api", version = "0.0.1" }
|
||||||
rustfs-appauth = { path = "crates/appauth", version = "0.0.1" }
|
appauth = { path = "./appauth", version = "0.0.1" }
|
||||||
rustfs-common = { path = "crates/common", version = "0.0.1" }
|
common = { path = "./common/common", version = "0.0.1" }
|
||||||
rustfs-crypto = { path = "crates/crypto", version = "0.0.1" }
|
crypto = { path = "./crypto", version = "0.0.1" }
|
||||||
rustfs-ecstore = { path = "crates/ecstore", version = "0.0.1" }
|
ecstore = { path = "./ecstore", version = "0.0.1" }
|
||||||
rustfs-iam = { path = "crates/iam", version = "0.0.1" }
|
iam = { path = "./iam", version = "0.0.1" }
|
||||||
rustfs-lock = { path = "crates/lock", version = "0.0.1" }
|
lock = { path = "./common/lock", version = "0.0.1" }
|
||||||
rustfs-madmin = { path = "crates/madmin", version = "0.0.1" }
|
madmin = { path = "./madmin", version = "0.0.1" }
|
||||||
rustfs-policy = { path = "crates/policy", version = "0.0.1" }
|
policy = { path = "./policy", version = "0.0.1" }
|
||||||
rustfs-protos = { path = "crates/protos", version = "0.0.1" }
|
protos = { path = "./common/protos", version = "0.0.1" }
|
||||||
rustfs-s3select-query = { path = "crates/s3select-query", version = "0.0.1" }
|
query = { path = "./s3select/query", version = "0.0.1" }
|
||||||
rustfs = { path = "./rustfs", version = "0.0.1" }
|
rustfs = { path = "./rustfs", version = "0.0.1" }
|
||||||
rustfs-zip = { path = "./crates/zip", version = "0.0.1" }
|
rustfs-zip = { path = "./crates/zip", version = "0.0.1" }
|
||||||
rustfs-config = { path = "./crates/config", version = "0.0.1" }
|
rustfs-config = { path = "./crates/config", version = "0.0.1" }
|
||||||
rustfs-obs = { path = "crates/obs", version = "0.0.1" }
|
rustfs-obs = { path = "crates/obs", version = "0.0.1" }
|
||||||
rustfs-notify = { path = "crates/notify", version = "0.0.1" }
|
rustfs-event-notifier = { path = "crates/event-notifier", version = "0.0.1" }
|
||||||
rustfs-utils = { path = "crates/utils", version = "0.0.1" }
|
rustfs-utils = { path = "crates/utils", version = "0.0.1" }
|
||||||
rustfs-rio = { path = "crates/rio", version = "0.0.1" }
|
workers = { path = "./common/workers", version = "0.0.1" }
|
||||||
rustfs-filemeta = { path = "crates/filemeta", version = "0.0.1" }
|
tokio-tar = "0.3.1"
|
||||||
rustfs-signer = { path = "crates/signer", version = "0.0.1" }
|
|
||||||
rustfs-workers = { path = "crates/workers", version = "0.0.1" }
|
|
||||||
aes-gcm = { version = "0.10.3", features = ["std"] }
|
|
||||||
arc-swap = "1.7.1"
|
|
||||||
argon2 = { version = "0.5.3", features = ["std"] }
|
|
||||||
atoi = "2.0.0"
|
atoi = "2.0.0"
|
||||||
async-channel = "2.3.1"
|
|
||||||
async-recursion = "1.1.1"
|
async-recursion = "1.1.1"
|
||||||
async-trait = "0.1.88"
|
async-trait = "0.1.88"
|
||||||
async-compression = { version = "0.4.0" }
|
|
||||||
atomic_enum = "0.3.0"
|
atomic_enum = "0.3.0"
|
||||||
aws-sdk-s3 = "1.95.0"
|
aws-sdk-s3 = "1.29.0"
|
||||||
axum = "0.8.4"
|
axum = "0.8.4"
|
||||||
axum-extra = "0.10.1"
|
axum-extra = "0.10.1"
|
||||||
axum-server = { version = "0.7.2", features = ["tls-rustls"] }
|
axum-server = { version = "0.7.2", features = ["tls-rustls"] }
|
||||||
base64-simd = "0.8.0"
|
backon = "1.5.1"
|
||||||
base64 = "0.22.1"
|
blake2 = "0.10.6"
|
||||||
brotli = "8.0.1"
|
bytes = "1.10.1"
|
||||||
bytes = { version = "1.10.1", features = ["serde"] }
|
|
||||||
bytesize = "2.0.1"
|
bytesize = "2.0.1"
|
||||||
byteorder = "1.5.0"
|
byteorder = "1.5.0"
|
||||||
cfg-if = "1.0.1"
|
|
||||||
chacha20poly1305 = { version = "0.10.1" }
|
|
||||||
chrono = { version = "0.4.41", features = ["serde"] }
|
chrono = { version = "0.4.41", features = ["serde"] }
|
||||||
clap = { version = "4.5.40", features = ["derive", "env"] }
|
clap = { version = "4.5.39", features = ["derive", "env"] }
|
||||||
|
config = "0.15.11"
|
||||||
const-str = { version = "0.6.2", features = ["std", "proc"] }
|
const-str = { version = "0.6.2", features = ["std", "proc"] }
|
||||||
crc32fast = "1.4.2"
|
|
||||||
criterion = { version = "0.5", features = ["html_reports"] }
|
|
||||||
dashmap = "6.1.0"
|
|
||||||
datafusion = "46.0.1"
|
datafusion = "46.0.1"
|
||||||
derive_builder = "0.20.2"
|
derive_builder = "0.20.2"
|
||||||
dioxus = { version = "0.6.3", features = ["router"] }
|
dioxus = { version = "0.6.3", features = ["router"] }
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
enumset = "1.1.6"
|
|
||||||
flatbuffers = "25.2.10"
|
flatbuffers = "25.2.10"
|
||||||
flate2 = "1.1.1"
|
flexi_logger = { version = "0.30.2", features = ["trc"] }
|
||||||
flexi_logger = { version = "0.31.2", features = ["trc", "dont_minimize_extra_stacks"] }
|
|
||||||
form_urlencoded = "1.2.1"
|
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
futures-core = "0.3.31"
|
futures-core = "0.3.31"
|
||||||
futures-util = "0.3.31"
|
futures-util = "0.3.31"
|
||||||
glob = "0.3.2"
|
glob = "0.3.2"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
hex-simd = "0.8.0"
|
|
||||||
highway = { version = "1.3.0" }
|
highway = { version = "1.3.0" }
|
||||||
hmac = "0.12.1"
|
|
||||||
hyper = "1.6.0"
|
hyper = "1.6.0"
|
||||||
hyper-util = { version = "0.1.14", features = [
|
hyper-util = { version = "0.1.14", features = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"server-auto",
|
"server-auto",
|
||||||
"server-graceful",
|
"server-graceful",
|
||||||
] }
|
] }
|
||||||
hyper-rustls = "0.27.5"
|
|
||||||
http = "1.3.1"
|
http = "1.3.1"
|
||||||
http-body = "1.0.1"
|
http-body = "1.0.1"
|
||||||
humantime = "2.2.0"
|
humantime = "2.2.0"
|
||||||
ipnetwork = { version = "0.21.1", features = ["serde"] }
|
include_dir = "0.7.4"
|
||||||
jsonwebtoken = "9.3.1"
|
jsonwebtoken = "9.3.1"
|
||||||
keyring = { version = "3.6.2", features = [
|
keyring = { version = "3.6.2", features = [
|
||||||
"apple-native",
|
"apple-native",
|
||||||
@@ -138,9 +103,9 @@ keyring = { version = "3.6.2", features = [
|
|||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
libsystemd = { version = "0.7.2" }
|
libsystemd = { version = "0.7.2" }
|
||||||
local-ip-address = "0.6.5"
|
local-ip-address = "0.6.5"
|
||||||
lz4 = "1.28.1"
|
|
||||||
matchit = "0.8.4"
|
matchit = "0.8.4"
|
||||||
md-5 = "0.10.6"
|
md-5 = "0.10.6"
|
||||||
|
mime = "0.3.17"
|
||||||
mime_guess = "2.0.5"
|
mime_guess = "2.0.5"
|
||||||
netif = "0.1.6"
|
netif = "0.1.6"
|
||||||
nix = { version = "0.30.1", features = ["fs"] }
|
nix = { version = "0.30.1", features = ["fs"] }
|
||||||
@@ -164,20 +129,17 @@ opentelemetry-semantic-conventions = { version = "0.30.0", features = [
|
|||||||
"semconv_experimental",
|
"semconv_experimental",
|
||||||
] }
|
] }
|
||||||
parking_lot = "0.12.4"
|
parking_lot = "0.12.4"
|
||||||
path-absolutize = "3.1.1"
|
|
||||||
path-clean = "1.0.1"
|
|
||||||
blake3 = { version = "1.8.2" }
|
|
||||||
pbkdf2 = "0.12.2"
|
|
||||||
percent-encoding = "2.3.1"
|
percent-encoding = "2.3.1"
|
||||||
pin-project-lite = "0.2.16"
|
pin-project-lite = "0.2.16"
|
||||||
|
# pin-utils = "0.1.0"
|
||||||
prost = "0.13.5"
|
prost = "0.13.5"
|
||||||
prost-build = "0.13.5"
|
prost-build = "0.13.5"
|
||||||
quick-xml = "0.37.5"
|
protobuf = "3.7"
|
||||||
rand = "0.9.1"
|
rand = "0.8.5"
|
||||||
rdkafka = { version = "0.37.0", features = ["tokio"] }
|
rdkafka = { version = "0.37.0", features = ["tokio"] }
|
||||||
reed-solomon-simd = { version = "3.0.1" }
|
reed-solomon-erasure = { version = "6.0.0", features = ["simd-accel"] }
|
||||||
regex = { version = "1.11.1" }
|
regex = { version = "1.11.1" }
|
||||||
reqwest = { version = "0.12.22", default-features = false, features = [
|
reqwest = { version = "0.12.19", default-features = false, features = [
|
||||||
"rustls-tls",
|
"rustls-tls",
|
||||||
"charset",
|
"charset",
|
||||||
"http2",
|
"http2",
|
||||||
@@ -192,26 +154,22 @@ rfd = { version = "0.15.3", default-features = false, features = [
|
|||||||
] }
|
] }
|
||||||
rmp = "0.8.14"
|
rmp = "0.8.14"
|
||||||
rmp-serde = "1.3.0"
|
rmp-serde = "1.3.0"
|
||||||
rsa = "0.9.8"
|
|
||||||
rumqttc = { version = "0.24" }
|
rumqttc = { version = "0.24" }
|
||||||
rust-embed = { version = "8.7.2" }
|
rust-embed = { version = "8.7.2" }
|
||||||
rust-i18n = { version = "3.1.4" }
|
|
||||||
rustfs-rsc = "2025.506.1"
|
rustfs-rsc = "2025.506.1"
|
||||||
rustls = { version = "0.23.28" }
|
rustls = { version = "0.23.27" }
|
||||||
rustls-pki-types = "1.12.0"
|
rustls-pki-types = "1.12.0"
|
||||||
rustls-pemfile = "2.2.0"
|
rustls-pemfile = "2.2.0"
|
||||||
s3s = { git = "https://github.com/Nugine/s3s.git", rev = "4733cdfb27b2713e832967232cbff413bb768c10" }
|
s3s = { git = "https://github.com/Nugine/s3s.git", rev = "4733cdfb27b2713e832967232cbff413bb768c10" }
|
||||||
shadow-rs = { version = "1.2.0", default-features = false }
|
s3s-policy = { git = "https://github.com/Nugine/s3s.git", rev = "4733cdfb27b2713e832967232cbff413bb768c10" }
|
||||||
|
shadow-rs = { version = "1.1.1", default-features = false }
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.140", features = ["raw_value"] }
|
serde_json = "1.0.140"
|
||||||
serde-xml-rs = "0.8.1"
|
|
||||||
serde_urlencoded = "0.7.1"
|
serde_urlencoded = "0.7.1"
|
||||||
sha1 = "0.10.6"
|
serde_with = "3.12.0"
|
||||||
sha2 = "0.10.9"
|
sha2 = "0.10.9"
|
||||||
siphasher = "1.0.1"
|
smallvec = { version = "1.15.0", features = ["serde"] }
|
||||||
smallvec = { version = "1.15.1", features = ["serde"] }
|
|
||||||
snafu = "0.8.6"
|
snafu = "0.8.6"
|
||||||
snap = "1.1.1"
|
|
||||||
socket2 = "0.5.10"
|
socket2 = "0.5.10"
|
||||||
strum = { version = "0.27.1", features = ["derive"] }
|
strum = { version = "0.27.1", features = ["derive"] }
|
||||||
sysinfo = "0.35.2"
|
sysinfo = "0.35.2"
|
||||||
@@ -226,12 +184,11 @@ time = { version = "0.3.41", features = [
|
|||||||
"serde",
|
"serde",
|
||||||
] }
|
] }
|
||||||
tokio = { version = "1.45.1", features = ["fs", "rt-multi-thread"] }
|
tokio = { version = "1.45.1", features = ["fs", "rt-multi-thread"] }
|
||||||
tokio-rustls = { version = "0.26.2", default-features = false }
|
|
||||||
tokio-stream = { version = "0.1.17" }
|
|
||||||
tokio-tar = "0.3.1"
|
|
||||||
tokio-util = { version = "0.7.15", features = ["io", "compat"] }
|
|
||||||
tonic = { version = "0.13.1", features = ["gzip"] }
|
tonic = { version = "0.13.1", features = ["gzip"] }
|
||||||
tonic-build = { version = "0.13.1" }
|
tonic-build = { version = "0.13.1" }
|
||||||
|
tokio-rustls = { version = "0.26.2", default-features = false }
|
||||||
|
tokio-stream = { version = "0.1.17" }
|
||||||
|
tokio-util = { version = "0.7.15", features = ["io", "compat"] }
|
||||||
tower = { version = "0.5.2", features = ["timeout"] }
|
tower = { version = "0.5.2", features = ["timeout"] }
|
||||||
tower-http = { version = "0.6.6", features = ["cors"] }
|
tower-http = { version = "0.6.6", features = ["cors"] }
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
@@ -248,11 +205,8 @@ uuid = { version = "1.17.0", features = [
|
|||||||
"fast-rng",
|
"fast-rng",
|
||||||
"macro-diagnostics",
|
"macro-diagnostics",
|
||||||
] }
|
] }
|
||||||
wildmatch = { version = "2.4.0", features = ["serde"] }
|
|
||||||
winapi = { version = "0.3.9" }
|
winapi = { version = "0.3.9" }
|
||||||
xxhash-rust = { version = "0.8.15", features = ["xxh64", "xxh3"] }
|
|
||||||
zip = "2.2.0"
|
|
||||||
zstd = "0.13.3"
|
|
||||||
|
|
||||||
[profile.wasm-dev]
|
[profile.wasm-dev]
|
||||||
inherits = "dev"
|
inherits = "dev"
|
||||||
@@ -266,6 +220,10 @@ inherits = "dev"
|
|||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
lto = "thin"
|
||||||
|
codegen-units = 1
|
||||||
|
panic = "abort" # Optional, remove the panic expansion code
|
||||||
|
strip = true # strip symbol information to reduce binary size
|
||||||
|
|
||||||
[profile.production]
|
[profile.production]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
|
|||||||
46
Dockerfile
46
Dockerfile
@@ -1,47 +1,17 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
# Install runtime dependencies
|
# RUN apk add --no-cache <package-name>
|
||||||
RUN apk add --no-cache \
|
|
||||||
ca-certificates \
|
|
||||||
tzdata \
|
|
||||||
&& rm -rf /var/cache/apk/*
|
|
||||||
|
|
||||||
# Create rustfs user and group
|
WORKDIR /app
|
||||||
RUN addgroup -g 1000 rustfs && \
|
|
||||||
adduser -D -s /bin/sh -u 1000 -G rustfs rustfs
|
|
||||||
|
|
||||||
# Create data directories
|
RUN mkdir -p /data/rustfs0 /data/rustfs1 /data/rustfs2 /data/rustfs3
|
||||||
RUN mkdir -p /data/rustfs && \
|
|
||||||
chown -R rustfs:rustfs /data
|
|
||||||
|
|
||||||
# Copy binary based on target architecture
|
COPY ./target/x86_64-unknown-linux-musl/release/rustfs /app/rustfs
|
||||||
COPY --chown=rustfs:rustfs \
|
|
||||||
target/*/release/rustfs \
|
|
||||||
/usr/local/bin/rustfs
|
|
||||||
|
|
||||||
RUN chmod +x /usr/local/bin/rustfs
|
RUN chmod +x /app/rustfs
|
||||||
|
|
||||||
# Switch to non-root user
|
EXPOSE 9000
|
||||||
USER rustfs
|
EXPOSE 9001
|
||||||
|
|
||||||
# Expose ports
|
|
||||||
EXPOSE 9000 9001
|
|
||||||
|
|
||||||
VOLUME /data
|
CMD ["/app/rustfs"]
|
||||||
|
|
||||||
# Set default command
|
|
||||||
CMD ["rustfs", "/data"]
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
# Multi-stage Dockerfile for RustFS
|
|
||||||
# Supports cross-compilation for amd64 and arm64 architectures
|
|
||||||
ARG TARGETPLATFORM
|
|
||||||
ARG BUILDPLATFORM
|
|
||||||
|
|
||||||
# Build stage
|
|
||||||
FROM --platform=$BUILDPLATFORM rust:1.85-bookworm AS builder
|
|
||||||
|
|
||||||
# Install required build dependencies
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
wget \
|
|
||||||
git \
|
|
||||||
curl \
|
|
||||||
unzip \
|
|
||||||
gcc \
|
|
||||||
pkg-config \
|
|
||||||
libssl-dev \
|
|
||||||
lld \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Install cross-compilation tools for ARM64
|
|
||||||
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
|
|
||||||
apt-get update && \
|
|
||||||
apt-get install -y gcc-aarch64-linux-gnu && \
|
|
||||||
rm -rf /var/lib/apt/lists/*; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install protoc
|
|
||||||
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-linux-x86_64.zip \
|
|
||||||
&& unzip protoc-31.1-linux-x86_64.zip -d protoc3 \
|
|
||||||
&& mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc \
|
|
||||||
&& mv protoc3/include/* /usr/local/include/ && rm -rf protoc-31.1-linux-x86_64.zip protoc3
|
|
||||||
|
|
||||||
# Install flatc
|
|
||||||
RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \
|
|
||||||
&& unzip Linux.flatc.binary.g++-13.zip \
|
|
||||||
&& mv flatc /usr/local/bin/ && chmod +x /usr/local/bin/flatc && rm -rf Linux.flatc.binary.g++-13.zip
|
|
||||||
|
|
||||||
# Set up Rust targets based on platform
|
|
||||||
RUN case "$TARGETPLATFORM" in \
|
|
||||||
"linux/amd64") rustup target add x86_64-unknown-linux-gnu ;; \
|
|
||||||
"linux/arm64") rustup target add aarch64-unknown-linux-gnu ;; \
|
|
||||||
*) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Set up environment for cross-compilation
|
|
||||||
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
|
|
||||||
ENV CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
|
|
||||||
ENV CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
|
|
||||||
|
|
||||||
WORKDIR /usr/src/rustfs
|
|
||||||
|
|
||||||
# Copy Cargo files for dependency caching
|
|
||||||
COPY Cargo.toml Cargo.lock ./
|
|
||||||
COPY */Cargo.toml ./*/
|
|
||||||
|
|
||||||
# Create dummy main.rs files for dependency compilation
|
|
||||||
RUN find . -name "Cargo.toml" -not -path "./Cargo.toml" | \
|
|
||||||
xargs -I {} dirname {} | \
|
|
||||||
xargs -I {} sh -c 'mkdir -p {}/src && echo "fn main() {}" > {}/src/main.rs'
|
|
||||||
|
|
||||||
# Build dependencies only (cache layer)
|
|
||||||
RUN case "$TARGETPLATFORM" in \
|
|
||||||
"linux/amd64") cargo build --release --target x86_64-unknown-linux-gnu ;; \
|
|
||||||
"linux/arm64") cargo build --release --target aarch64-unknown-linux-gnu ;; \
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Copy source code
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Generate protobuf code
|
|
||||||
RUN cargo run --bin gproto
|
|
||||||
|
|
||||||
# Build the actual application
|
|
||||||
RUN case "$TARGETPLATFORM" in \
|
|
||||||
"linux/amd64") \
|
|
||||||
cargo build --release --target x86_64-unknown-linux-gnu --bin rustfs && \
|
|
||||||
cp target/x86_64-unknown-linux-gnu/release/rustfs /usr/local/bin/rustfs \
|
|
||||||
;; \
|
|
||||||
"linux/arm64") \
|
|
||||||
cargo build --release --target aarch64-unknown-linux-gnu --bin rustfs && \
|
|
||||||
cp target/aarch64-unknown-linux-gnu/release/rustfs /usr/local/bin/rustfs \
|
|
||||||
;; \
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Runtime stage - Ubuntu minimal for better compatibility
|
|
||||||
FROM ubuntu:22.04
|
|
||||||
|
|
||||||
# Install runtime dependencies
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
ca-certificates \
|
|
||||||
tzdata \
|
|
||||||
wget \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Create rustfs user and group
|
|
||||||
RUN groupadd -g 1000 rustfs && \
|
|
||||||
useradd -d /app -g rustfs -u 1000 -s /bin/bash rustfs
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Create data directories
|
|
||||||
RUN mkdir -p /data/rustfs{0,1,2,3} && \
|
|
||||||
chown -R rustfs:rustfs /data /app
|
|
||||||
|
|
||||||
# Copy binary from builder stage
|
|
||||||
COPY --from=builder /usr/local/bin/rustfs /app/rustfs
|
|
||||||
RUN chmod +x /app/rustfs && chown rustfs:rustfs /app/rustfs
|
|
||||||
|
|
||||||
# Switch to non-root user
|
|
||||||
USER rustfs
|
|
||||||
|
|
||||||
# Expose ports
|
|
||||||
EXPOSE 9000 9001
|
|
||||||
|
|
||||||
# Health check
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
||||||
CMD wget --no-verbose --tries=1 --spider http://localhost:9000/health || exit 1
|
|
||||||
|
|
||||||
# Set default command
|
|
||||||
CMD ["/app/rustfs"]
|
|
||||||
201
LICENSE
201
LICENSE
@@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright 2024 Beijing Henghesha Technology Co., Ltd.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|||||||
118
Makefile
118
Makefile
@@ -79,121 +79,3 @@ build: BUILD_CMD = /root/.cargo/bin/cargo build --release --bin rustfs --target-
|
|||||||
build:
|
build:
|
||||||
$(DOCKER_CLI) build -t $(ROCKYLINUX_BUILD_IMAGE_NAME) -f $(DOCKERFILE_PATH)/Dockerfile.$(BUILD_OS) .
|
$(DOCKER_CLI) build -t $(ROCKYLINUX_BUILD_IMAGE_NAME) -f $(DOCKERFILE_PATH)/Dockerfile.$(BUILD_OS) .
|
||||||
$(DOCKER_CLI) run --rm --name $(ROCKYLINUX_BUILD_CONTAINER_NAME) -v $(shell pwd):/root/s3-rustfs -it $(ROCKYLINUX_BUILD_IMAGE_NAME) $(BUILD_CMD)
|
$(DOCKER_CLI) run --rm --name $(ROCKYLINUX_BUILD_CONTAINER_NAME) -v $(shell pwd):/root/s3-rustfs -it $(ROCKYLINUX_BUILD_IMAGE_NAME) $(BUILD_CMD)
|
||||||
|
|
||||||
.PHONY: build-musl
|
|
||||||
build-musl:
|
|
||||||
@echo "🔨 Building rustfs for x86_64-unknown-linux-musl..."
|
|
||||||
cargo build --target x86_64-unknown-linux-musl --bin rustfs -r
|
|
||||||
|
|
||||||
.PHONY: build-gnu
|
|
||||||
build-gnu:
|
|
||||||
@echo "🔨 Building rustfs for x86_64-unknown-linux-gnu..."
|
|
||||||
cargo build --target x86_64-unknown-linux-gnu --bin rustfs -r
|
|
||||||
|
|
||||||
.PHONY: deploy-dev
|
|
||||||
deploy-dev: build-musl
|
|
||||||
@echo "🚀 Deploying to dev server: $${IP}"
|
|
||||||
./scripts/dev_deploy.sh $${IP}
|
|
||||||
|
|
||||||
# Multi-architecture Docker build targets
|
|
||||||
.PHONY: docker-build-multiarch
|
|
||||||
docker-build-multiarch:
|
|
||||||
@echo "🏗️ Building multi-architecture Docker images..."
|
|
||||||
./scripts/build-docker-multiarch.sh
|
|
||||||
|
|
||||||
.PHONY: docker-build-multiarch-push
|
|
||||||
docker-build-multiarch-push:
|
|
||||||
@echo "🚀 Building and pushing multi-architecture Docker images..."
|
|
||||||
./scripts/build-docker-multiarch.sh --push
|
|
||||||
|
|
||||||
.PHONY: docker-build-multiarch-version
|
|
||||||
docker-build-multiarch-version:
|
|
||||||
@if [ -z "$(VERSION)" ]; then \
|
|
||||||
echo "❌ 错误: 请指定版本, 例如: make docker-build-multiarch-version VERSION=v1.0.0"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
@echo "🏗️ Building multi-architecture Docker images (version: $(VERSION))..."
|
|
||||||
./scripts/build-docker-multiarch.sh --version $(VERSION)
|
|
||||||
|
|
||||||
.PHONY: docker-push-multiarch-version
|
|
||||||
docker-push-multiarch-version:
|
|
||||||
@if [ -z "$(VERSION)" ]; then \
|
|
||||||
echo "❌ 错误: 请指定版本, 例如: make docker-push-multiarch-version VERSION=v1.0.0"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
@echo "🚀 Building and pushing multi-architecture Docker images (version: $(VERSION))..."
|
|
||||||
./scripts/build-docker-multiarch.sh --version $(VERSION) --push
|
|
||||||
|
|
||||||
.PHONY: docker-build-ubuntu
|
|
||||||
docker-build-ubuntu:
|
|
||||||
@echo "🏗️ Building multi-architecture Ubuntu Docker images..."
|
|
||||||
./scripts/build-docker-multiarch.sh --type ubuntu
|
|
||||||
|
|
||||||
.PHONY: docker-build-rockylinux
|
|
||||||
docker-build-rockylinux:
|
|
||||||
@echo "🏗️ Building multi-architecture RockyLinux Docker images..."
|
|
||||||
./scripts/build-docker-multiarch.sh --type rockylinux
|
|
||||||
|
|
||||||
.PHONY: docker-build-devenv
|
|
||||||
docker-build-devenv:
|
|
||||||
@echo "🏗️ Building multi-architecture development environment Docker images..."
|
|
||||||
./scripts/build-docker-multiarch.sh --type devenv
|
|
||||||
|
|
||||||
.PHONY: docker-build-all-types
|
|
||||||
docker-build-all-types:
|
|
||||||
@echo "🏗️ Building all multi-architecture Docker image types..."
|
|
||||||
./scripts/build-docker-multiarch.sh --type production
|
|
||||||
./scripts/build-docker-multiarch.sh --type ubuntu
|
|
||||||
./scripts/build-docker-multiarch.sh --type rockylinux
|
|
||||||
./scripts/build-docker-multiarch.sh --type devenv
|
|
||||||
|
|
||||||
.PHONY: docker-inspect-multiarch
|
|
||||||
docker-inspect-multiarch:
|
|
||||||
@if [ -z "$(IMAGE)" ]; then \
|
|
||||||
echo "❌ 错误: 请指定镜像, 例如: make docker-inspect-multiarch IMAGE=rustfs/rustfs:latest"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
@echo "🔍 Inspecting multi-architecture image: $(IMAGE)"
|
|
||||||
docker buildx imagetools inspect $(IMAGE)
|
|
||||||
|
|
||||||
.PHONY: build-cross-all
|
|
||||||
build-cross-all:
|
|
||||||
@echo "🔧 Building all target architectures..."
|
|
||||||
@if ! command -v cross &> /dev/null; then \
|
|
||||||
echo "📦 Installing cross..."; \
|
|
||||||
cargo install cross; \
|
|
||||||
fi
|
|
||||||
@echo "🔨 Generating protobuf code..."
|
|
||||||
cargo run --bin gproto || true
|
|
||||||
@echo "🔨 Building x86_64-unknown-linux-musl..."
|
|
||||||
cargo build --release --target x86_64-unknown-linux-musl --bin rustfs
|
|
||||||
@echo "🔨 Building aarch64-unknown-linux-gnu..."
|
|
||||||
cross build --release --target aarch64-unknown-linux-gnu --bin rustfs
|
|
||||||
@echo "✅ All architectures built successfully!"
|
|
||||||
|
|
||||||
.PHONY: help-docker
|
|
||||||
help-docker:
|
|
||||||
@echo "🐳 Docker 多架构构建帮助:"
|
|
||||||
@echo ""
|
|
||||||
@echo "基本构建:"
|
|
||||||
@echo " make docker-build-multiarch # 构建多架构镜像(不推送)"
|
|
||||||
@echo " make docker-build-multiarch-push # 构建并推送多架构镜像"
|
|
||||||
@echo ""
|
|
||||||
@echo "版本构建:"
|
|
||||||
@echo " make docker-build-multiarch-version VERSION=v1.0.0 # 构建指定版本"
|
|
||||||
@echo " make docker-push-multiarch-version VERSION=v1.0.0 # 构建并推送指定版本"
|
|
||||||
@echo ""
|
|
||||||
@echo "镜像类型:"
|
|
||||||
@echo " make docker-build-ubuntu # 构建 Ubuntu 镜像"
|
|
||||||
@echo " make docker-build-rockylinux # 构建 RockyLinux 镜像"
|
|
||||||
@echo " make docker-build-devenv # 构建开发环境镜像"
|
|
||||||
@echo " make docker-build-all-types # 构建所有类型镜像"
|
|
||||||
@echo ""
|
|
||||||
@echo "辅助工具:"
|
|
||||||
@echo " make build-cross-all # 构建所有架构的二进制文件"
|
|
||||||
@echo " make docker-inspect-multiarch IMAGE=xxx # 检查镜像的架构支持"
|
|
||||||
@echo ""
|
|
||||||
@echo "环境变量 (在推送时需要设置):"
|
|
||||||
@echo " DOCKERHUB_USERNAME Docker Hub 用户名"
|
|
||||||
@echo " DOCKERHUB_TOKEN Docker Hub 访问令牌"
|
|
||||||
@echo " GITHUB_TOKEN GitHub 访问令牌"
|
|
||||||
|
|||||||
153
README.md
153
README.md
@@ -1,115 +1,94 @@
|
|||||||
[](https://rustfs.com)
|
# RustFS
|
||||||
|
|
||||||
<p align="center">RustFS is a high-performance distributed object storage software built using Rust</p>
|
## English Documentation |[中文文档](README_ZH.md)
|
||||||
|
|
||||||
<p align="center">
|
### Prerequisites
|
||||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
||||||
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/rustfs/rustfs"/>
|
|
||||||
<img alt="Github Last Commit" src="https://img.shields.io/github/last-commit/rustfs/rustfs"/>
|
|
||||||
<img alt="Github Contributors" src="https://img.shields.io/github/contributors/rustfs/rustfs"/>
|
|
||||||
<img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/rustfs/rustfs"/>
|
|
||||||
<img alt="Discord" src="https://img.shields.io/discord/1107178041848909847?label=discord"/>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="center">
|
| Package | Version | Download Link |
|
||||||
<a href="https://docs.rustfs.com/en/introduction.html">Getting Started</a>
|
|---------|---------|----------------------------------------------------------------------------------------------------------------------------------|
|
||||||
· <a href="https://docs.rustfs.com/en/">Docs</a>
|
| Rust | 1.8.5+ | [rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) |
|
||||||
· <a href="https://github.com/rustfs/rustfs/issues">Bug reports</a>
|
| protoc | 30.2+ | [protoc-30.2-linux-x86_64.zip](https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip) |
|
||||||
· <a href="https://github.com/rustfs/rustfs/discussions">Discussions</a>
|
| flatc | 24.0+ | [Linux.flatc.binary.g++-13.zip](https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip) |
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="center">
|
### Building RustFS
|
||||||
English | <a href="https://github.com/rustfs/rustfs/blob/main/README_ZH.md">简体中文</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
RustFS is a high-performance distributed object storage software built using Rust, one of the most popular languages worldwide. Along with MinIO, it shares a range of advantages such as simplicity, S3 compatibility, open-source nature, support for data lakes, AI, and big data. Furthermore, it has a better and more user-friendly open-source license in comparison to other storage systems, being constructed under the Apache license. As Rust serves as its foundation, RustFS provides faster speed and safer distributed features for high-performance object storage.
|
#### Generate Protobuf Code
|
||||||
|
|
||||||
## Features
|
```bash
|
||||||
|
cargo run --bin gproto
|
||||||
|
```
|
||||||
|
|
||||||
- **High Performance**: Built with Rust, ensuring speed and efficiency.
|
#### Using Docker for Prerequisites
|
||||||
- **Distributed Architecture**: Scalable and fault-tolerant design for large-scale deployments.
|
|
||||||
- **S3 Compatibility**: Seamless integration with existing S3-compatible applications.
|
|
||||||
- **Data Lake Support**: Optimized for big data and AI workloads.
|
|
||||||
- **Open Source**: Licensed under Apache 2.0, encouraging community contributions and transparency.
|
|
||||||
- **User-Friendly**: Designed with simplicity in mind, making it easy to deploy and manage.
|
|
||||||
|
|
||||||
## RustFS vs MinIO
|
```yaml
|
||||||
|
- uses: arduino/setup-protoc@v3
|
||||||
|
with:
|
||||||
|
version: "30.2"
|
||||||
|
|
||||||
Stress test server parameters
|
- uses: Nugine/setup-flatc@v1
|
||||||
|
with:
|
||||||
|
version: "25.2.10"
|
||||||
|
```
|
||||||
|
|
||||||
| Type | parameter | Remark |
|
#### Adding Console Web UI
|
||||||
| - | - | - |
|
|
||||||
|CPU | 2 Core | Intel Xeon(Sapphire Rapids) Platinum 8475B , 2.7/3.2 GHz| |
|
|
||||||
|Memory| 4GB | |
|
|
||||||
|Network | 15Gbp | |
|
|
||||||
|Driver | 40GB x 4 | IOPS 3800 / Driver |
|
|
||||||
|
|
||||||
<https://github.com/user-attachments/assets/2e4979b5-260c-4f2c-ac12-c87fd558072a>
|
|
||||||
|
|
||||||
### RustFS vs Other object storage
|
|
||||||
|
|
||||||
| RustFS | Other object storage|
|
|
||||||
| - | - |
|
|
||||||
| Powerful Console | Simple and useless Console |
|
|
||||||
| Developed based on Rust language, memory is safer | Developed in Go or C, with potential issues like memory GC/leaks |
|
|
||||||
| Does not report logs to third-party countries | Reporting logs to other third countries may violate national security laws |
|
|
||||||
| Licensed under Apache, more business-friendly | AGPL V3 License and other License, polluted open source and License traps, infringement of intellectual property rights |
|
|
||||||
| Comprehensive S3 support, works with domestic and international cloud providers | Full support for S3, but no local cloud vendor support |
|
|
||||||
| Rust-based development, strong support for secure and innovative devices | Poor support for edge gateways and secure innovative devices|
|
|
||||||
| Stable commercial prices, free community support | High pricing, with costs up to $250,000 for 1PiB |
|
|
||||||
| No risk | Intellectual property risks and risks of prohibited uses |
|
|
||||||
|
|
||||||
## Quickstart
|
|
||||||
|
|
||||||
To get started with RustFS, follow these steps:
|
|
||||||
|
|
||||||
1. **Install RustFS**: Download the latest release from our [GitHub Releases](https://github.com/rustfs/rustfs/releases).
|
|
||||||
2. **Run RustFS**: Use the provided binary to start the server.
|
|
||||||
|
|
||||||
|
1. Download the latest console UI:
|
||||||
```bash
|
```bash
|
||||||
./rustfs /data
|
wget https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip
|
||||||
|
```
|
||||||
|
2. Create the static directory:
|
||||||
|
```bash
|
||||||
|
mkdir -p ./rustfs/static
|
||||||
|
```
|
||||||
|
3. Extract and compile RustFS:
|
||||||
|
```bash
|
||||||
|
unzip rustfs-console-latest.zip -d ./rustfs/static
|
||||||
|
cargo build
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Access the Console**: Open your web browser and navigate to `http://localhost:9001` to access the RustFS console.
|
### Running RustFS
|
||||||
4. **Create a Bucket**: Use the console to create a new bucket for your objects.
|
|
||||||
5. **Upload Objects**: You can upload files directly through the console or use S3-compatible APIs to interact with your RustFS instance.
|
|
||||||
|
|
||||||
## Documentation
|
#### Configuration
|
||||||
|
|
||||||
For detailed documentation, including configuration options, API references, and advanced usage, please visit our [Documentation](https://docs.rustfs.com).
|
Set the required environment variables:
|
||||||
|
|
||||||
## Getting Help
|
```bash
|
||||||
|
# Basic config
|
||||||
|
export RUSTFS_VOLUMES="./target/volume/test"
|
||||||
|
export RUSTFS_ADDRESS="0.0.0.0:9000"
|
||||||
|
export RUSTFS_CONSOLE_ENABLE=true
|
||||||
|
export RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9001"
|
||||||
|
|
||||||
If you have any questions or need assistance, you can:
|
# Observability config
|
||||||
|
export RUSTFS_OBS_ENDPOINT="http://localhost:4317"
|
||||||
|
|
||||||
- Check the [FAQ](https://github.com/rustfs/rustfs/discussions/categories/q-a) for common issues and solutions.
|
# Event message configuration
|
||||||
- Join our [GitHub Discussions](https://github.com/rustfs/rustfs/discussions) to ask questions and share your experiences.
|
#export RUSTFS_EVENT_CONFIG="./deploy/config/event.toml"
|
||||||
- Open an issue on our [GitHub Issues](https://github.com/rustfs/rustfs/issues) page for bug reports or feature requests.
|
|
||||||
|
|
||||||
## Links
|
```
|
||||||
|
|
||||||
- [Documentation](https://docs.rustfs.com) - The manual you should read
|
#### Start the service
|
||||||
- [Changelog](https://github.com/rustfs/rustfs/releases) - What we broke and fixed
|
|
||||||
- [GitHub Discussions](https://github.com/rustfs/rustfs/discussions) - Where the community lives
|
|
||||||
|
|
||||||
## Contact
|
```bash
|
||||||
|
./rustfs /data/rustfs
|
||||||
|
```
|
||||||
|
|
||||||
- **Bugs**: [GitHub Issues](https://github.com/rustfs/rustfs/issues)
|
### Observability Stack
|
||||||
- **Business**: <hello@rustfs.com>
|
|
||||||
- **Jobs**: <jobs@rustfs.com>
|
|
||||||
- **General Discussion**: [GitHub Discussions](https://github.com/rustfs/rustfs/discussions)
|
|
||||||
- **Contributing**: [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
||||||
|
|
||||||
## Contributors
|
#### Deployment
|
||||||
|
|
||||||
RustFS is a community-driven project, and we appreciate all contributions. Check out the [Contributors](https://github.com/rustfs/rustfs/graphs/contributors) page to see the amazing people who have helped make RustFS better.
|
1. Navigate to the observability directory:
|
||||||
|
```bash
|
||||||
|
cd .docker/observability
|
||||||
|
```
|
||||||
|
|
||||||
<a href="https://github.com/rustfs/rustfs/graphs/contributors">
|
2. Start the observability stack:
|
||||||
<img src="https://contrib.rocks/image?repo=rustfs/rustfs" />
|
```bash
|
||||||
</a>
|
docker compose -f docker-compose.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
#### Access Monitoring Dashboards
|
||||||
|
|
||||||
[Apache 2.0](https://opensource.org/licenses/Apache-2.0)
|
- Grafana: `http://localhost:3000` (credentials: `admin`/`admin`)
|
||||||
|
- Jaeger: `http://localhost:16686`
|
||||||
**RustFS** is a trademark of RustFS, Inc. All other trademarks are the property of their respective owners.
|
- Prometheus: `http://localhost:9090`
|
||||||
|
|||||||
156
README_ZH.md
156
README_ZH.md
@@ -1,115 +1,99 @@
|
|||||||
[](https://rustfs.com)
|
# RustFS
|
||||||
|
|
||||||
<p align="center">RustFS 是一个使用 Rust 构建的高性能分布式对象存储软件</p >
|
## [English Documentation](README.md) |中文文档
|
||||||
|
|
||||||
<p align="center">
|
### 前置要求
|
||||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
||||||
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/rustfs/rustfs"/>
|
|
||||||
<img alt="Github Last Commit" src="https://img.shields.io/github/last-commit/rustfs/rustfs"/>
|
|
||||||
<img alt="Github Contributors" src="https://img.shields.io/github/contributors/rustfs/rustfs"/>
|
|
||||||
<img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/rustfs/rustfs"/>
|
|
||||||
<img alt="Discord" src="https://img.shields.io/discord/1107178041848909847?label=discord"/>
|
|
||||||
</p >
|
|
||||||
|
|
||||||
<p align="center">
|
| 软件包 | 版本 | 下载链接 |
|
||||||
<a href="https://docs.rustfs.com/zh/introduction.html">快速开始</a >
|
|--------|--------|----------------------------------------------------------------------------------------------------------------------------------|
|
||||||
· <a href="https://docs.rustfs.com/zh/">文档</a >
|
| Rust | 1.8.5+ | [rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) |
|
||||||
· <a href="https://github.com/rustfs/rustfs/issues">问题报告</a >
|
| protoc | 30.2+ | [protoc-30.2-linux-x86_64.zip](https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip) |
|
||||||
· <a href="https://github.com/rustfs/rustfs/discussions">讨论</a >
|
| flatc | 24.0+ | [Linux.flatc.binary.g++-13.zip](https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip) |
|
||||||
</p >
|
|
||||||
|
|
||||||
<p align="center">
|
### 构建 RustFS
|
||||||
<a href="https://github.com/rustfs/rustfs/blob/main/README.md">English</a > | 简体中文
|
|
||||||
</p >
|
|
||||||
|
|
||||||
RustFS 是一个使用 Rust(全球最受欢迎的编程语言之一)构建的高性能分布式对象存储软件。与 MinIO 一样,它具有简单性、S3 兼容性、开源特性以及对数据湖、AI 和大数据的支持等一系列优势。此外,与其他存储系统相比,它采用 Apache 许可证构建,拥有更好、更用户友好的开源许可证。由于以 Rust 为基础,RustFS 为高性能对象存储提供了更快的速度和更安全的分布式功能。
|
#### 生成 Protobuf 代码
|
||||||
|
|
||||||
## 特性
|
```bash
|
||||||
|
cargo run --bin gproto
|
||||||
|
```
|
||||||
|
|
||||||
- **高性能**:使用 Rust 构建,确保速度和效率。
|
#### 使用 Docker 安装依赖
|
||||||
- **分布式架构**:可扩展且容错的设计,适用于大规模部署。
|
|
||||||
- **S3 兼容性**:与现有 S3 兼容应用程序无缝集成。
|
|
||||||
- **数据湖支持**:针对大数据和 AI 工作负载进行了优化。
|
|
||||||
- **开源**:采用 Apache 2.0 许可证,鼓励社区贡献和透明度。
|
|
||||||
- **用户友好**:设计简单,易于部署和管理。
|
|
||||||
|
|
||||||
## RustFS vs MinIO
|
```yaml
|
||||||
|
- uses: arduino/setup-protoc@v3
|
||||||
|
with:
|
||||||
|
version: "30.2"
|
||||||
|
|
||||||
压力测试服务器参数
|
- uses: Nugine/setup-flatc@v1
|
||||||
|
with:
|
||||||
|
version: "25.2.10"
|
||||||
|
```
|
||||||
|
|
||||||
| 类型 | 参数 | 备注 |
|
#### 添加控制台 Web UI
|
||||||
| - | - | - |
|
|
||||||
|CPU | 2 核心 | Intel Xeon(Sapphire Rapids) Platinum 8475B , 2.7/3.2 GHz| |
|
|
||||||
|内存| 4GB | |
|
|
||||||
|网络 | 15Gbp | |
|
|
||||||
|驱动器 | 40GB x 4 | IOPS 3800 / 驱动器 |
|
|
||||||
|
|
||||||
<https://github.com/user-attachments/assets/2e4979b5-260c-4f2c-ac12-c87fd558072a>
|
|
||||||
|
|
||||||
### RustFS vs 其他对象存储
|
|
||||||
|
|
||||||
| RustFS | 其他对象存储|
|
|
||||||
| - | - |
|
|
||||||
| 强大的控制台 | 简单且无用的控制台 |
|
|
||||||
| 基于 Rust 语言开发,内存更安全 | 使用 Go 或 C 开发,存在内存 GC/泄漏等潜在问题 |
|
|
||||||
| 不向第三方国家报告日志 | 向其他第三方国家报告日志可能违反国家安全法律 |
|
|
||||||
| 采用 Apache 许可证,对商业更友好 | AGPL V3 许可证等其他许可证,污染开源和许可证陷阱,侵犯知识产权 |
|
|
||||||
| 全面的 S3 支持,适用于国内外云提供商 | 完全支持 S3,但不支持本地云厂商 |
|
|
||||||
| 基于 Rust 开发,对安全和创新设备有强大支持 | 对边缘网关和安全创新设备支持较差|
|
|
||||||
| 稳定的商业价格,免费社区支持 | 高昂的定价,1PiB 成本高达 $250,000 |
|
|
||||||
| 无风险 | 知识产权风险和禁止使用的风险 |
|
|
||||||
|
|
||||||
## 快速开始
|
|
||||||
|
|
||||||
要开始使用 RustFS,请按照以下步骤操作:
|
|
||||||
|
|
||||||
1. **安装 RustFS**:从我们的 [GitHub Releases](https://github.com/rustfs/rustfs/releases) 下载最新版本。
|
|
||||||
2. **运行 RustFS**:使用提供的二进制文件启动服务器。
|
|
||||||
|
|
||||||
|
1. 下载最新的控制台 UI:
|
||||||
```bash
|
```bash
|
||||||
./rustfs /data
|
wget https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip
|
||||||
|
```
|
||||||
|
2. 创建静态资源目录:
|
||||||
|
```bash
|
||||||
|
mkdir -p ./rustfs/static
|
||||||
|
```
|
||||||
|
3. 解压并编译 RustFS:
|
||||||
|
```bash
|
||||||
|
unzip rustfs-console-latest.zip -d ./rustfs/static
|
||||||
|
cargo build
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **访问控制台**:打开 Web 浏览器并导航到 `http://localhost:9001` 以访问 RustFS 控制台。
|
### 运行 RustFS
|
||||||
4. **创建存储桶**:使用控制台为您的对象创建新的存储桶。
|
|
||||||
5. **上传对象**:您可以直接通过控制台上传文件,或使用 S3 兼容的 API 与您的 RustFS 实例交互。
|
|
||||||
|
|
||||||
## 文档
|
#### 配置
|
||||||
|
|
||||||
有关详细文档,包括配置选项、API 参考和高级用法,请访问我们的[文档](https://docs.rustfs.com)。
|
设置必要的环境变量:
|
||||||
|
|
||||||
## 获取帮助
|
```bash
|
||||||
|
# 基础配置
|
||||||
|
export RUSTFS_VOLUMES="./target/volume/test"
|
||||||
|
export RUSTFS_ADDRESS="0.0.0.0:9000"
|
||||||
|
export RUSTFS_CONSOLE_ENABLE=true
|
||||||
|
export RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9001"
|
||||||
|
|
||||||
如果您有任何问题或需要帮助,您可以:
|
# 可观测性配置
|
||||||
|
export RUSTFS_OBS_ENDPOINT="http://localhost:4317"
|
||||||
|
|
||||||
- 查看[常见问题解答](https://github.com/rustfs/rustfs/discussions/categories/q-a)以获取常见问题和解决方案。
|
# 事件消息配置
|
||||||
- 加入我们的 [GitHub 讨论](https://github.com/rustfs/rustfs/discussions)来提问和分享您的经验。
|
#export RUSTFS_EVENT_CONFIG="./deploy/config/event.toml"
|
||||||
- 在我们的 [GitHub Issues](https://github.com/rustfs/rustfs/issues) 页面上开启问题,报告错误或功能请求。
|
```
|
||||||
|
|
||||||
## 链接
|
#### 启动服务
|
||||||
|
|
||||||
- [文档](https://docs.rustfs.com) - 您应该阅读的手册
|
```bash
|
||||||
- [更新日志](https://docs.rustfs.com/changelog) - 我们破坏和修复的内容
|
./rustfs /data/rustfs
|
||||||
- [GitHub 讨论](https://github.com/rustfs/rustfs/discussions) - 社区所在地
|
```
|
||||||
|
|
||||||
## 联系
|
### 可观测性系统
|
||||||
|
|
||||||
- **错误报告**:[GitHub Issues](https://github.com/rustfs/rustfs/issues)
|
#### 部署
|
||||||
- **商务合作**:<hello@rustfs.com>
|
|
||||||
- **招聘**:<jobs@rustfs.com>
|
|
||||||
- **一般讨论**:[GitHub 讨论](https://github.com/rustfs/rustfs/discussions)
|
|
||||||
- **贡献**:[CONTRIBUTING.md](CONTRIBUTING.md)
|
|
||||||
|
|
||||||
## 贡献者
|
1. 进入可观测性目录:
|
||||||
|
```bash
|
||||||
|
cd .docker/observability
|
||||||
|
```
|
||||||
|
|
||||||
RustFS 是一个社区驱动的项目,我们感谢所有的贡献。查看[贡献者](https://github.com/rustfs/rustfs/graphs/contributors)页面,了解帮助 RustFS 变得更好的杰出人员。
|
2. 启动可观测性系统:
|
||||||
|
```bash
|
||||||
|
docker compose -f docker-compose.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
<a href="https://github.com/rustfs/rustfs/graphs/contributors">
|
#### 访问监控面板
|
||||||
<img src="https://contrib.rocks/image?repo=rustfs/rustfs" />
|
|
||||||
</a >
|
|
||||||
|
|
||||||
## 许可证
|
- Grafana: `http://localhost:3000` (默认账号/密码:`admin`/`admin`)
|
||||||
|
- Jaeger: `http://localhost:16686`
|
||||||
|
- Prometheus: `http://localhost:9090`
|
||||||
|
|
||||||
[Apache 2.0](https://opensource.org/licenses/Apache-2.0)
|
#### 配置可观测性
|
||||||
|
|
||||||
**RustFS** 是 RustFS, Inc. 的商标。所有其他商标均为其各自所有者的财产。
|
```
|
||||||
|
OpenTelemetry Collector 地址(endpoint): http://localhost:4317
|
||||||
|
```
|
||||||
154
SSE_KMS_IMPROVEMENTS.md
Normal file
154
SSE_KMS_IMPROVEMENTS.md
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
# RustFS SSE-KMS 改进实现总结
|
||||||
|
|
||||||
|
本次改进针对 RustFS 的 SSE-KMS 系统进行了四个主要增强,使其更符合 MinIO 标准并支持动态配置管理。
|
||||||
|
|
||||||
|
## 实现的改进
|
||||||
|
|
||||||
|
### 1. 创建 KMS 配置子系统 ✅
|
||||||
|
|
||||||
|
**实现位置**: `crates/config/src/lib.rs`
|
||||||
|
|
||||||
|
- 创建了统一的配置管理器 `ConfigManager`
|
||||||
|
- 支持动态 KMS 配置的读取、设置和持久化
|
||||||
|
- 提供线程安全的全局配置访问
|
||||||
|
- 支持配置验证和错误处理
|
||||||
|
|
||||||
|
**主要功能**:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// 全局配置管理器
|
||||||
|
ConfigManager::global().get_kms_config("vault").await
|
||||||
|
ConfigManager::global().set_kms_config("vault", config).await
|
||||||
|
ConfigManager::global().validate_all_configs().await
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. KMS 配置查找和验证 ✅
|
||||||
|
|
||||||
|
**实现位置**: `ecstore/src/config/kms.rs`
|
||||||
|
|
||||||
|
- 实现了完整的 KMS 配置结构 `Config`
|
||||||
|
- 支持环境变量和配置文件双重配置源
|
||||||
|
- 提供配置验证和连接测试功能
|
||||||
|
- 兼容 MinIO 的配置参数命名
|
||||||
|
|
||||||
|
**主要特性**:
|
||||||
|
|
||||||
|
- 支持 Vault 端点、密钥名称、认证 token 等配置
|
||||||
|
- 自动验证配置完整性和有效性
|
||||||
|
- 支持 TLS 配置和证书验证
|
||||||
|
- 提供连接测试功能
|
||||||
|
|
||||||
|
### 3. S3 标准元数据格式支持 ✅
|
||||||
|
|
||||||
|
**实现位置**: `crypto/src/sse_kms.rs`
|
||||||
|
|
||||||
|
- 实现了 MinIO 兼容的元数据格式
|
||||||
|
- 支持标准 S3 SSE-KMS HTTP 头部
|
||||||
|
- 提供元数据与 HTTP 头部的双向转换
|
||||||
|
- 支持分片加密的元数据管理
|
||||||
|
|
||||||
|
**标准头部支持**:
|
||||||
|
|
||||||
|
```
|
||||||
|
x-amz-server-side-encryption: aws:kms
|
||||||
|
x-amz-server-side-encryption-aws-kms-key-id: key-id
|
||||||
|
x-amz-server-side-encryption-context: context
|
||||||
|
x-amz-meta-sse-kms-encrypted-key: encrypted-data-key
|
||||||
|
x-amz-meta-sse-kms-iv: initialization-vector
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 管理 API 支持动态配置 ✅
|
||||||
|
|
||||||
|
**实现位置**: `rustfs/src/admin/handlers.rs` 和 `rustfs/src/admin/mod.rs`
|
||||||
|
|
||||||
|
- 添加了 KMS 配置管理的 REST API 端点
|
||||||
|
- 支持 MinIO 兼容的配置管理路径
|
||||||
|
- 提供获取和设置配置的 HTTP 接口
|
||||||
|
- 支持实时配置更新和验证
|
||||||
|
|
||||||
|
**API 端点**:
|
||||||
|
|
||||||
|
```
|
||||||
|
GET /minio/admin/v3/config # 获取所有配置
|
||||||
|
POST /minio/admin/v3/config/kms_vault/{target} # 设置KMS配置
|
||||||
|
GET /rustfs/admin/v3/config # RustFS原生配置API
|
||||||
|
POST /rustfs/admin/v3/config/kms_vault/{target} # RustFS原生设置API
|
||||||
|
```
|
||||||
|
|
||||||
|
## 技术特性
|
||||||
|
|
||||||
|
### 兼容性
|
||||||
|
|
||||||
|
- ✅ 完全兼容 MinIO 的 SSE-KMS 配置格式
|
||||||
|
- ✅ 支持标准 S3 SSE-KMS HTTP 头部
|
||||||
|
- ✅ 兼容 MinIO Admin API 配置管理接口
|
||||||
|
|
||||||
|
### 安全性
|
||||||
|
|
||||||
|
- ✅ 支持 RustyVault KMS 集成
|
||||||
|
- ✅ 数据密钥的安全生成和加密存储
|
||||||
|
- ✅ 支持 TLS 连接和证书验证
|
||||||
|
- ✅ 敏感配置信息的安全处理
|
||||||
|
|
||||||
|
### 性能
|
||||||
|
|
||||||
|
- ✅ 异步配置操作
|
||||||
|
- ✅ 线程安全的全局配置缓存
|
||||||
|
- ✅ 高效的元数据序列化/反序列化
|
||||||
|
- ✅ 支持分片并行加密
|
||||||
|
|
||||||
|
### 可维护性
|
||||||
|
|
||||||
|
- ✅ 模块化设计,职责分离
|
||||||
|
- ✅ 完整的错误处理和日志记录
|
||||||
|
- ✅ 丰富的单元测试覆盖
|
||||||
|
- ✅ 详细的文档和注释
|
||||||
|
|
||||||
|
## 使用示例
|
||||||
|
|
||||||
|
### 配置 KMS
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 通过环境变量配置
|
||||||
|
export RUSTFS_KMS_ENABLED=true
|
||||||
|
export RUSTFS_KMS_VAULT_ENDPOINT=http://vault:8200
|
||||||
|
export RUSTFS_KMS_VAULT_KEY_NAME=rustfs-key
|
||||||
|
export RUSTFS_KMS_VAULT_TOKEN=vault-token
|
||||||
|
|
||||||
|
# 通过API配置
|
||||||
|
curl -X POST "http://rustfs:9000/minio/admin/v3/config/kms_vault/default" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"endpoint": "http://vault:8200",
|
||||||
|
"key_name": "rustfs-encryption-key",
|
||||||
|
"token": "vault-token",
|
||||||
|
"enabled": true
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 使用 SSE-KMS 上传对象
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 使用aws-cli上传加密对象
|
||||||
|
aws s3 cp file.txt s3://bucket/file.txt \
|
||||||
|
--server-side-encryption aws:kms \
|
||||||
|
--ssekms-key-id rustfs-encryption-key
|
||||||
|
```
|
||||||
|
|
||||||
|
## 部署注意事项
|
||||||
|
|
||||||
|
1. **RustyVault 集成**: 确保 RustyVault 服务可访问且已正确配置 transit 引擎
|
||||||
|
2. **网络安全**: 建议在生产环境中使用 TLS 连接到 Vault
|
||||||
|
3. **权限管理**: 确保 RustFS 具有访问 Vault 密钥的适当权限
|
||||||
|
4. **监控**: 建议监控 KMS 连接状态和加密操作性能
|
||||||
|
|
||||||
|
## 后续发展
|
||||||
|
|
||||||
|
这次实现为 RustFS 的企业级加密功能奠定了坚实基础。未来可以考虑:
|
||||||
|
|
||||||
|
- 支持多个 KMS 提供商(AWS KMS, Azure Key Vault 等)
|
||||||
|
- 实现密钥轮换功能
|
||||||
|
- 添加加密性能监控和优化
|
||||||
|
- 支持更复杂的访问控制策略
|
||||||
|
|
||||||
|
通过这些改进,RustFS 现在具备了与 MinIO 相当的 SSE-KMS 功能,可以满足企业级数据加密需求。
|
||||||
19
appauth/Cargo.toml
Normal file
19
appauth/Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[package]
|
||||||
|
name = "appauth"
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
version.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
base64-simd = "0.8.0"
|
||||||
|
common.workspace = true
|
||||||
|
hex-simd = "0.8.0"
|
||||||
|
rand.workspace = true
|
||||||
|
rsa = "0.9.8"
|
||||||
|
serde.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
1
appauth/src/lib.rs
Normal file
1
appauth/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod token;
|
||||||
@@ -1,25 +1,10 @@
|
|||||||
// Copyright 2024 RustFS Team
|
use common::error::Result;
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use rsa::Pkcs1v15Encrypt;
|
use rsa::Pkcs1v15Encrypt;
|
||||||
use rsa::{
|
use rsa::{
|
||||||
RsaPrivateKey, RsaPublicKey,
|
|
||||||
pkcs8::{DecodePrivateKey, DecodePublicKey},
|
pkcs8::{DecodePrivateKey, DecodePublicKey},
|
||||||
rand_core::OsRng,
|
RsaPrivateKey, RsaPublicKey,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::io::{Error, Result};
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
||||||
pub struct Token {
|
pub struct Token {
|
||||||
@@ -33,8 +18,8 @@ pub struct Token {
|
|||||||
// 返回 base64 处理的加密字符串
|
// 返回 base64 处理的加密字符串
|
||||||
pub fn gencode(token: &Token, key: &str) -> Result<String> {
|
pub fn gencode(token: &Token, key: &str) -> Result<String> {
|
||||||
let data = serde_json::to_vec(token)?;
|
let data = serde_json::to_vec(token)?;
|
||||||
let public_key = RsaPublicKey::from_public_key_pem(key).map_err(Error::other)?;
|
let public_key = RsaPublicKey::from_public_key_pem(key)?;
|
||||||
let encrypted_data = public_key.encrypt(&mut OsRng, Pkcs1v15Encrypt, &data).map_err(Error::other)?;
|
let encrypted_data = public_key.encrypt(&mut rand::thread_rng(), Pkcs1v15Encrypt, &data)?;
|
||||||
Ok(base64_simd::URL_SAFE_NO_PAD.encode_to_string(&encrypted_data))
|
Ok(base64_simd::URL_SAFE_NO_PAD.encode_to_string(&encrypted_data))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,11 +28,9 @@ pub fn gencode(token: &Token, key: &str) -> Result<String> {
|
|||||||
// [key] 私钥字符串
|
// [key] 私钥字符串
|
||||||
// 返回 Token 对象
|
// 返回 Token 对象
|
||||||
pub fn parse(token: &str, key: &str) -> Result<Token> {
|
pub fn parse(token: &str, key: &str) -> Result<Token> {
|
||||||
let encrypted_data = base64_simd::URL_SAFE_NO_PAD
|
let encrypted_data = base64_simd::URL_SAFE_NO_PAD.decode_to_vec(token.as_bytes())?;
|
||||||
.decode_to_vec(token.as_bytes())
|
let private_key = RsaPrivateKey::from_pkcs8_pem(key)?;
|
||||||
.map_err(Error::other)?;
|
let decrypted_data = private_key.decrypt(Pkcs1v15Encrypt, &encrypted_data)?;
|
||||||
let private_key = RsaPrivateKey::from_pkcs8_pem(key).map_err(Error::other)?;
|
|
||||||
let decrypted_data = private_key.decrypt(Pkcs1v15Encrypt, &encrypted_data).map_err(Error::other)?;
|
|
||||||
let res: Token = serde_json::from_slice(&decrypted_data)?;
|
let res: Token = serde_json::from_slice(&decrypted_data)?;
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
@@ -66,19 +49,19 @@ pub fn parse_license(license: &str) -> Result<Token> {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
static TEST_PRIVATE_KEY: &str = "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCj86SrJIuxSxR6\nBJ/dlJEUIj6NeBRnhLQlCDdovuz61+7kJXVcxaR66w4m8W7SLEUP+IlPtnn6vmiG\n7XMhGNHIr7r1JsEVVLhZmL3tKI66DEZl786ZhG81BWqUlmcooIPS8UEPZNqJXLuz\nVGhxNyVGbj/tV7QC2pSISnKaixc+nrhxvo7w56p5qrm9tik0PjTgfZsUePkoBsSN\npoRkAauS14MAzK6HGB75CzG3dZqXUNWSWVocoWtQbZUwFGXyzU01ammsHQDvc2xu\nK1RQpd1qYH5bOWZ0N0aPFwT0r59HztFXg9sbjsnuhO1A7OiUOkc6iGVuJ0wm/9nA\nwZIBqzgjAgMBAAECggEAPMpeSEbotPhNw2BrllE76ec4omPfzPJbiU+em+wPGoNu\nRJHPDnMKJbl6Kd5jZPKdOOrCnxfd6qcnQsBQa/kz7+GYxMV12l7ra+1Cnujm4v0i\nLTHZvPpp8ZLsjeOmpF3AAzsJEJgon74OqtOlVjVIUPEYKvzV9ijt4gsYq0zfdYv0\nhrTMzyrGM4/UvKLsFIBROAfCeWfA7sXLGH8JhrRAyDrtCPzGtyyAmzoHKHtHafcB\nuyPFw/IP8otAgpDk5iiQPNkH0WwzAQIm12oHuNUa66NwUK4WEjXTnDg8KeWLHHNv\nIfN8vdbZchMUpMIvvkr7is315d8f2cHCB5gEO+GWAQKBgQDR/0xNll+FYaiUKCPZ\nvkOCAd3l5mRhsqnjPQ/6Ul1lAyYWpoJSFMrGGn/WKTa/FVFJRTGbBjwP+Mx10bfb\ngUg2GILDTISUh54fp4zngvTi9w4MWGKXrb7I1jPkM3vbJfC/v2fraQ/r7qHPpO2L\nf6ZbGxasIlSvr37KeGoelwcAQQKBgQDH3hmOTS2Hl6D4EXdq5meHKrfeoicGN7m8\noQK7u8iwn1R9zK5nh6IXxBhKYNXNwdCQtBZVRvFjjZ56SZJb7lKqa1BcTsgJfZCy\nnI3Uu4UykrECAH8AVCVqBXUDJmeA2yE+gDAtYEjvhSDHpUfWxoGHr0B/Oqk2Lxc/\npRy1qV5fYwKBgBWSL/hYVf+RhIuTg/s9/BlCr9SJ0g3nGGRrRVTlWQqjRCpXeFOO\nJzYqSq9pFGKUggEQxoOyJEFPwVDo9gXqRcyov+Xn2kaXl7qQr3yoixc1YZALFDWY\nd1ySBEqQr0xXnV9U/gvEgwotPRnjSzNlLWV2ZuHPtPtG/7M0o1H5GZMBAoGAKr3N\nW0gX53o+my4pCnxRQW+aOIsWq1a5aqRIEFudFGBOUkS2Oz+fI1P1GdrRfhnnfzpz\n2DK+plp/vIkFOpGhrf4bBlJ2psjqa7fdANRFLMaAAfyXLDvScHTQTCcnVUAHQPVq\n2BlSH56pnugyj7SNuLV6pnql+wdhAmRN2m9o1h8CgYAbX2juSr4ioXwnYjOUdrIY\n4+ERvHcXdjoJmmPcAm4y5NbSqLXyU0FQmplNMt2A5LlniWVJ9KNdjAQUt60FZw/+\nr76LdxXaHNZghyx0BOs7mtq5unSQXamZ8KixasfhE9uz3ij1jXjG6hafWkS8/68I\nuWbaZqgvy7a9oPHYlKH7Jg==\n-----END PRIVATE KEY-----\n";
|
static TEST_PRIVATE_KEY:&str ="-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCj86SrJIuxSxR6\nBJ/dlJEUIj6NeBRnhLQlCDdovuz61+7kJXVcxaR66w4m8W7SLEUP+IlPtnn6vmiG\n7XMhGNHIr7r1JsEVVLhZmL3tKI66DEZl786ZhG81BWqUlmcooIPS8UEPZNqJXLuz\nVGhxNyVGbj/tV7QC2pSISnKaixc+nrhxvo7w56p5qrm9tik0PjTgfZsUePkoBsSN\npoRkAauS14MAzK6HGB75CzG3dZqXUNWSWVocoWtQbZUwFGXyzU01ammsHQDvc2xu\nK1RQpd1qYH5bOWZ0N0aPFwT0r59HztFXg9sbjsnuhO1A7OiUOkc6iGVuJ0wm/9nA\nwZIBqzgjAgMBAAECggEAPMpeSEbotPhNw2BrllE76ec4omPfzPJbiU+em+wPGoNu\nRJHPDnMKJbl6Kd5jZPKdOOrCnxfd6qcnQsBQa/kz7+GYxMV12l7ra+1Cnujm4v0i\nLTHZvPpp8ZLsjeOmpF3AAzsJEJgon74OqtOlVjVIUPEYKvzV9ijt4gsYq0zfdYv0\nhrTMzyrGM4/UvKLsFIBROAfCeWfA7sXLGH8JhrRAyDrtCPzGtyyAmzoHKHtHafcB\nuyPFw/IP8otAgpDk5iiQPNkH0WwzAQIm12oHuNUa66NwUK4WEjXTnDg8KeWLHHNv\nIfN8vdbZchMUpMIvvkr7is315d8f2cHCB5gEO+GWAQKBgQDR/0xNll+FYaiUKCPZ\nvkOCAd3l5mRhsqnjPQ/6Ul1lAyYWpoJSFMrGGn/WKTa/FVFJRTGbBjwP+Mx10bfb\ngUg2GILDTISUh54fp4zngvTi9w4MWGKXrb7I1jPkM3vbJfC/v2fraQ/r7qHPpO2L\nf6ZbGxasIlSvr37KeGoelwcAQQKBgQDH3hmOTS2Hl6D4EXdq5meHKrfeoicGN7m8\noQK7u8iwn1R9zK5nh6IXxBhKYNXNwdCQtBZVRvFjjZ56SZJb7lKqa1BcTsgJfZCy\nnI3Uu4UykrECAH8AVCVqBXUDJmeA2yE+gDAtYEjvhSDHpUfWxoGHr0B/Oqk2Lxc/\npRy1qV5fYwKBgBWSL/hYVf+RhIuTg/s9/BlCr9SJ0g3nGGRrRVTlWQqjRCpXeFOO\nJzYqSq9pFGKUggEQxoOyJEFPwVDo9gXqRcyov+Xn2kaXl7qQr3yoixc1YZALFDWY\nd1ySBEqQr0xXnV9U/gvEgwotPRnjSzNlLWV2ZuHPtPtG/7M0o1H5GZMBAoGAKr3N\nW0gX53o+my4pCnxRQW+aOIsWq1a5aqRIEFudFGBOUkS2Oz+fI1P1GdrRfhnnfzpz\n2DK+plp/vIkFOpGhrf4bBlJ2psjqa7fdANRFLMaAAfyXLDvScHTQTCcnVUAHQPVq\n2BlSH56pnugyj7SNuLV6pnql+wdhAmRN2m9o1h8CgYAbX2juSr4ioXwnYjOUdrIY\n4+ERvHcXdjoJmmPcAm4y5NbSqLXyU0FQmplNMt2A5LlniWVJ9KNdjAQUt60FZw/+\nr76LdxXaHNZghyx0BOs7mtq5unSQXamZ8KixasfhE9uz3ij1jXjG6hafWkS8/68I\nuWbaZqgvy7a9oPHYlKH7Jg==\n-----END PRIVATE KEY-----\n";
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use rsa::{
|
use rsa::{
|
||||||
RsaPrivateKey,
|
|
||||||
pkcs8::{EncodePrivateKey, EncodePublicKey, LineEnding},
|
pkcs8::{EncodePrivateKey, EncodePublicKey, LineEnding},
|
||||||
|
RsaPrivateKey,
|
||||||
};
|
};
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
#[test]
|
#[test]
|
||||||
fn test_gencode_and_parse() {
|
fn test_gencode_and_parse() {
|
||||||
let mut rng = OsRng;
|
let mut rng = rand::thread_rng();
|
||||||
let bits = 2048;
|
let bits = 2048;
|
||||||
let private_key = RsaPrivateKey::new(&mut rng, bits).expect("Failed to generate private key");
|
let private_key = RsaPrivateKey::new(&mut rng, bits).expect("Failed to generate private key");
|
||||||
let public_key = RsaPublicKey::from(&private_key);
|
let public_key = RsaPublicKey::from(&private_key);
|
||||||
@@ -101,7 +84,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_invalid_token() {
|
fn test_parse_invalid_token() {
|
||||||
let private_key_pem = RsaPrivateKey::new(&mut OsRng, 2048)
|
let private_key_pem = RsaPrivateKey::new(&mut rand::thread_rng(), 2048)
|
||||||
.expect("Failed to generate private key")
|
.expect("Failed to generate private key")
|
||||||
.to_pkcs8_pem(LineEnding::LF)
|
.to_pkcs8_pem(LineEnding::LF)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
45
bucket_replicate_test.md
Normal file
45
bucket_replicate_test.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
启动两个rustfs
|
||||||
|
rustfs --address 0.0.0.0:9000 /rustfs-data9000
|
||||||
|
rustfs --address 0.0.0.0:9001 /rustfs-data9001
|
||||||
|
|
||||||
|
|
||||||
|
### 使用 minio mc 设置 alias 分别为 rustfs 和 rustfs2
|
||||||
|
|
||||||
|
|
||||||
|
### 创建 bucket
|
||||||
|
mc mb rustfs/srcbucket
|
||||||
|
|
||||||
|
### 创建 desc bucket
|
||||||
|
|
||||||
|
mc mb rustfs2/destbucket
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### 开启版本控制
|
||||||
|
|
||||||
|
mc version enable rustfs/srcbucket
|
||||||
|
mc version enable rustfs2/destbucket
|
||||||
|
|
||||||
|
#### 使用修改过的 mc 才能 add bucket replication
|
||||||
|
|
||||||
|
./mc replication add rustfs/srcbucket --remote-bucket rustfs2/destbucket
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###### 复制一个小文件;
|
||||||
|
mc cp ./1.txt rustfs/srcbucket
|
||||||
|
|
||||||
|
###### 查看是否成功
|
||||||
|
mc ls --versions rustfs/srcbucket/1.txt
|
||||||
|
mc ls --versions rustfs/destbucket/1.txt
|
||||||
|
|
||||||
|
|
||||||
|
##### 复制一个大文件
|
||||||
|
1 创建一个大文件
|
||||||
|
dd if=/dev/zero of=./dd.out bs=4096000 count=1000
|
||||||
|
|
||||||
|
mc cp ./dd.out rustfs/srcbucket/
|
||||||
|
|
||||||
|
##### 查看是否成功
|
||||||
|
mc ls --versions rustfs/srcbucket/dd.out
|
||||||
|
mc ls --versions rustfs2/destbucket/dd.out
|
||||||
@@ -1,24 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
# Get the current platform architecture
|
# 获取当前平台架构
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
# Set the target directory according to the schema
|
# 根据架构设置 target 目录
|
||||||
if [ "$ARCH" == "x86_64" ]; then
|
if [ "$ARCH" == "x86_64" ]; then
|
||||||
TARGET_DIR="target/x86_64"
|
TARGET_DIR="target/x86_64"
|
||||||
elif [ "$ARCH" == "aarch64" ]; then
|
elif [ "$ARCH" == "aarch64" ]; then
|
||||||
@@ -27,8 +13,8 @@ else
|
|||||||
TARGET_DIR="target/unknown"
|
TARGET_DIR="target/unknown"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set CARGO_TARGET_DIR and build the project
|
# 设置 CARGO_TARGET_DIR 并构建项目
|
||||||
CARGO_TARGET_DIR=$TARGET_DIR RUSTFLAGS="-C link-arg=-fuse-ld=mold" cargo build --release --package rustfs
|
CARGO_TARGET_DIR=$TARGET_DIR RUSTFLAGS="-C link-arg=-fuse-ld=mold" cargo build --package rustfs
|
||||||
|
|
||||||
echo -e "\a"
|
echo -e "\a"
|
||||||
echo -e "\a"
|
echo -e "\a"
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "rustfs-gui"
|
name = "rustfs-gui"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
@@ -29,7 +15,6 @@ keyring = { workspace = true }
|
|||||||
lazy_static = { workspace = true }
|
lazy_static = { workspace = true }
|
||||||
rfd = { workspace = true }
|
rfd = { workspace = true }
|
||||||
rust-embed = { workspace = true, features = ["interpolate-folder-path"] }
|
rust-embed = { workspace = true, features = ["interpolate-folder-path"] }
|
||||||
rust-i18n = { workspace = true }
|
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
sha2 = { workspace = true }
|
sha2 = { workspace = true }
|
||||||
|
|||||||
@@ -1,19 +1,3 @@
|
|||||||
/**
|
|
||||||
* Copyright 2024 RustFS Team
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
window.switchTab = function (tabId) {
|
window.switchTab = function (tabId) {
|
||||||
// Hide everything
|
// Hide everything
|
||||||
document.querySelectorAll('.tab-content').forEach(content => {
|
document.querySelectorAll('.tab-content').forEach(content => {
|
||||||
|
|||||||
@@ -1,19 +1,3 @@
|
|||||||
/**
|
|
||||||
* Copyright 2024 RustFS Team
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#navbar {
|
#navbar {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|||||||
@@ -1,19 +1,3 @@
|
|||||||
/**
|
|
||||||
* Copyright 2024 RustFS Team
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
*, ::before, ::after {
|
*, ::before, ::after {
|
||||||
--tw-border-spacing-x: 0;
|
--tw-border-spacing-x: 0;
|
||||||
--tw-border-spacing-y: 0;
|
--tw-border-spacing-y: 0;
|
||||||
|
|||||||
@@ -1,19 +1,3 @@
|
|||||||
/**
|
|
||||||
* Copyright 2024 RustFS Team
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use crate::components::navbar::LoadingSpinner;
|
use crate::components::navbar::LoadingSpinner;
|
||||||
use crate::route::Route;
|
use crate::route::Route;
|
||||||
use crate::utils::{RustFSConfig, ServiceManager};
|
use crate::utils::{RustFSConfig, ServiceManager};
|
||||||
@@ -44,11 +30,11 @@ pub fn Home() -> Element {
|
|||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let service = use_signal(|| ServiceManager::new());
|
let service = use_signal(|| ServiceManager::new());
|
||||||
let conf = RustFSConfig::load().unwrap_or_else(|e| {
|
let conf = RustFSConfig::load().unwrap_or_else(|e| {
|
||||||
ServiceManager::show_error(&format!("load config failed: {e}"));
|
ServiceManager::show_error(&format!("加载配置失败:{}", e));
|
||||||
RustFSConfig::default()
|
RustFSConfig::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
debug!("loaded configurations: {:?}", conf);
|
debug!("loaded configurations:{:?}", conf);
|
||||||
let config = use_signal(|| conf.clone());
|
let config = use_signal(|| conf.clone());
|
||||||
|
|
||||||
use dioxus_router::prelude::Link;
|
use dioxus_router::prelude::Link;
|
||||||
@@ -92,7 +78,7 @@ pub fn Home() -> Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
ServiceManager::show_error(&format!("start service failed: {e}"));
|
ServiceManager::show_error(&format!("服务启动失败:{}", e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Only set loading to false when it's actually done
|
// Only set loading to false when it's actually done
|
||||||
@@ -118,7 +104,7 @@ pub fn Home() -> Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
ServiceManager::show_error(&format!("stop service failed: {e}"));
|
ServiceManager::show_error(&format!("服务停止失败:{}", e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!("service_state: {:?}", service_state.read());
|
debug!("service_state: {:?}", service_state.read());
|
||||||
@@ -157,7 +143,6 @@ pub fn Home() -> Element {
|
|||||||
Title { "RustFS APP" }
|
Title { "RustFS APP" }
|
||||||
Meta {
|
Meta {
|
||||||
name: "description",
|
name: "description",
|
||||||
// TODO: translate to english
|
|
||||||
content: "RustFS RustFS 用热门安全的 Rust 语言开发,兼容 S3 协议。适用于 AI/ML 及海量数据存储、大数据、互联网、工业和保密存储等全部场景。近乎免费使用。遵循 Apache 2 协议,支持国产保密设备和系统。",
|
content: "RustFS RustFS 用热门安全的 Rust 语言开发,兼容 S3 协议。适用于 AI/ML 及海量数据存储、大数据、互联网、工业和保密存储等全部场景。近乎免费使用。遵循 Apache 2 协议,支持国产保密设备和系统。",
|
||||||
}
|
}
|
||||||
div { class: "min-h-screen flex flex-col items-center bg-white",
|
div { class: "min-h-screen flex flex-col items-center bg-white",
|
||||||
@@ -181,7 +166,7 @@ pub fn Home() -> Element {
|
|||||||
}
|
}
|
||||||
LoadingSpinner {
|
LoadingSpinner {
|
||||||
loading: loading.read().to_owned(),
|
loading: loading.read().to_owned(),
|
||||||
text: "processing...",
|
text: "服务处理中...",
|
||||||
}
|
}
|
||||||
button { class: button_class, onclick: toggle_service,
|
button { class: button_class, onclick: toggle_service,
|
||||||
svg {
|
svg {
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
mod home;
|
mod home;
|
||||||
pub use home::Home;
|
pub use home::Home;
|
||||||
mod navbar;
|
mod navbar;
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use crate::route::Route;
|
use crate::route::Route;
|
||||||
use dioxus::logger::tracing::debug;
|
use dioxus::logger::tracing::debug;
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use crate::components::navbar::LoadingSpinner;
|
use crate::components::navbar::LoadingSpinner;
|
||||||
use dioxus::logger::tracing::{debug, error};
|
use dioxus::logger::tracing::{debug, error};
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
@@ -63,7 +49,7 @@ pub fn Setting() -> Element {
|
|||||||
let config = config.read().clone();
|
let config = config.read().clone();
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
if let Err(e) = service.read().restart(config).await {
|
if let Err(e) = service.read().restart(config).await {
|
||||||
ServiceManager::show_error(&format!("发送重启命令失败:{e}"));
|
ServiceManager::show_error(&format!("发送重启命令失败:{}", e));
|
||||||
}
|
}
|
||||||
// reset the status when you're done
|
// reset the status when you're done
|
||||||
loading.set(false);
|
loading.set(false);
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
mod components;
|
mod components;
|
||||||
mod route;
|
mod route;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
mod router;
|
mod router;
|
||||||
|
|
||||||
pub use router::Route;
|
pub use router::Route;
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use crate::components::Navbar;
|
use crate::components::Navbar;
|
||||||
use crate::views::{HomeViews, SettingViews};
|
use crate::views::{HomeViews, SettingViews};
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use keyring::Entry;
|
use keyring::Entry;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
@@ -215,7 +201,7 @@ impl RustFSConfig {
|
|||||||
/// Clear the stored configuration from the system keyring
|
/// Clear the stored configuration from the system keyring
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// `Ok(())` if the configuration was successfully cleared, or an error if the operation failed.
|
/// Returns `Ok(())` if the configuration was successfully cleared, or an error if the operation failed.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
@@ -302,7 +288,7 @@ mod tests {
|
|||||||
|
|
||||||
for (input, expected) in test_cases {
|
for (input, expected) in test_cases {
|
||||||
let result = RustFSConfig::extract_host_port(input);
|
let result = RustFSConfig::extract_host_port(input);
|
||||||
assert_eq!(result, expected, "Failed for input: {input}");
|
assert_eq!(result, expected, "Failed for input: {}", input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +306,7 @@ mod tests {
|
|||||||
|
|
||||||
for input in invalid_cases {
|
for input in invalid_cases {
|
||||||
let result = RustFSConfig::extract_host_port(input);
|
let result = RustFSConfig::extract_host_port(input);
|
||||||
assert_eq!(result, None, "Should be None for input: {input}");
|
assert_eq!(result, None, "Should be None for input: {}", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case: empty host but valid port should still work
|
// Special case: empty host but valid port should still work
|
||||||
@@ -451,7 +437,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_debug_format() {
|
fn test_debug_format() {
|
||||||
let config = RustFSConfig::default_config();
|
let config = RustFSConfig::default_config();
|
||||||
let debug_str = format!("{config:?}");
|
let debug_str = format!("{:?}", config);
|
||||||
|
|
||||||
assert!(debug_str.contains("RustFSConfig"));
|
assert!(debug_str.contains("RustFSConfig"));
|
||||||
assert!(debug_str.contains("address"));
|
assert!(debug_str.contains("address"));
|
||||||
@@ -498,14 +484,14 @@ mod tests {
|
|||||||
fn test_very_long_strings() {
|
fn test_very_long_strings() {
|
||||||
let long_string = "a".repeat(1000);
|
let long_string = "a".repeat(1000);
|
||||||
let config = RustFSConfig {
|
let config = RustFSConfig {
|
||||||
address: format!("{long_string}:9000"),
|
address: format!("{}:9000", long_string),
|
||||||
host: long_string.clone(),
|
host: long_string.clone(),
|
||||||
port: "9000".to_string(),
|
port: "9000".to_string(),
|
||||||
access_key: long_string.clone(),
|
access_key: long_string.clone(),
|
||||||
secret_key: long_string.clone(),
|
secret_key: long_string.clone(),
|
||||||
domain_name: format!("{long_string}.com"),
|
domain_name: format!("{}.com", long_string),
|
||||||
volume_name: format!("/data/{long_string}"),
|
volume_name: format!("/data/{}", long_string),
|
||||||
console_address: format!("{long_string}:9001"),
|
console_address: format!("{}:9001", long_string),
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(config.host.len(), 1000);
|
assert_eq!(config.host.len(), 1000);
|
||||||
@@ -539,14 +525,14 @@ mod tests {
|
|||||||
host: "127.0.0.1".to_string(),
|
host: "127.0.0.1".to_string(),
|
||||||
port: "9000".to_string(),
|
port: "9000".to_string(),
|
||||||
access_key: "用户名".to_string(),
|
access_key: "用户名".to_string(),
|
||||||
secret_key: "密码 123".to_string(),
|
secret_key: "密码123".to_string(),
|
||||||
domain_name: "测试.com".to_string(),
|
domain_name: "测试.com".to_string(),
|
||||||
volume_name: "/数据/存储".to_string(),
|
volume_name: "/数据/存储".to_string(),
|
||||||
console_address: "127.0.0.1:9001".to_string(),
|
console_address: "127.0.0.1:9001".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(config.access_key, "用户名");
|
assert_eq!(config.access_key, "用户名");
|
||||||
assert_eq!(config.secret_key, "密码 123");
|
assert_eq!(config.secret_key, "密码123");
|
||||||
assert_eq!(config.domain_name, "测试.com");
|
assert_eq!(config.domain_name, "测试.com");
|
||||||
assert_eq!(config.volume_name, "/数据/存储");
|
assert_eq!(config.volume_name, "/数据/存储");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use crate::utils::RustFSConfig;
|
use crate::utils::RustFSConfig;
|
||||||
use dioxus::logger::tracing::{debug, error, info};
|
use dioxus::logger::tracing::{debug, error, info};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
@@ -25,7 +11,7 @@ use tokio::fs;
|
|||||||
use tokio::fs::File;
|
use tokio::fs::File;
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
use tokio::sync::{Mutex, mpsc};
|
use tokio::sync::{mpsc, Mutex};
|
||||||
|
|
||||||
#[derive(RustEmbed)]
|
#[derive(RustEmbed)]
|
||||||
#[folder = "$CARGO_MANIFEST_DIR/embedded-rustfs/"]
|
#[folder = "$CARGO_MANIFEST_DIR/embedded-rustfs/"]
|
||||||
@@ -198,7 +184,7 @@ impl ServiceManager {
|
|||||||
let cached_hash = fs::read_to_string(&hash_path).await?;
|
let cached_hash = fs::read_to_string(&hash_path).await?;
|
||||||
let expected_hash = RUSTFS_HASH.lock().await;
|
let expected_hash = RUSTFS_HASH.lock().await;
|
||||||
if cached_hash == *expected_hash {
|
if cached_hash == *expected_hash {
|
||||||
println!("Use cached rustfs: {executable_path:?}");
|
println!("Use cached rustfs: {:?}", executable_path);
|
||||||
return Ok(executable_path);
|
return Ok(executable_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,23 +235,23 @@ impl ServiceManager {
|
|||||||
match cmd {
|
match cmd {
|
||||||
ServiceCommand::Start(config) => {
|
ServiceCommand::Start(config) => {
|
||||||
if let Err(e) = Self::start_service(&config).await {
|
if let Err(e) = Self::start_service(&config).await {
|
||||||
Self::show_error(&format!("启动服务失败:{e}"));
|
Self::show_error(&format!("启动服务失败:{}", e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ServiceCommand::Stop => {
|
ServiceCommand::Stop => {
|
||||||
if let Err(e) = Self::stop_service().await {
|
if let Err(e) = Self::stop_service().await {
|
||||||
Self::show_error(&format!("停止服务失败:{e}"));
|
Self::show_error(&format!("停止服务失败:{}", e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ServiceCommand::Restart(config) => {
|
ServiceCommand::Restart(config) => {
|
||||||
if Self::check_service_status().await.is_some() {
|
if Self::check_service_status().await.is_some() {
|
||||||
if let Err(e) = Self::stop_service().await {
|
if let Err(e) = Self::stop_service().await {
|
||||||
Self::show_error(&format!("重启服务失败:{e}"));
|
Self::show_error(&format!("重启服务失败:{}", e));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Err(e) = Self::start_service(&config).await {
|
if let Err(e) = Self::start_service(&config).await {
|
||||||
Self::show_error(&format!("重启服务失败:{e}"));
|
Self::show_error(&format!("重启服务失败:{}", e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,7 +283,7 @@ impl ServiceManager {
|
|||||||
async fn start_service(config: &RustFSConfig) -> Result<(), Box<dyn Error>> {
|
async fn start_service(config: &RustFSConfig) -> Result<(), Box<dyn Error>> {
|
||||||
// Check if the service is already running
|
// Check if the service is already running
|
||||||
if let Some(existing_pid) = Self::check_service_status().await {
|
if let Some(existing_pid) = Self::check_service_status().await {
|
||||||
return Err(format!("服务已经在运行,PID: {existing_pid}").into());
|
return Err(format!("服务已经在运行,PID: {}", existing_pid).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare the service program
|
// Prepare the service program
|
||||||
@@ -318,7 +304,7 @@ impl ServiceManager {
|
|||||||
let ports = vec![main_port, console_port];
|
let ports = vec![main_port, console_port];
|
||||||
for port in ports {
|
for port in ports {
|
||||||
if Self::is_port_in_use(host, port).await {
|
if Self::is_port_in_use(host, port).await {
|
||||||
return Err(format!("端口 {port} 已被占用").into());
|
return Err(format!("端口 {} 已被占用", port).into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +327,7 @@ impl ServiceManager {
|
|||||||
|
|
||||||
// Check if the service started successfully
|
// Check if the service started successfully
|
||||||
if Self::is_port_in_use(host, main_port).await {
|
if Self::is_port_in_use(host, main_port).await {
|
||||||
Self::show_info(&format!("服务启动成功!进程 ID: {process_pid}"));
|
Self::show_info(&format!("服务启动成功!进程 ID: {}", process_pid));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
@@ -401,7 +387,7 @@ impl ServiceManager {
|
|||||||
/// println!("{:?}", result);
|
/// println!("{:?}", result);
|
||||||
/// ```
|
/// ```
|
||||||
async fn is_port_in_use(host: &str, port: u16) -> bool {
|
async fn is_port_in_use(host: &str, port: u16) -> bool {
|
||||||
TcpStream::connect(format!("{host}:{port}")).await.is_ok()
|
TcpStream::connect(format!("{}:{}", host, port)).await.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Show an error message
|
/// Show an error message
|
||||||
@@ -688,7 +674,7 @@ mod tests {
|
|||||||
message: "Test message".to_string(),
|
message: "Test message".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let debug_str = format!("{result:?}");
|
let debug_str = format!("{:?}", result);
|
||||||
assert!(debug_str.contains("ServiceOperationResult"));
|
assert!(debug_str.contains("ServiceOperationResult"));
|
||||||
assert!(debug_str.contains("success: true"));
|
assert!(debug_str.contains("success: true"));
|
||||||
assert!(debug_str.contains("Test message"));
|
assert!(debug_str.contains("Test message"));
|
||||||
@@ -705,8 +691,8 @@ mod tests {
|
|||||||
let cloned_manager = service_manager.clone();
|
let cloned_manager = service_manager.clone();
|
||||||
|
|
||||||
// Both should be valid (we can't test much more without async runtime)
|
// Both should be valid (we can't test much more without async runtime)
|
||||||
assert!(format!("{service_manager:?}").contains("ServiceManager"));
|
assert!(format!("{:?}", service_manager).contains("ServiceManager"));
|
||||||
assert!(format!("{cloned_manager:?}").contains("ServiceManager"));
|
assert!(format!("{:?}", cloned_manager).contains("ServiceManager"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,7 +710,7 @@ mod tests {
|
|||||||
|
|
||||||
for (input, expected) in test_cases {
|
for (input, expected) in test_cases {
|
||||||
let result = ServiceManager::extract_port(input);
|
let result = ServiceManager::extract_port(input);
|
||||||
assert_eq!(result, expected, "Failed for input: {input}");
|
assert_eq!(result, expected, "Failed for input: {}", input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -743,7 +729,7 @@ mod tests {
|
|||||||
|
|
||||||
for input in invalid_cases {
|
for input in invalid_cases {
|
||||||
let result = ServiceManager::extract_port(input);
|
let result = ServiceManager::extract_port(input);
|
||||||
assert_eq!(result, None, "Should be None for input: {input}");
|
assert_eq!(result, None, "Should be None for input: {}", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case: empty host but valid port should still work
|
// Special case: empty host but valid port should still work
|
||||||
@@ -760,10 +746,10 @@ mod tests {
|
|||||||
assert_eq!(ServiceManager::extract_port("host:0"), Some(0));
|
assert_eq!(ServiceManager::extract_port("host:0"), Some(0));
|
||||||
assert_eq!(ServiceManager::extract_port("host:65535"), Some(65535));
|
assert_eq!(ServiceManager::extract_port("host:65535"), Some(65535));
|
||||||
assert_eq!(ServiceManager::extract_port("host:65536"), None); // Out of range
|
assert_eq!(ServiceManager::extract_port("host:65536"), None); // Out of range
|
||||||
// IPv6-like address - extract_port takes the second part after split(':')
|
// IPv6-like address - extract_port takes the second part after split(':')
|
||||||
// For "::1:8080", split(':') gives ["", "", "1", "8080"], nth(1) gives ""
|
// For "::1:8080", split(':') gives ["", "", "1", "8080"], nth(1) gives ""
|
||||||
assert_eq!(ServiceManager::extract_port("::1:8080"), None); // Second part is empty
|
assert_eq!(ServiceManager::extract_port("::1:8080"), None); // Second part is empty
|
||||||
// For "[::1]:8080", split(':') gives ["[", "", "1]", "8080"], nth(1) gives ""
|
// For "[::1]:8080", split(':') gives ["[", "", "1]", "8080"], nth(1) gives ""
|
||||||
assert_eq!(ServiceManager::extract_port("[::1]:8080"), None); // Second part is empty
|
assert_eq!(ServiceManager::extract_port("[::1]:8080"), None); // Second part is empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use dioxus::logger::tracing::debug;
|
use dioxus::logger::tracing::debug;
|
||||||
use tracing_appender::non_blocking::WorkerGuard;
|
use tracing_appender::non_blocking::WorkerGuard;
|
||||||
use tracing_appender::rolling::{RollingFileAppender, Rotation};
|
use tracing_appender::rolling::{RollingFileAppender, Rotation};
|
||||||
@@ -108,7 +94,7 @@ mod tests {
|
|||||||
|
|
||||||
// We can't actually build it without creating directories,
|
// We can't actually build it without creating directories,
|
||||||
// but we can verify the builder pattern works
|
// but we can verify the builder pattern works
|
||||||
let debug_str = format!("{builder:?}");
|
let debug_str = format!("{:?}", builder);
|
||||||
// The actual debug format might be different, so just check it's not empty
|
// The actual debug format might be different, so just check it's not empty
|
||||||
assert!(!debug_str.is_empty());
|
assert!(!debug_str.is_empty());
|
||||||
// Check that it contains some expected parts
|
// Check that it contains some expected parts
|
||||||
@@ -126,10 +112,10 @@ mod tests {
|
|||||||
let never = Rotation::NEVER;
|
let never = Rotation::NEVER;
|
||||||
|
|
||||||
// Test that rotation types can be created and formatted
|
// Test that rotation types can be created and formatted
|
||||||
assert!(!format!("{daily:?}").is_empty());
|
assert!(!format!("{:?}", daily).is_empty());
|
||||||
assert!(!format!("{hourly:?}").is_empty());
|
assert!(!format!("{:?}", hourly).is_empty());
|
||||||
assert!(!format!("{minutely:?}").is_empty());
|
assert!(!format!("{:?}", minutely).is_empty());
|
||||||
assert!(!format!("{never:?}").is_empty());
|
assert!(!format!("{:?}", never).is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -173,10 +159,10 @@ mod tests {
|
|||||||
let error_filter = tracing_subscriber::EnvFilter::new("error");
|
let error_filter = tracing_subscriber::EnvFilter::new("error");
|
||||||
|
|
||||||
// Test that filters can be created
|
// Test that filters can be created
|
||||||
assert!(!format!("{info_filter:?}").is_empty());
|
assert!(!format!("{:?}", info_filter).is_empty());
|
||||||
assert!(!format!("{debug_filter:?}").is_empty());
|
assert!(!format!("{:?}", debug_filter).is_empty());
|
||||||
assert!(!format!("{warn_filter:?}").is_empty());
|
assert!(!format!("{:?}", warn_filter).is_empty());
|
||||||
assert!(!format!("{error_filter:?}").is_empty());
|
assert!(!format!("{:?}", error_filter).is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -215,7 +201,7 @@ mod tests {
|
|||||||
assert_eq!(suffix, "log");
|
assert_eq!(suffix, "log");
|
||||||
|
|
||||||
// Test that these would create valid filenames
|
// Test that these would create valid filenames
|
||||||
let sample_filename = format!("{prefix}.2024-01-01.{suffix}");
|
let sample_filename = format!("{}.2024-01-01.{}", prefix, suffix);
|
||||||
assert_eq!(sample_filename, "rustfs-cli.2024-01-01.log");
|
assert_eq!(sample_filename, "rustfs-cli.2024-01-01.log");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +243,7 @@ mod tests {
|
|||||||
assert_eq!(logs_dir_name, "logs");
|
assert_eq!(logs_dir_name, "logs");
|
||||||
|
|
||||||
// Test path joining
|
// Test path joining
|
||||||
let combined = format!("{rustfs_dir_name}/{logs_dir_name}");
|
let combined = format!("{}/{}", rustfs_dir_name, logs_dir_name);
|
||||||
assert_eq!(combined, "rustfs/logs");
|
assert_eq!(combined, "rustfs/logs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod helper;
|
mod helper;
|
||||||
mod logger;
|
mod logger;
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use crate::route::Route;
|
use crate::route::Route;
|
||||||
use dioxus::logger::tracing::info;
|
use dioxus::logger::tracing::info;
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use crate::components::Home;
|
use crate::components::Home;
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
mod home;
|
mod home;
|
||||||
mod setting;
|
mod setting;
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use crate::components::Setting;
|
use crate::components::Setting;
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,3 @@
|
|||||||
/**
|
|
||||||
* Copyright 2024 RustFS Team
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: "all",
|
mode: "all",
|
||||||
content: ["./src/**/*.{rs,html,css}", "./dist/**/*.html"],
|
content: ["./src/**/*.{rs,html,css}", "./dist/**/*.html"],
|
||||||
|
|||||||
15
common/common/Cargo.toml
Normal file
15
common/common/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[package]
|
||||||
|
name = "common"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
async-trait.workspace = true
|
||||||
|
lazy_static.workspace = true
|
||||||
|
scopeguard = "1.2.0"
|
||||||
|
tokio.workspace = true
|
||||||
|
tonic = { workspace = true }
|
||||||
|
tracing-error.workspace = true
|
||||||
@@ -1,33 +1,19 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::last_minute::{self};
|
use crate::last_minute::{self};
|
||||||
pub struct ReplicationLatency {
|
pub struct ReplicationLatency {
|
||||||
// Delays for single and multipart PUT requests
|
// 单个和多部分 PUT 请求的延迟
|
||||||
upload_histogram: last_minute::LastMinuteHistogram,
|
upload_histogram: last_minute::LastMinuteHistogram,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReplicationLatency {
|
impl ReplicationLatency {
|
||||||
// Merge two ReplicationLatency
|
// 合并两个 ReplicationLatency
|
||||||
pub fn merge(&mut self, other: &mut ReplicationLatency) -> &ReplicationLatency {
|
pub fn merge(&mut self, other: &mut ReplicationLatency) -> &ReplicationLatency {
|
||||||
self.upload_histogram.merge(&other.upload_histogram);
|
self.upload_histogram.merge(&other.upload_histogram);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get upload delay (categorized by object size interval)
|
// 获取上传延迟(按对象大小区间分类)
|
||||||
pub fn get_upload_latency(&mut self) -> HashMap<String, u64> {
|
pub fn get_upload_latency(&mut self) -> HashMap<String, u64> {
|
||||||
let mut ret = HashMap::new();
|
let mut ret = HashMap::new();
|
||||||
let avg = self.upload_histogram.get_avg_data();
|
let avg = self.upload_histogram.get_avg_data();
|
||||||
@@ -41,7 +27,7 @@ impl ReplicationLatency {
|
|||||||
self.upload_histogram.add(size, during);
|
self.upload_histogram.add(size, during);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulate the conversion from size tag to string
|
// 模拟从 size tag 到字符串的转换
|
||||||
fn size_tag_to_string(&self, tag: usize) -> String {
|
fn size_tag_to_string(&self, tag: usize) -> String {
|
||||||
match tag {
|
match tag {
|
||||||
0 => String::from("Size < 1 KiB"),
|
0 => String::from("Size < 1 KiB"),
|
||||||
339
common/common/src/error.rs
Normal file
339
common/common/src/error.rs
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
use tracing_error::{SpanTrace, SpanTraceStatus};
|
||||||
|
|
||||||
|
pub type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
|
||||||
|
|
||||||
|
pub type Result<T = (), E = Error> = std::result::Result<T, E>;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Error {
|
||||||
|
inner: Box<dyn std::error::Error + Send + Sync + 'static>,
|
||||||
|
span_trace: SpanTrace,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error {
|
||||||
|
/// Create a new error from a `std::error::Error`.
|
||||||
|
#[must_use]
|
||||||
|
#[track_caller]
|
||||||
|
pub fn new<T: std::error::Error + Send + Sync + 'static>(source: T) -> Self {
|
||||||
|
Self::from_std_error(source.into())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new error from a `std::error::Error`.
|
||||||
|
#[must_use]
|
||||||
|
#[track_caller]
|
||||||
|
pub fn from_std_error(inner: StdError) -> Self {
|
||||||
|
Self {
|
||||||
|
inner,
|
||||||
|
span_trace: SpanTrace::capture(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new error from a string.
|
||||||
|
#[must_use]
|
||||||
|
#[track_caller]
|
||||||
|
pub fn from_string(s: impl Into<String>) -> Self {
|
||||||
|
Self::msg(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new error from a string.
|
||||||
|
#[must_use]
|
||||||
|
#[track_caller]
|
||||||
|
pub fn msg(s: impl Into<String>) -> Self {
|
||||||
|
Self::from_std_error(s.into().into())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if the inner type is the same as `T`.
|
||||||
|
#[inline]
|
||||||
|
pub fn is<T: std::error::Error + 'static>(&self) -> bool {
|
||||||
|
self.inner.is::<T>()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns some reference to the inner value if it is of type `T`, or
|
||||||
|
/// `None` if it isn't.
|
||||||
|
#[inline]
|
||||||
|
pub fn downcast_ref<T: std::error::Error + 'static>(&self) -> Option<&T> {
|
||||||
|
self.inner.downcast_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns some mutable reference to the inner value if it is of type `T`, or
|
||||||
|
/// `None` if it isn't.
|
||||||
|
#[inline]
|
||||||
|
pub fn downcast_mut<T: std::error::Error + 'static>(&mut self) -> Option<&mut T> {
|
||||||
|
self.inner.downcast_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_io_err(&self) -> Option<std::io::Error> {
|
||||||
|
self.downcast_ref::<std::io::Error>()
|
||||||
|
.map(|e| std::io::Error::new(e.kind(), e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inner_string(&self) -> String {
|
||||||
|
self.inner.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: std::error::Error + Send + Sync + 'static> From<T> for Error {
|
||||||
|
fn from(e: T) -> Self {
|
||||||
|
Self::new(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for Error {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.inner)?;
|
||||||
|
|
||||||
|
if self.span_trace.status() != SpanTraceStatus::EMPTY {
|
||||||
|
write!(f, "\nspan_trace:\n{}", self.span_trace)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use std::io;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct CustomTestError {
|
||||||
|
message: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for CustomTestError {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "Custom test error: {}", self.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for CustomTestError {}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct AnotherTestError;
|
||||||
|
|
||||||
|
impl std::fmt::Display for AnotherTestError {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "Another test error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for AnotherTestError {}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_new_from_std_error() {
|
||||||
|
let io_error = io::Error::new(io::ErrorKind::NotFound, "File not found");
|
||||||
|
let error = Error::new(io_error);
|
||||||
|
|
||||||
|
assert!(error.inner_string().contains("File not found"));
|
||||||
|
assert!(error.is::<io::Error>());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_from_std_error() {
|
||||||
|
let io_error = io::Error::new(io::ErrorKind::PermissionDenied, "Permission denied");
|
||||||
|
let boxed_error: StdError = Box::new(io_error);
|
||||||
|
let error = Error::from_std_error(boxed_error);
|
||||||
|
|
||||||
|
assert!(error.inner_string().contains("Permission denied"));
|
||||||
|
assert!(error.is::<io::Error>());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_from_string() {
|
||||||
|
let error = Error::from_string("Test error message");
|
||||||
|
assert_eq!(error.inner_string(), "Test error message");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_msg() {
|
||||||
|
let error = Error::msg("Another test message");
|
||||||
|
assert_eq!(error.inner_string(), "Another test message");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_msg_with_string() {
|
||||||
|
let message = String::from("String message");
|
||||||
|
let error = Error::msg(message);
|
||||||
|
assert_eq!(error.inner_string(), "String message");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_is_type_checking() {
|
||||||
|
let io_error = io::Error::new(io::ErrorKind::InvalidInput, "Invalid input");
|
||||||
|
let error = Error::new(io_error);
|
||||||
|
|
||||||
|
assert!(error.is::<io::Error>());
|
||||||
|
assert!(!error.is::<CustomTestError>());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_downcast_ref() {
|
||||||
|
let io_error = io::Error::new(io::ErrorKind::TimedOut, "Operation timed out");
|
||||||
|
let error = Error::new(io_error);
|
||||||
|
|
||||||
|
let downcast_io = error.downcast_ref::<io::Error>();
|
||||||
|
assert!(downcast_io.is_some());
|
||||||
|
assert_eq!(downcast_io.unwrap().kind(), io::ErrorKind::TimedOut);
|
||||||
|
|
||||||
|
let downcast_custom = error.downcast_ref::<CustomTestError>();
|
||||||
|
assert!(downcast_custom.is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_downcast_mut() {
|
||||||
|
let io_error = io::Error::new(io::ErrorKind::Interrupted, "Operation interrupted");
|
||||||
|
let mut error = Error::new(io_error);
|
||||||
|
|
||||||
|
let downcast_io = error.downcast_mut::<io::Error>();
|
||||||
|
assert!(downcast_io.is_some());
|
||||||
|
assert_eq!(downcast_io.unwrap().kind(), io::ErrorKind::Interrupted);
|
||||||
|
|
||||||
|
let downcast_custom = error.downcast_mut::<CustomTestError>();
|
||||||
|
assert!(downcast_custom.is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_to_io_err() {
|
||||||
|
// Test with IO error
|
||||||
|
let original_io_error = io::Error::new(io::ErrorKind::BrokenPipe, "Broken pipe");
|
||||||
|
let error = Error::new(original_io_error);
|
||||||
|
|
||||||
|
let converted_io_error = error.to_io_err();
|
||||||
|
assert!(converted_io_error.is_some());
|
||||||
|
let io_err = converted_io_error.unwrap();
|
||||||
|
assert_eq!(io_err.kind(), io::ErrorKind::BrokenPipe);
|
||||||
|
assert!(io_err.to_string().contains("Broken pipe"));
|
||||||
|
|
||||||
|
// Test with non-IO error
|
||||||
|
let custom_error = CustomTestError {
|
||||||
|
message: "Not an IO error".to_string(),
|
||||||
|
};
|
||||||
|
let error = Error::new(custom_error);
|
||||||
|
|
||||||
|
let converted_io_error = error.to_io_err();
|
||||||
|
assert!(converted_io_error.is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_inner_string() {
|
||||||
|
let custom_error = CustomTestError {
|
||||||
|
message: "Test message".to_string(),
|
||||||
|
};
|
||||||
|
let error = Error::new(custom_error);
|
||||||
|
|
||||||
|
assert_eq!(error.inner_string(), "Custom test error: Test message");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_from_trait() {
|
||||||
|
let io_error = io::Error::new(io::ErrorKind::UnexpectedEof, "Unexpected EOF");
|
||||||
|
let error: Error = io_error.into();
|
||||||
|
|
||||||
|
assert!(error.is::<io::Error>());
|
||||||
|
assert!(error.inner_string().contains("Unexpected EOF"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_display() {
|
||||||
|
let custom_error = CustomTestError {
|
||||||
|
message: "Display test".to_string(),
|
||||||
|
};
|
||||||
|
let error = Error::new(custom_error);
|
||||||
|
|
||||||
|
let display_string = format!("{}", error);
|
||||||
|
assert!(display_string.contains("Custom test error: Display test"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_debug() {
|
||||||
|
let error = Error::msg("Debug test");
|
||||||
|
let debug_string = format!("{:?}", error);
|
||||||
|
|
||||||
|
assert!(debug_string.contains("Error"));
|
||||||
|
assert!(debug_string.contains("inner"));
|
||||||
|
assert!(debug_string.contains("span_trace"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_multiple_error_types() {
|
||||||
|
let errors = vec![
|
||||||
|
Error::new(io::Error::new(io::ErrorKind::NotFound, "Not found")),
|
||||||
|
Error::new(CustomTestError {
|
||||||
|
message: "Custom".to_string(),
|
||||||
|
}),
|
||||||
|
Error::new(AnotherTestError),
|
||||||
|
Error::msg("String error"),
|
||||||
|
];
|
||||||
|
|
||||||
|
assert!(errors[0].is::<io::Error>());
|
||||||
|
assert!(errors[1].is::<CustomTestError>());
|
||||||
|
assert!(errors[2].is::<AnotherTestError>());
|
||||||
|
assert!(!errors[3].is::<io::Error>());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_chain_compatibility() {
|
||||||
|
// Test that our Error type works well with error chains
|
||||||
|
let io_error = io::Error::new(io::ErrorKind::InvalidData, "Invalid data");
|
||||||
|
let error = Error::new(io_error);
|
||||||
|
|
||||||
|
// Should be able to convert back to Result
|
||||||
|
let result: Result<(), Error> = Err(error);
|
||||||
|
assert!(result.is_err());
|
||||||
|
|
||||||
|
// Test the error from the result
|
||||||
|
if let Err(err) = result {
|
||||||
|
assert!(err.is::<io::Error>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_result_type_alias() {
|
||||||
|
// Test the Result type alias
|
||||||
|
fn test_function() -> Result<String> {
|
||||||
|
Ok("Success".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_function_with_error() -> Result<String> {
|
||||||
|
Err(Error::msg("Test error"))
|
||||||
|
}
|
||||||
|
|
||||||
|
let success_result = test_function();
|
||||||
|
assert!(success_result.is_ok());
|
||||||
|
assert_eq!(success_result.unwrap(), "Success");
|
||||||
|
|
||||||
|
let error_result = test_function_with_error();
|
||||||
|
assert!(error_result.is_err());
|
||||||
|
assert_eq!(error_result.unwrap_err().inner_string(), "Test error");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_with_empty_message() {
|
||||||
|
let error = Error::msg("");
|
||||||
|
assert_eq!(error.inner_string(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_with_unicode_message() {
|
||||||
|
let unicode_message = "错误信息 🚨 Error message with émojis and ñon-ASCII";
|
||||||
|
let error = Error::msg(unicode_message);
|
||||||
|
assert_eq!(error.inner_string(), unicode_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_with_very_long_message() {
|
||||||
|
let long_message = "A".repeat(10000);
|
||||||
|
let error = Error::msg(&long_message);
|
||||||
|
assert_eq!(error.inner_string(), long_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_span_trace_capture() {
|
||||||
|
// Test that span trace is captured (though we can't easily test the content)
|
||||||
|
let error = Error::msg("Span trace test");
|
||||||
|
let display_string = format!("{}", error);
|
||||||
|
|
||||||
|
// The error should at least contain the message
|
||||||
|
assert!(display_string.contains("Span trace test"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@@ -85,7 +71,7 @@ impl std::fmt::Display for SizeCategory {
|
|||||||
SizeCategory::SizeGreaterThan1GiB => "SizeGreaterThan1GiB",
|
SizeCategory::SizeGreaterThan1GiB => "SizeGreaterThan1GiB",
|
||||||
SizeCategory::SizeLastElemMarker => "SizeLastElemMarker",
|
SizeCategory::SizeLastElemMarker => "SizeLastElemMarker",
|
||||||
};
|
};
|
||||||
write!(f, "{s}")
|
write!(f, "{}", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,7 +639,7 @@ mod tests {
|
|||||||
assert_eq!(elem.n, cloned.n);
|
assert_eq!(elem.n, cloned.n);
|
||||||
|
|
||||||
// Test Debug trait
|
// Test Debug trait
|
||||||
let debug_str = format!("{elem:?}");
|
let debug_str = format!("{:?}", elem);
|
||||||
assert!(debug_str.contains("100"));
|
assert!(debug_str.contains("100"));
|
||||||
assert!(debug_str.contains("200"));
|
assert!(debug_str.contains("200"));
|
||||||
assert!(debug_str.contains("5"));
|
assert!(debug_str.contains("5"));
|
||||||
@@ -769,7 +755,8 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
test_latency.totals[expected_idx].n, 1,
|
test_latency.totals[expected_idx].n, 1,
|
||||||
"Failed for timestamp {timestamp} (expected index {expected_idx})"
|
"Failed for timestamp {} (expected index {})",
|
||||||
|
timestamp, expected_idx
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -809,7 +796,7 @@ mod tests {
|
|||||||
n: 789,
|
n: 789,
|
||||||
};
|
};
|
||||||
|
|
||||||
let debug_str = format!("{elem:?}");
|
let debug_str = format!("{:?}", elem);
|
||||||
assert!(debug_str.contains("123"));
|
assert!(debug_str.contains("123"));
|
||||||
assert!(debug_str.contains("456"));
|
assert!(debug_str.contains("456"));
|
||||||
assert!(debug_str.contains("789"));
|
assert!(debug_str.contains("789"));
|
||||||
27
common/common/src/lib.rs
Normal file
27
common/common/src/lib.rs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
pub mod bucket_stats;
|
||||||
|
pub mod error;
|
||||||
|
pub mod globals;
|
||||||
|
pub mod last_minute;
|
||||||
|
|
||||||
|
// is ','
|
||||||
|
pub static DEFAULT_DELIMITER: u8 = 44;
|
||||||
|
|
||||||
|
/// Defers evaluation of a block of code until the end of the scope.
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! defer {
|
||||||
|
($($body:tt)*) => {
|
||||||
|
let _guard = {
|
||||||
|
pub struct Guard<F: FnOnce()>(Option<F>);
|
||||||
|
|
||||||
|
impl<F: FnOnce()> Drop for Guard<F> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
(self.0).take().map(|f| f());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Guard(Some(|| {
|
||||||
|
let _ = { $($body)* };
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
23
common/lock/Cargo.toml
Normal file
23
common/lock/Cargo.toml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[package]
|
||||||
|
name = "lock"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
async-trait.workspace = true
|
||||||
|
backon.workspace = true
|
||||||
|
common.workspace = true
|
||||||
|
lazy_static.workspace = true
|
||||||
|
protos.workspace = true
|
||||||
|
rand.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
tokio.workspace = true
|
||||||
|
tonic.workspace = true
|
||||||
|
tracing.workspace = true
|
||||||
|
tracing-error.workspace = true
|
||||||
|
url.workspace = true
|
||||||
|
uuid.workspace = true
|
||||||
@@ -1,22 +1,9 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use tokio::{sync::mpsc::Sender, time::sleep};
|
use tokio::{sync::mpsc::Sender, time::sleep};
|
||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
|
|
||||||
use crate::{LockApi, Locker, lock_args::LockArgs};
|
use crate::{lock_args::LockArgs, LockApi, Locker};
|
||||||
|
|
||||||
const DRW_MUTEX_REFRESH_INTERVAL: Duration = Duration::from_secs(10);
|
const DRW_MUTEX_REFRESH_INTERVAL: Duration = Duration::from_secs(10);
|
||||||
const LOCK_RETRY_MIN_INTERVAL: Duration = Duration::from_millis(250);
|
const LOCK_RETRY_MIN_INTERVAL: Duration = Duration::from_millis(250);
|
||||||
@@ -130,10 +117,7 @@ impl DRWMutex {
|
|||||||
quorum += 1;
|
quorum += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info!(
|
info!("lockBlocking {}/{} for {:?}: lockType readLock({}), additional opts: {:?}, quorum: {}, tolerance: {}, lockClients: {}\n", id, source, self.names, is_read_lock, opts, quorum, tolerance, locker_len);
|
||||||
"lockBlocking {}/{} for {:?}: lockType readLock({}), additional opts: {:?}, quorum: {}, tolerance: {}, lockClients: {}\n",
|
|
||||||
id, source, self.names, is_read_lock, opts, quorum, tolerance, locker_len
|
|
||||||
);
|
|
||||||
|
|
||||||
// Recalculate tolerance after potential quorum adjustment
|
// Recalculate tolerance after potential quorum adjustment
|
||||||
// Use saturating_sub to prevent underflow
|
// Use saturating_sub to prevent underflow
|
||||||
@@ -392,8 +376,8 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::local_locker::LocalLocker;
|
use crate::local_locker::LocalLocker;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
use common::error::{Error, Result};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::{Error, Result};
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
// Mock locker for testing
|
// Mock locker for testing
|
||||||
@@ -452,10 +436,10 @@ mod tests {
|
|||||||
async fn lock(&mut self, args: &LockArgs) -> Result<bool> {
|
async fn lock(&mut self, args: &LockArgs) -> Result<bool> {
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
if state.should_fail {
|
if state.should_fail {
|
||||||
return Err(Error::other("Mock lock failure"));
|
return Err(Error::from_string("Mock lock failure"));
|
||||||
}
|
}
|
||||||
if !state.is_online {
|
if !state.is_online {
|
||||||
return Err(Error::other("Mock locker offline"));
|
return Err(Error::from_string("Mock locker offline"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if already locked
|
// Check if already locked
|
||||||
@@ -470,7 +454,7 @@ mod tests {
|
|||||||
async fn unlock(&mut self, args: &LockArgs) -> Result<bool> {
|
async fn unlock(&mut self, args: &LockArgs) -> Result<bool> {
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
if state.should_fail {
|
if state.should_fail {
|
||||||
return Err(Error::other("Mock unlock failure"));
|
return Err(Error::from_string("Mock unlock failure"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(state.locks.remove(&args.uid).is_some())
|
Ok(state.locks.remove(&args.uid).is_some())
|
||||||
@@ -479,10 +463,10 @@ mod tests {
|
|||||||
async fn rlock(&mut self, args: &LockArgs) -> Result<bool> {
|
async fn rlock(&mut self, args: &LockArgs) -> Result<bool> {
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
if state.should_fail {
|
if state.should_fail {
|
||||||
return Err(Error::other("Mock rlock failure"));
|
return Err(Error::from_string("Mock rlock failure"));
|
||||||
}
|
}
|
||||||
if !state.is_online {
|
if !state.is_online {
|
||||||
return Err(Error::other("Mock locker offline"));
|
return Err(Error::from_string("Mock locker offline"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if write lock exists
|
// Check if write lock exists
|
||||||
@@ -497,7 +481,7 @@ mod tests {
|
|||||||
async fn runlock(&mut self, args: &LockArgs) -> Result<bool> {
|
async fn runlock(&mut self, args: &LockArgs) -> Result<bool> {
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
if state.should_fail {
|
if state.should_fail {
|
||||||
return Err(Error::other("Mock runlock failure"));
|
return Err(Error::from_string("Mock runlock failure"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(state.read_locks.remove(&args.uid).is_some())
|
Ok(state.read_locks.remove(&args.uid).is_some())
|
||||||
@@ -506,7 +490,7 @@ mod tests {
|
|||||||
async fn refresh(&mut self, _args: &LockArgs) -> Result<bool> {
|
async fn refresh(&mut self, _args: &LockArgs) -> Result<bool> {
|
||||||
let state = self.state.lock().unwrap();
|
let state = self.state.lock().unwrap();
|
||||||
if state.should_fail {
|
if state.should_fail {
|
||||||
return Err(Error::other("Mock refresh failure"));
|
return Err(Error::from_string("Mock refresh failure"));
|
||||||
}
|
}
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
@@ -625,7 +609,7 @@ mod tests {
|
|||||||
timeout: Duration::from_secs(5),
|
timeout: Duration::from_secs(5),
|
||||||
retry_interval: Duration::from_millis(100),
|
retry_interval: Duration::from_millis(100),
|
||||||
};
|
};
|
||||||
let debug_str = format!("{opts:?}");
|
let debug_str = format!("{:?}", opts);
|
||||||
assert!(debug_str.contains("timeout"));
|
assert!(debug_str.contains("timeout"));
|
||||||
assert!(debug_str.contains("retry_interval"));
|
assert!(debug_str.contains("retry_interval"));
|
||||||
}
|
}
|
||||||
@@ -863,7 +847,7 @@ mod tests {
|
|||||||
let lockers = create_mock_lockers(1);
|
let lockers = create_mock_lockers(1);
|
||||||
let mutex = DRWMutex::new("owner1".to_string(), names, lockers);
|
let mutex = DRWMutex::new("owner1".to_string(), names, lockers);
|
||||||
|
|
||||||
let debug_str = format!("{mutex:?}");
|
let debug_str = format!("{:?}", mutex);
|
||||||
assert!(debug_str.contains("DRWMutex"));
|
assert!(debug_str.contains("DRWMutex"));
|
||||||
assert!(debug_str.contains("owner"));
|
assert!(debug_str.contains("owner"));
|
||||||
assert!(debug_str.contains("names"));
|
assert!(debug_str.contains("names"));
|
||||||
@@ -896,8 +880,8 @@ mod tests {
|
|||||||
// Case 1: Even number of lockers
|
// Case 1: Even number of lockers
|
||||||
let locks = vec!["uid1".to_string(), "uid2".to_string(), "uid3".to_string(), "uid4".to_string()];
|
let locks = vec!["uid1".to_string(), "uid2".to_string(), "uid3".to_string(), "uid4".to_string()];
|
||||||
let tolerance = 2; // locks.len() / 2 = 4 / 2 = 2
|
let tolerance = 2; // locks.len() / 2 = 4 / 2 = 2
|
||||||
// locks.len() - tolerance = 4 - 2 = 2, which equals tolerance
|
// locks.len() - tolerance = 4 - 2 = 2, which equals tolerance
|
||||||
// So the special case applies: un_locks_failed >= tolerance
|
// So the special case applies: un_locks_failed >= tolerance
|
||||||
|
|
||||||
// All 4 failed unlocks
|
// All 4 failed unlocks
|
||||||
assert!(check_failed_unlocks(&locks, tolerance)); // 4 >= 2 = true
|
assert!(check_failed_unlocks(&locks, tolerance)); // 4 >= 2 = true
|
||||||
@@ -913,8 +897,8 @@ mod tests {
|
|||||||
// Case 2: Odd number of lockers
|
// Case 2: Odd number of lockers
|
||||||
let locks = vec!["uid1".to_string(), "uid2".to_string(), "uid3".to_string()];
|
let locks = vec!["uid1".to_string(), "uid2".to_string(), "uid3".to_string()];
|
||||||
let tolerance = 1; // locks.len() / 2 = 3 / 2 = 1
|
let tolerance = 1; // locks.len() / 2 = 3 / 2 = 1
|
||||||
// locks.len() - tolerance = 3 - 1 = 2, which does NOT equal tolerance (1)
|
// locks.len() - tolerance = 3 - 1 = 2, which does NOT equal tolerance (1)
|
||||||
// So the normal case applies: un_locks_failed > tolerance
|
// So the normal case applies: un_locks_failed > tolerance
|
||||||
|
|
||||||
// 3 failed unlocks
|
// 3 failed unlocks
|
||||||
assert!(check_failed_unlocks(&locks, tolerance)); // 3 > 1 = true
|
assert!(check_failed_unlocks(&locks, tolerance)); // 3 > 1 = true
|
||||||
@@ -1,25 +1,13 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
use std::sync::Arc;
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
use common::error::Result;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use local_locker::LocalLocker;
|
use local_locker::LocalLocker;
|
||||||
use lock_args::LockArgs;
|
use lock_args::LockArgs;
|
||||||
use remote_client::RemoteClient;
|
use remote_client::RemoteClient;
|
||||||
use std::io::Result;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
pub mod drwmutex;
|
pub mod drwmutex;
|
||||||
@@ -1,27 +1,13 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use std::io::{Error, Result};
|
use common::error::{Error, Result};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{Locker, lock_args::LockArgs};
|
use crate::{lock_args::LockArgs, Locker};
|
||||||
|
|
||||||
pub const MAX_DELETE_LIST: usize = 1000;
|
const MAX_DELETE_LIST: usize = 1000;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct LockRequesterInfo {
|
struct LockRequesterInfo {
|
||||||
@@ -130,8 +116,9 @@ impl LocalLocker {
|
|||||||
impl Locker for LocalLocker {
|
impl Locker for LocalLocker {
|
||||||
async fn lock(&mut self, args: &LockArgs) -> Result<bool> {
|
async fn lock(&mut self, args: &LockArgs) -> Result<bool> {
|
||||||
if args.resources.len() > MAX_DELETE_LIST {
|
if args.resources.len() > MAX_DELETE_LIST {
|
||||||
return Err(Error::other(format!(
|
return Err(Error::from_string(format!(
|
||||||
"internal error: LocalLocker.lock called with more than {MAX_DELETE_LIST} resources"
|
"internal error: LocalLocker.lock called with more than {} resources",
|
||||||
|
MAX_DELETE_LIST
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,8 +152,9 @@ impl Locker for LocalLocker {
|
|||||||
|
|
||||||
async fn unlock(&mut self, args: &LockArgs) -> Result<bool> {
|
async fn unlock(&mut self, args: &LockArgs) -> Result<bool> {
|
||||||
if args.resources.len() > MAX_DELETE_LIST {
|
if args.resources.len() > MAX_DELETE_LIST {
|
||||||
return Err(Error::other(format!(
|
return Err(Error::from_string(format!(
|
||||||
"internal error: LocalLocker.unlock called with more than {MAX_DELETE_LIST} resources"
|
"internal error: LocalLocker.unlock called with more than {} resources",
|
||||||
|
MAX_DELETE_LIST
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,9 +165,9 @@ impl Locker for LocalLocker {
|
|||||||
Some(lris) => {
|
Some(lris) => {
|
||||||
if !is_write_lock(lris) {
|
if !is_write_lock(lris) {
|
||||||
if err_info.is_empty() {
|
if err_info.is_empty() {
|
||||||
err_info = format!("unlock attempted on a read locked entity: {resource}");
|
err_info = format!("unlock attempted on a read locked entity: {}", resource);
|
||||||
} else {
|
} else {
|
||||||
err_info.push_str(&format!(", {resource}"));
|
err_info.push_str(&format!(", {}", resource));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lris.retain(|lri| {
|
lris.retain(|lri| {
|
||||||
@@ -209,7 +197,7 @@ impl Locker for LocalLocker {
|
|||||||
|
|
||||||
async fn rlock(&mut self, args: &LockArgs) -> Result<bool> {
|
async fn rlock(&mut self, args: &LockArgs) -> Result<bool> {
|
||||||
if args.resources.len() != 1 {
|
if args.resources.len() != 1 {
|
||||||
return Err(Error::other("internal error: localLocker.RLock called with more than one resource"));
|
return Err(Error::from_string("internal error: localLocker.RLock called with more than one resource"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let resource = &args.resources[0];
|
let resource = &args.resources[0];
|
||||||
@@ -253,7 +241,7 @@ impl Locker for LocalLocker {
|
|||||||
|
|
||||||
async fn runlock(&mut self, args: &LockArgs) -> Result<bool> {
|
async fn runlock(&mut self, args: &LockArgs) -> Result<bool> {
|
||||||
if args.resources.len() != 1 {
|
if args.resources.len() != 1 {
|
||||||
return Err(Error::other("internal error: localLocker.RLock called with more than one resource"));
|
return Err(Error::from_string("internal error: localLocker.RLock called with more than one resource"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut reply = false;
|
let mut reply = false;
|
||||||
@@ -261,7 +249,7 @@ impl Locker for LocalLocker {
|
|||||||
match self.lock_map.get_mut(resource) {
|
match self.lock_map.get_mut(resource) {
|
||||||
Some(lris) => {
|
Some(lris) => {
|
||||||
if is_write_lock(lris) {
|
if is_write_lock(lris) {
|
||||||
return Err(Error::other(format!("runlock attempted on a write locked entity: {resource}")));
|
return Err(Error::from_string(format!("runlock attempted on a write locked entity: {}", resource)));
|
||||||
} else {
|
} else {
|
||||||
lris.retain(|lri| {
|
lris.retain(|lri| {
|
||||||
if lri.uid == args.uid && (args.owner.is_empty() || lri.owner == args.owner) {
|
if lri.uid == args.uid && (args.owner.is_empty() || lri.owner == args.owner) {
|
||||||
@@ -401,8 +389,8 @@ fn format_uuid(s: &mut String, idx: &usize) {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::LocalLocker;
|
use super::LocalLocker;
|
||||||
use crate::{Locker, lock_args::LockArgs};
|
use crate::{lock_args::LockArgs, Locker};
|
||||||
use std::io::Result;
|
use common::error::Result;
|
||||||
use tokio;
|
use tokio;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -417,10 +405,10 @@ mod test {
|
|||||||
};
|
};
|
||||||
local_locker.lock(&args).await?;
|
local_locker.lock(&args).await?;
|
||||||
|
|
||||||
println!("lock local_locker: {local_locker:?} \n");
|
println!("lock local_locker: {:?} \n", local_locker);
|
||||||
|
|
||||||
local_locker.unlock(&args).await?;
|
local_locker.unlock(&args).await?;
|
||||||
println!("unlock local_locker: {local_locker:?}");
|
println!("unlock local_locker: {:?}", local_locker);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
22
common/lock/src/lock_args.rs
Normal file
22
common/lock/src/lock_args.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||||
|
pub struct LockArgs {
|
||||||
|
pub uid: String,
|
||||||
|
pub resources: Vec<String>,
|
||||||
|
pub owner: String,
|
||||||
|
pub source: String,
|
||||||
|
pub quorum: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for LockArgs {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"LockArgs[ uid: {}, resources: {:?}, owner: {}, source:{}, quorum: {} ]",
|
||||||
|
self.uid, self.resources, self.owner, self.source, self.quorum
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,6 @@
|
|||||||
// Copyright 2024 RustFS Team
|
use std::time::{Duration, Instant};
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use std::time::{Duration, Instant};
|
|
||||||
use tokio::{sync::RwLock, time::sleep};
|
use tokio::{sync::RwLock, time::sleep};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
@@ -90,8 +77,8 @@ impl LRWMutex {
|
|||||||
}
|
}
|
||||||
let sleep_time: u64;
|
let sleep_time: u64;
|
||||||
{
|
{
|
||||||
let mut rng = rand::rng();
|
let mut rng = rand::thread_rng();
|
||||||
sleep_time = rng.random_range(10..=50);
|
sleep_time = rng.gen_range(10..=50);
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(sleep_time)).await;
|
sleep(Duration::from_millis(sleep_time)).await;
|
||||||
}
|
}
|
||||||
@@ -138,7 +125,7 @@ impl LRWMutex {
|
|||||||
mod test {
|
mod test {
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
use std::io::Result;
|
use common::error::Result;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
||||||
use crate::lrwmutex::LRWMutex;
|
use crate::lrwmutex::LRWMutex;
|
||||||
@@ -1,28 +1,15 @@
|
|||||||
// Copyright 2024 RustFS Team
|
use std::{collections::HashMap, path::Path, sync::Arc, time::Duration};
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use std::{collections::HashMap, path::Path, sync::Arc, time::Duration};
|
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
LockApi,
|
|
||||||
drwmutex::{DRWMutex, Options},
|
drwmutex::{DRWMutex, Options},
|
||||||
lrwmutex::LRWMutex,
|
lrwmutex::LRWMutex,
|
||||||
|
LockApi,
|
||||||
};
|
};
|
||||||
use std::io::Result;
|
use common::error::Result;
|
||||||
|
|
||||||
pub type RWLockerImpl = Box<dyn RWLocker + Send + Sync>;
|
pub type RWLockerImpl = Box<dyn RWLocker + Send + Sync>;
|
||||||
|
|
||||||
@@ -271,12 +258,12 @@ impl RWLocker for LocalLockInstance {
|
|||||||
mod test {
|
mod test {
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
use std::io::Result;
|
use common::error::Result;
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
drwmutex::Options,
|
drwmutex::Options,
|
||||||
namespace_lock::{NsLockMap, new_nslock},
|
namespace_lock::{new_nslock, NsLockMap},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1,24 +1,11 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use crate::{Locker, lock_args::LockArgs};
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use rustfs_protos::{node_service_time_out_client, proto_gen::node_service::GenerallyLockRequest};
|
use common::error::{Error, Result};
|
||||||
use std::io::{Error, Result};
|
use protos::{node_service_time_out_client, proto_gen::node_service::GenerallyLockRequest};
|
||||||
use tonic::Request;
|
use tonic::Request;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
|
use crate::{lock_args::LockArgs, Locker};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct RemoteClient {
|
pub struct RemoteClient {
|
||||||
addr: String,
|
addr: String,
|
||||||
@@ -38,13 +25,13 @@ impl Locker for RemoteClient {
|
|||||||
let args = serde_json::to_string(args)?;
|
let args = serde_json::to_string(args)?;
|
||||||
let mut client = node_service_time_out_client(&self.addr)
|
let mut client = node_service_time_out_client(&self.addr)
|
||||||
.await
|
.await
|
||||||
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
|
.map_err(|err| Error::from_string(format!("can not get client, err: {}", err)))?;
|
||||||
let request = Request::new(GenerallyLockRequest { args });
|
let request = Request::new(GenerallyLockRequest { args });
|
||||||
|
|
||||||
let response = client.lock(request).await.map_err(Error::other)?.into_inner();
|
let response = client.lock(request).await?.into_inner();
|
||||||
|
|
||||||
if let Some(error_info) = response.error_info {
|
if let Some(error_info) = response.error_info {
|
||||||
return Err(Error::other(error_info));
|
return Err(Error::from_string(error_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(response.success)
|
Ok(response.success)
|
||||||
@@ -55,13 +42,13 @@ impl Locker for RemoteClient {
|
|||||||
let args = serde_json::to_string(args)?;
|
let args = serde_json::to_string(args)?;
|
||||||
let mut client = node_service_time_out_client(&self.addr)
|
let mut client = node_service_time_out_client(&self.addr)
|
||||||
.await
|
.await
|
||||||
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
|
.map_err(|err| Error::from_string(format!("can not get client, err: {}", err)))?;
|
||||||
let request = Request::new(GenerallyLockRequest { args });
|
let request = Request::new(GenerallyLockRequest { args });
|
||||||
|
|
||||||
let response = client.un_lock(request).await.map_err(Error::other)?.into_inner();
|
let response = client.un_lock(request).await?.into_inner();
|
||||||
|
|
||||||
if let Some(error_info) = response.error_info {
|
if let Some(error_info) = response.error_info {
|
||||||
return Err(Error::other(error_info));
|
return Err(Error::from_string(error_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(response.success)
|
Ok(response.success)
|
||||||
@@ -72,13 +59,13 @@ impl Locker for RemoteClient {
|
|||||||
let args = serde_json::to_string(args)?;
|
let args = serde_json::to_string(args)?;
|
||||||
let mut client = node_service_time_out_client(&self.addr)
|
let mut client = node_service_time_out_client(&self.addr)
|
||||||
.await
|
.await
|
||||||
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
|
.map_err(|err| Error::from_string(format!("can not get client, err: {}", err)))?;
|
||||||
let request = Request::new(GenerallyLockRequest { args });
|
let request = Request::new(GenerallyLockRequest { args });
|
||||||
|
|
||||||
let response = client.r_lock(request).await.map_err(Error::other)?.into_inner();
|
let response = client.r_lock(request).await?.into_inner();
|
||||||
|
|
||||||
if let Some(error_info) = response.error_info {
|
if let Some(error_info) = response.error_info {
|
||||||
return Err(Error::other(error_info));
|
return Err(Error::from_string(error_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(response.success)
|
Ok(response.success)
|
||||||
@@ -89,13 +76,13 @@ impl Locker for RemoteClient {
|
|||||||
let args = serde_json::to_string(args)?;
|
let args = serde_json::to_string(args)?;
|
||||||
let mut client = node_service_time_out_client(&self.addr)
|
let mut client = node_service_time_out_client(&self.addr)
|
||||||
.await
|
.await
|
||||||
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
|
.map_err(|err| Error::from_string(format!("can not get client, err: {}", err)))?;
|
||||||
let request = Request::new(GenerallyLockRequest { args });
|
let request = Request::new(GenerallyLockRequest { args });
|
||||||
|
|
||||||
let response = client.r_un_lock(request).await.map_err(Error::other)?.into_inner();
|
let response = client.r_un_lock(request).await?.into_inner();
|
||||||
|
|
||||||
if let Some(error_info) = response.error_info {
|
if let Some(error_info) = response.error_info {
|
||||||
return Err(Error::other(error_info));
|
return Err(Error::from_string(error_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(response.success)
|
Ok(response.success)
|
||||||
@@ -106,13 +93,13 @@ impl Locker for RemoteClient {
|
|||||||
let args = serde_json::to_string(args)?;
|
let args = serde_json::to_string(args)?;
|
||||||
let mut client = node_service_time_out_client(&self.addr)
|
let mut client = node_service_time_out_client(&self.addr)
|
||||||
.await
|
.await
|
||||||
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
|
.map_err(|err| Error::from_string(format!("can not get client, err: {}", err)))?;
|
||||||
let request = Request::new(GenerallyLockRequest { args });
|
let request = Request::new(GenerallyLockRequest { args });
|
||||||
|
|
||||||
let response = client.refresh(request).await.map_err(Error::other)?.into_inner();
|
let response = client.refresh(request).await?.into_inner();
|
||||||
|
|
||||||
if let Some(error_info) = response.error_info {
|
if let Some(error_info) = response.error_info {
|
||||||
return Err(Error::other(error_info));
|
return Err(Error::from_string(error_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(response.success)
|
Ok(response.success)
|
||||||
@@ -123,13 +110,13 @@ impl Locker for RemoteClient {
|
|||||||
let args = serde_json::to_string(args)?;
|
let args = serde_json::to_string(args)?;
|
||||||
let mut client = node_service_time_out_client(&self.addr)
|
let mut client = node_service_time_out_client(&self.addr)
|
||||||
.await
|
.await
|
||||||
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
|
.map_err(|err| Error::from_string(format!("can not get client, err: {}", err)))?;
|
||||||
let request = Request::new(GenerallyLockRequest { args });
|
let request = Request::new(GenerallyLockRequest { args });
|
||||||
|
|
||||||
let response = client.force_un_lock(request).await.map_err(Error::other)?.into_inner();
|
let response = client.force_un_lock(request).await?.into_inner();
|
||||||
|
|
||||||
if let Some(error_info) = response.error_info {
|
if let Some(error_info) = response.error_info {
|
||||||
return Err(Error::other(error_info));
|
return Err(Error::from_string(error_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(response.success)
|
Ok(response.success)
|
||||||
23
common/protos/Cargo.toml
Normal file
23
common/protos/Cargo.toml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[package]
|
||||||
|
name = "protos"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "gproto"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
#async-backtrace = { workspace = true, optional = true }
|
||||||
|
common.workspace = true
|
||||||
|
flatbuffers = { workspace = true }
|
||||||
|
prost = { workspace = true }
|
||||||
|
protobuf = { workspace = true }
|
||||||
|
tokio = { workspace = true }
|
||||||
|
tonic = { workspace = true, features = ["transport"] }
|
||||||
|
tower = { workspace = true }
|
||||||
|
prost-build = { workspace = true }
|
||||||
|
tonic-build = { workspace = true }
|
||||||
1
common/protos/src/generated/flatbuffers_generated/mod.rs
Normal file
1
common/protos/src/generated/flatbuffers_generated/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod models;
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
// automatically generated by the FlatBuffers compiler, do not modify
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
// @generated
|
// @generated
|
||||||
@@ -43,7 +29,7 @@ pub mod models {
|
|||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
Self {
|
Self {
|
||||||
_tab: unsafe { flatbuffers::Table::new(buf, loc) },
|
_tab: flatbuffers::Table::new(buf, loc),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
6
common/protos/src/generated/mod.rs
Normal file
6
common/protos/src/generated/mod.rs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#![allow(unused_imports)]
|
||||||
|
#![allow(clippy::all)]
|
||||||
|
pub mod proto_gen;
|
||||||
|
|
||||||
|
mod flatbuffers_generated;
|
||||||
|
pub use flatbuffers_generated::models::*;
|
||||||
1
common/protos/src/generated/proto_gen/mod.rs
Normal file
1
common/protos/src/generated/proto_gen/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod node_service;
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
// This file is @generated by prost-build.
|
// This file is @generated by prost-build.
|
||||||
/// --------------------------------------------------------------------
|
/// --------------------------------------------------------------------
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
@@ -25,15 +11,15 @@ pub struct Error {
|
|||||||
pub struct PingRequest {
|
pub struct PingRequest {
|
||||||
#[prost(uint64, tag = "1")]
|
#[prost(uint64, tag = "1")]
|
||||||
pub version: u64,
|
pub version: u64,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub body: ::prost::bytes::Bytes,
|
pub body: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct PingResponse {
|
pub struct PingResponse {
|
||||||
#[prost(uint64, tag = "1")]
|
#[prost(uint64, tag = "1")]
|
||||||
pub version: u64,
|
pub version: u64,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub body: ::prost::bytes::Bytes,
|
pub body: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct HealBucketRequest {
|
pub struct HealBucketRequest {
|
||||||
@@ -119,8 +105,8 @@ pub struct ReadAllRequest {
|
|||||||
pub struct ReadAllResponse {
|
pub struct ReadAllResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub data: ::prost::bytes::Bytes,
|
pub data: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(message, optional, tag = "3")]
|
#[prost(message, optional, tag = "3")]
|
||||||
pub error: ::core::option::Option<Error>,
|
pub error: ::core::option::Option<Error>,
|
||||||
}
|
}
|
||||||
@@ -133,8 +119,8 @@ pub struct WriteAllRequest {
|
|||||||
pub volume: ::prost::alloc::string::String,
|
pub volume: ::prost::alloc::string::String,
|
||||||
#[prost(string, tag = "3")]
|
#[prost(string, tag = "3")]
|
||||||
pub path: ::prost::alloc::string::String,
|
pub path: ::prost::alloc::string::String,
|
||||||
#[prost(bytes = "bytes", tag = "4")]
|
#[prost(bytes = "vec", tag = "4")]
|
||||||
pub data: ::prost::bytes::Bytes,
|
pub data: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct WriteAllResponse {
|
pub struct WriteAllResponse {
|
||||||
@@ -205,7 +191,7 @@ pub struct CheckPartsResponse {
|
|||||||
pub error: ::core::option::Option<Error>,
|
pub error: ::core::option::Option<Error>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct RenamePartRequest {
|
pub struct RenamePartRequst {
|
||||||
#[prost(string, tag = "1")]
|
#[prost(string, tag = "1")]
|
||||||
pub disk: ::prost::alloc::string::String,
|
pub disk: ::prost::alloc::string::String,
|
||||||
#[prost(string, tag = "2")]
|
#[prost(string, tag = "2")]
|
||||||
@@ -216,8 +202,8 @@ pub struct RenamePartRequest {
|
|||||||
pub dst_volume: ::prost::alloc::string::String,
|
pub dst_volume: ::prost::alloc::string::String,
|
||||||
#[prost(string, tag = "5")]
|
#[prost(string, tag = "5")]
|
||||||
pub dst_path: ::prost::alloc::string::String,
|
pub dst_path: ::prost::alloc::string::String,
|
||||||
#[prost(bytes = "bytes", tag = "6")]
|
#[prost(bytes = "vec", tag = "6")]
|
||||||
pub meta: ::prost::bytes::Bytes,
|
pub meta: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct RenamePartResponse {
|
pub struct RenamePartResponse {
|
||||||
@@ -227,7 +213,7 @@ pub struct RenamePartResponse {
|
|||||||
pub error: ::core::option::Option<Error>,
|
pub error: ::core::option::Option<Error>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct RenameFileRequest {
|
pub struct RenameFileRequst {
|
||||||
#[prost(string, tag = "1")]
|
#[prost(string, tag = "1")]
|
||||||
pub disk: ::prost::alloc::string::String,
|
pub disk: ::prost::alloc::string::String,
|
||||||
#[prost(string, tag = "2")]
|
#[prost(string, tag = "2")]
|
||||||
@@ -257,8 +243,8 @@ pub struct WriteRequest {
|
|||||||
pub path: ::prost::alloc::string::String,
|
pub path: ::prost::alloc::string::String,
|
||||||
#[prost(bool, tag = "4")]
|
#[prost(bool, tag = "4")]
|
||||||
pub is_append: bool,
|
pub is_append: bool,
|
||||||
#[prost(bytes = "bytes", tag = "5")]
|
#[prost(bytes = "vec", tag = "5")]
|
||||||
pub data: ::prost::bytes::Bytes,
|
pub data: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct WriteResponse {
|
pub struct WriteResponse {
|
||||||
@@ -285,8 +271,8 @@ pub struct ReadAtRequest {
|
|||||||
pub struct ReadAtResponse {
|
pub struct ReadAtResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub data: ::prost::bytes::Bytes,
|
pub data: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(int64, tag = "3")]
|
#[prost(int64, tag = "3")]
|
||||||
pub read_size: i64,
|
pub read_size: i64,
|
||||||
#[prost(message, optional, tag = "4")]
|
#[prost(message, optional, tag = "4")]
|
||||||
@@ -314,8 +300,8 @@ pub struct WalkDirRequest {
|
|||||||
/// indicate which one in the disks
|
/// indicate which one in the disks
|
||||||
#[prost(string, tag = "1")]
|
#[prost(string, tag = "1")]
|
||||||
pub disk: ::prost::alloc::string::String,
|
pub disk: ::prost::alloc::string::String,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub walk_dir_options: ::prost::bytes::Bytes,
|
pub walk_dir_options: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct WalkDirResponse {
|
pub struct WalkDirResponse {
|
||||||
@@ -647,8 +633,8 @@ pub struct LocalStorageInfoRequest {
|
|||||||
pub struct LocalStorageInfoResponse {
|
pub struct LocalStorageInfoResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub storage_info: ::prost::bytes::Bytes,
|
pub storage_info: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -661,8 +647,8 @@ pub struct ServerInfoRequest {
|
|||||||
pub struct ServerInfoResponse {
|
pub struct ServerInfoResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub server_properties: ::prost::bytes::Bytes,
|
pub server_properties: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -672,8 +658,8 @@ pub struct GetCpusRequest {}
|
|||||||
pub struct GetCpusResponse {
|
pub struct GetCpusResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub cpus: ::prost::bytes::Bytes,
|
pub cpus: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -683,8 +669,8 @@ pub struct GetNetInfoRequest {}
|
|||||||
pub struct GetNetInfoResponse {
|
pub struct GetNetInfoResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub net_info: ::prost::bytes::Bytes,
|
pub net_info: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -694,8 +680,8 @@ pub struct GetPartitionsRequest {}
|
|||||||
pub struct GetPartitionsResponse {
|
pub struct GetPartitionsResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub partitions: ::prost::bytes::Bytes,
|
pub partitions: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -705,8 +691,8 @@ pub struct GetOsInfoRequest {}
|
|||||||
pub struct GetOsInfoResponse {
|
pub struct GetOsInfoResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub os_info: ::prost::bytes::Bytes,
|
pub os_info: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -716,8 +702,8 @@ pub struct GetSeLinuxInfoRequest {}
|
|||||||
pub struct GetSeLinuxInfoResponse {
|
pub struct GetSeLinuxInfoResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub sys_services: ::prost::bytes::Bytes,
|
pub sys_services: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -727,8 +713,8 @@ pub struct GetSysConfigRequest {}
|
|||||||
pub struct GetSysConfigResponse {
|
pub struct GetSysConfigResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub sys_config: ::prost::bytes::Bytes,
|
pub sys_config: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -738,8 +724,8 @@ pub struct GetSysErrorsRequest {}
|
|||||||
pub struct GetSysErrorsResponse {
|
pub struct GetSysErrorsResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub sys_errors: ::prost::bytes::Bytes,
|
pub sys_errors: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -749,24 +735,24 @@ pub struct GetMemInfoRequest {}
|
|||||||
pub struct GetMemInfoResponse {
|
pub struct GetMemInfoResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub mem_info: ::prost::bytes::Bytes,
|
pub mem_info: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct GetMetricsRequest {
|
pub struct GetMetricsRequest {
|
||||||
#[prost(bytes = "bytes", tag = "1")]
|
#[prost(bytes = "vec", tag = "1")]
|
||||||
pub metric_type: ::prost::bytes::Bytes,
|
pub metric_type: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub opts: ::prost::bytes::Bytes,
|
pub opts: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct GetMetricsResponse {
|
pub struct GetMetricsResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub realtime_metrics: ::prost::bytes::Bytes,
|
pub realtime_metrics: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -776,8 +762,8 @@ pub struct GetProcInfoRequest {}
|
|||||||
pub struct GetProcInfoResponse {
|
pub struct GetProcInfoResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub proc_info: ::prost::bytes::Bytes,
|
pub proc_info: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -800,7 +786,7 @@ pub struct DownloadProfileDataResponse {
|
|||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(map = "string, bytes", tag = "2")]
|
#[prost(map = "string, bytes", tag = "2")]
|
||||||
pub data: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::bytes::Bytes>,
|
pub data: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::vec::Vec<u8>>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -813,8 +799,8 @@ pub struct GetBucketStatsDataRequest {
|
|||||||
pub struct GetBucketStatsDataResponse {
|
pub struct GetBucketStatsDataResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub bucket_stats: ::prost::bytes::Bytes,
|
pub bucket_stats: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -824,8 +810,8 @@ pub struct GetSrMetricsDataRequest {}
|
|||||||
pub struct GetSrMetricsDataResponse {
|
pub struct GetSrMetricsDataResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub sr_metrics_summary: ::prost::bytes::Bytes,
|
pub sr_metrics_summary: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -835,8 +821,8 @@ pub struct GetAllBucketStatsRequest {}
|
|||||||
pub struct GetAllBucketStatsResponse {
|
pub struct GetAllBucketStatsResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub bucket_stats_map: ::prost::bytes::Bytes,
|
pub bucket_stats_map: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -993,36 +979,36 @@ pub struct BackgroundHealStatusRequest {}
|
|||||||
pub struct BackgroundHealStatusResponse {
|
pub struct BackgroundHealStatusResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub bg_heal_state: ::prost::bytes::Bytes,
|
pub bg_heal_state: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct GetMetacacheListingRequest {
|
pub struct GetMetacacheListingRequest {
|
||||||
#[prost(bytes = "bytes", tag = "1")]
|
#[prost(bytes = "vec", tag = "1")]
|
||||||
pub opts: ::prost::bytes::Bytes,
|
pub opts: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct GetMetacacheListingResponse {
|
pub struct GetMetacacheListingResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub metacache: ::prost::bytes::Bytes,
|
pub metacache: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct UpdateMetacacheListingRequest {
|
pub struct UpdateMetacacheListingRequest {
|
||||||
#[prost(bytes = "bytes", tag = "1")]
|
#[prost(bytes = "vec", tag = "1")]
|
||||||
pub metacache: ::prost::bytes::Bytes,
|
pub metacache: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct UpdateMetacacheListingResponse {
|
pub struct UpdateMetacacheListingResponse {
|
||||||
#[prost(bool, tag = "1")]
|
#[prost(bool, tag = "1")]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
#[prost(bytes = "bytes", tag = "2")]
|
#[prost(bytes = "vec", tag = "2")]
|
||||||
pub metacache: ::prost::bytes::Bytes,
|
pub metacache: ::prost::alloc::vec::Vec<u8>,
|
||||||
#[prost(string, optional, tag = "3")]
|
#[prost(string, optional, tag = "3")]
|
||||||
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
pub error_info: ::core::option::Option<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
@@ -1105,9 +1091,9 @@ pub mod node_service_client {
|
|||||||
F: tonic::service::Interceptor,
|
F: tonic::service::Interceptor,
|
||||||
T::ResponseBody: Default,
|
T::ResponseBody: Default,
|
||||||
T: tonic::codegen::Service<
|
T: tonic::codegen::Service<
|
||||||
http::Request<tonic::body::Body>,
|
http::Request<tonic::body::Body>,
|
||||||
Response = http::Response<<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody>,
|
Response = http::Response<<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody>,
|
||||||
>,
|
>,
|
||||||
<T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
|
<T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
|
||||||
Into<StdError> + std::marker::Send + std::marker::Sync,
|
Into<StdError> + std::marker::Send + std::marker::Sync,
|
||||||
{
|
{
|
||||||
@@ -1312,7 +1298,7 @@ pub mod node_service_client {
|
|||||||
}
|
}
|
||||||
pub async fn rename_part(
|
pub async fn rename_part(
|
||||||
&mut self,
|
&mut self,
|
||||||
request: impl tonic::IntoRequest<super::RenamePartRequest>,
|
request: impl tonic::IntoRequest<super::RenamePartRequst>,
|
||||||
) -> std::result::Result<tonic::Response<super::RenamePartResponse>, tonic::Status> {
|
) -> std::result::Result<tonic::Response<super::RenamePartResponse>, tonic::Status> {
|
||||||
self.inner
|
self.inner
|
||||||
.ready()
|
.ready()
|
||||||
@@ -1327,7 +1313,7 @@ pub mod node_service_client {
|
|||||||
}
|
}
|
||||||
pub async fn rename_file(
|
pub async fn rename_file(
|
||||||
&mut self,
|
&mut self,
|
||||||
request: impl tonic::IntoRequest<super::RenameFileRequest>,
|
request: impl tonic::IntoRequest<super::RenameFileRequst>,
|
||||||
) -> std::result::Result<tonic::Response<super::RenameFileResponse>, tonic::Status> {
|
) -> std::result::Result<tonic::Response<super::RenameFileResponse>, tonic::Status> {
|
||||||
self.inner
|
self.inner
|
||||||
.ready()
|
.ready()
|
||||||
@@ -2344,11 +2330,11 @@ pub mod node_service_server {
|
|||||||
) -> std::result::Result<tonic::Response<super::CheckPartsResponse>, tonic::Status>;
|
) -> std::result::Result<tonic::Response<super::CheckPartsResponse>, tonic::Status>;
|
||||||
async fn rename_part(
|
async fn rename_part(
|
||||||
&self,
|
&self,
|
||||||
request: tonic::Request<super::RenamePartRequest>,
|
request: tonic::Request<super::RenamePartRequst>,
|
||||||
) -> std::result::Result<tonic::Response<super::RenamePartResponse>, tonic::Status>;
|
) -> std::result::Result<tonic::Response<super::RenamePartResponse>, tonic::Status>;
|
||||||
async fn rename_file(
|
async fn rename_file(
|
||||||
&self,
|
&self,
|
||||||
request: tonic::Request<super::RenameFileRequest>,
|
request: tonic::Request<super::RenameFileRequst>,
|
||||||
) -> std::result::Result<tonic::Response<super::RenameFileResponse>, tonic::Status>;
|
) -> std::result::Result<tonic::Response<super::RenameFileResponse>, tonic::Status>;
|
||||||
async fn write(
|
async fn write(
|
||||||
&self,
|
&self,
|
||||||
@@ -3003,10 +2989,10 @@ pub mod node_service_server {
|
|||||||
"/node_service.NodeService/RenamePart" => {
|
"/node_service.NodeService/RenamePart" => {
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
struct RenamePartSvc<T: NodeService>(pub Arc<T>);
|
struct RenamePartSvc<T: NodeService>(pub Arc<T>);
|
||||||
impl<T: NodeService> tonic::server::UnaryService<super::RenamePartRequest> for RenamePartSvc<T> {
|
impl<T: NodeService> tonic::server::UnaryService<super::RenamePartRequst> for RenamePartSvc<T> {
|
||||||
type Response = super::RenamePartResponse;
|
type Response = super::RenamePartResponse;
|
||||||
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
|
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
|
||||||
fn call(&mut self, request: tonic::Request<super::RenamePartRequest>) -> Self::Future {
|
fn call(&mut self, request: tonic::Request<super::RenamePartRequst>) -> Self::Future {
|
||||||
let inner = Arc::clone(&self.0);
|
let inner = Arc::clone(&self.0);
|
||||||
let fut = async move { <T as NodeService>::rename_part(&inner, request).await };
|
let fut = async move { <T as NodeService>::rename_part(&inner, request).await };
|
||||||
Box::pin(fut)
|
Box::pin(fut)
|
||||||
@@ -3031,10 +3017,10 @@ pub mod node_service_server {
|
|||||||
"/node_service.NodeService/RenameFile" => {
|
"/node_service.NodeService/RenameFile" => {
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
struct RenameFileSvc<T: NodeService>(pub Arc<T>);
|
struct RenameFileSvc<T: NodeService>(pub Arc<T>);
|
||||||
impl<T: NodeService> tonic::server::UnaryService<super::RenameFileRequest> for RenameFileSvc<T> {
|
impl<T: NodeService> tonic::server::UnaryService<super::RenameFileRequst> for RenameFileSvc<T> {
|
||||||
type Response = super::RenameFileResponse;
|
type Response = super::RenameFileResponse;
|
||||||
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
|
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
|
||||||
fn call(&mut self, request: tonic::Request<super::RenameFileRequest>) -> Self::Future {
|
fn call(&mut self, request: tonic::Request<super::RenameFileRequst>) -> Self::Future {
|
||||||
let inner = Arc::clone(&self.0);
|
let inner = Arc::clone(&self.0);
|
||||||
let fut = async move { <T as NodeService>::rename_file(&inner, request).await };
|
let fut = async move { <T as NodeService>::rename_file(&inner, request).await };
|
||||||
Box::pin(fut)
|
Box::pin(fut)
|
||||||
@@ -1,30 +1,16 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
mod generated;
|
mod generated;
|
||||||
|
|
||||||
use std::{error::Error, time::Duration};
|
use std::{error::Error, time::Duration};
|
||||||
|
|
||||||
|
use common::globals::GLOBAL_Conn_Map;
|
||||||
pub use generated::*;
|
pub use generated::*;
|
||||||
use proto_gen::node_service::node_service_client::NodeServiceClient;
|
use proto_gen::node_service::node_service_client::NodeServiceClient;
|
||||||
use rustfs_common::globals::GLOBAL_Conn_Map;
|
|
||||||
use tonic::{
|
use tonic::{
|
||||||
Request, Status,
|
|
||||||
metadata::MetadataValue,
|
metadata::MetadataValue,
|
||||||
service::interceptor::InterceptedService,
|
service::interceptor::InterceptedService,
|
||||||
transport::{Channel, Endpoint},
|
transport::{Channel, Endpoint},
|
||||||
|
Request, Status,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Default 100 MB
|
// Default 100 MB
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use std::{cmp, env, fs, io::Write, path::Path, process::Command};
|
use std::{cmp, env, fs, io::Write, path::Path, process::Command};
|
||||||
|
|
||||||
type AnyError = Box<dyn std::error::Error>;
|
type AnyError = Box<dyn std::error::Error>;
|
||||||
@@ -45,7 +31,7 @@ fn main() -> Result<(), AnyError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// path of proto file
|
// path of proto file
|
||||||
let project_root_dir = env::current_dir()?.join("");
|
let project_root_dir = env::current_dir()?.join("common/protos/src");
|
||||||
let proto_dir = project_root_dir.clone();
|
let proto_dir = project_root_dir.clone();
|
||||||
let proto_files = &["node.proto"];
|
let proto_files = &["node.proto"];
|
||||||
let proto_out_dir = project_root_dir.join("generated").join("proto_gen");
|
let proto_out_dir = project_root_dir.join("generated").join("proto_gen");
|
||||||
@@ -57,7 +43,6 @@ fn main() -> Result<(), AnyError> {
|
|||||||
// .file_descriptor_set_path(descriptor_set_path)
|
// .file_descriptor_set_path(descriptor_set_path)
|
||||||
.protoc_arg("--experimental_allow_proto3_optional")
|
.protoc_arg("--experimental_allow_proto3_optional")
|
||||||
.compile_well_known_types(true)
|
.compile_well_known_types(true)
|
||||||
.bytes(["."])
|
|
||||||
.emit_rerun_if_changed(false)
|
.emit_rerun_if_changed(false)
|
||||||
.compile_protos(proto_files, &[proto_dir.clone()])
|
.compile_protos(proto_files, &[proto_dir.clone()])
|
||||||
.map_err(|e| format!("Failed to generate protobuf file: {e}."))?;
|
.map_err(|e| format!("Failed to generate protobuf file: {e}."))?;
|
||||||
@@ -275,11 +260,11 @@ fn fmt() {
|
|||||||
if status.success() {
|
if status.success() {
|
||||||
println!("cargo fmt executed successfully.");
|
println!("cargo fmt executed successfully.");
|
||||||
} else {
|
} else {
|
||||||
eprintln!("cargo fmt failed with status: {status:?}");
|
eprintln!("cargo fmt failed with status: {:?}", status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to execute cargo fmt: {e}");
|
eprintln!("Failed to execute cargo fmt: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package node_service;
|
package node_service;
|
||||||
|
|
||||||
@@ -143,7 +129,7 @@ message CheckPartsResponse {
|
|||||||
optional Error error = 3;
|
optional Error error = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RenamePartRequest {
|
message RenamePartRequst {
|
||||||
string disk = 1;
|
string disk = 1;
|
||||||
string src_volume = 2;
|
string src_volume = 2;
|
||||||
string src_path = 3;
|
string src_path = 3;
|
||||||
@@ -157,7 +143,7 @@ message RenamePartResponse {
|
|||||||
optional Error error = 2;
|
optional Error error = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RenameFileRequest {
|
message RenameFileRequst {
|
||||||
string disk = 1;
|
string disk = 1;
|
||||||
string src_volume = 2;
|
string src_volume = 2;
|
||||||
string src_path = 3;
|
string src_path = 3;
|
||||||
@@ -189,7 +175,7 @@ message WriteResponse {
|
|||||||
// string path = 3;
|
// string path = 3;
|
||||||
// bytes data = 4;
|
// bytes data = 4;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// message AppendResponse {
|
// message AppendResponse {
|
||||||
// bool success = 1;
|
// bool success = 1;
|
||||||
// optional Error error = 2;
|
// optional Error error = 2;
|
||||||
@@ -769,8 +755,8 @@ service NodeService {
|
|||||||
rpc Delete(DeleteRequest) returns (DeleteResponse) {};
|
rpc Delete(DeleteRequest) returns (DeleteResponse) {};
|
||||||
rpc VerifyFile(VerifyFileRequest) returns (VerifyFileResponse) {};
|
rpc VerifyFile(VerifyFileRequest) returns (VerifyFileResponse) {};
|
||||||
rpc CheckParts(CheckPartsRequest) returns (CheckPartsResponse) {};
|
rpc CheckParts(CheckPartsRequest) returns (CheckPartsResponse) {};
|
||||||
rpc RenamePart(RenamePartRequest) returns (RenamePartResponse) {};
|
rpc RenamePart(RenamePartRequst) returns (RenamePartResponse) {};
|
||||||
rpc RenameFile(RenameFileRequest) returns (RenameFileResponse) {};
|
rpc RenameFile(RenameFileRequst) returns (RenameFileResponse) {};
|
||||||
rpc Write(WriteRequest) returns (WriteResponse) {};
|
rpc Write(WriteRequest) returns (WriteResponse) {};
|
||||||
rpc WriteStream(stream WriteRequest) returns (stream WriteResponse) {};
|
rpc WriteStream(stream WriteRequest) returns (stream WriteResponse) {};
|
||||||
// rpc Append(AppendRequest) returns (AppendResponse) {};
|
// rpc Append(AppendRequest) returns (AppendResponse) {};
|
||||||
15
common/workers/Cargo.toml
Normal file
15
common/workers/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[package]
|
||||||
|
name = "workers"
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
version.workspace = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
common.workspace = true
|
||||||
|
tokio.workspace = true
|
||||||
|
tracing.workspace = true
|
||||||
1
common/workers/src/lib.rs
Normal file
1
common/workers/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod workers;
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::{Mutex, Notify};
|
use tokio::sync::{Mutex, Notify};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
[package]
|
|
||||||
name = "rustfs-appauth"
|
|
||||||
edition.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
repository.workspace = true
|
|
||||||
rust-version.workspace = true
|
|
||||||
version.workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
base64-simd = { workspace = true }
|
|
||||||
rsa = { workspace = true }
|
|
||||||
serde.workspace = true
|
|
||||||
serde_json.workspace = true
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
pub mod token;
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
[package]
|
|
||||||
name = "rustfs-common"
|
|
||||||
version.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
repository.workspace = true
|
|
||||||
rust-version.workspace = true
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
lazy_static.workspace = true
|
|
||||||
tokio.workspace = true
|
|
||||||
tonic = { workspace = true }
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
pub mod bucket_stats;
|
|
||||||
// pub mod error;
|
|
||||||
pub mod globals;
|
|
||||||
pub mod last_minute;
|
|
||||||
|
|
||||||
// is ','
|
|
||||||
pub static DEFAULT_DELIMITER: u8 = 44;
|
|
||||||
|
|
||||||
/// Defers evaluation of a block of code until the end of the scope.
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! defer {
|
|
||||||
($($body:tt)*) => {
|
|
||||||
let _guard = {
|
|
||||||
pub struct Guard<F: FnOnce()>(Option<F>);
|
|
||||||
|
|
||||||
impl<F: FnOnce()> Drop for Guard<F> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
(self.0).take().map(|f| f());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Guard(Some(|| {
|
|
||||||
let _ = { $($body)* };
|
|
||||||
}))
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
# Copyright 2024 RustFS Team
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "rustfs-config"
|
name = "rustfs-config"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
@@ -21,17 +7,22 @@ rust-version.workspace = true
|
|||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
const-str = { workspace = true, optional = true }
|
config = { workspace = true }
|
||||||
|
const-str = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
|
tokio = { workspace = true, features = ["sync", "rt"] }
|
||||||
|
once_cell = { workspace = true }
|
||||||
|
thiserror = { workspace = true }
|
||||||
|
tracing = { workspace = true }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tokio = { workspace = true, features = [
|
||||||
|
"sync",
|
||||||
|
"rt",
|
||||||
|
"macros",
|
||||||
|
"rt-multi-thread",
|
||||||
|
] }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
constants = ["dep:const-str"]
|
|
||||||
notify = ["dep:const-str"]
|
|
||||||
observability = []
|
|
||||||
|
|
||||||
|
|||||||
200
crates/config/src/config.rs
Normal file
200
crates/config/src/config.rs
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
use crate::event::config::NotifierConfig;
|
||||||
|
use crate::ObservabilityConfig;
|
||||||
|
|
||||||
|
/// RustFs configuration
|
||||||
|
pub struct RustFsConfig {
|
||||||
|
pub observability: ObservabilityConfig,
|
||||||
|
pub event: NotifierConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RustFsConfig {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
observability: ObservabilityConfig::new(),
|
||||||
|
event: NotifierConfig::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for RustFsConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_new() {
|
||||||
|
let config = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Verify that observability config is properly initialized
|
||||||
|
assert!(!config.observability.sinks.is_empty(), "Observability sinks should not be empty");
|
||||||
|
assert!(config.observability.logger.is_some(), "Logger config should be present");
|
||||||
|
|
||||||
|
// Verify that event config is properly initialized
|
||||||
|
assert!(!config.event.store_path.is_empty(), "Event store path should not be empty");
|
||||||
|
assert!(config.event.channel_capacity > 0, "Channel capacity should be positive");
|
||||||
|
assert!(!config.event.adapters.is_empty(), "Event adapters should not be empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_default() {
|
||||||
|
let config = RustFsConfig::default();
|
||||||
|
|
||||||
|
// Default should be equivalent to new()
|
||||||
|
let new_config = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Compare observability config
|
||||||
|
assert_eq!(config.observability.sinks.len(), new_config.observability.sinks.len());
|
||||||
|
assert_eq!(config.observability.logger.is_some(), new_config.observability.logger.is_some());
|
||||||
|
|
||||||
|
// Compare event config
|
||||||
|
assert_eq!(config.event.store_path, new_config.event.store_path);
|
||||||
|
assert_eq!(config.event.channel_capacity, new_config.event.channel_capacity);
|
||||||
|
assert_eq!(config.event.adapters.len(), new_config.event.adapters.len());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_components_independence() {
|
||||||
|
let mut config = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Modify observability config
|
||||||
|
config.observability.sinks.clear();
|
||||||
|
|
||||||
|
// Event config should remain unchanged
|
||||||
|
assert!(!config.event.adapters.is_empty(), "Event adapters should remain unchanged");
|
||||||
|
assert!(config.event.channel_capacity > 0, "Channel capacity should remain unchanged");
|
||||||
|
|
||||||
|
// Create new config to verify independence
|
||||||
|
let new_config = RustFsConfig::new();
|
||||||
|
assert!(!new_config.observability.sinks.is_empty(), "New config should have default sinks");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_observability_integration() {
|
||||||
|
let config = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Test observability config properties
|
||||||
|
assert!(config.observability.otel.endpoint.is_empty() || !config.observability.otel.endpoint.is_empty());
|
||||||
|
assert!(config.observability.otel.use_stdout.is_some());
|
||||||
|
assert!(config.observability.otel.sample_ratio.is_some());
|
||||||
|
assert!(config.observability.otel.meter_interval.is_some());
|
||||||
|
assert!(config.observability.otel.service_name.is_some());
|
||||||
|
assert!(config.observability.otel.service_version.is_some());
|
||||||
|
assert!(config.observability.otel.environment.is_some());
|
||||||
|
assert!(config.observability.otel.logger_level.is_some());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_event_integration() {
|
||||||
|
let config = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Test event config properties
|
||||||
|
assert!(!config.event.store_path.is_empty(), "Store path should not be empty");
|
||||||
|
assert!(
|
||||||
|
config.event.channel_capacity >= 1000,
|
||||||
|
"Channel capacity should be reasonable for production"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Test that store path is a valid path format
|
||||||
|
let store_path = &config.event.store_path;
|
||||||
|
assert!(!store_path.contains('\0'), "Store path should not contain null characters");
|
||||||
|
|
||||||
|
// Test adapters configuration
|
||||||
|
for adapter in &config.event.adapters {
|
||||||
|
// Each adapter should have a valid configuration
|
||||||
|
match adapter {
|
||||||
|
crate::event::adapters::AdapterConfig::Webhook(_) => {
|
||||||
|
// Webhook adapter should be properly configured
|
||||||
|
}
|
||||||
|
crate::event::adapters::AdapterConfig::Kafka(_) => {
|
||||||
|
// Kafka adapter should be properly configured
|
||||||
|
}
|
||||||
|
crate::event::adapters::AdapterConfig::Mqtt(_) => {
|
||||||
|
// MQTT adapter should be properly configured
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_memory_usage() {
|
||||||
|
// Test that config doesn't use excessive memory
|
||||||
|
let config = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Basic memory usage checks
|
||||||
|
assert!(std::mem::size_of_val(&config) < 10000, "Config should not use excessive memory");
|
||||||
|
|
||||||
|
// Test that strings are not excessively long
|
||||||
|
assert!(config.event.store_path.len() < 1000, "Store path should not be excessively long");
|
||||||
|
|
||||||
|
// Test that collections are reasonably sized
|
||||||
|
assert!(config.observability.sinks.len() < 100, "Sinks collection should be reasonably sized");
|
||||||
|
assert!(config.event.adapters.len() < 100, "Adapters collection should be reasonably sized");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_serialization_compatibility() {
|
||||||
|
let config = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Test that observability config can be serialized (it has Serialize trait)
|
||||||
|
let observability_json = serde_json::to_string(&config.observability);
|
||||||
|
assert!(observability_json.is_ok(), "Observability config should be serializable");
|
||||||
|
|
||||||
|
// Test that event config can be serialized (it has Serialize trait)
|
||||||
|
let event_json = serde_json::to_string(&config.event);
|
||||||
|
assert!(event_json.is_ok(), "Event config should be serializable");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_debug_format() {
|
||||||
|
let config = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Test that observability config has Debug trait
|
||||||
|
let observability_debug = format!("{:?}", config.observability);
|
||||||
|
assert!(!observability_debug.is_empty(), "Observability config should have debug output");
|
||||||
|
assert!(
|
||||||
|
observability_debug.contains("ObservabilityConfig"),
|
||||||
|
"Debug output should contain type name"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Test that event config has Debug trait
|
||||||
|
let event_debug = format!("{:?}", config.event);
|
||||||
|
assert!(!event_debug.is_empty(), "Event config should have debug output");
|
||||||
|
assert!(event_debug.contains("NotifierConfig"), "Debug output should contain type name");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_clone_behavior() {
|
||||||
|
let config = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Test that observability config can be cloned
|
||||||
|
let observability_clone = config.observability.clone();
|
||||||
|
assert_eq!(observability_clone.sinks.len(), config.observability.sinks.len());
|
||||||
|
|
||||||
|
// Test that event config can be cloned
|
||||||
|
let event_clone = config.event.clone();
|
||||||
|
assert_eq!(event_clone.store_path, config.event.store_path);
|
||||||
|
assert_eq!(event_clone.channel_capacity, config.event.channel_capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rustfs_config_environment_independence() {
|
||||||
|
// Test that config creation doesn't depend on specific environment variables
|
||||||
|
// This test ensures the config can be created in any environment
|
||||||
|
|
||||||
|
let config1 = RustFsConfig::new();
|
||||||
|
let config2 = RustFsConfig::new();
|
||||||
|
|
||||||
|
// Both configs should have the same structure
|
||||||
|
assert_eq!(config1.observability.sinks.len(), config2.observability.sinks.len());
|
||||||
|
assert_eq!(config1.event.adapters.len(), config2.event.adapters.len());
|
||||||
|
|
||||||
|
// Store paths should be consistent
|
||||||
|
assert_eq!(config1.event.store_path, config2.event.store_path);
|
||||||
|
assert_eq!(config1.event.channel_capacity, config2.event.channel_capacity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2024 RustFS Team
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
use const_str::concat;
|
use const_str::concat;
|
||||||
|
|
||||||
/// Application name
|
/// Application name
|
||||||
@@ -115,7 +101,7 @@ pub const DEFAULT_LOG_FILENAME: &str = "rustfs.log";
|
|||||||
/// It is used to store the logs of the application.
|
/// It is used to store the logs of the application.
|
||||||
/// Default value: logs
|
/// Default value: logs
|
||||||
/// Environment variable: RUSTFS_OBSERVABILITY_LOG_DIRECTORY
|
/// Environment variable: RUSTFS_OBSERVABILITY_LOG_DIRECTORY
|
||||||
pub const DEFAULT_LOG_DIR: &str = "deploy/logs";
|
pub const DEFAULT_LOG_DIR: &str = "logs";
|
||||||
|
|
||||||
/// Default log rotation size mb for rustfs
|
/// Default log rotation size mb for rustfs
|
||||||
/// This is the default log rotation size for rustfs.
|
/// This is the default log rotation size for rustfs.
|
||||||
@@ -214,7 +200,7 @@ mod tests {
|
|||||||
// Test port related constants
|
// Test port related constants
|
||||||
assert_eq!(DEFAULT_PORT, 9000);
|
assert_eq!(DEFAULT_PORT, 9000);
|
||||||
|
|
||||||
assert_eq!(DEFAULT_CONSOLE_PORT, 9001);
|
assert_eq!(DEFAULT_CONSOLE_PORT, 9002);
|
||||||
|
|
||||||
assert_ne!(DEFAULT_PORT, DEFAULT_CONSOLE_PORT, "Main port and console port should be different");
|
assert_ne!(DEFAULT_PORT, DEFAULT_CONSOLE_PORT, "Main port and console port should be different");
|
||||||
}
|
}
|
||||||
@@ -229,7 +215,7 @@ mod tests {
|
|||||||
"Address should contain the default port"
|
"Address should contain the default port"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(DEFAULT_CONSOLE_ADDRESS, ":9001");
|
assert_eq!(DEFAULT_CONSOLE_ADDRESS, ":9002");
|
||||||
assert!(DEFAULT_CONSOLE_ADDRESS.starts_with(':'), "Console address should start with colon");
|
assert!(DEFAULT_CONSOLE_ADDRESS.starts_with(':'), "Console address should start with colon");
|
||||||
assert!(
|
assert!(
|
||||||
DEFAULT_CONSOLE_ADDRESS.contains(&DEFAULT_CONSOLE_PORT.to_string()),
|
DEFAULT_CONSOLE_ADDRESS.contains(&DEFAULT_CONSOLE_PORT.to_string()),
|
||||||
@@ -245,10 +231,10 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_const_str_concat_functionality() {
|
fn test_const_str_concat_functionality() {
|
||||||
// Test const_str::concat macro functionality
|
// Test const_str::concat macro functionality
|
||||||
let expected_address = format!(":{DEFAULT_PORT}");
|
let expected_address = format!(":{}", DEFAULT_PORT);
|
||||||
assert_eq!(DEFAULT_ADDRESS, expected_address);
|
assert_eq!(DEFAULT_ADDRESS, expected_address);
|
||||||
|
|
||||||
let expected_console_address = format!(":{DEFAULT_CONSOLE_PORT}");
|
let expected_console_address = format!(":{}", DEFAULT_CONSOLE_PORT);
|
||||||
assert_eq!(DEFAULT_CONSOLE_ADDRESS, expected_console_address);
|
assert_eq!(DEFAULT_CONSOLE_ADDRESS, expected_console_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,9 +256,9 @@ mod tests {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for constant in &string_constants {
|
for constant in &string_constants {
|
||||||
assert!(!constant.is_empty(), "String constant should not be empty: {constant}");
|
assert!(!constant.is_empty(), "String constant should not be empty: {}", constant);
|
||||||
assert!(!constant.starts_with(' '), "String constant should not start with space: {constant}");
|
assert!(!constant.starts_with(' '), "String constant should not start with space: {}", constant);
|
||||||
assert!(!constant.ends_with(' '), "String constant should not end with space: {constant}");
|
assert!(!constant.ends_with(' '), "String constant should not end with space: {}", constant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,8 +284,8 @@ mod tests {
|
|||||||
|
|
||||||
// These are default values, should be changed in production environments
|
// These are default values, should be changed in production environments
|
||||||
println!("Security Warning: Default credentials detected!");
|
println!("Security Warning: Default credentials detected!");
|
||||||
println!("Access Key: {DEFAULT_ACCESS_KEY}");
|
println!("Access Key: {}", DEFAULT_ACCESS_KEY);
|
||||||
println!("Secret Key: {DEFAULT_SECRET_KEY}");
|
println!("Secret Key: {}", DEFAULT_SECRET_KEY);
|
||||||
println!("These should be changed in production environments!");
|
println!("These should be changed in production environments!");
|
||||||
|
|
||||||
// Verify that key lengths meet minimum security requirements
|
// Verify that key lengths meet minimum security requirements
|
||||||
@@ -326,11 +312,11 @@ mod tests {
|
|||||||
let ports = [DEFAULT_PORT, DEFAULT_CONSOLE_PORT];
|
let ports = [DEFAULT_PORT, DEFAULT_CONSOLE_PORT];
|
||||||
let mut unique_ports = std::collections::HashSet::new();
|
let mut unique_ports = std::collections::HashSet::new();
|
||||||
for port in &ports {
|
for port in &ports {
|
||||||
assert!(unique_ports.insert(port), "Port {port} is duplicated");
|
assert!(unique_ports.insert(port), "Port {} is duplicated", port);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Address format consistency
|
// Address format consistency
|
||||||
assert_eq!(DEFAULT_ADDRESS, format!(":{DEFAULT_PORT}"));
|
assert_eq!(DEFAULT_ADDRESS, format!(":{}", DEFAULT_PORT));
|
||||||
assert_eq!(DEFAULT_CONSOLE_ADDRESS, format!(":{DEFAULT_CONSOLE_PORT}"));
|
assert_eq!(DEFAULT_CONSOLE_ADDRESS, format!(":{}", DEFAULT_CONSOLE_PORT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user