Skip to content

Commit

Permalink
chore(samples): no native sleep (#396)
Browse files Browse the repository at this point in the history
Co-authored-by: Justin Beckwith <[email protected]>
  • Loading branch information
alexander-fenster and JustinBeckwith authored Jul 8, 2020
1 parent aa4a293 commit fdf025d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions packages/google-cloud-dataproc/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
},
"dependencies": {
"@google-cloud/dataproc": "^2.1.0",
"@google-cloud/storage": "^5.0.0",
"sleep": "^6.1.0"
"@google-cloud/storage": "^5.0.0"
},
"devDependencies": {
"chai": "^4.2.0",
Expand Down
9 changes: 6 additions & 3 deletions packages/google-cloud-dataproc/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ function main(projectId, region, clusterName, jobFilePath) {
const dataproc = require('@google-cloud/dataproc');
const {Storage} = require('@google-cloud/storage');

const sleep = require('sleep');

// Create a cluster client with the endpoint set to the desired cluster region
const clusterClient = new dataproc.v1.ClusterControllerClient({
apiEndpoint: `${region}-dataproc.googleapis.com`,
Expand Down Expand Up @@ -111,7 +109,7 @@ function main(projectId, region, clusterName, jobFilePath) {
);
break;
}
await sleep.sleep(1);
await sleep(1);
[jobResp] = await jobClient.getJob(jobReq);
}

Expand Down Expand Up @@ -149,6 +147,11 @@ function main(projectId, region, clusterName, jobFilePath) {
quickstart();
}

// Helper function to sleep for the given number of seconds
function sleep(seconds) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}

const args = process.argv.slice(2);

if (args.length !== 4) {
Expand Down

0 comments on commit fdf025d

Please sign in to comment.