Skip to content

Commit

Permalink
fix example code error (#204)
Browse files Browse the repository at this point in the history
* fix example code error

* Update 09-selector.md
  • Loading branch information
libi authored Nov 3, 2023
1 parent a0e4586 commit bf10d98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/component/09-selector.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ type Rebalancer interface {
### HTTP Client

```go
import "github.com/go-kratos/kratos/v2/selector/p2c"
import "github.com/go-kratos/kratos/v2/selector/wrr"
import "github.com/go-kratos/kratos/v2/selector/filter"

// 创建路由 Filter:筛选版本号为"2.0.0"的实例
filter := filter.Version("2.0.0")
// 创建 P2C 负载均衡算法 Selector,并将路由 Filter 注入
selector.SetGlobalSelector(wrr.NewBuilder)
selector.SetGlobalSelector(wrr.NewBuilder())

hConn, err := http.NewClient(
context.Background(),
Expand All @@ -65,13 +65,13 @@ hConn, err := http.NewClient(
### gRPC Client

```go
import "github.com/go-kratos/kratos/v2/selector/p2c"
import "github.com/go-kratos/kratos/v2/selector/wrr"
import "github.com/go-kratos/kratos/v2/selector/filter"

// 创建路由 Filter:筛选版本号为"2.0.0"的实例
filter := filter.Version("2.0.0")
// 由于 gRPC 框架的限制,只能使用全局 balancer name 的方式来注入 selector
selector.SetGlobalSelector(wrr.NewBuilder)
selector.SetGlobalSelector(wrr.NewBuilder())

conn, err := grpc.DialInsecure(
context.Background(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ Supported implementations:
### HTTP Client

```go
import "github.com/go-kratos/kratos/v2/selector/p2c"
import "github.com/go-kratos/kratos/v2/selector/wrr"
import "github.com/go-kratos/kratos/v2/selector/filter"

// Create a route Filter: filter instances with version number "2.0.0".
filter := filter.Version("2.0.0")
// Create P2C load balancing algorithm Selector, and inject routing Filter.
selctor.SetGlobalSelector(wrr.NewBuilder)
selctor.SetGlobalSelector(wrr.NewBuilder())

hConn, err := http.NewClient(
http.WithEndpoint("discovery:///helloworld"),
Expand All @@ -64,13 +64,13 @@ hConn, err := http.NewClient(
### gRPC Client

```go
import "github.com/go-kratos/kratos/v2/selector/p2c"
import "github.com/go-kratos/kratos/v2/selector/wrr"
import "github.com/go-kratos/kratos/v2/selector/filter"

// Create a route Filter: filter instances with version number "2.0.0".
filter := filter.Version("2.0.0")
// Due to the limitations of the gRPC framework, only the global balancer name can be used to inject Selector.
selector.SetGlobalSelector(wrr.NewBuilder)
selector.SetGlobalSelector(wrr.NewBuilder())

conn, err := grpc.DialInsecure(
context.Background(),
Expand Down

0 comments on commit bf10d98

Please sign in to comment.