开发者社区 > 云原生 > 中间件 > 正文

应用高可用服务AHAS有基于sentinel集成到mse插件上实现集群限流的示例嘛?

应用高可用服务AHAS有基于sentinel集成到mse插件上实现集群限流的示例嘛?

展开
收起
青城山下庄文杰 2023-08-25 14:43:11 57 0
1 条回答
写回答
取消 提交回答
  • import (
    "fmt"

    "github.com/alibaba/sentinel-golang/core/flow"
    "github.com/alibaba/sentinel-golang/core/log"
    "github.com/alibaba/sentinel-golang/core/slots/cluster"
    "github.com/alibaba/sentinel-golang/core/stat"
    "github.com/alibaba/sentinel-golang/examples/cmd/helloworld/server"
    "github.com/alibaba/sentinel-golang/examples/cmd/helloworld/service"
    

    )

    func main() {
    // 创建流控规则
    rule := flow.NewRule("HelloWorld", flow.WithResource("helloworld"), flow.WithQps(10))
    // 创建集群限流器
    clusterLimiter := cluster.NewClusterLimiter(rule)
    // 启动微服务
    server.Run(service.NewService(), clusterLimiter)
    }

    2023-09-18 16:16:30
    赞同 展开评论 打赏

为企业提供高效、稳定、易扩展的中间件产品。

相关产品

  • 应用高可用服务
  • 微服务引擎
  • 热门讨论

    热门文章

    相关电子书

    更多
    阿里云容器 AHAS Sentinel 网关流控揭秘 立即下载
    《MSE 微服务网关》 立即下载
    云效助力企业集成安全到DevOps中 立即下载