update metadata

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-11-18 12:27:44 +03:00
parent 241e452ecf
commit 5098a36a6b
4 changed files with 13 additions and 7 deletions

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/golang/protobuf v1.4.3 github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.1 // indirect github.com/google/go-cmp v0.5.1 // indirect
github.com/unistack-org/micro-codec-bytes v0.0.0-20200828083432-4e49e953d844 github.com/unistack-org/micro-codec-bytes v0.0.0-20200828083432-4e49e953d844
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20201104214903-1fbf8b2e209e github.com/unistack-org/micro/v3 v3.0.2-0.20201117210202-01e64cb0c0f3
golang.org/x/net v0.0.0-20200904194848-62affa334b73 golang.org/x/net v0.0.0-20200904194848-62affa334b73
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 // indirect golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 // indirect
golang.org/x/text v0.3.3 // indirect golang.org/x/text v0.3.3 // indirect

4
go.sum
View File

@ -283,6 +283,10 @@ github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200920135754-1cbd1d2bad83/go.m
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200922103357-4c4fa00a5d94/go.mod h1:aL+8VhSXpx0SuEeXPOWUo5BgS7kyvWYobeXFay90UUM= github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200922103357-4c4fa00a5d94/go.mod h1:aL+8VhSXpx0SuEeXPOWUo5BgS7kyvWYobeXFay90UUM=
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20201104214903-1fbf8b2e209e h1:v27OUgoE2UOyCe6uLksdpG6oErx62nUXWIkTPxS7yIw= github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20201104214903-1fbf8b2e209e h1:v27OUgoE2UOyCe6uLksdpG6oErx62nUXWIkTPxS7yIw=
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20201104214903-1fbf8b2e209e/go.mod h1:LFvCXGOgcLIj2k/8eL71TpIpcJBN2SXXAUx8U6dz9Rw= github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20201104214903-1fbf8b2e209e/go.mod h1:LFvCXGOgcLIj2k/8eL71TpIpcJBN2SXXAUx8U6dz9Rw=
github.com/unistack-org/micro/v3 v3.0.2-0.20201114215340-e0ef8b2953b5 h1:iSyQgm4zZb8N/jphp5NOf6bC8FrGRcKNyDDtAeP1m5w=
github.com/unistack-org/micro/v3 v3.0.2-0.20201114215340-e0ef8b2953b5/go.mod h1:LYbzHigEudM10AbLZztVSX0Y4JWgj5nKIExil/99h6E=
github.com/unistack-org/micro/v3 v3.0.2-0.20201117210202-01e64cb0c0f3 h1:knz0mt3Ot/CIXp5dRyb5dAPYtKiWA9PDhazpXX5Iu3o=
github.com/unistack-org/micro/v3 v3.0.2-0.20201117210202-01e64cb0c0f3/go.mod h1:LYbzHigEudM10AbLZztVSX0Y4JWgj5nKIExil/99h6E=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA= github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=

View File

@ -3,6 +3,7 @@ package grpc
import ( import (
raw "github.com/unistack-org/micro-codec-bytes" raw "github.com/unistack-org/micro-codec-bytes"
"github.com/unistack-org/micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/metadata"
) )
type rpcRequest struct { type rpcRequest struct {
@ -10,7 +11,7 @@ type rpcRequest struct {
method string method string
contentType string contentType string
codec codec.Codec codec codec.Codec
header map[string]string header metadata.Metadata
body []byte body []byte
stream bool stream bool
payload interface{} payload interface{}
@ -20,7 +21,7 @@ type rpcMessage struct {
topic string topic string
contentType string contentType string
payload interface{} payload interface{}
header map[string]string header metadata.Metadata
body []byte body []byte
codec codec.Codec codec codec.Codec
} }
@ -45,7 +46,7 @@ func (r *rpcRequest) Codec() codec.Reader {
return r.codec return r.codec
} }
func (r *rpcRequest) Header() map[string]string { func (r *rpcRequest) Header() metadata.Metadata {
return r.header return r.header
} }
@ -77,7 +78,7 @@ func (r *rpcMessage) Payload() interface{} {
return r.payload return r.payload
} }
func (r *rpcMessage) Header() map[string]string { func (r *rpcMessage) Header() metadata.Metadata {
return r.header return r.header
} }

View File

@ -2,10 +2,11 @@ package grpc
import ( import (
"github.com/unistack-org/micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/metadata"
) )
type rpcResponse struct { type rpcResponse struct {
header map[string]string header metadata.Metadata
codec codec.Codec codec codec.Codec
} }
@ -13,7 +14,7 @@ func (r *rpcResponse) Codec() codec.Writer {
return r.codec return r.codec
} }
func (r *rpcResponse) WriteHeader(hdr map[string]string) { func (r *rpcResponse) WriteHeader(hdr metadata.Metadata) {
for k, v := range hdr { for k, v := range hdr {
r.header[k] = v r.header[k] = v
} }