Skip to content
Open
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
20 changes: 10 additions & 10 deletions client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ func WithAnalyticsEnabled(val bool) ConfigOption {
}
}

// WithURL set baseUrl for communicating with ff server
// WithURL sets baseUrl for communicating with ff server
func WithURL(url string) ConfigOption {
return func(config *config) {
config.url = url
}
}

// WithEventsURL set eventsURL for communicating with ff server
// WithEventsURL sets eventsURL for communicating with ff server
func WithEventsURL(url string) ConfigOption {
return func(config *config) {
config.eventsURL = url
}
}

// WithPullInterval set pulling interval in minutes
// WithPullInterval sets pulling interval in minutes
func WithPullInterval(interval uint) ConfigOption {
return func(config *config) {
config.pullInterval = interval
}
}

// WithCache set custom cache or predefined one from cache package
// WithCache sets custom cache or predefined one from cache package
func WithCache(cache cache.Cache) ConfigOption {
return func(config *config) {
config.Cache = cache
Expand All @@ -55,7 +55,7 @@ func WithCache(cache cache.Cache) ConfigOption {
}
}

// WithStore set custom storage or predefined one from storage package
// WithStore sets custom storage or predefined one from storage package
func WithStore(store storage.Storage) ConfigOption {
return func(config *config) {
config.Store = store
Expand All @@ -65,28 +65,28 @@ func WithStore(store storage.Storage) ConfigOption {
}
}

// WithLogger set custom logger used in main application
// WithLogger sets custom logger used in main application
func WithLogger(logger logger.Logger) ConfigOption {
return func(config *config) {
config.Logger = logger
}
}

// WithStreamEnabled set stream on or off
// WithStreamEnabled sets stream on or off
func WithStreamEnabled(val bool) ConfigOption {
return func(config *config) {
config.enableStream = val
}
}

// WithStoreEnabled set store on or off
// WithStoreEnabled sets store on or off
func WithStoreEnabled(val bool) ConfigOption {
return func(config *config) {
config.enableStore = val
}
}

// WithHTTPClient set auth and http client for use in interactions with ff server
// WithHTTPClient sets auth and http client for use in interactions with ff server
func WithHTTPClient(client *http.Client) ConfigOption {
return func(config *config) {
config.authHttpClient = client
Expand Down Expand Up @@ -131,7 +131,7 @@ func WithMaxAuthRetries(i int) ConfigOption {
}

// WithAuthRetryStrategy sets the backoff and retry strategy for client authentication requests
// Mainly used for testing purposes, as the SDKs default backoff strategy should be sufficient for most if not all scenarios.
// Mainly used for testing purposes, as the SDK's default backoff strategy should be sufficient for most if not all scenarios.
func WithAuthRetryStrategy(retryStrategy *backoff.ExponentialBackOff) ConfigOption {
return func(config *config) {
config.authRetryStrategy = retryStrategy
Expand Down
22 changes: 11 additions & 11 deletions types/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func NewInteger(value interface{}) (*Integer, error) {
newStr := Integer(num)
return &newStr, nil
}
return nil, fmt.Errorf("%v: cant cast to a integer", ErrWrongTypeAssertion)
return nil, fmt.Errorf("%v: can't cast to an integer", ErrWrongTypeAssertion)
}

// intOperator takes the first element from the slice, converts it to a int64 and passes to fn for processing.
// intOperator takes the first element from the slice, converts it to an int64 and passes to fn for processing.
// we ignore any additional elements if they exist.
func intOperator(value []string, fn func(int64) bool) bool {
if len(value) > 0 {
Expand All @@ -35,32 +35,32 @@ func intOperator(value []string, fn func(int64) bool) bool {
return false
}

// StartsWith always return false
// StartsWith always returns false
func (n Integer) StartsWith([]string) bool {
return false
}

// EndsWith always return false
// EndsWith always returns false
func (n Integer) EndsWith([]string) bool {
return false
}

// Match always return false
// Match always returns false
func (n Integer) Match([]string) bool {
return false
}

// Contains always return false
// Contains always returns false
func (n Integer) Contains([]string) bool {
return false
}

// EqualSensitive always return false
// EqualSensitive always returns false
func (n Integer) EqualSensitive([]string) bool {
return false
}

// Equal check if the number and value are equal
// Equal checks if the number and value are equal
func (n Integer) Equal(value []string) bool {
return intOperator(value, func(f int64) bool {
return int64(n) == f
Expand All @@ -74,7 +74,7 @@ func (n Integer) GreaterThan(value []string) bool {
})
}

// GreaterThanEqual checks if the number is greater or equal than the value
// GreaterThanEqual checks if the number is greater than or equal to the value
func (n Integer) GreaterThanEqual(value []string) bool {
return intOperator(value, func(f int64) bool {
return int64(n) >= f
Expand All @@ -88,14 +88,14 @@ func (n Integer) LessThan(value []string) bool {
})
}

// LessThanEqual checks if the number is less or equal than the value
// LessThanEqual checks if the number is less than or equal to the value
func (n Integer) LessThanEqual(value []string) bool {
return intOperator(value, func(f int64) bool {
return int64(n) <= f
})
}

// In checks if the number exist in slice of numbers (value)
// In checks if the number exists in a slice of numbers (value)
func (n Integer) In(value []string) bool {
for _, x := range value {
if n.Equal([]string{x}) {
Expand Down
20 changes: 10 additions & 10 deletions types/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func NewNumber(value interface{}) (*Number, error) {
newStr := Number(num)
return &newStr, nil
}
return nil, fmt.Errorf("%v: cant cast to a number", ErrWrongTypeAssertion)
return nil, fmt.Errorf("%v: can't cast to a number", ErrWrongTypeAssertion)
}

// numberOperator takes the first element from the slice, converts it to a float64 and passes to fn for processing.
Expand All @@ -34,32 +34,32 @@ func numberOperator(value []string, fn func(float64) bool) bool {
return false
}

// StartsWith always return false
// StartsWith always returns false
func (n Number) StartsWith(value []string) bool {
return false
}

// EndsWith always return false
// EndsWith always returns false
func (n Number) EndsWith(value []string) bool {
return false
}

// Match always return false
// Match always returns false
func (n Number) Match(value []string) bool {
return false
}

// Contains always return false
// Contains always returns false
func (n Number) Contains(value []string) bool {
return false
}

// EqualSensitive always return false
// EqualSensitive always returns false
func (n Number) EqualSensitive(value []string) bool {
return false
}

// Equal check if the number and value are equal
// Equal checks if the number and value are equal
func (n Number) Equal(value []string) bool {
return numberOperator(value, func(f float64) bool {
return float64(n) == f
Expand All @@ -73,7 +73,7 @@ func (n Number) GreaterThan(value []string) bool {
})
}

// GreaterThanEqual checks if the number is greater or equal than the value
// GreaterThanEqual checks if the number is greater than or equal to the value
func (n Number) GreaterThanEqual(value []string) bool {
return numberOperator(value, func(f float64) bool {
return float64(n) >= f
Expand All @@ -87,14 +87,14 @@ func (n Number) LessThan(value []string) bool {
})
}

// LessThanEqual checks if the number is less or equal than the value
// LessThanEqual checks if the number is less than or equal to the value
func (n Number) LessThanEqual(value []string) bool {
return numberOperator(value, func(f float64) bool {
return float64(n) <= f
})
}

// In checks if the number exist in slice of numbers (value)
// In checks if the number exists in a slice of numbers (value)
func (n Number) In(value []string) bool {
for _, x := range value {
if n.Equal([]string{x}) {
Expand Down
22 changes: 11 additions & 11 deletions types/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,52 +78,52 @@ func (s Slice) In(values []string) bool {
return false
}

// Equal always return false
// Equal always returns false
func (s Slice) Equal(value []string) bool {
return s.In(value)
}

// Contains always return false
// Contains always returns false
func (s Slice) Contains(values []string) bool {
return s.In(values)
}

// StartsWith always return false
// StartsWith always returns false
func (s Slice) StartsWith(value []string) bool {
return false
}

// EndsWith always return false
// EndsWith always returns false
func (s Slice) EndsWith(value []string) bool {
return false
}

// Match always return false
// Match always returns false
func (s Slice) Match(value []string) bool {
return false
}

// EqualSensitive always return false
// EqualSensitive always returns false
func (s Slice) EqualSensitive(value []string) bool {
return false
}

// GreaterThan always return false
// GreaterThan always returns false
func (s Slice) GreaterThan(value []string) bool {
return false
}

// GreaterThanEqual always return false
// GreaterThanEqual always returns false
func (s Slice) GreaterThanEqual(value []string) bool {
return false
}

// LessThan always return false
// LessThan always returns false
func (s Slice) LessThan(value []string) bool {
return false
}

// LessThanEqual always return false
// LessThanEqual always returns false
func (s Slice) LessThanEqual(value []string) bool {
return false
}
Expand Down Expand Up @@ -173,7 +173,7 @@ func boolcmp(attribute bool, values []string) bool {
return false
}

// validateSlice checks if this is a ptr and deference it
// validateSlice checks if this is a ptr and dereference it
// then validates that we are working with a slice.
func validateSlice(data interface{}) interface{} {
v := reflect.ValueOf(data)
Expand Down
22 changes: 11 additions & 11 deletions types/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ func NewString(value interface{}) (*String, error) {
newStr := String(str)
return &newStr, nil
}
return nil, fmt.Errorf("%v: cant cast to a string", ErrWrongTypeAssertion)
return nil, fmt.Errorf("%v: can't cast to a string", ErrWrongTypeAssertion)
}

// String implement Stringer interface
// String implements Stringer interface
func (s String) String() string {
return string(s)
}
Expand All @@ -33,21 +33,21 @@ func stringOperator(value []string, fn func(string) bool) bool {
return false
}

// StartsWith check if the string starts with the value
// StartsWith checks if the string starts with the value
func (s String) StartsWith(value []string) bool {
return stringOperator(value, func(c string) bool {
return strings.HasPrefix(string(s), c)
})
}

// EndsWith check if the string ends with the value
// EndsWith checks if the string ends with the value
func (s String) EndsWith(value []string) bool {
return stringOperator(value, func(c string) bool {
return strings.HasSuffix(string(s), c)
})
}

// Match check if the string match the regex value
// Match checks if the string matches the regex value
func (s String) Match(value []string) bool {
return stringOperator(value, func(c string) bool {
if matched, err := regexp.MatchString(string(s), c); err == nil {
Expand All @@ -57,21 +57,21 @@ func (s String) Match(value []string) bool {
})
}

// Contains check if the string contains the value
// Contains checks if the string contains the value
func (s String) Contains(value []string) bool {
return stringOperator(value, func(c string) bool {
return strings.Contains(string(s), c)
})
}

// EqualSensitive check if the string and value are equal (case sensitive)
// EqualSensitive checks if the string and value are equal (case sensitive)
func (s String) EqualSensitive(value []string) bool {
return stringOperator(value, func(c string) bool {
return string(s) == c
})
}

// Equal check if the string and value are equal
// Equal checks if the string and value are equal
func (s String) Equal(value []string) bool {
return stringOperator(value, func(c string) bool {
return strings.EqualFold(string(s), c)
Expand All @@ -85,7 +85,7 @@ func (s String) GreaterThan(value []string) bool {
})
}

// GreaterThanEqual checks if the string is greater or equal than the value
// GreaterThanEqual checks if the string is greater than or equal to the value
func (s String) GreaterThanEqual(value []string) bool {
return stringOperator(value, func(c string) bool {
return strings.ToLower(string(s)) >= strings.ToLower(c)
Expand All @@ -99,14 +99,14 @@ func (s String) LessThan(value []string) bool {
})
}

// LessThanEqual checks if the string is less or equal than the value
// LessThanEqual checks if the string is less than or equal to the value
func (s String) LessThanEqual(value []string) bool {
return stringOperator(value, func(c string) bool {
return strings.ToLower(string(s)) <= strings.ToLower(c)
})
}

// In checks if the string exist in slice of strings (value)
// In checks if the string exists in a slice of strings (value)
func (s String) In(value []string) bool {
for _, x := range value {
if strings.EqualFold(string(s), x) {
Expand Down