From 672c02e537b4baa8b28a33eb653e35e47c27901f Mon Sep 17 00:00:00 2001 From: Mark Phelps <209477+markphelps@users.noreply.github.com> Date: Fri, 3 Nov 2023 12:25:23 -0400 Subject: [PATCH] chore: fix build --- internal/cmd/protoc-gen-go-flipt-sdk/grpc.go | 9 -------- internal/cmd/protoc-gen-go-flipt-sdk/http.go | 8 ------- internal/cmd/protoc-gen-go-flipt-sdk/main.go | 12 +++-------- sdk/go/evaluation.sdk.gen.go | 21 +++---------------- sdk/go/grpc/grpc.sdk.gen.go | 10 +-------- sdk/go/http/evaluation.sdk.gen.go | 22 ++++++-------------- sdk/go/sdk.gen.go | 3 ++- 7 files changed, 15 insertions(+), 70 deletions(-) diff --git a/internal/cmd/protoc-gen-go-flipt-sdk/grpc.go b/internal/cmd/protoc-gen-go-flipt-sdk/grpc.go index f3878c2efa..63bd613487 100644 --- a/internal/cmd/protoc-gen-go-flipt-sdk/grpc.go +++ b/internal/cmd/protoc-gen-go-flipt-sdk/grpc.go @@ -36,11 +36,6 @@ func generateGRPC(gen *protogen.Plugin) { ) if len(file.Services) < 2 { - srv := file.Services[0] - if shouldIgnoreService(srv) { - continue - } - returnType := file.Services[0].GoName + "Client" g.P("func (t Transport) ", method, "() ", relativeImport(g, file, returnType), "{") g.P("return ", relativeImport(g, file, "New"+returnType), "(t.cc)") @@ -57,10 +52,6 @@ func generateGRPC(gen *protogen.Plugin) { g.P("}\n") for _, srv := range file.Services { - if shouldIgnoreService(srv) { - continue - } - returnType := srv.GoName + "Client" g.P("func (t ", groupType, ") ", returnType, "() ", relativeImport(g, file, returnType), " {") g.P("return ", relativeImport(g, file, "New"+returnType), "(t.cc)") diff --git a/internal/cmd/protoc-gen-go-flipt-sdk/http.go b/internal/cmd/protoc-gen-go-flipt-sdk/http.go index e2c310c8eb..a15656dae6 100644 --- a/internal/cmd/protoc-gen-go-flipt-sdk/http.go +++ b/internal/cmd/protoc-gen-go-flipt-sdk/http.go @@ -141,10 +141,6 @@ func generateHTTP(gen *protogen.Plugin, grpcAPIConfig string) { if len(file.Services) < 2 { srv := file.Services[0] - if shouldIgnoreService(srv) { - continue - } - returnType := srv.GoName + "Client" g.P("type ", returnType, " struct {") @@ -172,10 +168,6 @@ func generateHTTP(gen *protogen.Plugin, grpcAPIConfig string) { g.P("}\n") for _, srv := range file.Services { - if shouldIgnoreService(srv) { - continue - } - var ( returnType = srv.GoName + "Client" unexportedReturnType = unexport(returnType) diff --git a/internal/cmd/protoc-gen-go-flipt-sdk/main.go b/internal/cmd/protoc-gen-go-flipt-sdk/main.go index 8c7b9dfcd0..2f8a468135 100644 --- a/internal/cmd/protoc-gen-go-flipt-sdk/main.go +++ b/internal/cmd/protoc-gen-go-flipt-sdk/main.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "os" + "slices" "strings" "google.golang.org/protobuf/compiler/protogen" @@ -32,11 +33,12 @@ func main() { // warning. gen.SupportedFeatures |= uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) for _, f := range gen.Files { - if !f.Generate { continue } + f.Services = slices.DeleteFunc(f.Services, shouldIgnoreService) + generateSubSDK(gen, f) } @@ -121,10 +123,6 @@ func generateSubSDK(gen *protogen.Plugin, file *protogen.File) (typ, client stri g.P("type ", typ, "Client interface {") for _, srv := range file.Services { - if shouldIgnoreService(srv) { - continue - } - g.P(srv.GoName+"Client", "()", relativeImport(g, file, srv.GoName+"Client")) } g.P("}\n") @@ -136,10 +134,6 @@ func generateSubSDK(gen *protogen.Plugin, file *protogen.File) (typ, client stri } for _, srv := range file.Services { - if shouldIgnoreService(srv) { - continue - } - serviceName := srv.GoName if oneServicePackage { serviceName = typ diff --git a/sdk/go/evaluation.sdk.gen.go b/sdk/go/evaluation.sdk.gen.go index 208f23986c..2a1c894f75 100644 --- a/sdk/go/evaluation.sdk.gen.go +++ b/sdk/go/evaluation.sdk.gen.go @@ -7,27 +7,12 @@ import ( evaluation "go.flipt.io/flipt/rpc/flipt/evaluation" ) -type EvaluationClient interface { - EvaluationServiceClient() evaluation.EvaluationServiceClient -} - type Evaluation struct { - transport EvaluationClient - tokenProvider ClientTokenProvider -} - -type EvaluationService struct { transport evaluation.EvaluationServiceClient tokenProvider ClientTokenProvider } -func (s Evaluation) EvaluationService() *EvaluationService { - return &EvaluationService{ - transport: s.transport.EvaluationServiceClient(), - tokenProvider: s.tokenProvider, - } -} -func (x *EvaluationService) Boolean(ctx context.Context, v *evaluation.EvaluationRequest) (*evaluation.BooleanEvaluationResponse, error) { +func (x *Evaluation) Boolean(ctx context.Context, v *evaluation.EvaluationRequest) (*evaluation.BooleanEvaluationResponse, error) { ctx, err := authenticate(ctx, x.tokenProvider) if err != nil { return nil, err @@ -35,7 +20,7 @@ func (x *EvaluationService) Boolean(ctx context.Context, v *evaluation.Evaluatio return x.transport.Boolean(ctx, v) } -func (x *EvaluationService) Variant(ctx context.Context, v *evaluation.EvaluationRequest) (*evaluation.VariantEvaluationResponse, error) { +func (x *Evaluation) Variant(ctx context.Context, v *evaluation.EvaluationRequest) (*evaluation.VariantEvaluationResponse, error) { ctx, err := authenticate(ctx, x.tokenProvider) if err != nil { return nil, err @@ -43,7 +28,7 @@ func (x *EvaluationService) Variant(ctx context.Context, v *evaluation.Evaluatio return x.transport.Variant(ctx, v) } -func (x *EvaluationService) Batch(ctx context.Context, v *evaluation.BatchEvaluationRequest) (*evaluation.BatchEvaluationResponse, error) { +func (x *Evaluation) Batch(ctx context.Context, v *evaluation.BatchEvaluationRequest) (*evaluation.BatchEvaluationResponse, error) { ctx, err := authenticate(ctx, x.tokenProvider) if err != nil { return nil, err diff --git a/sdk/go/grpc/grpc.sdk.gen.go b/sdk/go/grpc/grpc.sdk.gen.go index 1cefb6f63e..d586e1138d 100644 --- a/sdk/go/grpc/grpc.sdk.gen.go +++ b/sdk/go/grpc/grpc.sdk.gen.go @@ -57,18 +57,10 @@ func (t Transport) FliptClient() flipt.FliptClient { return flipt.NewFliptClient(t.cc) } -type evaluationClient struct { - cc grpc.ClientConnInterface -} - -func (t evaluationClient) EvaluationServiceClient() evaluation.EvaluationServiceClient { +func (t Transport) EvaluationClient() evaluation.EvaluationServiceClient { return evaluation.NewEvaluationServiceClient(t.cc) } -func (t Transport) EvaluationClient() _go.EvaluationClient { - return evaluationClient{cc: t.cc} -} - func (t Transport) MetaClient() meta.MetadataServiceClient { return meta.NewMetadataServiceClient(t.cc) } diff --git a/sdk/go/http/evaluation.sdk.gen.go b/sdk/go/http/evaluation.sdk.gen.go index ed9dbadee7..ac6c812053 100644 --- a/sdk/go/http/evaluation.sdk.gen.go +++ b/sdk/go/http/evaluation.sdk.gen.go @@ -6,7 +6,6 @@ import ( bytes "bytes" context "context" evaluation "go.flipt.io/flipt/rpc/flipt/evaluation" - _go "go.flipt.io/flipt/sdk/go" grpc "google.golang.org/grpc" protojson "google.golang.org/protobuf/encoding/protojson" io "io" @@ -14,21 +13,12 @@ import ( url "net/url" ) -type evaluationClient struct { +type EvaluationServiceClient struct { client *http.Client addr string } -func (t evaluationClient) EvaluationServiceClient() evaluation.EvaluationServiceClient { - return &evaluationServiceClient{client: t.client, addr: t.addr} -} - -type evaluationServiceClient struct { - client *http.Client - addr string -} - -func (x *evaluationServiceClient) Boolean(ctx context.Context, v *evaluation.EvaluationRequest, _ ...grpc.CallOption) (*evaluation.BooleanEvaluationResponse, error) { +func (x *EvaluationServiceClient) Boolean(ctx context.Context, v *evaluation.EvaluationRequest, _ ...grpc.CallOption) (*evaluation.BooleanEvaluationResponse, error) { var body io.Reader var values url.Values reqData, err := protojson.Marshal(v) @@ -60,7 +50,7 @@ func (x *evaluationServiceClient) Boolean(ctx context.Context, v *evaluation.Eva return &output, nil } -func (x *evaluationServiceClient) Variant(ctx context.Context, v *evaluation.EvaluationRequest, _ ...grpc.CallOption) (*evaluation.VariantEvaluationResponse, error) { +func (x *EvaluationServiceClient) Variant(ctx context.Context, v *evaluation.EvaluationRequest, _ ...grpc.CallOption) (*evaluation.VariantEvaluationResponse, error) { var body io.Reader var values url.Values reqData, err := protojson.Marshal(v) @@ -92,7 +82,7 @@ func (x *evaluationServiceClient) Variant(ctx context.Context, v *evaluation.Eva return &output, nil } -func (x *evaluationServiceClient) Batch(ctx context.Context, v *evaluation.BatchEvaluationRequest, _ ...grpc.CallOption) (*evaluation.BatchEvaluationResponse, error) { +func (x *EvaluationServiceClient) Batch(ctx context.Context, v *evaluation.BatchEvaluationRequest, _ ...grpc.CallOption) (*evaluation.BatchEvaluationResponse, error) { var body io.Reader var values url.Values reqData, err := protojson.Marshal(v) @@ -124,6 +114,6 @@ func (x *evaluationServiceClient) Batch(ctx context.Context, v *evaluation.Batch return &output, nil } -func (t Transport) EvaluationClient() _go.EvaluationClient { - return evaluationClient{client: t.client, addr: t.addr} +func (t Transport) EvaluationClient() evaluation.EvaluationServiceClient { + return &EvaluationServiceClient{client: t.client, addr: t.addr} } diff --git a/sdk/go/sdk.gen.go b/sdk/go/sdk.gen.go index a50383b193..ac80f31de7 100644 --- a/sdk/go/sdk.gen.go +++ b/sdk/go/sdk.gen.go @@ -5,6 +5,7 @@ package sdk import ( context "context" flipt "go.flipt.io/flipt/rpc/flipt" + evaluation "go.flipt.io/flipt/rpc/flipt/evaluation" meta "go.flipt.io/flipt/rpc/flipt/meta" metadata "google.golang.org/grpc/metadata" ) @@ -12,7 +13,7 @@ import ( type Transport interface { AuthClient() AuthClient FliptClient() flipt.FliptClient - EvaluationClient() EvaluationClient + EvaluationClient() evaluation.EvaluationServiceClient MetaClient() meta.MetadataServiceClient }