Skip to content

Commit 192d45a

Browse files
chore(go-feature-flag): Support new hook format (#641)
Signed-off-by: Thomas Poignant <[email protected]>
1 parent c2e1a73 commit 192d45a

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

providers/go-feature-flag/pkg/hook/data_collector_hook.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ func NewDataCollectorHook(dataCollectorManager *controller.DataCollectorManager)
1313
}
1414

1515
type dataCollectorHook struct {
16+
openfeature.UnimplementedHook
1617
dataCollectorManager *controller.DataCollectorManager
1718
}
1819

19-
func (d *dataCollectorHook) After(ctx context.Context, hookCtx openfeature.HookContext,
20+
func (d *dataCollectorHook) After(_ context.Context, hookCtx openfeature.HookContext,
2021
evalDetails openfeature.InterfaceEvaluationDetails, hint openfeature.HookHints) error {
2122
if evalDetails.Reason != openfeature.CachedReason {
2223
// we send it only when cached because the evaluation will be collected directly in the relay-proxy
@@ -37,7 +38,7 @@ func (d *dataCollectorHook) After(ctx context.Context, hookCtx openfeature.HookC
3738
return nil
3839
}
3940

40-
func (d *dataCollectorHook) Error(ctx context.Context, hookCtx openfeature.HookContext,
41+
func (d *dataCollectorHook) Error(_ context.Context, hookCtx openfeature.HookContext,
4142
err error, hint openfeature.HookHints) {
4243
event := model.FeatureEvent{
4344
Kind: "feature",
@@ -52,12 +53,3 @@ func (d *dataCollectorHook) Error(ctx context.Context, hookCtx openfeature.HookC
5253
}
5354
_ = d.dataCollectorManager.AddEvent(event)
5455
}
55-
56-
func (d *dataCollectorHook) Before(context.Context, openfeature.HookContext, openfeature.HookHints) (*openfeature.EvaluationContext, error) {
57-
// Do nothing, needed to satisfy the interface
58-
return nil, nil
59-
}
60-
61-
func (d *dataCollectorHook) Finally(context.Context, openfeature.HookContext, openfeature.HookHints) {
62-
// Do nothing, needed to satisfy the interface
63-
}

providers/go-feature-flag/pkg/hook/evaluation_enrichment_hook.go

+1-15
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,10 @@ func NewEvaluationEnrichmentHook(exporterMetadata map[string]interface{}) openfe
1010
}
1111

1212
type evaluationEnrichmentHook struct {
13+
openfeature.UnimplementedHook
1314
exporterMetadata map[string]interface{}
1415
}
1516

16-
func (d *evaluationEnrichmentHook) After(_ context.Context, _ openfeature.HookContext,
17-
_ openfeature.InterfaceEvaluationDetails, _ openfeature.HookHints) error {
18-
// Do nothing, needed to satisfy the interface
19-
return nil
20-
}
21-
22-
func (d *evaluationEnrichmentHook) Error(_ context.Context, _ openfeature.HookContext,
23-
_ error, _ openfeature.HookHints) {
24-
// Do nothing, needed to satisfy the interface
25-
}
26-
2717
func (d *evaluationEnrichmentHook) Before(_ context.Context, hookCtx openfeature.HookContext, _ openfeature.HookHints) (*openfeature.EvaluationContext, error) {
2818
attributes := hookCtx.EvaluationContext().Attributes()
2919
if goffSpecific, ok := attributes["gofeatureflag"]; ok {
@@ -39,7 +29,3 @@ func (d *evaluationEnrichmentHook) Before(_ context.Context, hookCtx openfeature
3929
newCtx := openfeature.NewEvaluationContext(hookCtx.EvaluationContext().TargetingKey(), attributes)
4030
return &newCtx, nil
4131
}
42-
43-
func (d *evaluationEnrichmentHook) Finally(context.Context, openfeature.HookContext, openfeature.HookHints) {
44-
// Do nothing, needed to satisfy the interface
45-
}

0 commit comments

Comments
 (0)