Skip to content

Commit

Permalink
refactor: migrate to connectrpc/connect-go (#990)
Browse files Browse the repository at this point in the history
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

Migrate from bufbuild/connect-go to connectrpc/connect-go.

### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->

Closes #790.

### Notes
<!-- any additional notes for this PR -->

### Follow-up Tasks
<!-- anything that is related to this PR but not done here should be
noted under this section -->
<!-- if there is a need for a new issue, please link it here -->

I'll also create a PR in https://github.com/open-feature/go-sdk-contrib
to migrate to connectrpc/connect-go for the flagd provider.

### How to test
<!-- if applicable, add testing instructions under this section -->

Signed-off-by: Craig Pastro <craig.pastro@gmail.com>
  • Loading branch information
craigpastro committed Nov 13, 2023
1 parent e9347cc commit 7dd5b2b
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 407 deletions.
10 changes: 4 additions & 6 deletions core/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/open-feature/flagd/core
go 1.20

require (
buf.build/gen/go/open-feature/flagd/bufbuild/connect-go v1.9.0-20230720212818-3675556880a1.1
buf.build/gen/go/open-feature/flagd/connectrpc/go v1.12.0-20231031123731-ac2ec0f39838.1
buf.build/gen/go/open-feature/flagd/grpc/go v1.3.0-20230710190440-2333a9579c1a.1
buf.build/gen/go/open-feature/flagd/protocolbuffers/go v1.31.0-20230720212818-3675556880a1.1
github.com/bufbuild/connect-go v1.10.0
github.com/bufbuild/connect-opentelemetry-go v0.4.0
buf.build/gen/go/open-feature/flagd/protocolbuffers/go v1.31.0-20231031123731-ac2ec0f39838.2
connectrpc.com/connect v1.12.0
connectrpc.com/otelconnect v0.6.0
github.com/diegoholiveira/jsonlogic/v3 v3.3.2
github.com/fsnotify/fsnotify v1.7.0
github.com/golang/mock v1.6.0
Expand Down Expand Up @@ -85,11 +85,9 @@ require (
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.42.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
Expand Down
185 changes: 13 additions & 172 deletions core/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/pkg/service/flag-evaluation/connect_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"
"time"

schemaConnectV1 "buf.build/gen/go/open-feature/flagd/bufbuild/connect-go/schema/v1/schemav1connect"
schemaConnectV1 "buf.build/gen/go/open-feature/flagd/connectrpc/go/schema/v1/schemav1connect"
"github.com/open-feature/flagd/core/pkg/eval"
"github.com/open-feature/flagd/core/pkg/logger"
"github.com/open-feature/flagd/core/pkg/service"
Expand Down
2 changes: 1 addition & 1 deletion core/pkg/service/flag-evaluation/flag_evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

schemaV1 "buf.build/gen/go/open-feature/flagd/protocolbuffers/go/schema/v1"
"github.com/bufbuild/connect-go"
"connectrpc.com/connect"
"github.com/open-feature/flagd/core/pkg/eval"
"github.com/open-feature/flagd/core/pkg/logger"
"github.com/open-feature/flagd/core/pkg/model"
Expand Down
2 changes: 1 addition & 1 deletion core/pkg/service/flag-evaluation/flag_evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

schemaV1 "buf.build/gen/go/open-feature/flagd/protocolbuffers/go/schema/v1"
"github.com/bufbuild/connect-go"
"connectrpc.com/connect"
"github.com/golang/mock/gomock"
"github.com/open-feature/flagd/core/pkg/eval"
mock "github.com/open-feature/flagd/core/pkg/eval/mock"
Expand Down
2 changes: 1 addition & 1 deletion core/pkg/service/flag-evaluation/flag_evaluator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

schemaV1 "buf.build/gen/go/open-feature/flagd/protocolbuffers/go/schema/v1"
"github.com/bufbuild/connect-go"
"connectrpc.com/connect"
"google.golang.org/protobuf/types/known/structpb"
)

Expand Down
4 changes: 2 additions & 2 deletions core/pkg/service/flag-evaluation/json_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"errors"
"fmt"

"github.com/bufbuild/connect-go"
"connectrpc.com/connect"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/runtime/protoiface"
)

// WithJSON customizes a connect-go Client or Handler's JSON by exposing MarshalOptions, and UnmarshalOptions
// See: https://github.com/bufbuild/connect-go/blob/main/codec.go
// See: https://github.com/connectrpc/connect-go/blob/main/codec.go
// Heavily inspired by https://github.com/akshayjshah/connectproto
func WithJSON(marshal protojson.MarshalOptions, unmarshal protojson.UnmarshalOptions) connect.Option {
return connect.WithOptions(
Expand Down
2 changes: 1 addition & 1 deletion core/pkg/service/iservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package service
import (
"context"

"github.com/bufbuild/connect-go"
"connectrpc.com/connect"
)

type NotificationType string
Expand Down
2 changes: 1 addition & 1 deletion core/pkg/service/middleware/metrics/http_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (w *responseWriterInterceptor) Hijack() (net.Conn, *bufio.ReadWriter, error
}

// Flush need to exist to be compatible with connect-go.
// See github.com/bufbuild/connect-go@v1.5.2/protocol_connect.go @ line 135
// See https://github.com/connectrpc/connect-go/blob/main/protocol_connect.go
func (w *responseWriterInterceptor) Flush() {
f, ok := w.ResponseWriter.(http.Flusher)
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions core/pkg/telemetry/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"time"

"github.com/bufbuild/connect-go"
otelconnect "github.com/bufbuild/connect-opentelemetry-go"
"connectrpc.com/connect"
"connectrpc.com/otelconnect"
"github.com/open-feature/flagd/core/pkg/logger"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
Expand Down
2 changes: 0 additions & 2 deletions flagd-proxy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ require (
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/twmb/murmur3 v1.1.8 // indirect
Expand Down
Loading

0 comments on commit 7dd5b2b

Please sign in to comment.