Skip to content

Commit

Permalink
getting dumber and dumber - remove once handler for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sighphyre committed Dec 8, 2023
1 parent 926d5bd commit 63993de
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
2 changes: 0 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,11 @@ func (uc *Client) isEnabled(feature string, options ...FeatureOption) api.Strate
}

func (uc *Client) isParentDependencySatisfied(feature *api.Feature, context context.Context) bool {
warnOnce := &WarnOnce{}

dependenciesSatisfied := func(parent api.Dependency) bool {
parentToggle := uc.repository.getToggle(parent.Feature)

if parentToggle == nil {
warnOnce.Warn("the parent toggle was not found in the cache, the evaluation of this dependency will always be false")
return false
}

Expand Down
15 changes: 1 addition & 14 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"os/user"
"reflect"
"sync"
"time"
)

Expand Down Expand Up @@ -46,18 +45,6 @@ func contains(arr []string, str string) bool {
return false
}

// WarnOnce is a type for handling warnings that should only be displayed once.
type WarnOnce struct {
once sync.Once
}

// Warn logs the warning message once.
func (wo *WarnOnce) Warn(message string) {
wo.once.Do(func() {
fmt.Println("Warning:", message)
})
}

func every(slice interface{}, condition func(interface{}) bool) bool {
sliceValue := reflect.ValueOf(slice)

Expand All @@ -66,7 +53,7 @@ func every(slice interface{}, condition func(interface{}) bool) bool {
return false
}

if (sliceValue.Len() == 0) {
if sliceValue.Len() == 0 {
return false
}

Expand Down

0 comments on commit 63993de

Please sign in to comment.