Skip to content

feat: Eventing support for flagd provider #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Sep 4, 2023

Conversation

Kavindu-Dodan
Copy link
Contributor

@Kavindu-Dodan Kavindu-Dodan commented Aug 25, 2023

This PR

Adds OpenFeature Events extension 1 support to flagd provider

tldr

  • UseIService.go as the main interface between provider and grpc handling (flagd connectivity)
  • Cache is now extracted to a dedicated service (potential improvements exist here)
  • Provider configurations are extracted to a dedicated component named configuration.go
  • Eventing support

Review commit by commit OR with a checkout of the original branch to have more focus


Main refactoring on this PR focuses on isolating grpc based flagd connectivity to the service layer. This was done by refactoring provider.go and updating IService.go. With the change, we no longer have grpc dependencies at provider level. This is favorable for future efforts such as in-memory provider capability proposed through open-feature/flagd#848

Caching is now isolated to a dedicated service. This isolation helps to pass the service to appropriate caching locations and maintain a single cache within the provider.

Provider configurations were also extracted to a new component to reduce logic at the provider level.

Given below is an overview of component relationships in the current state,

image

Footnotes

  1. https://openfeature.dev/specification/sections/events

Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
@Kavindu-Dodan Kavindu-Dodan requested a review from a team as a code owner August 25, 2023 20:55
@github-actions github-actions bot requested a review from toddbaert August 25, 2023 20:55
@@ -12,7 +12,7 @@ test:
go list -f '{{.Dir}}/...' -m | xargs -I{} go test -v {}

lint:
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latest release is not compatible with go version 1.19+ variants

Comment on lines +105 to +113
if s.cache.IsEnabled() {
fromCache, ok := s.cache.GetCache().Get(key)
if ok {
fromCacheResDetail, ok := fromCache.(openfeature.BoolResolutionDetail)
if ok {
fromCacheResDetail.Reason = ReasonCached
return fromCacheResDetail
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if we could use generics or some other mechanism to reduce this duplication.

Copy link
Contributor Author

@Kavindu-Dodan Kavindu-Dodan Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on this. I did not attempt this to reduce review efforts. Change in the PR fully maps to current main's logic (helps to see if there's API change/response change). But once merged, we might be able to find some commons and extract them to generic handlers

@toddbaert toddbaert self-requested a review August 28, 2023 18:14
Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only blocker for my approval (but please correct me if I'm misunderstanding).

Somewhat related: I think we should (in a spearate PR) implement the e2e flagd tests we had in the go-sdk here (since we've replaced them with the in-memory provider). This would give us more confidence around things like dep updates, etc in this provider.

I would be happy to work on that, or at least create an issue.

Kavindu-Dodan and others added 3 commits August 28, 2023 14:18
Co-authored-by: Todd Baert <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Co-authored-by: Todd Baert <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
}

certificatePath := os.Getenv(flagdServerCertPathEnvironmentVariableName)
if certificatePath != "" || os.Getenv(flagdTLSEnvironmentVariableName) == "true" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe worth trimming and lowercase the value of flagdTLSEnvironmentVariableName

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this is needed 🤔 I didn't want to add/change the behavior of this logic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, this doesn't need to be part of this PR. However, maybe it is worth unifying across languages how to process bool env var. @toddbaert do we have somewhere in the spec a common way for SDKs to handle truthy and falsy values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We document the value in lowercase 1. May be this is sufficient

Footnotes

  1. https://github.com/open-feature/go-sdk-contrib/tree/main/providers/flagd#using-flagdfromenv

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I updated the documentation to have lowercase options. See commit 0756c4f

Kavindu-Dodan and others added 8 commits August 29, 2023 10:12
Co-authored-by: Giovanni Liva <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Co-authored-by: Giovanni Liva <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Co-authored-by: Giovanni Liva <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Copy link
Member

@thisthat thisthat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Kavindu-Dodan 🙌

@toddbaert toddbaert self-requested a review September 1, 2023 13:48
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants