diff --git a/providers/go-feature-flag/pkg/hook/data_collector_hook.go b/providers/go-feature-flag/pkg/hook/data_collector_hook.go index 16e99de95..dd7a476a0 100644 --- a/providers/go-feature-flag/pkg/hook/data_collector_hook.go +++ b/providers/go-feature-flag/pkg/hook/data_collector_hook.go @@ -13,10 +13,11 @@ func NewDataCollectorHook(dataCollectorManager *controller.DataCollectorManager) } type dataCollectorHook struct { + openfeature.UnimplementedHook dataCollectorManager *controller.DataCollectorManager } -func (d *dataCollectorHook) After(ctx context.Context, hookCtx openfeature.HookContext, +func (d *dataCollectorHook) After(_ context.Context, hookCtx openfeature.HookContext, evalDetails openfeature.InterfaceEvaluationDetails, hint openfeature.HookHints) error { if evalDetails.Reason != openfeature.CachedReason { // 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 return nil } -func (d *dataCollectorHook) Error(ctx context.Context, hookCtx openfeature.HookContext, +func (d *dataCollectorHook) Error(_ context.Context, hookCtx openfeature.HookContext, err error, hint openfeature.HookHints) { event := model.FeatureEvent{ Kind: "feature", @@ -52,12 +53,3 @@ func (d *dataCollectorHook) Error(ctx context.Context, hookCtx openfeature.HookC } _ = d.dataCollectorManager.AddEvent(event) } - -func (d *dataCollectorHook) Before(context.Context, openfeature.HookContext, openfeature.HookHints) (*openfeature.EvaluationContext, error) { - // Do nothing, needed to satisfy the interface - return nil, nil -} - -func (d *dataCollectorHook) Finally(context.Context, openfeature.HookContext, openfeature.HookHints) { - // Do nothing, needed to satisfy the interface -} diff --git a/providers/go-feature-flag/pkg/hook/evaluation_enrichment_hook.go b/providers/go-feature-flag/pkg/hook/evaluation_enrichment_hook.go index 71462a8f0..dfdf74c79 100644 --- a/providers/go-feature-flag/pkg/hook/evaluation_enrichment_hook.go +++ b/providers/go-feature-flag/pkg/hook/evaluation_enrichment_hook.go @@ -10,20 +10,10 @@ func NewEvaluationEnrichmentHook(exporterMetadata map[string]interface{}) openfe } type evaluationEnrichmentHook struct { + openfeature.UnimplementedHook exporterMetadata map[string]interface{} } -func (d *evaluationEnrichmentHook) After(_ context.Context, _ openfeature.HookContext, - _ openfeature.InterfaceEvaluationDetails, _ openfeature.HookHints) error { - // Do nothing, needed to satisfy the interface - return nil -} - -func (d *evaluationEnrichmentHook) Error(_ context.Context, _ openfeature.HookContext, - _ error, _ openfeature.HookHints) { - // Do nothing, needed to satisfy the interface -} - func (d *evaluationEnrichmentHook) Before(_ context.Context, hookCtx openfeature.HookContext, _ openfeature.HookHints) (*openfeature.EvaluationContext, error) { attributes := hookCtx.EvaluationContext().Attributes() if goffSpecific, ok := attributes["gofeatureflag"]; ok { @@ -39,7 +29,3 @@ func (d *evaluationEnrichmentHook) Before(_ context.Context, hookCtx openfeature newCtx := openfeature.NewEvaluationContext(hookCtx.EvaluationContext().TargetingKey(), attributes) return &newCtx, nil } - -func (d *evaluationEnrichmentHook) Finally(context.Context, openfeature.HookContext, openfeature.HookHints) { - // Do nothing, needed to satisfy the interface -}