Skip to content

Commit

Permalink
Merge pull request #1 from kitex-contrib/add_demo
Browse files Browse the repository at this point in the history
feat: add demo
  • Loading branch information
ppzqh authored Mar 9, 2023
2 parents 6cf7b6e + 41ffc73 commit 0fc32c3
Show file tree
Hide file tree
Showing 5 changed files with 858 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This resolver needs an implemented Resolver, which is able to resolve instances
```
// Define a filter function.
// For example, only get the instances with a tag of {"k":"v"}.
filterFunc = func(ctx context.Context, instance []discovery.Instance) []discovery.Instance {
filterFunc := func(ctx context.Context, instance []discovery.Instance) []discovery.Instance {
var res []discovery.Instance
for _, ins := range instance {
if v, ok := ins.Tag("k"); ok && v == "v" {
Expand Down Expand Up @@ -42,3 +42,6 @@ tagResolver := ruleBasedResolver.NewRuleBasedResolver(resolver, filterRule)
// add this option when construct Kitex Client
opt := client.WithResolver(tagResolver)
```

## Demo
Please refer to the `/demo` for details.
4 changes: 4 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Demo
This demo uses [etcd-registry](github.com/kitex-contrib/registry-etcd) as the original resolver and configure a filter rule to use the rule-based resolver.

Please make sure [etcd](https://etcd.io/) is configured before running the demo.
31 changes: 31 additions & 0 deletions demo/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module demo

go 1.18

require (
github.com/cloudwego/kitex v0.5.0
github.com/kitex-contrib/registry-etcd v0.1.0
github.com/kitex-contrib/resolver-rule-based v0.0.0-20230309083100-6cf7b6e5f2b4
)

require (
github.com/apache/thrift v0.13.0 // indirect
github.com/choleraehyq/pid v0.0.16 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
go.etcd.io/etcd/client/v3 v3.5.5 // indirect
go.uber.org/atomic v1.8.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/grpc v1.41.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 0fc32c3

Please sign in to comment.