Skip to content

Commit b07991d

Browse files
author
Brendan Benner
committed
Extend CrawlerClient in TokenCrawlerClient to resolve bean injection issues
1 parent 0e48019 commit b07991d

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

data-prepper-plugins/saas-source-plugins/source-crawler/src/main/java/org/opensearch/dataprepper/plugins/source/source_crawler/base/TokenCrawlerClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Interface for Crawler client to support token-based pagination. This interface can
1414
* be implemented by different saas clients.
1515
*/
16-
public interface TokenCrawlerClient<T extends SaasWorkerProgressState> {
16+
public interface TokenCrawlerClient<T extends SaasWorkerProgressState> extends CrawlerClient<PaginationCrawlerWorkerProgressState> {
1717

1818
/**
1919
* This will be the main API called by crawler. This method assumes that {@link

data-prepper-plugins/saas-source-plugins/source-crawler/src/main/java/org/opensearch/dataprepper/plugins/source/source_crawler/base/TokenPaginationCrawler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public class TokenPaginationCrawler implements Crawler<PaginationCrawlerWorkerPr
3434
private static final String PAGINATION_WORKER_PARTITIONS_CREATED = "paginationWorkerPartitionsCreated";
3535
private static final String INVALID_PAGINATION_ITEMS = "invalidPaginationItems";
3636
private final Timer crawlingTimer;
37-
private final TokenCrawlerClient client;
37+
private final CrawlerClient client;
3838
private final Counter parititionsCreatedCounter;
3939
private final Counter invalidPaginationItemsCounter;
4040

41-
public TokenPaginationCrawler(TokenCrawlerClient client,
41+
public TokenPaginationCrawler(CrawlerClient client,
4242
PluginMetrics pluginMetrics) {
4343
this.client = client;
4444
this.crawlingTimer = pluginMetrics.timer("crawlingTime");
@@ -55,7 +55,7 @@ public Instant crawl(LeaderPartition leaderPartition,
5555
TokenPaginationCrawlerLeaderProgressState leaderProgressState = (TokenPaginationCrawlerLeaderProgressState) leaderPartition
5656
.getProgressState().get();
5757
String lastToken = leaderProgressState.getLastToken();
58-
Iterator<ItemInfo> itemInfoIterator = client.listItems(lastToken);
58+
Iterator<ItemInfo> itemInfoIterator = ((TokenCrawlerClient) client).listItems(lastToken);
5959
String latestToken = lastToken;
6060
log.info("Starting to crawl the source with last item ID: {}", lastToken);
6161
do {
@@ -122,4 +122,3 @@ private void createPartition(List<ItemInfo> itemInfoList, EnhancedSourceCoordina
122122
parititionsCreatedCounter.increment();
123123
}
124124
}
125-

0 commit comments

Comments
 (0)