@@ -1349,49 +1349,66 @@ protected function exportGroupFunctions(int $batchSize, array $resources): void
13491349 private function exportFunctions (int $ batchSize ): void
13501350 {
13511351 $ this ->functions = new Functions ($ this ->client );
1352+ /**
1353+ * @var Func|null $lastFunction
1354+ */
1355+ $ lastFunction = null ;
1356+ while (true ) {
1357+ $ queries = [Query::limit ($ batchSize )];
13521358
1353- $ queries = [];
1359+ if ($ this ->rootResourceId !== '' && $ this ->rootResourceType === Resource::TYPE_FUNCTION ) {
1360+ $ queries [] = Query::equal ('$id ' , $ this ->rootResourceId );
1361+ $ queries [] = Query::limit (1 );
1362+ }
13541363
1355- if ($ this ->rootResourceId !== '' && $ this ->rootResourceType === Resource::TYPE_FUNCTION ) {
1356- $ queries [] = Query::equal ('$id ' , $ this ->rootResourceId );
1357- $ queries [] = Query::limit (1 );
1358- }
1364+ if ($ lastFunction ) {
1365+ $ queries [] = Query::cursorAfter ($ lastFunction ->getId ());
1366+ }
13591367
1360- $ functions = $ this ->functions ->list ($ queries );
1368+ $ response = $ this ->functions ->list ($ queries );
13611369
1362- if ($ functions ['total ' ] === 0 ) {
1363- return ;
1364- }
13651370
1366- $ convertedResources = [];
1367-
1368- foreach ($ functions ['functions ' ] as $ function ) {
1369- $ convertedFunc = new Func (
1370- $ function ['$id ' ],
1371- $ function ['name ' ],
1372- $ function ['runtime ' ],
1373- $ function ['execute ' ],
1374- $ function ['enabled ' ],
1375- $ function ['events ' ],
1376- $ function ['schedule ' ],
1377- $ function ['timeout ' ],
1378- $ function ['deploymentId ' ] ?? '' ,
1379- $ function ['entrypoint ' ]
1380- );
1381-
1382- $ convertedResources [] = $ convertedFunc ;
1371+ if ($ response ['total ' ] === 0 ) {
1372+ return ;
1373+ }
13831374
1384- foreach ($ function ['vars ' ] as $ var ) {
1385- $ convertedResources [] = new EnvVar (
1386- $ var ['$id ' ],
1387- $ convertedFunc ,
1388- $ var ['key ' ],
1389- $ var ['value ' ],
1375+ $ functions = [];
1376+ $ convertedResources = [];
1377+
1378+ foreach ($ response ['functions ' ] as $ function ) {
1379+ $ convertedFunc = new Func (
1380+ $ function ['$id ' ],
1381+ $ function ['name ' ],
1382+ $ function ['runtime ' ],
1383+ $ function ['execute ' ],
1384+ $ function ['enabled ' ],
1385+ $ function ['events ' ],
1386+ $ function ['schedule ' ],
1387+ $ function ['timeout ' ],
1388+ $ function ['deploymentId ' ] ?? '' ,
1389+ $ function ['entrypoint ' ]
13901390 );
1391+ $ functions [] = $ convertedFunc ;
1392+
1393+ $ convertedResources [] = $ convertedFunc ;
1394+
1395+ foreach ($ function ['vars ' ] as $ var ) {
1396+ $ convertedResources [] = new EnvVar (
1397+ $ var ['$id ' ],
1398+ $ convertedFunc ,
1399+ $ var ['key ' ],
1400+ $ var ['value ' ],
1401+ );
1402+ }
13911403 }
1392- }
13931404
1394- $ this ->callback ($ convertedResources );
1405+ $ lastFunction = $ functions [count ($ functions ) - 1 ];
1406+
1407+ $ this ->callback ($ convertedResources );
1408+ if (count ($ functions ) < $ batchSize ) {
1409+ return ;
1410+ }
1411+ }
13951412 }
13961413
13971414 /**
0 commit comments