11<?php
2-
32/**
43 * Copyright 2018 Google Inc.
54 *
@@ -56,15 +55,11 @@ function l_diversity(
5655 string $ datasetId ,
5756 string $ tableId ,
5857 string $ sensitiveAttribute ,
59- array $ quasiIdNames
58+ array $ quasiIdNames
6059): void {
6160 // Instantiate a client.
62- $ dlp = new DlpServiceClient ([
63- 'projectId ' => $ callingProjectId ,
64- ]);
65- $ pubsub = new PubSubClient ([
66- 'projectId ' => $ callingProjectId ,
67- ]);
61+ $ dlp = new DlpServiceClient ();
62+ $ pubsub = new PubSubClient ();
6863 $ topic = $ pubsub ->topic ($ topicId );
6964
7065 // Construct risk analysis config
@@ -119,8 +114,10 @@ function ($id) {
119114 $ startTime = time ();
120115 do {
121116 foreach ($ subscription ->pull () as $ message ) {
122- if (isset ($ message ->attributes ()['DlpJobName ' ]) &&
123- $ message ->attributes ()['DlpJobName ' ] === $ job ->getName ()) {
117+ if (
118+ isset ($ message ->attributes ()['DlpJobName ' ]) &&
119+ $ message ->attributes ()['DlpJobName ' ] === $ job ->getName ()
120+ ) {
124121 $ subscription ->acknowledge ($ message );
125122 // Get the updated job. Loop to avoid race condition with DLP API.
126123 do {
@@ -129,7 +126,7 @@ function ($id) {
129126 break 2 ; // break from parent do while
130127 }
131128 }
132- printf ('Waiting for job to complete ' . PHP_EOL );
129+ print ('Waiting for job to complete ' . PHP_EOL );
133130 // Exponential backoff with max delay of 60 seconds
134131 sleep (min (60 , pow (2 , ++$ attempt )));
135132 } while (time () - $ startTime < 600 ); // 10 minute timeout
@@ -182,10 +179,10 @@ function ($id) {
182179 }
183180 break ;
184181 case JobState::PENDING :
185- printf ('Job has not completed. Consider a longer timeout or an asynchronous execution model ' . PHP_EOL );
182+ print ('Job has not completed. Consider a longer timeout or an asynchronous execution model ' . PHP_EOL );
186183 break ;
187184 default :
188- printf ('Unexpected job state. Most likely, the job is either running or has not yet started. ' );
185+ print ('Unexpected job state. Most likely, the job is either running or has not yet started. ' );
189186 }
190187}
191188# [END dlp_l_diversity]
0 commit comments