This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for the google wrappers support in unary calls and tests for it
- Loading branch information
1 parent
9328083
commit 05a4176
Showing
6 changed files
with
478 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package wrappers_testing | ||
|
||
import ( | ||
context "context" | ||
|
||
wrappers "github.com/golang/protobuf/ptypes/wrappers" | ||
grpc "google.golang.org/grpc" | ||
) | ||
|
||
//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative test.proto | ||
|
||
// Register registers a test service that could be used for the testing gRPC wrappers | ||
func Register(r grpc.ServiceRegistrar) *service { | ||
s := &service{} | ||
|
||
RegisterServiceServer(r, s) | ||
|
||
return s | ||
} | ||
|
||
type service struct { | ||
UnimplementedServiceServer | ||
|
||
TestStringImplementation func(context.Context, *wrappers.StringValue) (*wrappers.StringValue, error) | ||
TestIntegerImplementation func(context.Context, *wrappers.Int64Value) (*wrappers.Int64Value, error) | ||
TestBooleanImplementation func(context.Context, *wrappers.BoolValue) (*wrappers.BoolValue, error) | ||
TestDoubleImplementation func(context.Context, *wrappers.DoubleValue) (*wrappers.DoubleValue, error) | ||
} | ||
|
||
func (s *service) TestString(ctx context.Context, in *wrappers.StringValue) (*wrappers.StringValue, error) { | ||
if s.TestStringImplementation != nil { | ||
return s.TestStringImplementation(ctx, in) | ||
} | ||
|
||
return s.UnimplementedServiceServer.TestString(ctx, in) | ||
} | ||
|
||
func (s *service) TestInteger(ctx context.Context, in *wrappers.Int64Value) (*wrappers.Int64Value, error) { | ||
if s.TestIntegerImplementation != nil { | ||
return s.TestIntegerImplementation(ctx, in) | ||
} | ||
|
||
return s.UnimplementedServiceServer.TestInteger(ctx, in) | ||
} | ||
|
||
func (s *service) TestBoolean(ctx context.Context, in *wrappers.BoolValue) (*wrappers.BoolValue, error) { | ||
if s.TestBooleanImplementation != nil { | ||
return s.TestBooleanImplementation(ctx, in) | ||
} | ||
|
||
return s.UnimplementedServiceServer.TestBoolean(ctx, in) | ||
} | ||
|
||
func (s *service) TestDouble(ctx context.Context, in *wrappers.DoubleValue) (*wrappers.DoubleValue, error) { | ||
if s.TestBooleanImplementation != nil { | ||
return s.TestDoubleImplementation(ctx, in) | ||
} | ||
|
||
return s.UnimplementedServiceServer.TestDouble(ctx, in) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
|
||
package grpc.wrappers.testing; | ||
|
||
// this proto contains service that helps tests some of well-known types or wrappers | ||
// https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/wrappers.proto | ||
|
||
import "google/protobuf/wrappers.proto"; | ||
|
||
option go_package ="./wrappers_testing"; | ||
|
||
service Service { | ||
rpc TestString(google.protobuf.StringValue) returns (google.protobuf.StringValue); | ||
rpc TestInteger(google.protobuf.Int64Value) returns (google.protobuf.Int64Value); | ||
rpc TestBoolean(google.protobuf.BoolValue) returns (google.protobuf.BoolValue); | ||
rpc TestDouble(google.protobuf.DoubleValue) returns (google.protobuf.DoubleValue); | ||
} |
Oops, something went wrong.