Go controls the metadata of grpc

JasonHome 2022-01-15 02:24:03

1、 brief introduction

gRPC Let's implement remote calls just like local calls , For every time rpc call , There may be some useful data , And these data can be passed through metadata To pass on .metadata In order to key-value Storage of data in the form of , among key yes string type , and value yes []string, That is, a string slice type .metadata bring client and server It can provide the other party with some information about this call , Just once http Requested RequestHeader and ResponseHeaader equally .http in header The declaration cycle of is once http request , that metadata The life cycle of is once rpc call .

2、 Official source code and documentation

3、 Use

3.1 newly build metadata

MD The type is actually map,key yes string,value yes string The section of

type MD map

Similar articles