Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unused protobuf stuff #248

Merged
merged 1 commit into from
Apr 22, 2024
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
54 changes: 1 addition & 53 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/devcyclehq/go-server-sdk/v2/util"

"github.com/devcyclehq/go-server-sdk/v2/api"
"github.com/devcyclehq/go-server-sdk/v2/proto"
"github.com/matryer/try"
)

Expand Down Expand Up @@ -153,7 +152,7 @@ func (c *Client) IsLocalBucketing() bool {
func (c *Client) handleInitialization() {
c.isInitialized = true

if(c.IsLocalBucketing()){
if c.IsLocalBucketing() {
util.Infof("Client initialized with local bucketing %v", c.localBucketing.GetClientUUID())
}
if c.DevCycleOptions.OnInitializedChannel != nil {
Expand Down Expand Up @@ -184,57 +183,6 @@ func (c *Client) GetRawConfig() (config []byte, etag string, err error) {
return nil, "", errors.New("cannot read raw config; config manager has no config")
}

func createNullableString(val string) *proto.NullableString {
if val == "" {
return &proto.NullableString{Value: "", IsNull: true}
} else {
return &proto.NullableString{Value: val, IsNull: false}
}
}

func createNullableDouble(val float64) *proto.NullableDouble {
if math.IsNaN(val) {
return &proto.NullableDouble{Value: 0, IsNull: true}
} else {
return &proto.NullableDouble{Value: val, IsNull: false}
}
}

func createNullableCustomData(data map[string]interface{}) *proto.NullableCustomData {
dataMap := map[string]*proto.CustomDataValue{}

if len(data) == 0 {
return &proto.NullableCustomData{
Value: dataMap,
IsNull: true,
}
}
// pull the values from the map and convert to the nullable data objects for protobuf
for key, val := range data {
if val == nil {
dataMap[key] = &proto.CustomDataValue{Type: proto.CustomDataType_Null}
continue
}

switch val := val.(type) {
case string:
dataMap[key] = &proto.CustomDataValue{Type: proto.CustomDataType_Str, StringValue: val}
case float64:
dataMap[key] = &proto.CustomDataValue{Type: proto.CustomDataType_Num, DoubleValue: val}
case bool:
dataMap[key] = &proto.CustomDataValue{Type: proto.CustomDataType_Bool, BoolValue: val}
default:
// if we don't know what it is, just set it to null
dataMap[key] = &proto.CustomDataValue{Type: proto.CustomDataType_Null}
}
}

return &proto.NullableCustomData{
Value: dataMap,
IsNull: false,
}
}

/*
Get all features by key for user data
- @param body
Expand Down
22 changes: 2 additions & 20 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,6 @@ func TestClient_VariableEventIsQueued(t *testing.T) {
require.NoError(t, err)
}

func TestClient_VariableLocal(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
httpConfigMock(200)

c, err := NewClient(test_environmentKey, &Options{})
fatalErr(t, err)

user := User{UserId: "j_test", DeviceModel: "testing"}
variable, err := c.Variable(user, "test", true)
fatalErr(t, err)
fmt.Println(variable)

variableValue, err := c.VariableValue(user, "test", true)
fatalErr(t, err)
fmt.Println(variableValue)
}
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): Renaming of test function should reflect the updated functionality.

Ensure the new test name accurately represents the test's scope and purpose, especially after significant codebase changes.

Suggested change
}
func TestClient_VariableLocalBehavior(t *testing.T) {

Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Test function rename needs verification for coverage.

The renaming of TestClient_VariableLocalProtobuf to TestClient_VariableLocal suggests a shift in focus possibly due to the removal of protobuf dependencies. Please ensure that the new test name accurately reflects the test's purpose and that all necessary aspects are still being tested.


func TestClient_VariableLocalFlush(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
Expand All @@ -223,7 +205,7 @@ func TestClient_VariableLocalFlush(t *testing.T) {
fmt.Println(variable)
}

func TestClient_VariableLocalProtobuf(t *testing.T) {
func TestClient_VariableLocal(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
httpConfigMock(200)
Expand Down Expand Up @@ -258,7 +240,7 @@ func TestClient_VariableLocalProtobuf(t *testing.T) {
}
}

func TestClient_VariableLocalProtobuf_UserWithCustomData(t *testing.T) {
func TestClient_VariableLocal_UserWithCustomData(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
httpConfigMock(200)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/open-feature/go-sdk v1.8.0
github.com/stretchr/testify v1.8.4
github.com/twmb/murmur3 v1.1.7
google.golang.org/protobuf v1.29.1
)

require (
Expand Down
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91
github.com/go-playground/validator/v10 v10.18.0 h1:BvolUXjp4zuvkZ5YN5t7ebzbhlUtPsPm2S9NAZ5nl9U=
github.com/go-playground/validator/v10 v10.18.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc=
Expand Down Expand Up @@ -49,10 +46,6 @@ golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM=
google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
22 changes: 0 additions & 22 deletions proto/helpers.go

This file was deleted.

Loading
Loading