func MapToCmd(ctx context.Context, headerMap map[string]string) (SofaRpcCmd, error) {

	// TODO: temporary use bolt.HeaderProtocolCode, need to use common definition
	if proto, exist := headerMap[SofaPropertyHeader(HeaderProtocolCode)]; exist {
		protoValue := ConvertPropertyValueUint8(proto)
		protocolCode := protoValue

		if conv, ok := sofaConvFactory[protocolCode]; ok {
			//TODO:  delete this copy
			// proxy downstream maybe retry, use the headerMap many times
			// if proxy downstream can keep a encoded header(iobuf)
			// map to cmd will be called only once, so we can modify the map without a copy
			headerCopy := make(map[string]string, len(headerMap))
			for k, v := range headerMap {
				headerCopy[k] = v
			}
			return conv.MapToCmd(ctx, headerCopy)
		}
		return nil, rpc.ErrUnrecognizedCode
	}
	return nil, rpc.ErrNoProtocolCode
}
// MapToCmd  expect src header data type as `protocol.CommonHeader`
MapToCmd  expect src header data type as `protocol.CommonHeader`
// MapToCmd expect src header data type as ` protocol . CommonHeader `
func MapToCmd(ctx context.Context, headerMap map[string]string) (SofaRpcCmd, error) {
	if proto, exist := headerMap[SofaPropertyHeader(HeaderProtocolCode)]; exist {
		protoValue := ConvertPropertyValueUint8(proto)
		protocolCode := protoValue
		if conv, ok := sofaConvFactory[protocolCode]; ok {
			headerCopy := make(map[string]string, len(headerMap))
			for k, v := range headerMap {
				headerCopy[k] = v
			}
			return conv.MapToCmd(ctx, headerCopy)
		}
		return nil, rpc.ErrUnrecognizedCode
	}
	return nil, rpc.ErrNoProtocolCode
}
func MapToCmd ( ctx context . Context , headerMap map [ string ] string ) ( SofaRpcCmd , error ) { if proto , exist := headerMap [ SofaPropertyHeader ( HeaderProtocolCode ) ] ; exist { protoValue := ConvertPropertyValueUint8 ( proto ) protocolCode := protoValue if conv , ok := sofaConvFactory [ protocolCode ] ; ok { headerCopy := make ( map [ string ] string , len ( headerMap ) ) for k , v := range headerMap { headerCopy [ k ] = v } return conv . MapToCmd ( ctx , headerCopy ) } return nil , rpc . ErrUnrecognizedCode } return nil , rpc . ErrNoProtocolCode }
MapToCmd  expect src header data type as `protocol.CommonHeader`
MapToCmd expect src header data type as ` protocol . CommonHeader `
// TODO: temporary use bolt.HeaderProtocolCode, need to use common definition //TODO:  delete this copy // proxy downstream maybe retry, use the headerMap many times // if proxy downstream can keep a encoded header(iobuf) // map to cmd will be called only once, so we can modify the map without a copy