@@ -35,6 +35,9 @@ import (
35
35
"github.com/google/uuid"
36
36
)
37
37
38
+ // Quota ExportAssets Requests per minute
39
+ const waitSecOnQuotaExceeded = 70
40
+
38
41
// Global structure for global variables to optimize the cloud function performances
39
42
type Global struct {
40
43
assetClient * asset.Client
@@ -213,6 +216,19 @@ func EntryPoint(ctxEvent context.Context, PubSubMessage gps.PubSubMessage, globa
213
216
214
217
operation , err := global .assetClient .ExportAssets (global .ctx , global .request )
215
218
if err != nil {
219
+ if strings .Contains (strings .ToLower (err .Error ()), "quota" ) {
220
+ log .Println (glo.Entry {
221
+ MicroserviceName : global .microserviceName ,
222
+ InstanceName : global .instanceName ,
223
+ Environment : global .environment ,
224
+ Severity : "WARNING" ,
225
+ Message : fmt .Sprintf ("waiting_on_quota_exceeded" ),
226
+ Description : fmt .Sprintf ("ExportAssets quota is gone, wait for %d seconds then retry" , waitSecOnQuotaExceeded ),
227
+ TriggeringPubsubID : global .PubSubID ,
228
+ })
229
+ time .Sleep (waitSecOnQuotaExceeded * time .Second )
230
+ return err
231
+ }
216
232
log .Println (glo.Entry {
217
233
MicroserviceName : global .microserviceName ,
218
234
InstanceName : global .instanceName ,
0 commit comments