mardi 4 août 2015

Aws S3 nodeJs synchronous

I'm new to javascript also node.js environment. It's hard for me to use the call back. Because when I have a lot of procedure linked together, it's hard to write and it will becomes very nasty.

So, after I google for the answer, I found the async tool, but it still run like that it can execute the codes block by block using call back. for example, f1 -> f2 -> f3 ...

however, we always has a delay for the server and my computer. then If I do some thing like create buckets, then print how many I got. It will print out the original amount of buckets not after I add one. Same situation like delete bucket .... can some god help me

thanks...

  async.parallel([
      function f1(callback)
      {
          settingBucket (s3, 'testjsbucket2');
          callback(null, '1');
      }
      ,
      function f2(callback)
      {
        settingBucket(s3, 'testjsbucket3');
        callback(null, '2');
      }
      ,
      function f3(callback)
      {
        listBucket(s3);
        callback(null, '3');
      }
      ,
      function f4(callback)
      {
          deleteBucket(s3, 'testjsbucket2');
          callback(null, '4');
      }
      ,
      function f5(callback)
      {
          deleteBucket(s3, 'testjsbucket3');
          callback(null, '5');
      }
      ,
      function f6(callback)
      {
          listBucket(s3);
          callback(null, '6');
      },
    ],
    function(err, results){
        console.log(results);
    });




Aucun commentaire:

Enregistrer un commentaire