title: Google Pub/Sub to control RateLimit
body: <p>I've made one cloud function to do the following:</p>
  <ol>
  <li>Get order id's filtert on day before today (around 400 id's) one time at night.</li>
  <li>For each id get detailed information from source.</li>
  <li>For each detailed information get extra information from target.</li>
  <li>Send to target as invoice.</li>
  </ol>
  <p>My problem is in step 2. The rate limit is 14 request per minute. So i was thinking to create an Pub/Sub between 1 and 2. Create a subscription function that pulls messages from the topic. Processes 14 of them and ack those messages, then resolve the promise. But this leave me with questions:</p>
  <ol>
  <li>Is this the right flow?</li>
  <li>How do i schedule step 2?</li>
  </ol>
  <ul>
  <li>if i get a 429 response i wait for 1 minute (this will be billed)</li>
  <li>let step 2 run every 1 minute to not get the 429 response code? (this will run a long time of the day when there are no messages.</li>
  <li>instead of pulling let the pub/sub trigger the function, check the response code -&gt; if 429 then wait for 1 minute to proces. But then my question: Will it invoke one instance of the cloud function or multiple?</li>
  </ul>
  <p>I hope someone can share some thoughts. I'm new to cloud functions and async programming. My hole function works as expected with a limit of 5 orders. Just later on i came acros this rate limit (i know, stupid me).</p>