Skip to content

feat: Create interface for eval events. #1288

Merged
Kavindu-Dodan merged 1 commit intoopen-feature:mainfrom
connyay:export-eventing-config
Apr 25, 2024
Merged

feat: Create interface for eval events. #1288
Kavindu-Dodan merged 1 commit intoopen-feature:mainfrom
connyay:export-eventing-config

Conversation

@connyay
Copy link
Copy Markdown
Contributor

@connyay connyay commented Apr 17, 2024

This PR

Before this change the eval services used a unexported
struct which prevented creating eval services outside of
this package.

This change creates a new IEvents interface that allows
providing custom impls of flag eval services.

Related Issues

Notes

Follow-up Tasks

How to test

@connyay connyay requested a review from a team April 17, 2024 22:27
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 17, 2024

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit b38764d
🔍 Latest deploy log https://app.netlify.com/sites/polite-licorice-3db33c/deploys/6628199b491e7c0008d7566f

@connyay connyay force-pushed the export-eventing-config branch from a087eca to 8a89c26 Compare April 18, 2024 00:26
Comment thread flagd/pkg/service/flag-evaluation/connect_service.go Outdated
@connyay
Copy link
Copy Markdown
Contributor Author

connyay commented Apr 18, 2024

would like to mount an eval service in an existing server, but don't see a way I can get this working without EventingConfiguration being exported.

It is possible I am breaking the warranty seal here, but this is pseudo code of what I'm trying to do:

func (f *flagdWrapper) Init(ctx context.Context) error {
	log := logging.GetLogger().With("component", "flagd.evaluation.v1").Desugar()
	reqIDLogging := false
	logger := logger.NewLogger(log, reqIDLogging)
	marshalOpts := flagdService.WithJSON(
		protojson.MarshalOptions{EmitUnpopulated: true},
		protojson.UnmarshalOptions{DiscardUnknown: true},
	)
	var (
		eval            evaluator.IEvaluator
		metricsRecorder *telemetry.MetricsRecorder
	)
	evalSvc := flagdService.NewFlagEvaluationService(
		logger, eval, nil /*eventingCfg*/, metricsRecorder,
	)
	_, flagdHandler := evaluationV1.NewServiceHandler(evalSvc, marshalOpts)

	prefix := "/flagd.evaluation.v1.Service/"
	service.MustGetHTTPServeMux(ctx).
		Handle(prefix, flagdHandler)

	return f.Initializer.Init(ctx)
}

Comment thread flagd/pkg/service/flag-evaluation/eventing.go Outdated
Comment thread flagd/pkg/service/flag-evaluation/connect_service.go Outdated
@Kavindu-Dodan
Copy link
Copy Markdown
Contributor

would like to mount an eval service in an existing server, but don't see a way I can get this working without EventingConfiguration being exported.

It is possible I am breaking the warranty seal here, but this is pseudo code of what I'm trying to do:

func (f *flagdWrapper) Init(ctx context.Context) error {
	log := logging.GetLogger().With("component", "flagd.evaluation.v1").Desugar()
	reqIDLogging := false
	logger := logger.NewLogger(log, reqIDLogging)
	marshalOpts := flagdService.WithJSON(
		protojson.MarshalOptions{EmitUnpopulated: true},
		protojson.UnmarshalOptions{DiscardUnknown: true},
	)
	var (
		eval            evaluator.IEvaluator
		metricsRecorder *telemetry.MetricsRecorder
	)
	evalSvc := flagdService.NewFlagEvaluationService(
		logger, eval, nil /*eventingCfg*/, metricsRecorder,
	)
	_, flagdHandler := evaluationV1.NewServiceHandler(evalSvc, marshalOpts)

	prefix := "/flagd.evaluation.v1.Service/"
	service.MustGetHTTPServeMux(ctx).
		Handle(prefix, flagdHandler)

	return f.Initializer.Init(ctx)
}

Thank you for showing the intended usage of the service. I proposed a few improvements to the PR so that it improves testability and makes component interactions clearer.

However, you should understand that as maintainers we cannot guarantee backward compatibility of the ConnectService in the long run. On the other hand, we will continue to avoid breaking changes in the flagd core [1] as this is intended to be a reusable component. For example, flagd Go provider use flagd core internally for in-process evaluations.

[1] - https://github.com/open-feature/flagd/tree/main/core

@Kavindu-Dodan
Copy link
Copy Markdown
Contributor

@connyay let me know if you can work on the proposed changes. If so we can include this alogn with our next release - #1292

