diff --git a/buffer.go b/buffer.go deleted file mode 100644 index c43bb23..0000000 --- a/buffer.go +++ /dev/null @@ -1,14 +0,0 @@ -package grpc - -import ( - "bytes" -) - -type buffer struct { - *bytes.Buffer -} - -func (b *buffer) Close() error { - b.Buffer.Reset() - return nil -} diff --git a/grpc.go b/grpc.go index 6f5c378..c6a3f5d 100644 --- a/grpc.go +++ b/grpc.go @@ -2,7 +2,6 @@ package grpc import ( - "bytes" "context" "crypto/tls" "fmt" @@ -19,6 +18,7 @@ import ( "github.com/micro/go-micro/registry" "github.com/micro/go-micro/transport" + "github.com/micro/go-micro/util/buf" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/encoding" @@ -491,7 +491,8 @@ func (g *grpcClient) Publish(ctx context.Context, p client.Message, opts ...clie return errors.InternalServerError("go.micro.client", err.Error()) } - b := &buffer{bytes.NewBuffer(nil)} + b := buf.New(nil) + if err := cf(b).Write(&codec.Message{Type: codec.Event}, p.Payload()); err != nil { return errors.InternalServerError("go.micro.client", err.Error()) }