Wednesday 15 June 2011

javascript - Context in Highland.js -


I like the style of responsive programming in Highland.js and in general. I am struggling with reference loss and I I am trying to determine how to handle beautifully in terms of models where the goal is to leave the state. For example, I have an array of accounts in Amazon Web Services.

  var account = [{accessId: "12345", "secretive": "abc123", "account": "foo"}, {accessId: "34512" "secretKey": "def456 "," Account ":" bar "}];  

My goal is to create a spreadsheet originally from all of its EC2 instances running in an area. something like that.

  account. Example Size --------- | ------------- foo | M3.xlarge foo | C3.medium bar | Common workflow will be  
  1. Go through each account
  2. Call EC2 decryensinstance
  3. somehow

    In the normal input, we want to loop here, when we make each call in EC2 encrypted intents, the reference will be present (for account accounts)

      {var instances = Ec2DescribeInstaces (account); For example (examples in examples) {results.push ({account: account.name, example: instance.size}); }}  

    In the responsive programming, which I think, I will do something like

      _ (accounts) .map (ec2DescribeInstaces) .parallel (2). Each (function (results) {results.push (results);});  

    any guidance ??? So at the end of this series, I have examples from Amazon. But I am not sure how to tie those accounts back to get these names. I know that I can hack around this to get value, but I am looking for the best practices and some beautiful things.

    So @borgie, like the bottom ??? In addition to the data coming back from Amazon, I would need to return a "reference" object with both data. My only concern with this is that if I'm passing a reference about the whole series, Wrapping, stuffing, and wrapping for the call.

      ec2DescribeInstances = _ wrap wrapback function (function (accountdata, callback) {// We use a pick up ec2 = new AWS.C2 (Lonspic (accountdata, access kiid ',' extactky ') By removing the external account name;) ec2.describeInstances ({Filters: [{name: 'instance-state-name', value: ['running'}}]}, function (fault, data) {if ) Return callback (err); // Here I create an object that returns the AWS response callback (empty, {"account": account data, "data": data}}})}};  

itemprop = "text">

You can use, which takes two currents and gives a stream of pairs, therefore, using your stream generated ec2Instances as an example Has been:

  var ec2InstanceStream = _ (accounts) .map (ec2DescribeInstaces) parallel (2); _ (acounts) .zip (ec2InstanceStream); .each (function (result) {/ / Each result: [{/ * original account *}, {/ * ec2 example},} results.push (result);});  

So now you have everything Together you can do it well of course. For example, if you want to merge each pair into one object, then you can .map (_ expand) before .each () add step Objects can be together.


No comments:

Post a Comment