@connyay
Copy link
Copy Markdown
Contributor Author

connyay commented Apr 19, 2024

@connyay let me know if you can work on the proposed changes. If so we can include this alogn with our next release - #1292

I can rework this to use interfaces. Will get to it over the next few days. You dont need to wait on me to cut a release though.

@Kavindu-Dodan
Copy link
Copy Markdown
Contributor

@connyay let me know if you can work on the proposed changes. If so we can include this alogn with our next release - #1292

I can rework this to use interfaces. Will get to it over the next few days. You dont need to wait on me to cut a release though.

Thanks and look forward to the change.

@connyay connyay changed the title feat: Export EventingConfiguration. feat: Create interface for eval events. Apr 23, 2024
@connyay connyay requested a review from Kavindu-Dodan April 23, 2024 13:32
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.25%. Comparing base (1c530ab) to head (b38764d).
Report is 56 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1288      +/-   ##
==========================================
+ Coverage   73.69%   77.25%   +3.56%     
==========================================
  Files          32       20      -12     
  Lines        3140     1618    -1522     
==========================================
- Hits         2314     1250    -1064     
+ Misses        717      286     -431     
+ Partials      109       82      -27     

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

@Kavindu-Dodan Kavindu-Dodan force-pushed the export-eventing-config branch from 20d0408 to ffa1919 Compare April 23, 2024 20:05
Copy link
Copy Markdown
Contributor

@Kavindu-Dodan Kavindu-Dodan left a comment

Choose a reason for hiding this comment

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

Changes looks good 🎉

@connyay could you please rebase and add DCO signature to commits. You can check the guide here - https://github.com/open-feature/flagd/pull/1288/checks?check_run_id=24131045370

Before this change the eval services used a unexported
struct which prevented creating eval services outside of
this package.

This change creates a new IEvents interface that allows
providing custom impls of flag eval services.

Signed-off-by: Connor Hindley <connor.hindley@tanium.com>
@connyay connyay force-pushed the export-eventing-config branch from ffa1919 to b38764d Compare April 23, 2024 20:27
@connyay
Copy link
Copy Markdown
Contributor Author

connyay commented Apr 23, 2024

However, you should understand that as maintainers we cannot guarantee backward compatibility of the ConnectService in the long run. On the other hand, we will continue to avoid breaking changes in the flagd core [1] as this is intended to be a reusable component. For example, flagd Go provider use flagd core internally for in-process evaluations.

Totally understand. Appreciate you still being open to this PR even with that being said 👍

@connyay connyay requested a review from Kavindu-Dodan April 25, 2024 15:26
@Kavindu-Dodan
Copy link
Copy Markdown
Contributor

However, you should understand that as maintainers we cannot guarantee backward compatibility of the ConnectService in the long run. On the other hand, we will continue to avoid breaking changes in the flagd core [1] as this is intended to be a reusable component. For example, flagd Go provider use flagd core internally for in-process evaluations.

Totally understand. Appreciate you still being open to this PR even with that being said 👍

👍 you're welcome. Please continuously check flagd releases for any important changes.

I will merge this when other maintainers approve

Copy link
Copy Markdown
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'm fine with this, given the caveats @Kavindu-Dodan mentioned.

@Kavindu-Dodan Kavindu-Dodan merged commit 9714215 into open-feature:main Apr 25, 2024
@github-actions github-actions Bot mentioned this pull request Apr 25, 2024
Kavindu-Dodan pushed a commit that referenced this pull request May 10, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>flagd: 0.10.2</summary>

##
[0.10.2](flagd/v0.10.1...flagd/v0.10.2)
(2024-05-10)


### ✨ New Features

* Create interface for eval events.
([#1288](#1288))
([9714215](9714215))


### 🧹 Chore

* bump go deps to latest
([#1307](#1307))
([004ad08](004ad08))
</details>

<details><summary>flagd-proxy: 0.6.2</summary>

##
[0.6.2](flagd-proxy/v0.6.1...flagd-proxy/v0.6.2)
(2024-05-10)


### 🧹 Chore

* bump go deps to latest
([#1307](#1307))
([004ad08](004ad08))
</details>

<details><summary>core: 0.9.2</summary>

##
[0.9.2](core/v0.9.1...core/v0.9.2)
(2024-05-10)


### ✨ New Features

* improve error log and add flag disabled handling for ofrep
([#1306](#1306))
([39ae4fe](39ae4fe))


### 🧹 Chore

* bump go deps to latest
([#1307](#1307))
([004ad08](004ad08))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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