Skip to content
Merged
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
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@
<a href="https://codecov.io/gh/openflagr/flagr">
<img src="https://codecov.io/gh/openflagr/flagr/branch/main/graph/badge.svg?token=iwjv26grrN">
</a>
<a href="https://deepwiki.com/openflagr/flagr">
<img src="https://deepwiki.com/badge.svg?color=green" alt="Ask DeepWiki">
</a>
</p>

## Introduction

`openflagr/flagr` is a community-driven OSS effort of advancing the development of Flagr.

Flagr is an open source Go service that delivers the right experience to the right entity and monitors the impact. It provides feature flags, experimentation (A/B testing), and dynamic configuration. It has clear swagger REST APIs for flags management and flag evaluation.

## Documentation

- https://openflagr.github.io/flagr

## Quick demo
Expand Down Expand Up @@ -56,7 +61,6 @@ curl --request POST \
}'
```


## Flagr Evaluation Performance

Tested with `vegeta`. For more details, see [benchmarks](./benchmark).
Expand All @@ -80,14 +84,14 @@ Error Set:

## Client Libraries

| Language | Clients |
| -------- | ------- |
| Go | [goflagr](https://github.com/openflagr/goflagr) |
| Language | Clients |
| ---------- | ----------------------------------------------- |
| Go | [goflagr](https://github.com/openflagr/goflagr) |
| Javascript | [jsflagr](https://github.com/openflagr/jsflagr) |
| Python | [pyflagr](https://github.com/openflagr/pyflagr) |
| Ruby | [rbflagr](https://github.com/openflagr/rbflagr) |
| Python | [pyflagr](https://github.com/openflagr/pyflagr) |
| Ruby | [rbflagr](https://github.com/openflagr/rbflagr) |

## License and Credit

- [`openflagr/flagr`](https://github.com/openflagr/flagr) Apache 2.0
- [`checkr/flagr`](https://github.com/checkr/flagr) Apache 2.0

8 changes: 4 additions & 4 deletions pkg/config/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ func SetupGlobalMiddleware(handler http.Handler) http.Handler {

type recoveryLogger struct{}

func (r *recoveryLogger) Printf(format string, v ...interface{}) {
func (r *recoveryLogger) Printf(format string, v ...any) {
logrus.Errorf(format, v...)
}

func (r *recoveryLogger) Println(v ...interface{}) {
func (r *recoveryLogger) Println(v ...any) {
logrus.Errorln(v...)
}

Expand All @@ -133,7 +133,7 @@ setupJWTAuthMiddleware setup an JWTMiddleware from the ENV config
*/
func setupJWTAuthMiddleware() *jwtAuth {
var signingMethod jwt.SigningMethod
var validationKey interface{}
var validationKey any
var errParsingKey error

switch Config.JWTAuthSigningMethod {
Expand All @@ -155,7 +155,7 @@ func setupJWTAuthMiddleware() *jwtAuth {
PrefixWhitelistPaths: Config.JWTAuthPrefixWhitelistPaths,
ExactWhitelistPaths: Config.JWTAuthExactWhitelistPaths,
JWTMiddleware: jwtmiddleware.New(jwtmiddleware.Options{
ValidationKeyGetter: func(token *jwt.Token) (interface{}, error) {
ValidationKeyGetter: func(token *jwt.Token) (any, error) {
return validationKey, errParsingKey
},
SigningMethod: signingMethod,
Expand Down
2 changes: 1 addition & 1 deletion pkg/entity/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
)

// AutoMigrateTables stores the entity tables that we can auto migrate in gorm
var AutoMigrateTables = []interface{}{
var AutoMigrateTables = []any{
Flag{},
Constraint{},
Distribution{},
Expand Down
2 changes: 1 addition & 1 deletion pkg/entity/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
type EvalContext struct {
EntityID string
EntityType string
EntityContext map[string]interface{}
EntityContext map[string]any

EnableDebug bool
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/entity/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func GenFixtureFlag() Flag {
Model: gorm.Model{ID: 301},
FlagID: 100,
Key: "treatment",
Attachment: map[string]interface{}{
Attachment: map[string]any{
"value": "321",
},
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/entity/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func (l *Logger) LogMode(level gorm_logger.LogLevel) gorm_logger.Interface {
return &newlogger
}

func (l *Logger) Info(ctx context.Context, s string, args ...interface{}) {
func (l *Logger) Info(ctx context.Context, s string, args ...any) {
logrus.WithContext(ctx).Infof(s, args...)
}

func (l *Logger) Warn(ctx context.Context, s string, args ...interface{}) {
func (l *Logger) Warn(ctx context.Context, s string, args ...any) {
logrus.WithContext(ctx).Warnf(s, args...)
}

func (l *Logger) Error(ctx context.Context, s string, args ...interface{}) {
func (l *Logger) Error(ctx context.Context, s string, args ...any) {
logrus.WithContext(ctx).Errorf(s, args...)
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/handler/crud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ func TestCrudVariants(t *testing.T) {
VariantID: int64(1),
Body: &models.PutVariantRequest{
Key: util.StringPtr("another_control"),
Attachment: map[string]interface{}{
Attachment: map[string]any{
"valid_string_value": "1",
},
},
Expand All @@ -946,7 +946,7 @@ func TestCrudVariants(t *testing.T) {
VariantID: int64(1),
Body: &models.PutVariantRequest{
Key: util.StringPtr("another_control"),
Attachment: map[string]interface{}{
Attachment: map[string]any{
"valid_int_value": 1,
},
},
Expand All @@ -958,8 +958,8 @@ func TestCrudVariants(t *testing.T) {
VariantID: int64(1),
Body: &models.PutVariantRequest{
Key: util.StringPtr("another_control"),
Attachment: map[string]interface{}{
"valid_structured_value": map[string]interface{}{
Attachment: map[string]any{
"valid_structured_value": map[string]any{
"string_value": "string",
"int_value": 1,
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/handler/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type Error struct {
StatusCode int
Message string
Values []interface{}
Values []any
}

func (e *Error) Error() string {
Expand All @@ -20,7 +20,7 @@ func (e *Error) Error() string {
}

// NewError creates Error
func NewError(statusCode int, msg string, values ...interface{}) *Error {
func NewError(statusCode int, msg string, values ...any) *Error {
return &Error{
StatusCode: statusCode,
Message: msg,
Expand All @@ -29,7 +29,7 @@ func NewError(statusCode int, msg string, values ...interface{}) *Error {
}

// ErrorMessage generates error messages
func ErrorMessage(s string, data ...interface{}) *models.Error {
func ErrorMessage(s string, data ...any) *models.Error {
return &models.Error{
Message: util.StringPtr(fmt.Sprintf(s, data...)),
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/handler/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ var evalSegment = func(
evalNextSegment bool,
) {
if len(segment.Constraints) != 0 {
m, ok := evalContext.EntityContext.(map[string]interface{})
m, ok := evalContext.EntityContext.(map[string]any)
if !ok {
log = &models.SegmentDebugLog{
Msg: fmt.Sprintf("constraints are present in the segment_id %v, but got invalid entity_context: %s.", segment.ID, spew.Sdump(evalContext.EntityContext)),
Expand Down Expand Up @@ -356,7 +356,7 @@ var evalSegment = func(
return vID, log, false
}

func debugConstraintMsg(enableDebug bool, expr conditions.Expr, m map[string]interface{}) string {
func debugConstraintMsg(enableDebug bool, expr conditions.Expr, m map[string]any) string {
if !enableDebug {
return ""
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/handler/eval_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (ec *EvalCache) getByTagsALL(tags []string) map[uint]*entity.Flag {
}

// GetByFlagKeyOrID gets the flag by Key or ID
func (ec *EvalCache) GetByFlagKeyOrID(keyOrID interface{}) *entity.Flag {
func (ec *EvalCache) GetByFlagKeyOrID(keyOrID any) *entity.Flag {
s := util.SafeString(keyOrID)

ec.cacheMutex.RLock()
Expand All @@ -152,7 +152,7 @@ func (ec *EvalCache) reloadMapCache() error {
defer config.Global.NewrelicApp.StartTransaction("eval_cache_reload", nil, nil).End()
}

_, _, err := withtimeout.Do(ec.refreshTimeout, func() (interface{}, error) {
_, _, err := withtimeout.Do(ec.refreshTimeout, func() (any, error) {
idCache, keyCache, tagCache, err := ec.fetchAllFlags()
if err != nil {
return nil, err
Expand Down
Loading
Loading