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

[2.0] gzip encoding support #22

Merged
merged 2 commits into from
Sep 2, 2023
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
11 changes: 11 additions & 0 deletions example/simple/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/encoding/gzip"
"google.golang.org/grpc/status"

pb "github.com/bavix/gripmock/protogen/example/simple"
Expand Down Expand Up @@ -72,6 +73,16 @@ func main() {
}
log.Printf("Greeting: %s (return code %d)", r.Message, r.ReturnCode)

name = "simple3"
r, err = c.SayHello(context.Background(), &pb.Request{Name: name}, grpc.UseCompressor(gzip.Name))
if err != nil {
log.Fatalf("error from grpc: %v", err)
}
if r.ReturnCode != 3 {
log.Fatalf("grpc server returned code: %d, expected code: %d", r.ReturnCode, 3)
}
log.Printf("Greeting (gzip): %s (return code %d)", r.Message, r.ReturnCode)

name = "error"
r, err = c.SayHello(context.Background(), &pb.Request{Name: name})
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/yaml2json/convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func New() *Convertor {
return &Convertor{engine: &engine{}}
}

func (t *Convertor) Execute(name string, data []byte) (res []byte, err error) {
func (t *Convertor) Execute(name string, data []byte) ([]byte, error) {
bytes, err := t.engine.Execute(name, data)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions protoc-gen-gripmock/server.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
_ "google.golang.org/grpc/encoding/gzip"

"github.com/bavix/gripmock/pkg/sdk"
)
Expand Down