<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # Feature Flags > 原文:[https://docs.gitlab.com/ee/operations/feature_flags.html](https://docs.gitlab.com/ee/operations/feature_flags.html) * [How it works](#how-it-works) * [Create a feature flag](#create-a-feature-flag) * [Rollout strategy (legacy)](#rollout-strategy-legacy) * [Feature flag strategies](#feature-flag-strategies) * [All users](#all-users) * [Percent of Users](#percent-of-users) * [User IDs](#user-ids) * [User List](#user-list) * [Enable or disable feature flag strategies](#enable-or-disable-feature-flag-strategies) * [Disable a feature flag for a specific environment](#disable-a-feature-flag-for-a-specific-environment) * [Disable a feature flag for all environments](#disable-a-feature-flag-for-all-environments) * [Integrate feature flags with your application](#integrate-feature-flags-with-your-application) * [Get access credentials](#get-access-credentials) * [Choose a client library](#choose-a-client-library) * [Feature flags API information](#feature-flags-api-information) * [Golang application example](#golang-application-example) * [Ruby application example](#ruby-application-example) * [Feature Flag Related Issues](#feature-flag-related-issues) * [Enable or disable Feature Flag Related Issues](#enable-or-disable-feature-flag-related-issues-core-only) # Feature Flags[](#feature-flags-premium "Permalink") 在 GitLab 11.4 中[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/7433) . 借助功能標志,您可以將應用程序的新功能部署到較小的批量生產中. 您可以將功能打開或關閉到部分用戶,以幫助您實現持續交付. 功能標記有助于降低風險,使您能夠進行受控測試,并將功能交付與客戶發布分開. 有關實際使用的功能標志的示例,請參閱[用于部署的 GitLab,功能標志和錯誤跟蹤](https://www.youtube.com/embed/5tw2p6lwXxo) . ## How it works[](#how-it-works "Permalink") GitLab 使用功能切換服務[Unleash](https://github.com/Unleash/unleash) . 通過在 GitLab 中啟用或禁用標記,您的應用程序可以確定要啟用或禁用的功能. 您可以在 GitLab 中創建功能標記,并使用應用程序中的 API 來獲取功能標記及其狀態的列表. 必須將應用程序配置為與 GitLab 進行通信,因此,開發人員可以使用兼容的客戶端庫并將[功能標記集成到您的應用程序中](#integrate-feature-flags-with-your-application) . ## Create a feature flag[](#create-a-feature-flag "Permalink") 要創建并啟用功能標志: 1. 導航到項目的" **操作">"功能標志"** . 2. 單擊**新功能標志**按鈕. 3. 輸入一個以字母開頭的名稱,該名稱僅包含小寫字母,數字,下劃線( `_` )或破折號( `-` ),并且不以破折號( `-` )或下劃線( `_` )結尾. 4. 輸入描述(可選,最多 255 個字符). 5. Enter details about how the flag should be applied: * 在 GitLab 13.0 和更早版本中,添加**Environment specs** . 對于每個環境,包括" **狀態"** (默認啟用)和" [**部署"策略**](#rollout-strategy-legacy) (默認為" **所有用戶"** ). * 在 GitLab 13.1 和更高版本中,添加 Feature Flag [**Strategies**](#feature-flag-strategies) . 對于每種策略,請包括" **類型"** (默認為" [**所有用戶"**](#all-users) )和" **環境"** (默認為所有環境). 6. Click **創建功能標志**. 您可以通過單擊 列表中任何功能標志旁邊的(編輯)按鈕. ## Rollout strategy (legacy)[](#rollout-strategy-legacy "Permalink") 在 GitLab 12.2 中[引入](https://gitlab.com/gitlab-org/gitlab/-/issues/8240) . 在 GitLab 13.0 和更早版本中," **推出"策略**設置會影響哪些用戶將啟用該功能. 選擇要啟用該功能的用戶百分比. 如果禁用環境規范,則推出策略將無效. 可以設置為: * 全部用戶 * [Percent of users](#percent-of-users) * (可選)您可以單擊" **包括其他用戶 ID"**復選框,并添加特定用戶 ID 列表以啟用該功能. * [User IDs](#user-ids) ## Feature flag strategies[](#feature-flag-strategies "Permalink") 版本歷史 * 在 GitLab 13.0 中[引入](https://gitlab.com/gitlab-org/gitlab/-/issues/35555) . * 它部署在功能標記后面,默認情況下處于禁用狀態. * 在 GitLab.com 上啟用了它. * 要在 GitLab 自管實例中使用它,請讓 GitLab 管理員[啟用它](#enable-or-disable-feature-flag-strategies) . 您可以在多個環境中應用功能標記策略,而無需多次定義策略. GitLab 功能標志使用[Unleash](https://unleash.github.io)作為功??能標志引擎. 在"釋放"中,有用于粒度特征標志控件的[策略](https://unleash.github.io/docs/activation_strategy) . GitLab 功能標志可以有多種策略,支持的策略有: * [All users](#all-users) * [Percent of Users](#percent-of-users) * [User IDs](#user-ids) * [User List](#user-list) 可以在[創建](#create-a-feature-flag)功能部件標記時將策略添加到功能部件標記,也可以在[創建](#create-a-feature-flag)后通過導航到" **操作">"功能部件標記"**并單擊以編輯現有功能部件標記 (編輯). ### All users[](#all-users "Permalink") 為所有用戶啟用該功能. 它使用[`default`](https://unleash.github.io/docs/activation_strategy#default)釋放激活策略. ### Percent of Users[](#percent-of-users "Permalink") 為一定百分比的已認證用戶啟用該功能. 它使用[`gradualRolloutUserId`](https://unleash.github.io/docs/activation_strategy#gradualrolloutuserid)釋放激活策略. 例如,將值設置為 15%即可為 15%的經過身份驗證的用戶啟用該功能. 推出百分比可以從 0%到 100%. **注意:**對于已登錄的用戶,但對于匿名用戶,保證了粘性(同一用戶的一致應用程序行為).**警告:**如果選擇此策略,則**必須**為 Unleash 客戶端提供一個用戶 ID,以啟用該功能. 請參見下面的[Ruby 示例](#ruby-application-example) . ### User IDs[](#user-ids "Permalink") 在 GitLab 12.2 中[引入](https://gitlab.com/gitlab-org/gitlab/-/issues/8240) . [更新](https://gitlab.com/gitlab-org/gitlab/-/issues/34363)為在 GitLab 12.6 中按環境定義. 為目標用戶列表啟用該功能. 它是使用 Unleash [`userWithId`](https://unleash.github.io/docs/activation_strategy#userwithid)激活策略實現的. 輸入用戶 ID 作為逗號分隔的值列表. 例如, `user@example.com, user2@example.com`或`username1,username2,username3`等. **注意:**用戶 ID 是您的應用程序用戶的標識符. 他們不必是 GitLab 用戶.**注意:** **必須**為 Unleash 客戶端提供用戶 ID,才能為目標用戶啟用該功能. 請參見下面的[Ruby 示例](#ruby-application-example) . ### User List[](#user-list "Permalink") 在 GitLab 13.1 中[引入](https://gitlab.com/gitlab-org/gitlab/-/issues/35930) . 為使用[Feature Flag User List API](../api/feature_flag_user_lists.html)創建的[用戶列表](../api/feature_flag_user_lists.html)啟用功能. 與[用戶 ID](#user-ids)相似,它使用 Unleash [`userWithId`](https://unleash.github.io/docs/activation_strategy#userwithid)激活策略. ### Enable or disable feature flag strategies[](#enable-or-disable-feature-flag-strategies "Permalink") 此功能正在開發中,但已準備好進行測試. 它部署在**默認情況下禁用**的功能標志的后面. [有權訪問 GitLab Rails 控制臺的 GitLab 管理員](../administration/feature_flags.html)可以為您的實例啟用它. 要啟用它: ``` Feature.enable(:feature_flags_new_version) ``` 禁用它: ``` Feature.disable(:feature_flags_new_version) ``` ## Disable a feature flag for a specific environment[](#disable-a-feature-flag-for-a-specific-environment "Permalink") 在[GitLab 13.0 和更早版本中](https://gitlab.com/gitlab-org/gitlab/-/issues/8621) ,要為特定環境禁用功能標志: 1. 導航到項目的" **操作">"功能標志"** . 2. 對于要禁用的功能標志,請單擊"鉛筆"圖標. 3. 禁用標志: * 在 GitLab 13.0 和更低版本中:滑動環境的"狀態"切換. 或者,要刪除環境規范,請單擊右側的" **刪除(X)"**圖標. * 在 GitLab 13.1 及更高版本:對于每一個戰略,它適用于在**環境** ,刪除環境. 4. Click **保存更改**. ## Disable a feature flag for all environments[](#disable-a-feature-flag-for-all-environments "Permalink") 禁用所有環境的功能標志: 1. 導航到項目的" **操作">"功能標志"** . 2. 對于要禁用的功能標志,請將狀態切換滑動到**禁用** . 功能標志顯示在" **禁用"**選項卡上. ## Integrate feature flags with your application[](#integrate-feature-flags-with-your-application "Permalink") 要在應用程序中使用功能標志,請從 GitLab 獲取訪問憑據. 然后使用客戶端庫準備您的應用程序. ### Get access credentials[](#get-access-credentials "Permalink") 要獲取您的應用程序需要與 GitLab 通信的訪問憑據: 1. 導航到項目的" **操作">"功能標志"** . 2. 單擊**配置**按鈕以查看以下內容: * **API URL** :客戶端(應用程序)連接以獲取功能標志列表的 URL. * **實例 ID** :授權檢索功能標志的唯一令牌. * **應用程序名稱** :運行環境的名稱. 例如,如果應用程序為生產服務器運行,則應用程序名稱將為`production`或類似名稱. 該值用于環境規格評估. **注意:**這些字段的含義可能會隨著時間而改變. 例如,我們不確定**實例 ID**是分配給**Environment 的**是單個令牌還是多個令牌. 另外, **應用程序名稱**可以描述應用程序的版本,而不是運行環境. ### Choose a client library[](#choose-a-client-library "Permalink") GitLab 實現與 Unleash 客戶端兼容的單個后端. 使用 Unleash 客戶端,開發人員可以在應用程序代碼中定義標志的默認值. 如果提供的配置文件中不存在該標志,則每個功能標志評估都可以表達所需的結果. 目前,Unleash [提供了許多用于各種語言和框架的 SDK](https://github.com/Unleash/unleash#client-implementations) . ### Feature flags API information[](#feature-flags-api-information "Permalink") 有關 API 的內容,請參見: * [Feature Flags API](../api/feature_flags.html) * [功能標志規范 API](../api/feature_flag_specs.html) (已[在 GitLab 14.0 中](https://gitlab.com/gitlab-org/gitlab/-/issues/213369)棄用并[計劃將其刪除](https://gitlab.com/gitlab-org/gitlab/-/issues/213369) .) * [Feature Flag User Lists API](../api/feature_flag_user_lists.html) * [Legacy Feature Flags API](../api/feature_flags_legacy.html) ### Golang application example[](#golang-application-example "Permalink") 這是一個如何在 Golang 應用程序中集成特征標記的示例: ``` package main import ( "io" "log" "net/http" "github.com/Unleash/unleash-client-go" ) type metricsInterface struct { } func init() { unleash.Initialize( unleash.WithUrl("https://gitlab.com/api/v4/feature_flags/unleash/42"), unleash.WithInstanceId("29QmjsW6KngPR5JNPMWx"), unleash.WithAppName("production"), unleash.WithListener(&metricsInterface{}), ) } func helloServer(w http.ResponseWriter, req *http.Request) { if unleash.IsEnabled("my_feature_name") { io.WriteString(w, "Feature enabled\n") } else { io.WriteString(w, "hello, world!\n") } } func main() { http.HandleFunc("/", helloServer) log.Fatal(http.ListenAndServe(":8080", nil)) } ``` ### Ruby application example[](#ruby-application-example "Permalink") 這是一個如何在 Ruby 應用程序中集成功能標記的示例. 為 Unleash 客戶端提供了一個用戶 ID,以與" **百分比"卷展欄(已登錄用戶)卷**展策略或" **目標用戶"**列表一起使用. ``` #!/usr/bin/env ruby require 'unleash' require 'unleash/context' unleash = Unleash::Client.new({ url: 'http://gitlab.com/api/v4/feature_flags/unleash/42', app_name: 'production', instance_id: '29QmjsW6KngPR5JNPMWx' }) unleash_context = Unleash::Context.new # Replace "123" with the id of an authenticated user. # Note that the context's user id must be a string: # https://unleash.github.io/docs/unleash_context unleash_context.user_id = "123" if unleash.is_enabled?("my_feature_name", unleash_context) puts "Feature enabled" else puts "hello, world!" end ``` ## Feature Flag Related Issues[](#feature-flag-related-issues "Permalink") 版本歷史 * 在 GitLab 13.2 中[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36617) . * 它部署在默認情況下啟用的功能標志后面. * 在 GitLab.com 上啟用了它. * 不能根據項目啟用或禁用它 * 建議用于生產. * 對于 GitLab 自我管理的實例,GitLab 管理員可以選擇禁用它. 您可以將相關問題鏈接到功能標志. 在" **鏈接的問題"**部分中,單擊`+`按鈕,然后輸入問題參考編號或問題的完整 URL. 此功能類似于[相關問題](../user/project/issues/related_issues.html)功能. ### Enable or disable Feature Flag Related Issues[](#enable-or-disable-feature-flag-related-issues-core-only "Permalink") 與功能標記相關??的問題正在開發中,但已準備好用于生產. 它部署在**默認情況下啟用**的功能標志的后面. [有權訪問 GitLab Rails 控制臺的 GitLab 管理員](../administration/feature_flags.html)可以選擇為您的實例禁用它. 禁用它: ``` Feature.disable(:feature_flags_issue_links) ``` To enable it: ``` Feature.enable(:feature_flags_issue_links) ```
                  <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>

                              哎呀哎呀视频在线观看