Skip to content

Commit

Permalink
Merge branch 'main' into fix/release-please-artifact-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
beeme1mr authored Sep 23, 2022
2 parents ea63833 + 7559754 commit 8a9849c
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0"
".": "0.1.1"
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

## [0.1.1](https://github.com/open-feature/flagd/compare/v0.1.0...v0.1.1) (2022-09-23)


### Bug Fixes

* bubbles up unclean error exits ([#170](https://github.com/open-feature/flagd/issues/170)) ([9f7db02](https://github.com/open-feature/flagd/commit/9f7db0259d2d24cb880eeddaebd3b8f48758248a))
* upgrade package containing vulnerability ([#162](https://github.com/open-feature/flagd/issues/162)) ([82278c7](https://github.com/open-feature/flagd/commit/82278c7cf08cc6b50f49ab500caf6f9003fc0823))
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ curl -X POST "localhost:8013/flags/myBoolFlag/resolve/boolean"
Result:

```sh
{"value":true,"reason":"STATIC","variant":"on"}
{"value":true,"reason":"DEFAULT","variant":"on"}
```

<br />
Expand All @@ -58,7 +58,7 @@ curl -X POST "localhost:8013/flags/myStringFlag/resolve/string"
Result:

```sh
{"value":"val1","reason":"STATIC","variant":"key1"}
{"value":"val1","reason":"DEFAULT","variant":"key1"}
```

<br />
Expand All @@ -74,7 +74,7 @@ curl -X POST "localhost:8013/flags/myIntFlag/resolve/int"
Result:

```sh
{"value":"1","reason":"STATIC","variant":"one"}
{"value":"1","reason":"DEFAULT","variant":"one"}
```

[Why is this `int` response a `string`?](./docs/http_int_response.md)
Expand All @@ -92,7 +92,7 @@ curl -X POST "localhost:8013/flags/myFloatFlag/resolve/float"
Result:

```sh
{"value":1.23,"reason":"STATIC","variant":"one"}
{"value":1.23,"reason":"DEFAULT","variant":"one"}
```

<br />
Expand All @@ -108,7 +108,7 @@ curl -X POST "localhost:8013/flags/myObjectFlag/resolve/object"
Result:

```sh
{"value":{"key":"val"},"reason":"STATIC","variant":"object1"}
{"value":{"key":"val"},"reason":"DEFAULT","variant":"object1"}
```

<br />
Expand Down Expand Up @@ -173,7 +173,7 @@ This enables you to use an upgraded connection for the previous example requests

```
curl -X POST "https://localhost:8013/flags/myBoolFlag/resolve/boolean"
// {"value":true,"reason":"STATIC","variant":"on"}
// {"value":true,"reason":"DEFAULT","variant":"on"}
```

## Multiple source example
Expand Down
6 changes: 5 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ var startCmd = &cobra.Command{
})
if err != nil {
log.Error(err)
os.Exit(1)
}

rt.Start()
if err := rt.Start(); err != nil {
log.Error(err)
os.Exit(1)
}
},
}
4 changes: 2 additions & 2 deletions docs/http_int_response.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ curl -X POST "localhost:8013/flags/myIntFlag/resolve/int"
```
Result:
```sh
{"value":"1","reason":"STATIC","variant":"one"}
{"value":"1","reason":"DEFAULT","variant":"one"}
```
When interacting directly with the flagD http(s) api and requesting an `int` the response type will be a `string`. This behaviour is introduced by [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway), which uses [proto3 json mapping](https://developers.google.com/protocol-buffers/docs/proto3#json) to build the response object. If a number value is required, and none of the provided SDK's can be used, then it is recommended to use the `float64` endpoint instead:
<br />
Expand All @@ -18,5 +18,5 @@ curl -X POST "localhost:8013/flags/myIntFlag/resolve/float"
```
Result:
```sh
{"value":1.23,"reason":"STATIC","variant":"one"}
{"value":1.23,"reason":"DEFAULT","variant":"one"}
```
6 changes: 3 additions & 3 deletions pkg/eval/fractional_evaluation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func TestFractionalEvaluation(t *testing.T) {
context: &structpb.Struct{},
expectedVariant: "red",
expectedValue: "#FF0000",
expectedReason: model.StaticReason,
expectedReason: model.DefaultReason,
},
"fallback to default variant if invalid variant as result of fractional evaluation": {
flags: Flags{
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestFractionalEvaluation(t *testing.T) {
}},
expectedVariant: "red",
expectedValue: "#FF0000",
expectedReason: model.StaticReason,
expectedReason: model.DefaultReason,
},
"fallback to default variant if percentages don't sum to 100": {
flags: Flags{
Expand Down Expand Up @@ -274,7 +274,7 @@ func TestFractionalEvaluation(t *testing.T) {
}},
expectedVariant: "red",
expectedValue: "#FF0000",
expectedReason: model.StaticReason,
expectedReason: model.DefaultReason,
},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/eval/json_evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ func (je *JSONEvaluator) evaluateVariant(
return variant, model.TargetingMatchReason, nil
}

// if it's not a valid variant, use the default (static) value
return je.state.Flags[flagKey].DefaultVariant, model.StaticReason, nil
// if it's not a valid variant, use the default value
return je.state.Flags[flagKey].DefaultVariant, model.DefaultReason, nil
}

