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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] ### 熱點參數限流 ``` 基于并發數控制熱點參數: { Resource: "some-test", MetricType: hotspot.Concurrency, ParamIndex: 0, Threshold: 100, DurationInSec: 1, }, ``` 基于請求數控制熱點參數 ``` { Resource: "some-test", MetricType: hotspot.QPS, ControlBehavior: hotspot.Reject ParamIndex: 1, Threshold: 100, BurstCount: 5, DurationInSec: 1, }, ``` <details> <summary>main.go</summary> ``` package main import ( "fmt" "log" "math/rand" "time" sentinel "github.com/alibaba/sentinel-golang/api" "github.com/alibaba/sentinel-golang/core/hotspot" "github.com/alibaba/sentinel-golang/util" ) type fooStruct struct { n int64 } func main() { // We should initialize Sentinel first. err := sentinel.InitDefault() if err != nil { log.Fatalf("Unexpected error: %+v", err) } m := make([]hotspot.SpecificValue, 1) m[0] = hotspot.SpecificValue{ ValKind: hotspot.KindInt, ValStr: "9", Threshold: 0, } var Resource = "test" _, err = hotspot.LoadRules([]*hotspot.Rule{ //{ // Resource: Resource, // MetricType: hotspot.QPS, // ControlBehavior: hotspot.Reject, // ParamIndex: 1, // Threshold: 50, // MaxQueueingTimeMs: 0, // BurstCount: 0, // DurationInSec: 1, // SpecificItems: m, //}, { Resource: Resource, MetricType: hotspot.QPS, ControlBehavior: hotspot.Reject, ParamIndex: 2, Threshold: 5,// 請求閾值 MaxQueueingTimeMs: 0, BurstCount: 10, DurationInSec: 1, SpecificItems: make([]hotspot.SpecificValue, 0), }, }) if err != nil { log.Fatalf("Unexpected error: %+v", err) return } fmt.Println("Sentinel Go hot-spot param flow control demo is running. You may see the pass/block metric in the metric log.") for i := 0; i < 20; i++ { go func() { e, b := sentinel.Entry(Resource, sentinel.WithArgs(true, rand.Uint32()%30, "sentinel", fooStruct{rand.Int63() % 5})) if b != nil { // Blocked. We could get the block reason from the BlockError. time.Sleep(time.Duration(rand.Uint64()%50) * time.Millisecond) fmt.Println(util.CurrentTimeMillis(), b.Error()) } else { // Passed, wrap the logic here. fmt.Println(util.CurrentTimeMillis(), "passed") time.Sleep(time.Duration(rand.Uint64()%50) * time.Millisecond) // Be sure the entry is exited finally. e.Exit() } }() } //for { // e, b := sentinel.Entry(Resource, sentinel.WithArgs(false, uint32(9), "ahas", fooStruct{rand.Int63() % 5})) // if b != nil { // // Blocked. We could get the block reason from the BlockError. // time.Sleep(time.Duration(rand.Uint64()%50) * time.Millisecond) // } else { // // Passed, wrap the logic here. // fmt.Println(util.CurrentTimeMillis(), "passed") // time.Sleep(time.Duration(rand.Uint64()%50) * time.Millisecond) // // // Be sure the entry is exited finally. // e.Exit() // } //} select{} } ``` </details> <br/>
                  <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>

                              哎呀哎呀视频在线观看