<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                7-依賴和傘工程 ============== [外部依賴]() [內部依賴]() [傘工程]() [在傘依賴之中]() [總結]() 本章我們簡短地討論在Mix中如何管理依賴。 我們的應用程序```kv```完成了,現在是時候實現我們第一章提到的那個處理請求的服務器了: ``` CREATE shopping OK PUT shopping milk 1 OK PUT shopping eggs 3 OK GET shopping milk 1 OK DELETE shopping eggs OK ``` 我們不會再往```kv```應用程序中添加代碼,而是來創建一個TCP服務器作為```kv```的客戶端。 因為整個Elixir生態系統被設定為更加適應應用程序。因此我們最好是把工程分成小的應用程序,而不是大一統。 在創建新的應用程序之前,我們必須先來討論Mix如何處理依賴。 實際中,我們會遇到兩種依賴:內部的和外部的。Mix都支持。 ## 7.1-外部依賴 外部的依賴不是你整的。比如,你要發布的KV程序,它需要HTTP的API,你可以用[Plug](http://github.com/elixir-lang/plug)作為一個外部依賴。 安裝外部依賴很簡單。通常我們使用[Hex包管理器](http://hex.pm/)。你只要在```mix.exs```中的deps函數中列出依賴: ```elixir def deps do [{:plug, "~> 0.5.0"}] end ``` 這個依賴引用的是plug在0.5.x系列版本中最新推送給Hex的一個。```~>```后面跟著版本數字。更多關于如何指定某特定版本的信息,請參考[Version模塊文檔](http://elixir-lang.org/docs/stable/elixir/Version.html)。 通常推給Hex的都是穩定的發行版。如果你想依賴的是正在開發中的最新版本,那么Mix還支持你引用git中的相應repo: ```elixir def deps do [{:plug, git: "git://github.com/elixir-lang/plug.git"}] end ``` 你會注意到,當你給你的工程加了一個依賴后,Mix會生成了一個```mix.lock```文件,用該文件確保_可重復的構建_。 lock文件必須ckeckin到你的版本管理系統中去,來保證任何使用這個工程的人都擁有和你同樣的依賴的版本。 Mix提供了很多依賴相關的操作,可以用```mix help```查看: ```elixir $ mix help mix deps # List dependencies and their status mix deps.clean # Remove the given dependencies' files mix deps.compile # Compile dependencies mix deps.get # Get all out of date dependencies mix deps.unlock # Unlock the given dependencies mix deps.update # Update the given dependencies ``` 最常用的操作是```mix deps.get```和```mix deps.update```。 一旦獲取了依賴程序,這些程序會自動被編譯好供你使用。 關于deps操作,可以通過```mix help deps```或者[Mix.Tasks.Deps模塊文檔](http://elixir-lang.org/docs/stable/mix/Mix.Tasks.Deps.html)閱讀更多信息。 ## 7.2-內部依賴 內部的依賴指的是你在同一個工程中的某個程序。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看