Skip to content
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

feat: add single evaluation endpoint for OFREP #3267

Merged
merged 5 commits into from
Jul 29, 2024

Conversation

thepabloaguilar
Copy link
Contributor

@thepabloaguilar thepabloaguilar commented Jul 10, 2024

Hi guys, I'm opening this PR to gather opinions around the implementation of this endpoint for OFREP! What I thought was to just translate the protocol to Flipt internals and I did it by declaring an interface which is implemented by evaluation server as all the stuff to evaluate a flag is there, and also the OFREP layer will translate the errors to the expected pattern.

Refs #2980

@thepabloaguilar
Copy link
Contributor Author

Have you had a chance to check this out @markphelps / @GeorgeMac / @erka?

Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

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

looking great @thepabloaguilar !! great approach

just a few comments so far

internal/server/evaluation/ofrep_bridge.go Show resolved Hide resolved
internal/server/ofrep/errors.go Outdated Show resolved Hide resolved
rpc/flipt/ofrep/ofrep.proto Outdated Show resolved Hide resolved
@markphelps
Copy link
Collaborator

@thepabloaguilar can I help with anything here?

@thepabloaguilar
Copy link
Contributor Author

@markphelps I'm gonna take a look this weekend! Tough week 😆

@thepabloaguilar thepabloaguilar changed the title [WIP] feat: add ofrep evaluation endpoint feat: add single evaluation endpoint for OFREP Jul 25, 2024
@thepabloaguilar thepabloaguilar marked this pull request as ready for review July 25, 2024 03:27
@thepabloaguilar thepabloaguilar requested a review from a team as a code owner July 25, 2024 03:27
Copy link

codecov bot commented Jul 25, 2024

Codecov Report

Attention: Patch coverage is 78.80795% with 32 lines in your changes missing coverage. Please review.

Project coverage is 64.42%. Comparing base (c005e90) to head (da7e3a6).
Report is 11 commits behind head on main.

Files Patch % Lines
internal/server/ofrep/errors.go 62.50% 10 Missing and 5 partials ⚠️
internal/server/ofrep/evaluation.go 82.35% 7 Missing and 2 partials ⚠️
internal/server/evaluation/ofrep_bridge.go 84.90% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3267      +/-   ##
==========================================
+ Coverage   64.26%   64.42%   +0.15%     
==========================================
  Files         168      172       +4     
  Lines       13582    13731     +149     
==========================================
+ Hits         8729     8846     +117     
- Misses       4185     4207      +22     
- Partials      668      678      +10     
Flag Coverage Δ
unittests 64.42% <78.80%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@erka
Copy link
Collaborator

erka commented Jul 25, 2024

Great work @thepabloaguilar!

I tried to use OpenFeature go client for OFREP and somehow it ins't happy with the our metadata in response. It looks like we return null for it and client fails with openfeature: PARSE_ERROR: metadata must be a map of string keys and arbitrary values. Here is what I have with curl

❯ curl -X POST http://localhost:8080/ofrep/v1/evaluate/flags/variant-flag
{"key":"variant-flag","reason":"DEFAULT","variant":"azul","metadata":null,"value":"azul"}

This is my example

package main

import (
	"context"

	"github.com/open-feature/go-sdk-contrib/providers/ofrep"
	"github.com/open-feature/go-sdk/openfeature"
)

func main() {
	ofrepProvider := ofrep.NewProvider("http://localhost:8080")
	openfeature.SetProvider(ofrepProvider)
	client := openfeature.NewClient("default")
	value := client.String(context.Background(), "variant-flag", "", openfeature.EvaluationContext{})
	println("result", value)
}

I have no issue if I add empty metadata in resp := &ofrep.EvaluatedFlag{...} object.

@thepabloaguilar
Copy link
Contributor Author

@erka the return must be an empty object {}, just fixed it!

@markphelps
Copy link
Collaborator

@thepabloaguilar I added support for ofrep targetingKey here: thepabloaguilar#1

Signed-off-by: Pablo Aguilar <[email protected]>
@thepabloaguilar
Copy link
Contributor Author

Done the changes! Sorry @markphelps unconsciously I overrode your changes but I've put them back

Copy link
Collaborator

@erka erka left a comment

Choose a reason for hiding this comment

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

Looks great! @thepabloaguilar

Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

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

looks great! thank you @thepabloaguilar !!

@markphelps markphelps added the automerge Used by Kodiak bot to automerge PRs label Jul 29, 2024
@kodiakhq kodiakhq bot merged commit 9d25c18 into flipt-io:main Jul 29, 2024
31 of 32 checks passed
@thepabloaguilar thepabloaguilar deleted the issue-2980-single-evaluation branch July 29, 2024 13:48
@erka erka added the openfeature Created by Linear-GitHub Sync label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Used by Kodiak bot to automerge PRs openfeature Created by Linear-GitHub Sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants