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

[FFM-2186] integration of the evaluation engine into the sdk client #75

Merged
merged 5 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
.idea
c.out
20 changes: 8 additions & 12 deletions analyticsservice/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"sync"
"time"

"github.com/harness/ff-golang-server-sdk/rest"

"github.com/harness/ff-golang-server-sdk/evaluation"
"github.com/harness/ff-golang-server-sdk/metricsclient"

Expand All @@ -31,8 +33,8 @@ const (

type analyticsEvent struct {
target *evaluation.Target
featureConfig evaluation.FeatureConfig
variation evaluation.Variation
featureConfig *rest.FeatureConfig
variation *rest.Variation
count int
}

Expand Down Expand Up @@ -75,28 +77,22 @@ func (as *AnalyticsService) Start(ctx context.Context, client *metricsclient.Cli
}

func (as *AnalyticsService) startTimer(ctx context.Context) {
timerloop:
for {
select {
case <-time.After(as.timeout):
as.sendDataAndResetCache(ctx)
case <-ctx.Done():
close(as.analyticsChan)
break timerloop
return
}
}
}

// PushToQueue is used to queue analytics data to send to the server
func (as *AnalyticsService) PushToQueue(target *evaluation.Target, featureConfig *evaluation.FeatureConfig, variation evaluation.Variation) {
fc := evaluation.FeatureConfig{}
if featureConfig != nil {
fc = *featureConfig
}
func (as *AnalyticsService) PushToQueue(featureConfig *rest.FeatureConfig, target *evaluation.Target, variation *rest.Variation) {

ad := analyticsEvent{
target: target,
featureConfig: fc,
featureConfig: featureConfig,
variation: variation,
}
as.analyticsChan <- ad
Expand Down Expand Up @@ -136,7 +132,7 @@ func (as *AnalyticsService) sendDataAndResetCache(ctx context.Context) {
for _, analytic := range analyticsData {
if analytic.target != nil {
if analytic.target.Anonymous == nil || !*analytic.target.Anonymous {
var targetAttributes []metricsclient.KeyValue
targetAttributes := make([]metricsclient.KeyValue, 0)
if analytic.target.Attributes != nil {
targetAttributes = make([]metricsclient.KeyValue, 0, len(*analytic.target.Attributes))
for key, value := range *analytic.target.Attributes {
Expand Down
Loading