micro-client-grpc/response.go

39 lines
640 B
Go
Raw Normal View History

2019-06-08 19:40:44 +01:00
package grpc
import (
"strings"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/metadata"
2019-06-08 19:40:44 +01:00
"google.golang.org/grpc"
)
type response struct {
conn *PoolConn
2019-06-08 19:40:44 +01:00
stream grpc.ClientStream
codec codec.Codec
2019-06-08 19:40:44 +01:00
}
// Read the response
func (r *response) Codec() codec.Codec {
return r.codec
2019-06-08 19:40:44 +01:00
}
// read the header
func (r *response) Header() metadata.Metadata {
meta, err := r.stream.Header()
2019-06-08 19:40:44 +01:00
if err != nil {
return nil
2019-06-08 19:40:44 +01:00
}
md := metadata.New(len(meta))
for k, v := range meta {
md.Set(k, strings.Join(v, ","))
2019-06-08 19:40:44 +01:00
}
return md
2019-06-08 19:40:44 +01:00
}
// Read the undecoded response
func (r *response) Read() ([]byte, error) {
return nil, nil
2019-06-08 19:40:44 +01:00
}