Skip to content

feat: enhance provider with Bucketeer SDK integration and evaluation methods#3

Merged
nnnkkk7 merged 7 commits intomainfrom
feat/impl-methods
May 7, 2025
Merged

feat: enhance provider with Bucketeer SDK integration and evaluation methods#3
nnnkkk7 merged 7 commits intomainfrom
feat/impl-methods

Conversation

@nnnkkk7
Copy link
Contributor

@nnnkkk7 nnnkkk7 commented Apr 21, 2025

  • Feature Provider implementation with Bucketeer SDK integration
  • Evaluation methods for 5 data types (Boolean, String, Float, Int, Object)
  • Mapping between Bucketeer evaluation reasons and OpenFeature reasons
  • Conversion logic from OpenFeature context to Bucketeer user
  • Comprehensive unit tests

@nnnkkk7 nnnkkk7 force-pushed the feat/impl-methods branch from d70595e to 1957b54 Compare April 23, 2025 04:41
@nnnkkk7 nnnkkk7 changed the title feat: enhance provider with Bucketeer SDK integration and evaluation … feat: enhance provider with Bucketeer SDK integration and evaluation methods Apr 23, 2025
@nnnkkk7 nnnkkk7 marked this pull request as ready for review April 23, 2025 04:51
@nnnkkk7 nnnkkk7 requested review from cre8ivejp, hvn2k1 and kakcy April 23, 2025 04:52
@cre8ivejp cre8ivejp requested a review from Copilot April 25, 2025 04:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR integrates the Bucketeer SDK into the feature provider to support evaluation methods for Boolean, String, Float, Int, and Object flag types and maps Bucketeer evaluation reasons to OpenFeature reasons.

  • Implements the BucketeerSDK interface with evaluation methods for various data types.
  • Converts OpenFeature context into a Bucketeer user and maps evaluation reasons accordingly.
  • Adds comprehensive unit tests for the new functionality.
Files not reviewed (1)
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

pkg/provider.go:120

  • The variable 'flag' appears to be used without a declaration in this function; please ensure it is passed as a parameter or defined within the scope to prevent undefined variable errors.
evaluation := p.sdk.BoolVariationDetails(ctx, bucketeerUser, flag, defaultValue)

nnnkkk7 and others added 3 commits April 25, 2025 14:07
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nnnkkk7 nnnkkk7 requested a review from duyhungtnn April 25, 2025 07:14
Copy link
Collaborator

@duyhungtnn duyhungtnn left a comment

Choose a reason for hiding this comment

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

Hi @nnnkkk7,
Great work!

I have a few comments—please take a look.

assert.Equal(t, test.expectedReason, actual)
})
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will you add the e2e tests ?

Copy link
Contributor Author

@nnnkkk7 nnnkkk7 Apr 30, 2025

Choose a reason for hiding this comment

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

Yes!
I'll add it in another PR!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, please add the document on how to initiate and use the provider, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok!

@nnnkkk7 nnnkkk7 force-pushed the feat/impl-methods branch from 0de5986 to 0293115 Compare April 30, 2025 09:35
@nnnkkk7 nnnkkk7 force-pushed the feat/impl-methods branch from 0293115 to 39273ad Compare April 30, 2025 09:47
@nnnkkk7 nnnkkk7 requested a review from duyhungtnn April 30, 2025 09:55
Copy link
Collaborator

@duyhungtnn duyhungtnn left a comment

Choose a reason for hiding this comment

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

Your changes look good.
I’m just wondering if we could support more data types in the OpenFeature EvaluationContext.

pkg/provider.go Outdated
Comment on lines +276 to +284
valStr, ok := val.(string)
if !ok {
return user.User{},
ToPtr(openfeature.NewParseErrorResolutionError(
fmt.Sprintf("key %q, value %q can not be converted to string", key, val),
),
)
}
bucketeerUser.Data[key] = valStr
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
valStr, ok := val.(string)
if !ok {
return user.User{},
ToPtr(openfeature.NewParseErrorResolutionError(
fmt.Sprintf("key %q, value %q can not be converted to string", key, val),
),
)
}
bucketeerUser.Data[key] = valStr
switch v := val.(type) {
case string:
bucketeerUser.Data[key] = v
default:
jsonBytes, err := json.Marshal(v)
if err != nil {
return user.User{}, ToPtr(openfeature.NewParseErrorResolutionError(
fmt.Sprintf("key %q, value %q cannot be converted to JSON string: %v", key, val, err),
))
}
bucketeerUser.Data[key] = string(jsonBytes)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think ?
If the val contains unsupported data types (e.g., functions, channels, circular references), json.Marshal will fail and return an error.
Otherwise, it seems good.

Copy link
Contributor Author

@nnnkkk7 nnnkkk7 May 1, 2025

Choose a reason for hiding this comment

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

Thank you!
I fixed and added the test!
fix: add other data types to toBucketeerUser

assert.Equal(t, test.expectedReason, actual)
})
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, please add the document on how to initiate and use the provider, too.

@nnnkkk7 nnnkkk7 requested a review from duyhungtnn May 1, 2025 09:48
Copy link
Collaborator

@duyhungtnn duyhungtnn left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@nnnkkk7 nnnkkk7 merged commit 0d3d31c into main May 7, 2025
4 checks passed
@nnnkkk7 nnnkkk7 deleted the feat/impl-methods branch June 18, 2025 07:17
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.

3 participants