├── .gitignore ├── LICENSE ├── README.md ├── assets ├── .DS_Store ├── CNAME ├── banner1.png ├── bigPicture.js └── custom.js ├── book.toml ├── deploy ├── src ├── .DS_Store └── SUMMARY.md └── theme ├── index.hbs └── style.css /.gitignore: -------------------------------------------------------------------------------- 1 | book 2 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More_considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution 4.0 International Public License 58 | 59 | By exercising the Licensed Rights (defined below), You accept and agree 60 | to be bound by the terms and conditions of this Creative Commons 61 | Attribution 4.0 International Public License ("Public License"). To the 62 | extent this Public License may be interpreted as a contract, You are 63 | granted the Licensed Rights in consideration of Your acceptance of 64 | these terms and conditions, and the Licensor grants You such rights in 65 | consideration of benefits the Licensor receives from making the 66 | Licensed Material available under these terms and conditions. 67 | 68 | 69 | Section 1 -- Definitions. 70 | 71 | a. Adapted Material means material subject to Copyright and Similar 72 | Rights that is derived from or based upon the Licensed Material 73 | and in which the Licensed Material is translated, altered, 74 | arranged, transformed, or otherwise modified in a manner requiring 75 | permission under the Copyright and Similar Rights held by the 76 | Licensor. For purposes of this Public License, where the Licensed 77 | Material is a musical work, performance, or sound recording, 78 | Adapted Material is always produced where the Licensed Material is 79 | synched in timed relation with a moving image. 80 | 81 | b. Adapter's License means the license You apply to Your Copyright 82 | and Similar Rights in Your contributions to Adapted Material in 83 | accordance with the terms and conditions of this Public License. 84 | 85 | c. Copyright and Similar Rights means copyright and/or similar rights 86 | closely related to copyright including, without limitation, 87 | performance, broadcast, sound recording, and Sui Generis Database 88 | Rights, without regard to how the rights are labeled or 89 | categorized. For purposes of this Public License, the rights 90 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 91 | Rights. 92 | 93 | d. Effective Technological Measures means those measures that, in the 94 | absence of proper authority, may not be circumvented under laws 95 | fulfilling obligations under Article 11 of the WIPO Copyright 96 | Treaty adopted on December 20, 1996, and/or similar international 97 | agreements. 98 | 99 | e. Exceptions and Limitations means fair use, fair dealing, and/or 100 | any other exception or limitation to Copyright and Similar Rights 101 | that applies to Your use of the Licensed Material. 102 | 103 | f. Licensed Material means the artistic or literary work, database, 104 | or other material to which the Licensor applied this Public 105 | License. 106 | 107 | g. Licensed Rights means the rights granted to You subject to the 108 | terms and conditions of this Public License, which are limited to 109 | all Copyright and Similar Rights that apply to Your use of the 110 | Licensed Material and that the Licensor has authority to license. 111 | 112 | h. Licensor means the individual(s) or entity(ies) granting rights 113 | under this Public License. 114 | 115 | i. Share means to provide material to the public by any means or 116 | process that requires permission under the Licensed Rights, such 117 | as reproduction, public display, public performance, distribution, 118 | dissemination, communication, or importation, and to make material 119 | available to the public including in ways that members of the 120 | public may access the material from a place and at a time 121 | individually chosen by them. 122 | 123 | j. Sui Generis Database Rights means rights other than copyright 124 | resulting from Directive 96/9/EC of the European Parliament and of 125 | the Council of 11 March 1996 on the legal protection of databases, 126 | as amended and/or succeeded, as well as other essentially 127 | equivalent rights anywhere in the world. 128 | 129 | k. You means the individual or entity exercising the Licensed Rights 130 | under this Public License. Your has a corresponding meaning. 131 | 132 | 133 | Section 2 -- Scope. 134 | 135 | a. License grant. 136 | 137 | 1. Subject to the terms and conditions of this Public License, 138 | the Licensor hereby grants You a worldwide, royalty-free, 139 | non-sublicensable, non-exclusive, irrevocable license to 140 | exercise the Licensed Rights in the Licensed Material to: 141 | 142 | a. reproduce and Share the Licensed Material, in whole or 143 | in part; and 144 | 145 | b. produce, reproduce, and Share Adapted Material. 146 | 147 | 2. Exceptions and Limitations. For the avoidance of doubt, where 148 | Exceptions and Limitations apply to Your use, this Public 149 | License does not apply, and You do not need to comply with 150 | its terms and conditions. 151 | 152 | 3. Term. The term of this Public License is specified in Section 153 | 6(a). 154 | 155 | 4. Media and formats; technical modifications allowed. The 156 | Licensor authorizes You to exercise the Licensed Rights in 157 | all media and formats whether now known or hereafter created, 158 | and to make technical modifications necessary to do so. The 159 | Licensor waives and/or agrees not to assert any right or 160 | authority to forbid You from making technical modifications 161 | necessary to exercise the Licensed Rights, including 162 | technical modifications necessary to circumvent Effective 163 | Technological Measures. For purposes of this Public License, 164 | simply making modifications authorized by this Section 2(a) 165 | (4) never produces Adapted Material. 166 | 167 | 5. Downstream recipients. 168 | 169 | a. Offer from the Licensor -- Licensed Material. Every 170 | recipient of the Licensed Material automatically 171 | receives an offer from the Licensor to exercise the 172 | Licensed Rights under the terms and conditions of this 173 | Public License. 174 | 175 | b. No downstream restrictions. You may not offer or impose 176 | any additional or different terms or conditions on, or 177 | apply any Effective Technological Measures to, the 178 | Licensed Material if doing so restricts exercise of the 179 | Licensed Rights by any recipient of the Licensed 180 | Material. 181 | 182 | 6. No endorsement. Nothing in this Public License constitutes or 183 | may be construed as permission to assert or imply that You 184 | are, or that Your use of the Licensed Material is, connected 185 | with, or sponsored, endorsed, or granted official status by, 186 | the Licensor or others designated to receive attribution as 187 | provided in Section 3(a)(1)(A)(i). 188 | 189 | b. Other rights. 190 | 191 | 1. Moral rights, such as the right of integrity, are not 192 | licensed under this Public License, nor are publicity, 193 | privacy, and/or other similar personality rights; however, to 194 | the extent possible, the Licensor waives and/or agrees not to 195 | assert any such rights held by the Licensor to the limited 196 | extent necessary to allow You to exercise the Licensed 197 | Rights, but not otherwise. 198 | 199 | 2. Patent and trademark rights are not licensed under this 200 | Public License. 201 | 202 | 3. To the extent possible, the Licensor waives any right to 203 | collect royalties from You for the exercise of the Licensed 204 | Rights, whether directly or through a collecting society 205 | under any voluntary or waivable statutory or compulsory 206 | licensing scheme. In all other cases the Licensor expressly 207 | reserves any right to collect such royalties. 208 | 209 | 210 | Section 3 -- License Conditions. 211 | 212 | Your exercise of the Licensed Rights is expressly made subject to the 213 | following conditions. 214 | 215 | a. Attribution. 216 | 217 | 1. If You Share the Licensed Material (including in modified 218 | form), You must: 219 | 220 | a. retain the following if it is supplied by the Licensor 221 | with the Licensed Material: 222 | 223 | i. identification of the creator(s) of the Licensed 224 | Material and any others designated to receive 225 | attribution, in any reasonable manner requested by 226 | the Licensor (including by pseudonym if 227 | designated); 228 | 229 | ii. a copyright notice; 230 | 231 | iii. a notice that refers to this Public License; 232 | 233 | iv. a notice that refers to the disclaimer of 234 | warranties; 235 | 236 | v. a URI or hyperlink to the Licensed Material to the 237 | extent reasonably practicable; 238 | 239 | b. indicate if You modified the Licensed Material and 240 | retain an indication of any previous modifications; and 241 | 242 | c. indicate the Licensed Material is licensed under this 243 | Public License, and include the text of, or the URI or 244 | hyperlink to, this Public License. 245 | 246 | 2. You may satisfy the conditions in Section 3(a)(1) in any 247 | reasonable manner based on the medium, means, and context in 248 | which You Share the Licensed Material. For example, it may be 249 | reasonable to satisfy the conditions by providing a URI or 250 | hyperlink to a resource that includes the required 251 | information. 252 | 253 | 3. If requested by the Licensor, You must remove any of the 254 | information required by Section 3(a)(1)(A) to the extent 255 | reasonably practicable. 256 | 257 | 4. If You Share Adapted Material You produce, the Adapter's 258 | License You apply must not prevent recipients of the Adapted 259 | Material from complying with this Public License. 260 | 261 | 262 | Section 4 -- Sui Generis Database Rights. 263 | 264 | Where the Licensed Rights include Sui Generis Database Rights that 265 | apply to Your use of the Licensed Material: 266 | 267 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 268 | to extract, reuse, reproduce, and Share all or a substantial 269 | portion of the contents of the database; 270 | 271 | b. if You include all or a substantial portion of the database 272 | contents in a database in which You have Sui Generis Database 273 | Rights, then the database in which You have Sui Generis Database 274 | Rights (but not its individual contents) is Adapted Material; and 275 | 276 | c. You must comply with the conditions in Section 3(a) if You Share 277 | all or a substantial portion of the contents of the database. 278 | 279 | For the avoidance of doubt, this Section 4 supplements and does not 280 | replace Your obligations under this Public License where the Licensed 281 | Rights include other Copyright and Similar Rights. 282 | 283 | 284 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 285 | 286 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 287 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 288 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 289 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 290 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 291 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 292 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 293 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 294 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 295 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 296 | 297 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 298 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 299 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 300 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 301 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 302 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 303 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 304 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 305 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 306 | 307 | c. The disclaimer of warranties and limitation of liability provided 308 | above shall be interpreted in a manner that, to the extent 309 | possible, most closely approximates an absolute disclaimer and 310 | waiver of all liability. 311 | 312 | 313 | Section 6 -- Term and Termination. 314 | 315 | a. This Public License applies for the term of the Copyright and 316 | Similar Rights licensed here. However, if You fail to comply with 317 | this Public License, then Your rights under this Public License 318 | terminate automatically. 319 | 320 | b. Where Your right to use the Licensed Material has terminated under 321 | Section 6(a), it reinstates: 322 | 323 | 1. automatically as of the date the violation is cured, provided 324 | it is cured within 30 days of Your discovery of the 325 | violation; or 326 | 327 | 2. upon express reinstatement by the Licensor. 328 | 329 | For the avoidance of doubt, this Section 6(b) does not affect any 330 | right the Licensor may have to seek remedies for Your violations 331 | of this Public License. 332 | 333 | c. For the avoidance of doubt, the Licensor may also offer the 334 | Licensed Material under separate terms or conditions or stop 335 | distributing the Licensed Material at any time; however, doing so 336 | will not terminate this Public License. 337 | 338 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 339 | License. 340 | 341 | 342 | Section 7 -- Other Terms and Conditions. 343 | 344 | a. The Licensor shall not be bound by any additional or different 345 | terms or conditions communicated by You unless expressly agreed. 346 | 347 | b. Any arrangements, understandings, or agreements regarding the 348 | Licensed Material not stated herein are separate from and 349 | independent of the terms and conditions of this Public License. 350 | 351 | 352 | Section 8 -- Interpretation. 353 | 354 | a. For the avoidance of doubt, this Public License does not, and 355 | shall not be interpreted to, reduce, limit, restrict, or impose 356 | conditions on any use of the Licensed Material that could lawfully 357 | be made without permission under this Public License. 358 | 359 | b. To the extent possible, if any provision of this Public License is 360 | deemed unenforceable, it shall be automatically reformed to the 361 | minimum extent necessary to make it enforceable. If the provision 362 | cannot be reformed, it shall be severed from this Public License 363 | without affecting the enforceability of the remaining terms and 364 | conditions. 365 | 366 | c. No term or condition of this Public License will be waived and no 367 | failure to comply consented to unless expressly agreed to by the 368 | Licensor. 369 | 370 | d. Nothing in this Public License constitutes or may be interpreted 371 | as a limitation upon, or waiver of, any privileges and immunities 372 | that apply to the Licensor or You, including from the legal 373 | processes of any jurisdiction or authority. 374 | 375 | 376 | ======================================================================= 377 | 378 | Creative Commons is not a party to its public 379 | licenses. Notwithstanding, Creative Commons may elect to apply one of 380 | its public licenses to material it publishes and in those instances 381 | will be considered the "Licensor." The text of the Creative Commons 382 | public licenses is dedicated to the public domain under the CC0 Public 383 | Domain Dedication. Except for the limited purpose of indicating that 384 | material is shared under a Creative Commons public license or as 385 | otherwise permitted by the Creative Commons policies published at 386 | creativecommons.org/policies, Creative Commons does not authorize the 387 | use of the trademark "Creative Commons" or any other trademark or logo 388 | of Creative Commons without its prior written consent including, 389 | without limitation, in connection with any unauthorized modifications 390 | to any of its public licenses or any other arrangements, 391 | understandings, or agreements concerning use of licensed material. For 392 | the avoidance of doubt, this paragraph does not form part of the 393 | public licenses. 394 | 395 | Creative Commons may be contacted at creativecommons.org. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## SRE 工程师指南 2 | 3 | 可以说这几年 SRE 的概念挺火的,相比传统运维来说,SRE 工程师要会的东西多的多,例如 SRE 需要既懂开发,又懂运维,能端到端参与产品研发生命周期全过程,围绕高可用和自动化建立四大关键能力。 4 | 5 | 1)编码能力是SRE的基本技能要求,强调软件和系统工程能力; 6 | 7 | 2)具备“软件工程”思维,要有站点和服务高可用设计能力,同时将高可用架构和软件工程方法应用到产品研发过程; 8 | 9 | 3)有能力进行自动化研发,用自动化软件完成运维和系统高可用性工作; 10 | 11 | 4)SRE要懂得如何高效的洞察整个平台,上到业务下到某个硬件或数据库 12 | 13 | 看的有点迷糊?那就具体点来说,**你要懂开发、懂运维、熟悉 k8s 、熟悉 Observability ,熟悉 devops 等等**,我的天,要求也太高了吧,毕竟每一块都是难啃的骨头。 14 | 15 | 但是,话说回来,真因为难,才值钱才吃香,偷偷告诉大家中高级 SRE 工程师没有 35 岁失业的说法哦。 16 | 17 | ## 这本书的目标用户 18 | 19 | SRE 有这么多领域要学习,那这本书的目标显然就不是让你精通各个领域,而是带领大家高屋建瓴的学习 SRE 必须的知识,以及如何将其融会贯通并迅速的上手工作,并且也会在合适的地方给出深入学习的路线。 20 | 21 | -------------------------------------------------------------------------------- /assets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunface/SRE-course/e042ed65bf803782d8de2d5ca9c8deb9e15708fd/assets/.DS_Store -------------------------------------------------------------------------------- /assets/CNAME: -------------------------------------------------------------------------------- 1 | cookbook.rs -------------------------------------------------------------------------------- /assets/banner1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunface/SRE-course/e042ed65bf803782d8de2d5ca9c8deb9e15708fd/assets/banner1.png -------------------------------------------------------------------------------- /assets/bigPicture.js: -------------------------------------------------------------------------------- 1 | var BigPicture=function(){var t,n,e,o,i,r,a,c,p,s,l,d,u,f,m,b,g,h,x,v,y,w,_,T,k,M,S,L,E,A,H,z,I,C=[],D={},O="appendChild",N="createElement",V="removeChild";function W(){var n=t.getBoundingClientRect();return"transform:translate3D("+(n.left-(e.clientWidth-n.width)/2)+"px, "+(n.top-(e.clientHeight-n.height)/2)+"px, 0) scale3D("+t.clientWidth/o.clientWidth+", "+t.clientHeight/o.clientHeight+", 0)"}function q(t){var n=A.length-1;if(!u){if(t>0&&E===n||t<0&&!E){if(!I.loop)return j(i,""),void setTimeout(j,9,i,"animation:"+(t>0?"bpl":"bpf")+" .3s;transition:transform .35s");E=t>0?-1:n+1}if([(E=Math.max(0,Math.min(E+t,n)))-1,E,E+1].forEach(function(t){if(t=Math.max(0,Math.min(t,n)),!D[t]){var e=A[t].src,o=document[N]("IMG");o.addEventListener("load",F.bind(null,e)),o.src=e,D[t]=o}}),D[E].complete)return B(t);u=1,j(m,"opacity:.4;"),e[O](m),D[E].onload=function(){y&&B(t)},D[E].onerror=function(){A[E]={error:"Error loading image"},y&&B(t)}}}function B(n){u&&(e[V](m),u=0);var r=A[E];if(r.error)alert(r.error);else{var a=e.querySelector("img:last-of-type");j(i=o=D[E],"animation:"+(n>0?"bpfl":"bpfr")+" .35s;transition:transform .35s"),j(a,"animation:"+(n>0?"bpfol":"bpfor")+" .35s both"),e[O](i),r.el&&(t=r.el)}H.innerHTML=E+1+"/"+A.length,X(A[E].caption),M&&M([i,A[E]])}function P(){var t,n,e=.95*window.innerHeight,o=.95*window.innerWidth,i=I.dimensions||[1920,1080],r=i[0],a=i[1],p=a/r;p>e/o?n=(t=Math.min(a,e))/p:t=(n=Math.min(r,o))*p,c.style.cssText+="width:"+n+"px;height:"+t+"px;"}function G(t){~[1,4].indexOf(o.readyState)?(U(),setTimeout(function(){o.play()},99)):o.error?U(t):f=setTimeout(G,35,t)}function R(n){I.noLoader||(n&&j(m,"top:"+t.offsetTop+"px;left:"+t.offsetLeft+"px;height:"+t.clientHeight+"px;width:"+t.clientWidth+"px"),t.parentElement[n?O:V](m),u=n)}function X(t){t&&(g.innerHTML=t),j(b,"opacity:"+(t?"1;pointer-events:auto":"0"))}function F(t){!~C.indexOf(t)&&C.push(t)}function U(t){if(u&&R(),T&&T(),"string"==typeof t)return $(),I.onError?I.onError():alert("Error: The requested "+t+" could not be loaded.");_&&F(s),o.style.cssText+=W(),j(e,"opacity:1;pointer-events:auto"),k=setTimeout(k,410),v=1,y=!!A,setTimeout(function(){o.style.cssText+="transition:transform .35s;transform:none",h&&setTimeout(X,250,h)},60)}function Y(t){var n=t?t.target:e,i=[b,x,r,a,g,L,S,m];n.blur(),w||~i.indexOf(n)||(o.style.cssText+=W(),j(e,"pointer-events:auto"),setTimeout($,350),clearTimeout(k),v=0,w=1)}function $(){if((o===c?p:o).removeAttribute("src"),document.body[V](e),e[V](o),j(e,""),j(o,""),X(0),y){for(var t=e.querySelectorAll("img"),n=0;n',n}function d(t,n){var e=document[N]("button");return e.className="bp-lr",e.innerHTML='',j(e,n),e.onclick=function(n){n.stopPropagation(),q(t)},e}var f=document[N]("STYLE");f.innerHTML="#bp_caption,#bp_container{bottom:0;left:0;right:0;position:fixed;opacity:0}#bp_container>*,#bp_loader{position:absolute;right:0;z-index:10}#bp_container,#bp_caption,#bp_container svg{pointer-events:none}#bp_container{top:0;z-index:9999;background:rgba(0,0,0,.7);opacity:0;transition:opacity .35s}#bp_loader{top:0;left:0;bottom:0;display:flex;align-items:center;cursor:wait;background:0;z-index:9}#bp_loader svg{width:50%;max-width:300px;max-height:50%;margin:auto;animation:bpturn 1s infinite linear}#bp_aud,#bp_container img,#bp_sv,#bp_vid{user-select:none;max-height:96%;max-width:96%;top:0;bottom:0;left:0;margin:auto;box-shadow:0 0 3em rgba(0,0,0,.4);z-index:-1}#bp_sv{background:#111}#bp_sv svg{width:66px}#bp_caption{font-size:.9em;padding:1.3em;background:rgba(15,15,15,.94);color:#fff;text-align:center;transition:opacity .3s}#bp_aud{width:650px;top:calc(50% - 20px);bottom:auto;box-shadow:none}#bp_count{left:0;right:auto;padding:14px;color:rgba(255,255,255,.7);font-size:22px;cursor:default}#bp_container button{position:absolute;border:0;outline:0;background:0;cursor:pointer;transition:all .1s}#bp_container>.bp-x{padding:0;height:41px;width:41px;border-radius:100%;top:8px;right:14px;opacity:.8;line-height:1}#bp_container>.bp-x:focus,#bp_container>.bp-x:hover{background:rgba(255,255,255,.2)}.bp-x svg,.bp-xc svg{height:21px;width:20px;fill:#fff;vertical-align:top;}.bp-xc svg{width:16px}#bp_container .bp-xc{left:2%;bottom:100%;padding:9px 20px 7px;background:#d04444;border-radius:2px 2px 0 0;opacity:.85}#bp_container .bp-xc:focus,#bp_container .bp-xc:hover{opacity:1}.bp-lr{top:50%;top:calc(50% - 130px);padding:99px 0;width:6%;background:0;border:0;opacity:.4;transition:opacity .1s}.bp-lr:focus,.bp-lr:hover{opacity:.8}@keyframes bpf{50%{transform:translatex(15px)}100%{transform:none}}@keyframes bpl{50%{transform:translatex(-15px)}100%{transform:none}}@keyframes bpfl{0%{opacity:0;transform:translatex(70px)}100%{opacity:1;transform:none}}@keyframes bpfr{0%{opacity:0;transform:translatex(-70px)}100%{opacity:1;transform:none}}@keyframes bpfol{0%{opacity:1;transform:none}100%{opacity:0;transform:translatex(-70px)}}@keyframes bpfor{0%{opacity:1;transform:none}100%{opacity:0;transform:translatex(70px)}}@keyframes bpturn{0%{transform:none}100%{transform:rotate(360deg)}}@media (max-width:600px){.bp-lr{font-size:15vw}}",document.head[O](f),(e=document[N]("DIV")).id="bp_container",e.onclick=Y,l=s("bp-x"),e[O](l),"ontouchstart"in window&&(z=1,e.ontouchstart=function(n){var e=n.changedTouches;t=e[0].pageX},e.ontouchmove=function(t){t.preventDefault()},e.ontouchend=function(n){var e=n.changedTouches;if(y){var o=e[0].pageX-t;o<-30&&q(1),o>30&&q(-1)}}),i=document[N]("IMG"),(r=document[N]("VIDEO")).id="bp_vid",r.setAttribute("playsinline",1),r.controls=1,r.loop=1,(a=document[N]("audio")).id="bp_aud",a.controls=1,a.loop=1,(H=document[N]("span")).id="bp_count",(b=document[N]("DIV")).id="bp_caption",(x=s("bp-xc")).onclick=X.bind(null,0),b[O](x),g=document[N]("SPAN"),b[O](g),e[O](b),S=d(1,"transform:scalex(-1)"),L=d(-1,"left:0;right:auto"),(m=document[N]("DIV")).id="bp_loader",m.innerHTML='',(c=document[N]("DIV")).id="bp_sv",(p=document[N]("IFRAME")).setAttribute("allowfullscreen",1),p.allow="autoplay; fullscreen",p.onload=function(){return c[V](m)},j(p,"border:0;position:absolute;height:100%;width:100%;left:0;top:0"),c[O](p),i.onload=U,i.onerror=U.bind(null,"image"),window.addEventListener("resize",function(){y||u&&R(1),o===c&&P()}),document.addEventListener("keyup",function(t){var n=t.keyCode;27===n&&v&&Y(),y&&(39===n&&q(1),37===n&&q(-1),38===n&&q(10),40===n&&q(-10))}),document.addEventListener("keydown",function(t){y&&~[37,38,39,40].indexOf(t.keyCode)&&t.preventDefault()}),document.addEventListener("focus",function(t){v&&!e.contains(t.target)&&(t.stopPropagation(),l.focus())},1),n=1}(),u&&(clearTimeout(f),$()),I=w,d=w.ytSrc||w.vimeoSrc,T=w.animationStart,k=w.animationEnd,M=w.onChangeImage,_=0,h=(t=w.el).getAttribute("data-caption"),w.gallery?function(n,r){var a=I.galleryAttribute||"data-bp";if(Array.isArray(n))A=n,h=n[E=r||0].caption;else{var c=(A=[].slice.call("string"==typeof n?document.querySelectorAll(n+" ["+a+"]"):n)).indexOf(t);E=0===r||r?r:-1!==c?c:0,A=A.map(function(t){return{el:t,src:t.getAttribute(a),caption:t.getAttribute("data-caption")}})}_=1,!~C.indexOf(s=A[E].src)&&R(1),A.length>1?(e[O](H),H.innerHTML=E+1+"/"+A.length,z||(e[O](S),e[O](L))):A=0,(o=i).src=s}(w.gallery,w.position):d||w.iframeSrc?(o=c,I.ytSrc?W="https://www.youtube.com/embed/"+d+"?html5=1&rel=0&playsinline=1&autoplay=1":I.vimeoSrc?W="https://player.vimeo.com/video/"+d+"?autoplay=1":I.iframeSrc&&(W=I.iframeSrc),j(m,""),c[O](m),p.src=W,P(),setTimeout(U,9)):w.imgSrc?(_=1,!~C.indexOf(s=w.imgSrc)&&R(1),(o=i).src=s):w.audio?(R(1),(o=a).src=w.audio,G("audio file")):w.vidSrc?(R(1),w.dimensions&&j(r,"width:"+w.dimensions[0]+"px"),D=w.vidSrc,Array.isArray(D)?(o=r.cloneNode(),D.forEach(function(t){var n=document[N]("SOURCE");n.src=t,n.type="video/"+t.match(/.(\w+)$/)[1],o[O](n)})):(o=r).src=D,G("video")):(o=i).src="IMG"===t.tagName?t.src:window.getComputedStyle(t).backgroundImage.replace(/^url|[(|)|'|"]/g,""),e[O](o),document.body[O](e),{close:Y,next:function(){return q(1)},prev:function(){return q(-1)}};var W}}(); -------------------------------------------------------------------------------- /assets/custom.js: -------------------------------------------------------------------------------- 1 | var initAll = function () { 2 | var path = window.location.pathname; 3 | if (path.endsWith("/print.html")) { 4 | return; 5 | } 6 | 7 | var images = document.querySelectorAll("main img") 8 | Array.prototype.forEach.call(images, function (img) { 9 | img.addEventListener("click", function () { 10 | BigPicture({ 11 | el: img, 12 | }); 13 | }); 14 | }); 15 | 16 | // Un-active everything when you click it 17 | Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function (el) { 18 | el.addEventHandler("click", function () { 19 | Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function (el) { 20 | el.classList.remove("active"); 21 | }); 22 | el.classList.add("active"); 23 | }); 24 | }); 25 | 26 | var updateFunction = function () { 27 | var id = null; 28 | var elements = document.getElementsByClassName("header"); 29 | Array.prototype.forEach.call(elements, function (el) { 30 | if (window.pageYOffset >= el.offsetTop) { 31 | id = el; 32 | } 33 | }); 34 | 35 | Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function (el) { 36 | el.classList.remove("active"); 37 | }); 38 | 39 | Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function (el) { 40 | if (id == null) { 41 | return; 42 | } 43 | if (id.href.localeCompare(el.href) == 0) { 44 | el.classList.add("active"); 45 | } 46 | }); 47 | }; 48 | 49 | var pagetoc = document.getElementsByClassName("pagetoc")[0]; 50 | var elements = document.getElementsByClassName("header"); 51 | Array.prototype.forEach.call(elements, function (el) { 52 | var link = document.createElement("a"); 53 | 54 | // Indent shows hierarchy 55 | var indent = ""; 56 | switch (el.parentElement.tagName) { 57 | case "H1": 58 | return; 59 | case "H3": 60 | indent = "20px"; 61 | break; 62 | case "H4": 63 | indent = "40px"; 64 | break; 65 | default: 66 | break; 67 | } 68 | 69 | link.appendChild(document.createTextNode(el.text)); 70 | link.style.paddingLeft = indent; 71 | link.href = el.href; 72 | pagetoc.appendChild(link); 73 | }); 74 | updateFunction.call(); 75 | 76 | // Handle active elements on scroll 77 | window.addEventListener("scroll", updateFunction); 78 | 79 | document.getElementById("theme-list").addEventListener("click", function (e) { 80 | var iframe = document.querySelector('.giscus-frame'); 81 | if (!iframe) return; 82 | var theme; 83 | if (e.target.className === "theme") { 84 | theme = e.target.id; 85 | } else { 86 | return; 87 | } 88 | 89 | // 若当前 mdbook 主题不是 Light 或 Rust ,则将 giscuz 主题设置为 transparent_dark 90 | var giscusTheme = "light" 91 | if (theme != "light" && theme != "rust") { 92 | giscusTheme = "transparent_dark"; 93 | } 94 | 95 | var msg = { 96 | setConfig: { 97 | theme: giscusTheme 98 | } 99 | }; 100 | iframe.contentWindow.postMessage({ giscus: msg }, 'https://giscus.app'); 101 | }); 102 | 103 | pagePath = pagePath.replace("index.md", ""); 104 | pagePath = pagePath.replace(".md", ""); 105 | if (pagePath.length > 0) { 106 | if (pagePath.charAt(pagePath.length-1) == "/"){ 107 | pagePath = pagePath.substring(0, pagePath.length-1) 108 | } 109 | }else { 110 | pagePath = "index" 111 | } 112 | 113 | // add vistors count 114 | var ele = document.createElement("div"); 115 | ele.setAttribute("align","center"); 116 | var count = document.createElement("img") 117 | count.setAttribute("src", "https://visitor-badge.glitch.me/badge?page_id=" + path); 118 | ele.appendChild(count); 119 | var divider =document.createElement("hr") 120 | 121 | document.getElementById("giscus-container").appendChild(ele); 122 | document.getElementById("giscus-container").appendChild(divider); 123 | 124 | // 选取浏览器默认使用的语言 125 | const lang = navigator.language || navigator.userLanguage 126 | 127 | // 若当前 mdbook 主题为 Light 或 Rust ,则将 giscuz 主题设置为 light 128 | var theme = "transparent_dark"; 129 | const themeClass = document.getElementsByTagName("html")[0].className; 130 | if (themeClass.indexOf("light") != -1 || themeClass.indexOf("rust") != -1) { 131 | theme = "light" 132 | } 133 | 134 | var script = document.createElement("script") 135 | script.type = "text/javascript"; 136 | script.src = "https://giscus.app/client.js"; 137 | script.async = true; 138 | script.crossOrigin = "anonymous"; 139 | script.setAttribute("data-repo", "sunface/rust-cookbook"); 140 | script.setAttribute("data-repo-id", "R_kgDOHH0skA="); 141 | script.setAttribute("data-category", "giscus"); 142 | script.setAttribute("data-category-id", "DIC_kwDOHH0skM4COa8c"); 143 | script.setAttribute("data-mapping", "specific"); 144 | script.setAttribute("data-term", pagePath); 145 | script.setAttribute("data-reactions-enabled", "1"); 146 | script.setAttribute("data-emit-metadata", "0"); 147 | script.setAttribute("data-input-position", "top"); 148 | script.setAttribute("data-theme", theme); 149 | script.setAttribute("data-lang", lang); 150 | // 预先加载评论会更好,这样用户读到那边时,评论就加载好了 151 | // script.setAttribute("data-loading", "lazy"); 152 | document.getElementById("giscus-container").appendChild(script); 153 | 154 | 155 | 156 | }; 157 | 158 | window.addEventListener('load', initAll); -------------------------------------------------------------------------------- /book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | authors = ["sunface"] 3 | language = "zh-CN" 4 | title = "Rust Cookbook" 5 | src = "src" 6 | 7 | [output.html] 8 | additional-css = ["theme/style.css"] 9 | additional-js = ["assets/custom.js", "assets/bigPicture.js"] 10 | git-repository-url = "https://github.com/sunface/rust-cookbook" 11 | edit-url-template = "https://github.com/sunface/rust-cookbook/edit/main/{path}" 12 | 13 | [output.html.playground] 14 | editable = true 15 | copy-js = true 16 | # line-numbers = true 17 | 18 | [output.html.fold] 19 | enable = true 20 | level = 2 21 | 22 | [rust] 23 | edition = "2021" #在线运行用2021版本的 24 | -------------------------------------------------------------------------------- /deploy: -------------------------------------------------------------------------------- 1 | ## this script deploys the static website of course.rs to github pages 2 | 3 | ## build static website for book 4 | mdbook build 5 | ## copy CNAME info to book dir 6 | cp ./assets/CNAME ./book/ 7 | 8 | 9 | ## init git repo 10 | cd book 11 | git init 12 | git config user.name "sunface" 13 | git config user.email "cto@188.com" 14 | git add . 15 | git commit -m 'deploy' 16 | git branch -M gh-pages 17 | git remote add origin https://github.com/sunface/rust-cookbook 18 | 19 | ## push to github pages 20 | git push -u -f origin gh-pages -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunface/SRE-course/e042ed65bf803782d8de2d5ca9c8deb9e15708fd/src/.DS_Store -------------------------------------------------------------------------------- /src/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | 10 | 11 | -------------------------------------------------------------------------------- /theme/index.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ title }} 7 | {{#if is_print }} 8 | 9 | {{/if}} 10 | {{#if base_url}} 11 | 12 | {{/if}} 13 | 14 | 15 | 16 | {{> head}} 17 | 18 | 19 | 20 | 21 | 22 | 23 | {{#if favicon_svg}} 24 | 25 | {{/if}} 26 | {{#if favicon_png}} 27 | 28 | {{/if}} 29 | 30 | 31 | 32 | {{#if print_enable}} 33 | 34 | {{/if}} 35 | 36 | 37 | 38 | {{#if copy_fonts}} 39 | 40 | {{/if}} 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | {{#each additional_css}} 49 | 50 | {{/each}} 51 | 52 | {{#if mathjax_support}} 53 | 54 | 55 | {{/if}} 56 | 57 | 58 | 59 | 60 | 64 | 65 | 66 | 78 | 79 | 80 | 90 | 91 | 92 | 102 | 103 | 109 | 110 |
111 | 112 |
113 | {{> header}} 114 | 115 | 158 | 159 | {{#if search_enabled}} 160 | 170 | {{/if}} 171 | 172 | 173 | 180 | 181 |
182 | 183 |
184 |
185 | {{{ content }}} 186 |
187 |
188 | 189 | 205 |
206 |
207 | 208 | 221 | 222 |
223 | 224 | {{#if livereload}} 225 | 226 | 238 | {{/if}} 239 | 240 | {{#if google_analytics}} 241 | 242 | 255 | {{/if}} 256 | 257 | {{#if playground_line_numbers}} 258 | 261 | {{/if}} 262 | 263 | {{#if playground_copyable}} 264 | 267 | {{/if}} 268 | 269 | {{#if playground_js}} 270 | 271 | 272 | 273 | 274 | 275 | {{/if}} 276 | 277 | {{#if search_js}} 278 | 279 | 280 | 281 | {{/if}} 282 | 283 | 284 | 285 | 286 | 289 | 290 | 291 | 292 | {{#each additional_js}} 293 | 294 | {{/each}} 295 | 296 | {{#if is_print}} 297 | {{#if mathjax_support}} 298 | 305 | {{else}} 306 | 311 | {{/if}} 312 | {{/if}} 313 | 314 | 315 | -------------------------------------------------------------------------------- /theme/style.css: -------------------------------------------------------------------------------- 1 | @media only screen and (max-width:1080px) { 2 | .sidetoc { 3 | display: none !important; 4 | } 5 | } 6 | 7 | @media only screen and (min-width:1080px) { 8 | main { 9 | position: relative; 10 | padding-right: 170px; 11 | } 12 | .sidetoc { 13 | margin-left: auto; 14 | margin-right: auto; 15 | /*left: calc(100% + (var(--content-max-width))/4 - 180px);*/ 16 | left: calc(100% - 200px); 17 | position: absolute; 18 | } 19 | .pagetoc { 20 | position: fixed; 21 | width: 200px; 22 | height: calc(100vh - var(--menu-bar-height) - 10rem); 23 | overflow: auto; 24 | z-index: 1000; 25 | } 26 | .pagetoc a { 27 | border-left: 1px solid var(--sidebar-bg); 28 | color: var(--fg) !important; 29 | display: block; 30 | padding-bottom: 5px; 31 | padding-top: 5px; 32 | padding-left: 10px; 33 | text-align: left; 34 | text-decoration: none; 35 | font-size: 1.2rem; 36 | } 37 | .pagetoc a:hover, 38 | .pagetoc a.active { 39 | background: var(--sidebar-bg); 40 | color: var(--sidebar-fg) !important; 41 | } 42 | .pagetoc .active { 43 | background: var(--sidebar-bg); 44 | color: var(--sidebar-fg); 45 | } 46 | } 47 | 48 | .page-footer { 49 | margin-top: 50px; 50 | border-top: 1px solid #ccc; 51 | overflow: hidden; 52 | padding: 10px 0; 53 | color: gray; 54 | } 55 | 56 | /* 修改章节目录的间距 */ 57 | .chapter li.chapter-item { 58 | /* 没有文件时的文字颜色 */ 59 | color: #939da3; 60 | margin-top: 1rem; 61 | } 62 | 63 | /* 修改滚动条宽度 */ 64 | ::-webkit-scrollbar { 65 | width: 5px; 66 | } 67 | 68 | /* 表格靠左对齐 */ 69 | table { 70 | margin-left: 0 !important; 71 | } 72 | 73 | /* 只使用底部的页面跳转,因为左右两边的宽跳转会被 page-toc 遮盖 */ 74 | @media only screen and (max-width: 2560px) { 75 | .nav-wide-wrapper { display: none; } 76 | .nav-wrapper { display: block; } 77 | } 78 | @media only screen and (max-width: 2560px) { 79 | .sidebar-visible .nav-wide-wrapper { display: none; } 80 | .sidebar-visible .nav-wrapper { display: block; } 81 | } 82 | 83 | 84 | /* 修改顶部图标大小 */ 85 | /* #menu-bar { 86 | font-size: 17px; 87 | } */ 88 | /* 修改 github 样式 */ 89 | .fa-github { 90 | font-weight: 550; 91 | } 92 | .fa-github:after{ 93 | content: "星光点点比不过你的 🌟"; 94 | margin-left: 4px; 95 | } 96 | 97 | /* Fix on mobile device */ 98 | code { 99 | word-break: break-word; 100 | } --------------------------------------------------------------------------------