Skip to content

Commit e509afa

Browse files
authored
feat: added custom grpc resolver (#587)
Signed-off-by: Pradeep <[email protected]>
1 parent 51238a0 commit e509afa

File tree

9 files changed

+253
-1196
lines changed

9 files changed

+253
-1196
lines changed

providers/flagd/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Configuration can be provided as constructor options or as environment variables
6969
|----------------------------------------------------------|--------------------------------|-----------------------------|-----------|---------------------|
7070
| WithHost | FLAGD_HOST | string | localhost | rpc & in-process |
7171
| WithPort | FLAGD_PORT | number | 8013 | rpc & in-process |
72+
| WithTargetUri | FLAGD_TARGET_URI | string | "" | in-process |
7273
| WithTLS | FLAGD_TLS | boolean | false | rpc & in-process |
7374
| WithSocketPath | FLAGD_SOCKET_PATH | string | "" | rpc & in-process |
7475
| WithCertificatePath | FLAGD_SERVER_CERT_PATH | string | "" | rpc & in-process |
@@ -100,6 +101,20 @@ On invocation of a flag evaluation (if caching is available) an attempt is made
100101
By default, the provider is configured to use LRU caching with up to 1000 entries.
101102
This can be changed through constructor option or environment variable `FLAGD_MAX_CACHE_SIZE`
102103

104+
### Target URI Support (gRPC name resolution)
105+
106+
The `TargetUri` is meant for gRPC custom name resolution (default is `dns`), this allows users to use different
107+
resolution method e.g. `xds`. Currently, we are supporting all [core resolver](https://grpc.io/docs/guides/custom-name-resolution/)
108+
and one custom resolver for `envoy` proxy resolution. For more details, please refer the
109+
[RFC](https://github.com/open-feature/flagd/blob/main/docs/reference/specifications/proposal/rfc-grpc-custom-name-resolver.md) document.
110+
111+
```go
112+
openfeature.SetProvider(flagd.NewProvider(
113+
flagd.WithInProcessResolver(),
114+
flagd.WithTargetUri("envoy://localhost:9211/test.service"),
115+
))
116+
```
117+
103118
## Supported Events
104119

105120
The flagd provider emits `PROVIDER_READY`, `PROVIDER_ERROR` and `PROVIDER_CONFIGURATION_CHANGED` events.

providers/flagd/go.mod

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,32 @@ toolchain go1.22.3
66

77
require (
88
buf.build/gen/go/open-feature/flagd/connectrpc/go v1.17.0-20240906125204-0a6a901b42e8.1
9-
buf.build/gen/go/open-feature/flagd/grpc/go v1.5.1-20240215170432-1e611e2999cc.1
10-
buf.build/gen/go/open-feature/flagd/protocolbuffers/go v1.34.2-20240906125204-0a6a901b42e8.2
9+
buf.build/gen/go/open-feature/flagd/grpc/go v1.5.1-20240906125204-0a6a901b42e8.1
10+
buf.build/gen/go/open-feature/flagd/protocolbuffers/go v1.35.1-20240906125204-0a6a901b42e8.1
1111
connectrpc.com/connect v1.17.0
1212
connectrpc.com/otelconnect v0.7.1
1313
github.com/cucumber/godog v0.14.1
14-
github.com/go-logr/logr v1.4.1
14+
github.com/go-logr/logr v1.4.2
1515
github.com/google/go-cmp v0.6.0
1616
github.com/hashicorp/golang-lru/v2 v2.0.7
17-
github.com/open-feature/flagd/core v0.9.1
17+
github.com/open-feature/flagd/core v0.10.4
1818
github.com/open-feature/go-sdk v1.11.0
1919
github.com/open-feature/go-sdk-contrib/tests/flagd v1.4.1
20-
go.uber.org/mock v0.4.0
21-
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f
22-
golang.org/x/net v0.26.0
23-
google.golang.org/grpc v1.64.1
24-
google.golang.org/protobuf v1.34.2
25-
sigs.k8s.io/controller-runtime v0.17.3
20+
go.uber.org/mock v0.5.0
21+
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
22+
golang.org/x/net v0.30.0
23+
google.golang.org/grpc v1.67.1
24+
google.golang.org/protobuf v1.35.1
25+
sigs.k8s.io/controller-runtime v0.19.0
2626
)
2727

2828
require (
2929
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df // indirect
3030
github.com/cucumber/gherkin/go/v26 v26.2.0 // indirect
3131
github.com/cucumber/messages/go/v21 v21.0.1 // indirect
32-
github.com/diegoholiveira/jsonlogic/v3 v3.5.2 // indirect
32+
github.com/diegoholiveira/jsonlogic/v3 v3.5.3 // indirect
3333
github.com/fsnotify/fsnotify v1.7.0 // indirect
34+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
3435
github.com/go-logr/stdr v1.2.2 // indirect
3536
github.com/go-logr/zapr v1.3.0 // indirect
3637
github.com/gofrs/uuid v4.3.1+incompatible // indirect
@@ -43,29 +44,29 @@ require (
4344
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
4445
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4546
github.com/modern-go/reflect2 v1.0.2 // indirect
46-
github.com/open-feature/flagd-schemas v0.2.9-0.20240408192555-ea4f119d2bd7 // indirect
47-
github.com/rogpeppe/go-internal v1.11.0 // indirect
47+
github.com/open-feature/flagd-schemas v0.2.9-0.20240708163558-2aa89b314322 // indirect
4848
github.com/spf13/pflag v1.0.5 // indirect
4949
github.com/twmb/murmur3 v1.1.8 // indirect
50+
github.com/x448/float16 v0.8.4 // indirect
5051
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
5152
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
5253
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
5354
github.com/zeebo/xxh3 v1.0.2 // indirect
54-
go.opentelemetry.io/otel v1.25.0 // indirect
55-
go.opentelemetry.io/otel/metric v1.25.0 // indirect
56-
go.opentelemetry.io/otel/trace v1.25.0 // indirect
55+
go.opentelemetry.io/otel v1.31.0 // indirect
56+
go.opentelemetry.io/otel/metric v1.31.0 // indirect
57+
go.opentelemetry.io/otel/trace v1.31.0 // indirect
5758
go.uber.org/multierr v1.11.0 // indirect
5859
go.uber.org/zap v1.27.0 // indirect
59-
golang.org/x/mod v0.17.0 // indirect
60-
golang.org/x/sys v0.21.0 // indirect
61-
golang.org/x/text v0.16.0 // indirect
62-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
60+
golang.org/x/mod v0.21.0 // indirect
61+
golang.org/x/sys v0.26.0 // indirect
62+
golang.org/x/text v0.19.0 // indirect
63+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
6364
gopkg.in/inf.v0 v0.9.1 // indirect
6465
gopkg.in/yaml.v2 v2.4.0 // indirect
6566
gopkg.in/yaml.v3 v3.0.1 // indirect
66-
k8s.io/apimachinery v0.29.3 // indirect
67-
k8s.io/klog/v2 v2.120.1 // indirect
68-
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect
67+
k8s.io/apimachinery v0.31.1 // indirect
68+
k8s.io/klog/v2 v2.130.1 // indirect
69+
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
6970
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
7071
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
7172
)

0 commit comments

Comments
 (0)