// validateDefaultVariants returns an error if any of the default variants aren't valid
Expand Down
10 changes: 5 additions & 5 deletions pkg/eval/json_evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func TestResolveBooleanValue(t *testing.T) {
reason string
errorCode string
}{
{StaticBoolFlag, nil, StaticBoolValue, model.StaticReason, ""},
{StaticBoolFlag, nil, StaticBoolValue, model.DefaultReason, ""},
{DynamicBoolFlag, map[string]interface{}{ColorProp: ColorValue}, StaticBoolValue, model.TargetingMatchReason, ""},
{StaticObjectFlag, nil, StaticBoolValue, model.ErrorReason, model.TypeMismatchErrorCode},
{MissingFlag, nil, StaticBoolValue, model.ErrorReason, model.FlagNotFoundErrorCode},
Expand Down Expand Up @@ -365,7 +365,7 @@ func TestResolveStringValue(t *testing.T) {
reason string
errorCode string
}{
{StaticStringFlag, nil, StaticStringValue, model.StaticReason, ""},
{StaticStringFlag, nil, StaticStringValue, model.DefaultReason, ""},
{DynamicStringFlag, map[string]interface{}{ColorProp: ColorValue}, DynamicStringValue, model.TargetingMatchReason, ""},
{StaticObjectFlag, nil, "", model.ErrorReason, model.TypeMismatchErrorCode},
{MissingFlag, nil, "", model.ErrorReason, model.FlagNotFoundErrorCode},
Expand Down Expand Up @@ -405,7 +405,7 @@ func TestResolveFloatValue(t *testing.T) {
reason string
errorCode string
}{
{StaticFloatFlag, nil, StaticFloatValue, model.StaticReason, ""},
{StaticFloatFlag, nil, StaticFloatValue, model.DefaultReason, ""},
{DynamicFloatFlag, map[string]interface{}{ColorProp: ColorValue}, DynamicFloatValue, model.TargetingMatchReason, ""},
{StaticObjectFlag, nil, 13, model.ErrorReason, model.TypeMismatchErrorCode},
{MissingFlag, nil, 13, model.ErrorReason, model.FlagNotFoundErrorCode},
Expand Down Expand Up @@ -445,7 +445,7 @@ func TestResolveIntValue(t *testing.T) {
reason string
errorCode string
}{
{StaticIntFlag, nil, StaticIntValue, model.StaticReason, ""},
{StaticIntFlag, nil, StaticIntValue, model.DefaultReason, ""},
{DynamicIntFlag, map[string]interface{}{ColorProp: ColorValue}, DynamicIntValue, model.TargetingMatchReason, ""},
{StaticObjectFlag, nil, 13, model.ErrorReason, model.TypeMismatchErrorCode},
{MissingFlag, nil, 13, model.ErrorReason, model.FlagNotFoundErrorCode},
Expand Down Expand Up @@ -485,7 +485,7 @@ func TestResolveObjectValue(t *testing.T) {
reason string
errorCode string
}{
{StaticObjectFlag, nil, StaticObjectValue, model.StaticReason, ""},
{StaticObjectFlag, nil, StaticObjectValue, model.DefaultReason, ""},
{DynamicObjectFlag, map[string]interface{}{ColorProp: ColorValue}, DynamicObjectValue, model.TargetingMatchReason, ""},
{StaticBoolFlag, nil, "{}", model.ErrorReason, model.TypeMismatchErrorCode},
{MissingFlag, nil, "{}", model.ErrorReason, model.FlagNotFoundErrorCode},
Expand Down
1 change: 0 additions & 1 deletion pkg/model/reason.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const (
SplitReason = "SPLIT"
DisabledReason = "DISABLED"
DefaultReason = "DEFAULT"
StaticReason = "STATIC"
UnknownReason = "UNKNOWN"
ErrorReason = "ERROR"
)
15 changes: 7 additions & 8 deletions pkg/runtime/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@ package runtime

import (
"context"
"errors"
"os"
"os/signal"
"syscall"

"golang.org/x/sync/errgroup"
)

func (r *Runtime) Start() {
func (r *Runtime) Start() error {
if r.Service == nil {
r.Logger.Error("no Service set")
return
return errors.New("no Service set")
}
if len(r.SyncImpl) == 0 {
r.Logger.Error("no SyncImplementation set")
return
return errors.New("no SyncImplementation set")
}
if r.Evaluator == nil {
r.Logger.Error("no Evaluator set")
return
return errors.New("no Evaluator set")
}

ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
Expand All @@ -40,6 +38,7 @@ func (r *Runtime) Start() {

<-gCtx.Done()
if err := g.Wait(); err != nil {
r.Logger.Error(err)
return err
}
return nil
}
Loading

1 comment on commit 8a9849c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Go Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: 8a9849c Previous: b655e88 Ratio
BenchmarkGRPCService_ResolveBoolean/eval_returns_error 10167 ns/op 1192 B/op 37 allocs/op 6441 ns/op 1192 B/op 37 allocs/op 1.58
BenchmarkGRPCService_ResolveBoolean/happy_path 3088 ns/op 240 B/op 5 allocs/op 2219 ns/op 240 B/op 5 allocs/op 1.39
BenchmarkGRPCService_ResolveString/happy_path 3045 ns/op 256 B/op 5 allocs/op 2221 ns/op 256 B/op 5 allocs/op 1.37
BenchmarkGRPCService_ResolveString/eval_returns_error 9866 ns/op 1208 B/op 37 allocs/op 6478 ns/op 1208 B/op 37 allocs/op 1.52
BenchmarkGRPCService_ResolveFloat/happy_path 3033 ns/op 240 B/op 5 allocs/op 2214 ns/op 240 B/op 5 allocs/op 1.37
BenchmarkGRPCService_ResolveFloat/eval_returns_error 10009 ns/op 1192 B/op 37 allocs/op 6423 ns/op 1192 B/op 37 allocs/op 1.56
BenchmarkGRPCService_ResolveInt/happy_path 2895 ns/op 240 B/op 5 allocs/op 2216 ns/op 240 B/op 5 allocs/op 1.31
BenchmarkGRPCService_ResolveInt/eval_returns_error 9761 ns/op 1192 B/op 37 allocs/op 6415 ns/op 1192 B/op 37 allocs/op 1.52
BenchmarkGRPCService_ResolveObject/happy_path 4731 ns/op 1400 B/op 20 allocs/op 3485 ns/op 1400 B/op 20 allocs/op 1.36
BenchmarkGRPCService_ResolveObject/eval_returns_error 9605 ns/op 1288 B/op 39 allocs/op 6213 ns/op 1288 B/op 39 allocs/op 1.55

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.