Skip to content

Commit fdf025d

Browse files
chore(samples): no native sleep (#396)
Co-authored-by: Justin Beckwith <justin.beckwith@gmail.com>
1 parent aa4a293 commit fdf025d

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

packages/google-cloud-dataproc/samples/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
},
1616
"dependencies": {
1717
"@google-cloud/dataproc": "^2.1.0",
18-
"@google-cloud/storage": "^5.0.0",
19-
"sleep": "^6.1.0"
18+
"@google-cloud/storage": "^5.0.0"
2019
},
2120
"devDependencies": {
2221
"chai": "^4.2.0",

packages/google-cloud-dataproc/samples/quickstart.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ function main(projectId, region, clusterName, jobFilePath) {
2828
const dataproc = require('@google-cloud/dataproc');
2929
const {Storage} = require('@google-cloud/storage');
3030

31-
const sleep = require('sleep');
32-
3331
// Create a cluster client with the endpoint set to the desired cluster region
3432
const clusterClient = new dataproc.v1.ClusterControllerClient({
3533
apiEndpoint: `${region}-dataproc.googleapis.com`,
@@ -111,7 +109,7 @@ function main(projectId, region, clusterName, jobFilePath) {
111109
);
112110
break;
113111
}
114-
await sleep.sleep(1);
112+
await sleep(1);
115113
[jobResp] = await jobClient.getJob(jobReq);
116114
}
117115

@@ -149,6 +147,11 @@ function main(projectId, region, clusterName, jobFilePath) {
149147
quickstart();
150148
}
151149

150+
// Helper function to sleep for the given number of seconds
151+
function sleep(seconds) {
152+
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
153+
}
154+
152155
const args = process.argv.slice(2);
153156

154157
if (args.length !== 4) {

0 commit comments

Comments
 (0)